├── packages ├── .gitkeep ├── react-accounting-textfield │ ├── index.ts │ ├── .babelrc │ ├── tests │ │ ├── babel.config.js │ │ └── tsconfig.spec.json │ ├── accounting.d.ts │ ├── tsconfig.lib.json │ ├── jest.config.ts │ ├── .eslintrc.json │ ├── tsconfig.json │ ├── package.json │ ├── src │ │ ├── assets │ │ │ └── icons │ │ │ │ ├── exclamationCircle.tsx │ │ │ │ └── euro.tsx │ │ ├── components │ │ │ ├── Uncontrolled.tsx │ │ │ └── Controlled.tsx │ │ ├── Textfield.test.tsx │ │ ├── utils │ │ │ ├── index.ts │ │ │ └── utils.test.ts │ │ └── index.tsx │ ├── types │ │ └── index.ts │ ├── project.json │ └── README.md ├── flexysearch-react │ ├── src │ │ ├── state │ │ │ ├── actions.ts │ │ │ ├── state.ts │ │ │ └── reducer.ts │ │ ├── index.ts │ │ └── provider │ │ │ ├── FlexysearchProvider.tsx │ │ │ └── useFlexysearchProvider.test.tsx │ ├── .babelrc │ ├── types │ │ ├── internal.ts │ │ └── index.ts │ ├── jest.config.ts │ ├── .eslintrc.json │ ├── tsconfig.json │ ├── tsconfig.spec.json │ ├── package.json │ ├── tsconfig.lib.json │ ├── project.json │ └── README.md └── flexysearch │ ├── src │ ├── utils │ │ ├── helpers │ │ │ ├── regexp.ts │ │ │ └── objects.ts │ │ ├── hash.ts │ │ ├── __tests__ │ │ │ └── hash.test.ts │ │ ├── number.ts │ │ ├── strings.ts │ │ └── dates.ts │ ├── tests │ │ ├── __mocks__ │ │ │ ├── strings │ │ │ │ ├── expectedEquals.json │ │ │ │ ├── expectedEmpty.json │ │ │ │ └── expectedNotContains.json │ │ │ ├── dates │ │ │ │ ├── expectIs.json │ │ │ │ ├── expectNotEmpty.json │ │ │ │ ├── expectBetween.json │ │ │ │ ├── expectEmpty.json │ │ │ │ ├── expectBefore.json │ │ │ │ ├── expectAfter.json │ │ │ │ └── expectNotEquals.json │ │ │ └── numbers │ │ │ │ ├── expectedNumberEmpty.json │ │ │ │ ├── expectBiggerThan.json │ │ │ │ ├── expectBiggerOrEquals.json │ │ │ │ ├── expectSmallerThan.json │ │ │ │ ├── expectSmallerOrEquals.json │ │ │ │ ├── expectedNumberNotEmpty.json │ │ │ │ ├── expectDifferentFrom.json │ │ │ │ └── expectedNumberNotContains.json │ │ ├── custom.test.ts │ │ ├── operators.test.ts │ │ ├── paginate.test.ts │ │ ├── strings.test.ts │ │ ├── dates.test.ts │ │ └── numbers.test.ts │ ├── features │ │ └── Paginator.ts │ └── index.ts │ ├── tsconfig.lib.json │ ├── tsconfig.spec.json │ ├── jest.config.ts │ ├── .eslintrc.json │ ├── tsconfig.json │ ├── package.json │ ├── project.json │ ├── README.md │ └── interfaces │ └── index.ts ├── apps └── docs │ ├── static │ ├── .nojekyll │ └── img │ │ ├── favicon.ico │ │ ├── docusaurus.png │ │ ├── docusaurus-social-card.jpg │ │ ├── logo.svg │ │ └── undraw_docusaurus_tree.svg │ ├── babel.config.js │ ├── src │ ├── pages │ │ ├── markdown-page.md │ │ ├── index.module.css │ │ └── index.js │ ├── components │ │ └── HomepageFeatures │ │ │ ├── styles.module.css │ │ │ └── index.js │ └── css │ │ └── custom.css │ ├── docs │ ├── packages │ │ ├── _category_.json │ │ ├── flexysearch │ │ │ ├── _category_.json │ │ │ ├── installation.md │ │ │ ├── contribution.md │ │ │ ├── example-ssr-data.md │ │ │ └── example-global-filter.md │ │ └── react-accounting-textfield │ │ │ ├── _category_.json │ │ │ ├── installation.md │ │ │ └── react-accounting-textfield.md │ ├── changelogs │ │ ├── Changelogs-Core.md │ │ ├── Changelogs-React.md │ │ └── Changelogs-Textfield.md │ └── intro.md │ ├── .gitignore │ ├── package.json │ ├── sidebars.js │ ├── README.md │ ├── examples │ ├── Textfield.tsx │ ├── TableWithSSRdata.tsx │ └── TableWithGlobalFilter.tsx │ └── docusaurus.config.js ├── .eslintignore ├── babel.config.json ├── .prettierrc ├── .prettierignore ├── jest.config.ts ├── .github ├── dependabot.yml ├── FUNDING.yml └── workflows │ └── pull_request.yml ├── CONTRIBUTING.md ├── .editorconfig ├── .vscode └── extensions.json ├── jest.preset.js ├── __mocks__ ├── babyBornsSequencial.json ├── items.json ├── movies.json └── babyBorns.json ├── .gitignore ├── README.md ├── tsconfig.base.json ├── nx.json ├── .eslintrc.json ├── gulpfile.js ├── tools └── scripts │ └── publish.mjs ├── CHANGELOG.md ├── package.json └── techstack.md /packages/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/docs/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "babelrcRoots": ["*"] 3 | } 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "semi": false 4 | } 5 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./src"; 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Add files here to ignore them from prettier formatting 2 | 3 | /dist 4 | /coverage 5 | 6 | /.nx/cache -------------------------------------------------------------------------------- /apps/docs/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /apps/docs/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexcastrodev/flexysearch/HEAD/apps/docs/static/img/favicon.ico -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | import { getJestProjects } from '@nx/jest' 2 | 3 | export default { 4 | projects: getJestProjects(), 5 | } 6 | -------------------------------------------------------------------------------- /apps/docs/static/img/docusaurus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexcastrodev/flexysearch/HEAD/apps/docs/static/img/docusaurus.png -------------------------------------------------------------------------------- /packages/flexysearch-react/src/state/actions.ts: -------------------------------------------------------------------------------- 1 | export enum Kind { 2 | SET_DATA_ACTION, 3 | SET_FILTERED_DATA_ACTION, 4 | } 5 | -------------------------------------------------------------------------------- /packages/flexysearch/src/utils/helpers/regexp.ts: -------------------------------------------------------------------------------- 1 | export const VALIDATE_DATE_REGEXP = new RegExp('\\d{4,4}\\-\\d{2,2}\\-\\d{2,2}', 'g') 2 | -------------------------------------------------------------------------------- /apps/docs/static/img/docusaurus-social-card.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexcastrodev/flexysearch/HEAD/apps/docs/static/img/docusaurus-social-card.jpg -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/strings/expectedEquals.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Film 1", 5 | "year": 2009 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: 'github-actions' 5 | directory: '/' 6 | schedule: 7 | interval: 'weekly' 8 | -------------------------------------------------------------------------------- /apps/docs/src/pages/markdown-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Markdown page example 3 | --- 4 | 5 | # Markdown page example 6 | 7 | You don't need React to write simple standalone pages. 8 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/dates/expectIs.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 10, 3 | "first_name": "Kincaid", 4 | "last_name": "Dautry", 5 | "born_at": "2021-12-27" 6 | }] 7 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | This guide shows you how to contributing with this project 3 | 4 | https://alexcastrodev.notion.site/How-to-contribute-492221e48f824156930f217ddb788c56 5 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Packages", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Discover all Packages" 7 | } 8 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "nrwl.angular-console", 4 | "esbenp.prettier-vscode", 5 | "dbaeumer.vscode-eslint", 6 | "firsttris.vscode-jest-runner" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/flexysearch/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Flexyseach", 3 | "position": 1, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn and install" 7 | } 8 | } -------------------------------------------------------------------------------- /packages/flexysearch/src/utils/hash.ts: -------------------------------------------------------------------------------- 1 | export const hashCode = (s: string): number => { 2 | let h = 0 3 | for (let i = 0; i < s.length; i++) { 4 | h = (Math.imul(31, h) + s.charCodeAt(i)) | 0 5 | } 6 | 7 | return h 8 | } 9 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/react-accounting-textfield/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "React Accounting Textfield", 3 | "position": 2, 4 | "link": { 5 | "type": "generated-index", 6 | "description": "Learn and install" 7 | } 8 | } -------------------------------------------------------------------------------- /apps/docs/docs/packages/react-accounting-textfield/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Installation 6 | 7 | ## React Accounting Textfield 8 | 9 | ```bash 10 | yarn add react-accounting-textfield 11 | ``` 12 | -------------------------------------------------------------------------------- /apps/docs/src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /packages/flexysearch-react/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@nx/react/babel", 5 | { 6 | "runtime": "automatic", 7 | "useBuiltIns": "usage" 8 | } 9 | ] 10 | ], 11 | "plugins": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/flexysearch-react/src/state/state.ts: -------------------------------------------------------------------------------- 1 | import { FlexysearchHookState } from './../../types/index'; 2 | 3 | const initialState: FlexysearchHookState = { 4 | data: [], 5 | filtered_data: [], 6 | }; 7 | export default initialState; 8 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@nx/react/babel", 5 | { 6 | "runtime": "automatic", 7 | "useBuiltIns": "usage" 8 | } 9 | ] 10 | ], 11 | "plugins": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectedNumberEmpty.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 13, 4 | "title": "Film Null", 5 | "year": null 6 | }, 7 | { 8 | "id": 14, 9 | "title": "Film empty", 10 | "year": "" 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/tests/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | ['@babel/preset-env', { targets: { node: 'current' } }], 4 | '@babel/preset-typescript', 5 | ['@babel/preset-react', { runtime: 'automatic' }], 6 | ], 7 | } 8 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/flexysearch/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Installation 6 | 7 | ## Flexysearch core 8 | 9 | ```bash 10 | yarn add flexysearch 11 | ``` 12 | 13 | ## Flexysearch react 14 | 15 | ```bash 16 | yarn add flexysearch-react 17 | ```` 18 | 19 | -------------------------------------------------------------------------------- /packages/flexysearch-react/types/internal.ts: -------------------------------------------------------------------------------- 1 | import { Kind } from '../src/state/actions'; 2 | 3 | export type ReducerAction = 4 | | { 5 | kind: Kind.SET_DATA_ACTION; 6 | payload: unknown[]; 7 | } 8 | | { 9 | kind: Kind.SET_FILTERED_DATA_ACTION; 10 | payload: unknown[]; 11 | }; 12 | -------------------------------------------------------------------------------- /packages/flexysearch/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "declaration": true, 6 | "types": ["node"] 7 | }, 8 | "include": ["src/**/*.ts"], 9 | "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/accounting.d.ts: -------------------------------------------------------------------------------- 1 | declare module "accounting" { 2 | interface AccountingStatic { 3 | unformat(value: string, ...args: any[]): number; 4 | formatMoney(value: unknown, ...args: any[]): string; 5 | } 6 | 7 | const accounting: AccountingStatic; 8 | export = accounting; 9 | } 10 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/dates/expectNotEmpty.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "first_name": "Amber", 5 | "last_name": "Pockey", 6 | "born_at": "2022-08-12" 7 | }, { 8 | "id": 2, 9 | "first_name": "Marcile", 10 | "last_name": "Wesson", 11 | "born_at": "2021-10-23" 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /apps/docs/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectBiggerThan.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 2, 4 | "title": "Film 2", 5 | "year": 2015 6 | }, 7 | { 8 | "id": 8, 9 | "title": "Film 8", 10 | "year": 2015 11 | }, 12 | { 13 | "id": 9, 14 | "title": "Film 9", 15 | "year": 2020 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /packages/flexysearch/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "module": "commonjs", 6 | "types": ["jest", "node"] 7 | }, 8 | "include": [ 9 | "jest.config.ts", 10 | "src/**/*.test.ts", 11 | "src/**/*.spec.ts", 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /jest.preset.js: -------------------------------------------------------------------------------- 1 | const nxPreset = require('@nx/jest/preset').default; 2 | module.exports = { 3 | ...nxPreset, 4 | testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'], 5 | transform: { 6 | '^.+\\.(ts|js|html)$': 'ts-jest', 7 | }, 8 | resolver: '@nx/jest/plugins/resolver', 9 | moduleFileExtensions: ['ts', 'js', 'html'], 10 | coverageReporters: ['html'], 11 | } 12 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "module": "commonjs", 6 | "types": ["jest", "node"] 7 | }, 8 | "include": [ 9 | "jest.config.ts", 10 | "src/**/*.test.ts", 11 | "src/**/*.spec.ts", 12 | "src/**/*.d.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /packages/flexysearch/jest.config.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export default { 3 | displayName: 'flexysearch', 4 | preset: '../../jest.preset.js', 5 | transform: { 6 | '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], 7 | }, 8 | moduleFileExtensions: ['ts', 'js', 'html'], 9 | coverageDirectory: '/coverage/packages/flexysearch', 10 | }; 11 | -------------------------------------------------------------------------------- /packages/flexysearch-react/src/index.ts: -------------------------------------------------------------------------------- 1 | import FlexysearchProvider, { 2 | useFlexysearchProvider, 3 | } from './provider/FlexysearchProvider'; 4 | 5 | const useFlexysearch = useFlexysearchProvider; 6 | 7 | const moduleToExport = { 8 | Provider: FlexysearchProvider, 9 | hook: useFlexysearch, 10 | }; 11 | 12 | export { useFlexysearch, FlexysearchProvider }; 13 | export default moduleToExport; 14 | -------------------------------------------------------------------------------- /packages/flexysearch/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../../.eslintrc.json"], 3 | "ignorePatterns": ["!**/*"], 4 | "overrides": [ 5 | { 6 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], 7 | "rules": {} 8 | }, 9 | { 10 | "files": ["*.ts", "*.tsx"], 11 | "rules": {} 12 | }, 13 | { 14 | "files": ["*.js", "*.jsx"], 15 | "rules": {} 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/dates/expectBetween.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 97, 3 | "first_name": "Annabella", 4 | "last_name": "Rapelli", 5 | "born_at": "2022-01-02" 6 | }, { 7 | "id": 98, 8 | "first_name": "Jedd", 9 | "last_name": "MacDavitt", 10 | "born_at": "2022-01-03" 11 | }, { 12 | "id": 99, 13 | "first_name": "Penni", 14 | "last_name": "Lockhart", 15 | "born_at": "2022-01-04" 16 | }] 17 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/dates/expectEmpty.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 3, 4 | "first_name": "Druci", 5 | "last_name": "Braune", 6 | "born_at": null 7 | }, { 8 | "id": 4, 9 | "first_name": "Andreas", 10 | "last_name": "Casassa", 11 | "born_at": "" 12 | }, { 13 | "id": 5, 14 | "first_name": "Harriette", 15 | "last_name": "Jeffers", 16 | "born_at": "null" 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /packages/flexysearch/src/utils/__tests__/hash.test.ts: -------------------------------------------------------------------------------- 1 | import { hashCode } from '../hash' 2 | 3 | describe('Should match strings', () => { 4 | it('[String]: Should create hashCode string', () => { 5 | const hash = hashCode('Alex') 6 | const hash2 = hashCode('Alex') 7 | const hash3 = hashCode('Alexa') 8 | 9 | expect(hash).toBe(hash2) 10 | expect(hash).not.toBe(hash3) 11 | expect(hash2).not.toBe(hash3) 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/flexysearch/contribution.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 4 3 | --- 4 | 5 | # Deploy your site 6 | 7 | # **How to contribute** 8 | 9 | You can check our https://github.com/AlexcastroDev/flexysearch/issues or you can create a new one, and fork this project, finally open a PR to `dev` branch. 10 | 11 | I'll be quick to implement and improve this package, and if you open a pull request, i'll help you with a new release as soon as possible. 12 | 13 | -------------------------------------------------------------------------------- /packages/flexysearch-react/jest.config.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export default { 3 | displayName: 'flexysearch-react', 4 | preset: '../../jest.preset.js', 5 | transform: { 6 | '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', 7 | '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], 8 | }, 9 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], 10 | coverageDirectory: '../../coverage/packages/flexysearch-react', 11 | } 12 | -------------------------------------------------------------------------------- /apps/docs/src/pages/index.module.css: -------------------------------------------------------------------------------- 1 | /** 2 | * CSS files with the .module.css suffix will be treated as CSS modules 3 | * and scoped locally. 4 | */ 5 | 6 | .heroBanner { 7 | padding: 4rem 0; 8 | text-align: center; 9 | position: relative; 10 | overflow: hidden; 11 | } 12 | 13 | @media screen and (max-width: 996px) { 14 | .heroBanner { 15 | padding: 2rem; 16 | } 17 | } 18 | 19 | .buttons { 20 | display: flex; 21 | align-items: center; 22 | justify-content: center; 23 | } 24 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/jest.config.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export default { 3 | displayName: "react-accounting-textfield", 4 | preset: "../../jest.preset.js", 5 | transform: { 6 | "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest", 7 | "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }], 8 | }, 9 | moduleFileExtensions: ["ts", "tsx", "js", "jsx"], 10 | coverageDirectory: "../../coverage/packages/react-accounting-textfield", 11 | }; 12 | -------------------------------------------------------------------------------- /packages/flexysearch-react/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["plugin:@nx/react", "../../.eslintrc.json"], 3 | "ignorePatterns": ["!**/*"], 4 | "overrides": [ 5 | { 6 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], 7 | "rules": { 8 | "react-hooks/exhaustive-deps": "off" 9 | } 10 | }, 11 | { 12 | "files": ["*.ts", "*.tsx"], 13 | "rules": {} 14 | }, 15 | { 16 | "files": ["*.js", "*.jsx"], 17 | "rules": {} 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectBiggerOrEquals.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 2, 4 | "title": "Film 2", 5 | "year": 2015 6 | }, 7 | { 8 | "id": 3, 9 | "title": "Film 3", 10 | "year": 2014 11 | }, 12 | { 13 | "id": 4, 14 | "title": "Film 4", 15 | "year": 2014 16 | }, 17 | { 18 | "id": 8, 19 | "title": "Film 8", 20 | "year": 2015 21 | }, 22 | { 23 | "id": 9, 24 | "title": "Film 9", 25 | "year": 2020 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["plugin:@nx/react", "../../.eslintrc.json"], 3 | "ignorePatterns": ["!**/*"], 4 | "overrides": [ 5 | { 6 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], 7 | "rules": { 8 | "react-hooks/exhaustive-deps": "off" 9 | } 10 | }, 11 | { 12 | "files": ["*.ts", "*.tsx"], 13 | "rules": {} 14 | }, 15 | { 16 | "files": ["*.js", "*.jsx"], 17 | "rules": {} 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/flexysearch-react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react-jsx", 4 | "allowJs": false, 5 | "allowSyntheticDefaultImports": true, 6 | "strict": true, 7 | "resolveJsonModule": true, 8 | "esModuleInterop": true 9 | }, 10 | "files": [], 11 | "include": [], 12 | "references": [ 13 | { 14 | "path": "./tsconfig.lib.json" 15 | }, 16 | { 17 | "path": "./tsconfig.spec.json" 18 | } 19 | ], 20 | "extends": "../../tsconfig.base.json" 21 | } 22 | -------------------------------------------------------------------------------- /apps/docs/src/components/HomepageFeatures/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import clsx from 'clsx'; 3 | import styles from './styles.module.css'; 4 | 5 | export default function HomepageFeatures() { 6 | return ( 7 |
8 |
9 |
10 | 11 |
12 |
13 |
14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /packages/flexysearch-react/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "module": "commonjs", 6 | "types": ["jest", "node"] 7 | }, 8 | "include": [ 9 | "jest.config.ts", 10 | "src/**/*.test.ts", 11 | "src/**/*.spec.ts", 12 | "src/**/*.test.tsx", 13 | "src/**/*.spec.tsx", 14 | "src/**/*.test.js", 15 | "src/**/*.spec.js", 16 | "src/**/*.test.jsx", 17 | "src/**/*.spec.jsx", 18 | "src/**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/flexysearch/src/utils/helpers/objects.ts: -------------------------------------------------------------------------------- 1 | export const omit = ( 2 | object: Record, 3 | keys: Array 4 | ): Record => { 5 | if (!object) return {} 6 | try { 7 | const payload = Object.entries(object).filter( 8 | ([key]) => !keys.includes(key) 9 | ) 10 | const data: { [key: string]: any } = {} 11 | 12 | payload.forEach((item) => { 13 | const [key, value] = item 14 | data[key] = value 15 | }) 16 | return data 17 | } catch { 18 | return {} 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/tests/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "module": "commonjs", 6 | "types": ["jest", "node"] 7 | }, 8 | "include": [ 9 | "jest.config.ts", 10 | "src/**/*.test.ts", 11 | "src/**/*.spec.ts", 12 | "src/**/*.test.tsx", 13 | "src/**/*.spec.tsx", 14 | "src/**/*.test.js", 15 | "src/**/*.spec.js", 16 | "src/**/*.test.jsx", 17 | "src/**/*.spec.jsx", 18 | "src/**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "jsx": "react-jsx", 4 | "allowJs": false, 5 | "allowSyntheticDefaultImports": true, 6 | "strict": true, 7 | "resolveJsonModule": true, 8 | "esModuleInterop": true 9 | }, 10 | "files": [], 11 | "include": [ 12 | "./types/**/*.d.ts", 13 | ], 14 | "references": [ 15 | { 16 | "path": "./tsconfig.lib.json" 17 | }, 18 | { 19 | "path": "./tsconfig.spec.json" 20 | } 21 | ], 22 | "extends": "../../tsconfig.base.json" 23 | } 24 | -------------------------------------------------------------------------------- /packages/flexysearch-react/types/index.ts: -------------------------------------------------------------------------------- 1 | import { IRule } from 'flexysearch'; 2 | 3 | export interface FlexysearchHookProvider { 4 | data: T[]; 5 | filtered_data: T[]; 6 | setData: (data: T[]) => void; 7 | updateGlobalSearch: (value: string) => void; 8 | updateFilterRules: (rules: IRule[]) => void; 9 | handleClearFilter: () => void; 10 | searchValue: string; 11 | rules: IRule[]; 12 | } 13 | 14 | export interface FlexysearchHookProps { 15 | data?: T[]; 16 | } 17 | 18 | export interface FlexysearchHookState { 19 | data: T[]; 20 | filtered_data: T[]; 21 | } 22 | -------------------------------------------------------------------------------- /apps/docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flexysearch-docs", 3 | "version": "0.0.0", 4 | "private": true, 5 | "devDependencies": { 6 | "react-accounting-textfield": "*" 7 | }, 8 | "scripts": { 9 | "docusaurus": "docusaurus", 10 | "start": "docusaurus start", 11 | "build": "docusaurus build", 12 | "swizzle": "docusaurus swizzle", 13 | "deploy": "docusaurus deploy", 14 | "clear": "docusaurus clear", 15 | "serve": "docusaurus serve", 16 | "write-translations": "docusaurus write-translations", 17 | "write-heading-ids": "docusaurus write-heading-ids" 18 | } 19 | } -------------------------------------------------------------------------------- /__mocks__/babyBornsSequencial.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 96, 3 | "first_name": "Parrnell", 4 | "last_name": "Woodley", 5 | "born_at": "2022-01-01" 6 | }, { 7 | "id": 97, 8 | "first_name": "Annabella", 9 | "last_name": "Rapelli", 10 | "born_at": "2022-01-02" 11 | }, { 12 | "id": 98, 13 | "first_name": "Jedd", 14 | "last_name": "MacDavitt", 15 | "born_at": "2022-01-03" 16 | }, { 17 | "id": 99, 18 | "first_name": "Penni", 19 | "last_name": "Lockhart", 20 | "born_at": "2022-01-04" 21 | }, { 22 | "id": 100, 23 | "first_name": "Tammara", 24 | "last_name": "Toupe", 25 | "born_at": "2022-01-05" 26 | }] 27 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/dates/expectBefore.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 2, 3 | "first_name": "Marcile", 4 | "last_name": "Wesson", 5 | "born_at": "2021-10-23" 6 | }, { 7 | "id": 6, 8 | "first_name": "Penny", 9 | "last_name": "Caslane", 10 | "born_at": "2022-03-22" 11 | }, { 12 | "id": 7, 13 | "first_name": "Kris", 14 | "last_name": "Royse", 15 | "born_at": "2021-12-05" 16 | }, { 17 | "id": 9, 18 | "first_name": "Nisse", 19 | "last_name": "Reeson", 20 | "born_at": "2022-03-07" 21 | }, { 22 | "id": 10, 23 | "first_name": "Kincaid", 24 | "last_name": "Dautry", 25 | "born_at": "2021-12-27" 26 | }] 27 | -------------------------------------------------------------------------------- /packages/flexysearch/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "forceConsistentCasingInFileNames": true, 6 | "strict": true, 7 | "noImplicitOverride": true, 8 | "noPropertyAccessFromIndexSignature": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "resolveJsonModule": true, 12 | "esModuleInterop": true 13 | }, 14 | "files": [], 15 | "include": [], 16 | "references": [ 17 | { 18 | "path": "./tsconfig.lib.json" 19 | }, 20 | { 21 | "path": "./tsconfig.spec.json" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectSmallerThan.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Film 1", 5 | "year": 2009 6 | }, 7 | { 8 | "id": 5, 9 | "title": "Film 5", 10 | "year": 2001 11 | }, 12 | { 13 | "id": 6, 14 | "title": "Film 6", 15 | "year": 2000 16 | }, 17 | { 18 | "id": 7, 19 | "title": "Film 7", 20 | "year": 2009 21 | }, 22 | { 23 | "id": 10, 24 | "title": "Film 10", 25 | "year": 1997 26 | }, 27 | { 28 | "id": 11, 29 | "title": "Film 11", 30 | "year": 1992 31 | }, 32 | { 33 | "id": 12, 34 | "title": "Film 12", 35 | "year": 1990 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-accounting-textfield", 3 | "version": "1.2.11", 4 | "main": "./index.ts", 5 | "dependencies": { 6 | "clsx": "^1.2.1" 7 | }, 8 | "peerDependencies": { 9 | "react": "^18.1.0", 10 | "react-dom": "^18.1.0" 11 | }, 12 | "description": "A React component for currency textfield", 13 | "author": { 14 | "name": "alexandro castro", 15 | "email": "alexoliveira7x@gmail.com" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/AlexcastroDev/flexysearch.git" 20 | }, 21 | "homepage": "https://alexcastrodev.github.io/flexysearch", 22 | "license": "MIT" 23 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | dist 5 | tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | 41 | .nx/cache -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | This monorepo contains some of my npm packages. 4 | 5 | It's hard to maintain multiple packages in different repositories, so I decided to create a monorepo to maintain all my packages. 6 | 7 | In near future, I want to transfer all my packages to a organization, but for now, I will maintain them here. 8 | 9 | ## Packages 10 | 11 | - [Flexysearch](./packages/flexysearch/README.md) 12 | - [Flexysearch React](./packages/flexysearch-react/README.md) 13 | - [React Accounting Textfield](./packages/react-accounting-textfield/README.md) 14 | 15 | ## Documentation 16 | 17 | - [Docs](https://alexcastrodev.github.io/flexysearch/docs/packages/react-accounting-textfield/) 18 | -------------------------------------------------------------------------------- /apps/docs/docs/changelogs/Changelogs-Core.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Package flexysearch 6 | 7 | ## [Unreleased] 8 | 9 | ## [Release] 10 | 11 | ## [1.2.3] Flexysearch - 2023-09-12 12 | 13 | ## Fixes 14 | 15 | - Fix pagination offset calculation 16 | 17 | ## [1.2.2] Flexysearch - 2023-09-12 18 | 19 | ## Added 20 | 21 | - Handlers of undefined values 22 | 23 | ## [1.2.1] Flexysearch - 2023-09-12 24 | 25 | ## Added 26 | 27 | - IPaginationResult interface 28 | 29 | ## [1.2.0] Flexysearch - 2023-09-12 30 | 31 | ## Added 32 | 33 | - Pagination support 34 | 35 | ## [1.1.0] Flexysearch - 2023-04-14 36 | 37 | ## Changed 38 | 39 | - Implementation with Flexysearch React 40 | -------------------------------------------------------------------------------- /packages/flexysearch-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flexysearch-react", 3 | "version": "1.0.0", 4 | "main": "./src/index.ts", 5 | "dependencies": { 6 | "flexysearch": "1.0.0" 7 | }, 8 | "peerDependencies": { 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0" 11 | }, 12 | "description": "A package for tables searching flexibly with React", 13 | "author": { 14 | "name": "alexandro castro", 15 | "email": "alexoliveira7x@gmail.com" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/AlexcastroDev/flexysearch.git" 20 | }, 21 | "homepage": "https://alexcastrodev.github.io/flexysearch", 22 | "license": "MIT" 23 | } 24 | -------------------------------------------------------------------------------- /packages/flexysearch/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flexysearch", 3 | "version": "1.2.3", 4 | "source": "src/index.ts", 5 | "main": "src/index.js", 6 | "module": "src/index.esm.js", 7 | "types": "src/index.d.ts", 8 | "files": [ 9 | "src", 10 | "interfaces" 11 | ], 12 | "type": "commonjs", 13 | "description": "A package for tables searching flexibly", 14 | "author": { 15 | "name": "alexandro castro", 16 | "email": "alexoliveira7x@gmail.com" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/AlexcastroDev/flexysearch.git" 21 | }, 22 | "homepage": "https://alexcastrodev.github.io/flexysearch", 23 | "license": "MIT" 24 | } 25 | -------------------------------------------------------------------------------- /packages/flexysearch-react/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "types": ["node"] 6 | }, 7 | "files": [ 8 | "../../node_modules/@nx/react/typings/cssmodule.d.ts", 9 | "../../node_modules/@nx/react/typings/image.d.ts" 10 | ], 11 | "exclude": [ 12 | "jest.config.ts", 13 | "src/**/*.spec.ts", 14 | "src/**/*.test.ts", 15 | "src/**/*.spec.tsx", 16 | "src/**/*.test.tsx", 17 | "src/**/*.spec.js", 18 | "src/**/*.test.js", 19 | "src/**/*.spec.jsx", 20 | "src/**/*.test.jsx" 21 | ], 22 | "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] 23 | } 24 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/strings/expectedEmpty.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 13, 4 | "title": "Fog Scent Xpressio Perfume", 5 | "price": 13, 6 | "colors": "" 7 | }, 8 | { 9 | "id": 14, 10 | "title": "Non-Alcoholic Concentrated Perfume Oil", 11 | "price": 120, 12 | "colors": "" 13 | }, 14 | { 15 | "id": 16, 16 | "title": "Hyaluronic Acid Serum", 17 | "price": 19, 18 | "colors": "" 19 | }, 20 | { 21 | "id": 18, 22 | "title": "Oil Free Moisturizer 100ml", 23 | "price": 40, 24 | "colors": "" 25 | }, 26 | { 27 | "id": 19, 28 | "title": "Skin Beauty Serum.", 29 | "price": 46, 30 | "colors": "" 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "importHelpers": true, 11 | "target": "es2015", 12 | "module": "esnext", 13 | "lib": ["es2017", "dom"], 14 | "skipLibCheck": true, 15 | "skipDefaultLibCheck": true, 16 | "baseUrl": ".", 17 | "paths": { 18 | "flexysearch-react": ["packages/flexysearch-react/src/index.ts"], 19 | "react-accounting-textfield": ["packages/react-accounting-textfield/src/index.ts"], 20 | } 21 | }, 22 | "exclude": ["node_modules", "tmp"] 23 | } 24 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/dates/expectAfter.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 1, 3 | "first_name": "Amber", 4 | "last_name": "Pockey", 5 | "born_at": "2022-08-12" 6 | }, { 7 | "id": 6, 8 | "first_name": "Penny", 9 | "last_name": "Caslane", 10 | "born_at": "2022-03-22" 11 | }, { 12 | "id": 7, 13 | "first_name": "Kris", 14 | "last_name": "Royse", 15 | "born_at": "2021-12-05" 16 | }, { 17 | "id": 8, 18 | "first_name": "Delinda", 19 | "last_name": "Sydall", 20 | "born_at": "2022-07-30" 21 | }, { 22 | "id": 9, 23 | "first_name": "Nisse", 24 | "last_name": "Reeson", 25 | "born_at": "2022-03-07" 26 | }, { 27 | "id": 10, 28 | "first_name": "Kincaid", 29 | "last_name": "Dautry", 30 | "born_at": "2021-12-27" 31 | }] 32 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/assets/icons/exclamationCircle.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export const ExclamationCircleIcon: React.FC< 4 | React.SVGAttributes 5 | > = (props) => { 6 | return ( 7 | 8 | 9 | 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/flexysearch-react/src/state/reducer.ts: -------------------------------------------------------------------------------- 1 | import { ReducerAction } from './../../types/internal'; 2 | import { FlexysearchHookState } from './../../types'; 3 | import { Kind } from './actions'; 4 | 5 | const SearchReducer = ( 6 | state: FlexysearchHookState, 7 | action: ReducerAction 8 | ) => { 9 | switch (action.kind) { 10 | case Kind.SET_DATA_ACTION: { 11 | return { 12 | ...state, 13 | data: action.payload, 14 | }; 15 | } 16 | case Kind.SET_FILTERED_DATA_ACTION: { 17 | return { 18 | ...state, 19 | filtered_data: action.payload, 20 | }; 21 | } 22 | default: { 23 | return { 24 | ...state, 25 | }; 26 | } 27 | } 28 | }; 29 | 30 | export default SearchReducer; 31 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: alexcastrodev 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectSmallerOrEquals.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Film 1", 5 | "year": 2009 6 | }, 7 | { 8 | "id": 3, 9 | "title": "Film 3", 10 | "year": 2014 11 | }, 12 | { 13 | "id": 4, 14 | "title": "Film 4", 15 | "year": 2014 16 | }, 17 | { 18 | "id": 5, 19 | "title": "Film 5", 20 | "year": 2001 21 | }, 22 | { 23 | "id": 6, 24 | "title": "Film 6", 25 | "year": 2000 26 | }, 27 | { 28 | "id": 7, 29 | "title": "Film 7", 30 | "year": 2009 31 | }, 32 | { 33 | "id": 10, 34 | "title": "Film 10", 35 | "year": 1997 36 | }, 37 | { 38 | "id": 11, 39 | "title": "Film 11", 40 | "year": 1992 41 | }, 42 | { 43 | "id": 12, 44 | "title": "Film 12", 45 | "year": 1990 46 | } 47 | ] 48 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/components/Uncontrolled.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { IUncontrolledProps } from '../../types' 3 | import {eventInputToCurrency} from '../utils' 4 | export const CurrencyInputUncontrolled: React.FC = ({ 5 | inputProps, 6 | defaultValue, 7 | value, 8 | handleBlur, 9 | handleChange, 10 | setInputValue, 11 | testID = 'react-currency-input-uncontrolled', 12 | }) => { 13 | React.useEffect(() => { 14 | if (defaultValue !== 'undefined') { 15 | setInputValue(eventInputToCurrency(defaultValue)) 16 | } 17 | }, []) 18 | 19 | return ( 20 | 27 | ) 28 | } 29 | 30 | export default CurrencyInputUncontrolled 31 | -------------------------------------------------------------------------------- /apps/docs/docs/changelogs/Changelogs-React.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Package flexysearch-react 6 | 7 | ## [Unreleased] 8 | 9 | ## [Release] 10 | 11 | ## [1.0.0] - 2023-04-14 12 | 13 | ## Changed 14 | 15 | - Add Changelog section 16 | - Removed core-js from the project dependencies, as it was deemed unnecessary. 17 | 18 | ## Impact 19 | 20 | The project no longer relies on core-js for polyfilling and other utility functions. 21 | This change is expected to improve the project's performance and reduce its overall footprint. 22 | 23 | ## Feedback 24 | 25 | If you encounter any issues related to this change, please don't hesitate to report them to us. We will do our best to address them promptly. 26 | Note: The "Unreleased" heading indicates that this change has not yet been released to production. When the change is released, the heading will be updated to reflect the version number. 27 | -------------------------------------------------------------------------------- /apps/docs/sidebars.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Creating a sidebar enables you to: 3 | - create an ordered group of docs 4 | - render a sidebar for each doc of that group 5 | - provide next/previous navigation 6 | 7 | The sidebars can be generated from the filesystem, or explicitly defined here. 8 | 9 | Create as many sidebars as you want. 10 | */ 11 | 12 | // @ts-check 13 | 14 | /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ 15 | const sidebars = { 16 | // By default, Docusaurus generates a sidebar from the docs folder structure 17 | tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], 18 | 19 | // But you can create a sidebar manually 20 | /* 21 | tutorialSidebar: [ 22 | 'intro', 23 | 'hello', 24 | { 25 | type: 'category', 26 | label: 'Tutorial', 27 | items: ['tutorial-basics/create-a-document'], 28 | }, 29 | ], 30 | */ 31 | }; 32 | 33 | module.exports = sidebars; 34 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/strings/expectedNotContains.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 2, 4 | "title": "Film 2", 5 | "year": 2015 6 | }, 7 | { 8 | "id": 3, 9 | "title": "Film 3", 10 | "year": 2014 11 | }, 12 | { 13 | "id": 4, 14 | "title": "Film 4", 15 | "year": 2014 16 | }, 17 | { 18 | "id": 5, 19 | "title": "Film 5", 20 | "year": 2001 21 | }, 22 | { 23 | "id": 6, 24 | "title": "Film 6", 25 | "year": 2000 26 | }, 27 | { 28 | "id": 7, 29 | "title": "Film 7", 30 | "year": 2009 31 | }, 32 | { 33 | "id": 8, 34 | "title": "Film 8", 35 | "year": 2015 36 | }, 37 | { 38 | "id": 9, 39 | "title": "Film 9", 40 | "year": 2020 41 | }, 42 | { 43 | "id": 13, 44 | "title": "Film Null", 45 | "year": null 46 | }, 47 | { 48 | "id": 14, 49 | "title": "Film empty", 50 | "year": "" 51 | } 52 | ] 53 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/react-accounting-textfield/react-accounting-textfield.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | import Textfield from '../../../examples/Textfield' 6 | 7 | # React Accounting Textfield 8 | 9 | ## Create your first React Page 10 | 11 | Create a file at `src/components/textfield.tsx`: 12 | 13 | 14 | 15 | ## Code 16 | 17 | ```jsx title="src/components/textfield.tsx" 18 | import React from 'react'; 19 | import { CurrencyInput } from 'react-accounting-textfield'; 20 | 21 | export default function App({ appProps }) { 22 | return ( 23 | { 26 | pushEvent('onBlurCurrency', data) 27 | }} 28 | onChangeCurrency={(data) => { 29 | pushEvent('onChangeCurrency', data) 30 | setValue(data.value)} 31 | } 32 | maximumFractionDigits={2} // default 2 33 | /> 34 | ); 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /apps/docs/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. 4 | 5 | ### Installation 6 | 7 | ``` 8 | $ yarn 9 | ``` 10 | 11 | ### Local Development 12 | 13 | ``` 14 | $ yarn start 15 | ``` 16 | 17 | This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ### Build 20 | 21 | ``` 22 | $ yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ### Deployment 28 | 29 | Using SSH: 30 | 31 | ``` 32 | $ USE_SSH=true yarn deploy 33 | ``` 34 | 35 | Not using SSH: 36 | 37 | ``` 38 | $ GIT_USER= yarn deploy 39 | ``` 40 | 41 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 42 | -------------------------------------------------------------------------------- /nx.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "nx/presets/npm.json", 3 | "$schema": "./node_modules/nx/schemas/nx-schema.json", 4 | "generators": { 5 | "@nx/react": { 6 | "application": { 7 | "babel": true 8 | }, 9 | "library": { 10 | "unitTestRunner": "jest" 11 | } 12 | } 13 | }, 14 | "targetDefaults": { 15 | "lint": { 16 | "inputs": [ 17 | "default", 18 | "{workspaceRoot}/.eslintrc.json", 19 | "{workspaceRoot}/.eslintignore" 20 | ], 21 | "cache": true 22 | }, 23 | "build": { 24 | "cache": true 25 | }, 26 | "@nx/jest:jest": { 27 | "inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"], 28 | "cache": true, 29 | "options": { 30 | "passWithNoTests": true 31 | }, 32 | "configurations": { 33 | "ci": { 34 | "ci": true, 35 | "codeCoverage": true 36 | } 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/assets/icons/euro.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export const EuroSignIcon: React.FC> = ( 4 | props 5 | ) => { 6 | return ( 7 | 8 | 9 | 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/flexysearch/example-ssr-data.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | --- 4 | 5 | import TableWithGlobalFilter from '../../../examples/TableWithSSRdata' 6 | 7 | # SSR Data 8 | 9 | ## Create your first React Page 10 | 11 | Create a file at `src/pages/my-react-page.js`: 12 | 13 | 14 | 15 | ## Code 16 | 17 | Show full code 18 | 19 | ```jsx title="src/pages/my-react-page.tsx" 20 | import React from 'react'; 21 | import { useFlexysearch, FlexysearchProvider } from 'flexysearch-react'; 22 | 23 | // Each Table should have the FlexysearchProvider 24 | export default function App({ appProps }) { 25 | return ( 26 | // You can set default data here 27 | // 28 | 29 | 30 | 31 | ); 32 | } 33 | ``` 34 | -------------------------------------------------------------------------------- /apps/docs/docs/packages/flexysearch/example-global-filter.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 2 3 | --- 4 | 5 | import TableWithGlobalFilter from '../../../examples/TableWithGlobalFilter' 6 | 7 | # Global filter 8 | 9 | ## Create your first React Page 10 | 11 | Create a file at `src/pages/my-react-page.js`: 12 | 13 | 14 | 15 | ## Code 16 | 17 | Show full code 18 | 19 | ```jsx title="src/pages/my-react-page.tsx" 20 | import React from 'react'; 21 | import { useFlexysearch, FlexysearchProvider } from 'flexysearch-react'; 22 | 23 | const data = [{ name: 'Testing', mass: 100 }]; 24 | 25 | // Each Table should have the FlexysearchProvider 26 | export default function Module() { 27 | return ( 28 | // You can set default data here 29 | // 30 | 31 | 32 | 33 | ); 34 | } 35 | ``` 36 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "ignorePatterns": ["**/*"], 4 | "plugins": ["@nx"], 5 | "overrides": [ 6 | { 7 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], 8 | "rules": { 9 | "@nx/enforce-module-boundaries": [ 10 | "error", 11 | { 12 | "enforceBuildableLibDependency": true, 13 | "allow": [], 14 | "depConstraints": [ 15 | { 16 | "sourceTag": "*", 17 | "onlyDependOnLibsWithTags": ["*"] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | }, 24 | { 25 | "files": ["*.ts", "*.tsx"], 26 | "extends": ["plugin:@nx/typescript"], 27 | "rules": {} 28 | }, 29 | { 30 | "files": ["*.js", "*.jsx"], 31 | "extends": ["plugin:@nx/javascript"], 32 | "rules": {} 33 | }, 34 | { 35 | "files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"], 36 | "env": { 37 | "jest": true 38 | }, 39 | "rules": {} 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/dates/expectNotEquals.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 1, 3 | "first_name": "Amber", 4 | "last_name": "Pockey", 5 | "born_at": "2022-08-12" 6 | }, { 7 | "id": 2, 8 | "first_name": "Marcile", 9 | "last_name": "Wesson", 10 | "born_at": "2021-10-23" 11 | }, { 12 | "id": 3, 13 | "first_name": "Druci", 14 | "last_name": "Braune", 15 | "born_at": null 16 | }, { 17 | "id": 4, 18 | "first_name": "Andreas", 19 | "last_name": "Casassa", 20 | "born_at": "" 21 | }, { 22 | "id": 5, 23 | "first_name": "Harriette", 24 | "last_name": "Jeffers", 25 | "born_at": "null" 26 | }, { 27 | "id": 6, 28 | "first_name": "Penny", 29 | "last_name": "Caslane", 30 | "born_at": "2022-03-22" 31 | }, { 32 | "id": 7, 33 | "first_name": "Kris", 34 | "last_name": "Royse", 35 | "born_at": "2021-12-05" 36 | }, { 37 | "id": 8, 38 | "first_name": "Delinda", 39 | "last_name": "Sydall", 40 | "born_at": "2022-07-30" 41 | }, { 42 | "id": 9, 43 | "first_name": "Nisse", 44 | "last_name": "Reeson", 45 | "born_at": "2022-03-07" 46 | }] 47 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectedNumberNotEmpty.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Film 1", 5 | "year": 2009 6 | }, 7 | { 8 | "id": 2, 9 | "title": "Film 2", 10 | "year": 2015 11 | }, 12 | { 13 | "id": 3, 14 | "title": "Film 3", 15 | "year": 2014 16 | }, 17 | { 18 | "id": 4, 19 | "title": "Film 4", 20 | "year": 2014 21 | }, 22 | { 23 | "id": 5, 24 | "title": "Film 5", 25 | "year": 2001 26 | }, 27 | { 28 | "id": 6, 29 | "title": "Film 6", 30 | "year": 2000 31 | }, 32 | { 33 | "id": 7, 34 | "title": "Film 7", 35 | "year": 2009 36 | }, 37 | { 38 | "id": 8, 39 | "title": "Film 8", 40 | "year": 2015 41 | }, 42 | { 43 | "id": 9, 44 | "title": "Film 9", 45 | "year": 2020 46 | }, 47 | { 48 | "id": 10, 49 | "title": "Film 10", 50 | "year": 1997 51 | }, 52 | { 53 | "id": 11, 54 | "title": "Film 11", 55 | "year": 1992 56 | }, 57 | { 58 | "id": 12, 59 | "title": "Film 12", 60 | "year": 1990 61 | } 62 | ] 63 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectDifferentFrom.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Film 1", 5 | "year": 2009 6 | }, 7 | { 8 | "id": 2, 9 | "title": "Film 2", 10 | "year": 2015 11 | }, 12 | { 13 | "id": 5, 14 | "title": "Film 5", 15 | "year": 2001 16 | }, 17 | { 18 | "id": 6, 19 | "title": "Film 6", 20 | "year": 2000 21 | }, 22 | { 23 | "id": 7, 24 | "title": "Film 7", 25 | "year": 2009 26 | }, 27 | { 28 | "id": 8, 29 | "title": "Film 8", 30 | "year": 2015 31 | }, 32 | { 33 | "id": 9, 34 | "title": "Film 9", 35 | "year": 2020 36 | }, 37 | { 38 | "id": 10, 39 | "title": "Film 10", 40 | "year": 1997 41 | }, 42 | { 43 | "id": 11, 44 | "title": "Film 11", 45 | "year": 1992 46 | }, 47 | { 48 | "id": 12, 49 | "title": "Film 12", 50 | "year": 1990 51 | }, 52 | { 53 | "id": 13, 54 | "title": "Film Null", 55 | "year": null 56 | }, 57 | { 58 | "id": 14, 59 | "title": "Film empty", 60 | "year": "" 61 | } 62 | ] 63 | -------------------------------------------------------------------------------- /.github/workflows/pull_request.yml: -------------------------------------------------------------------------------- 1 | name: Pull request workflow 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '**' 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.event.number || github.sha }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | test_pull_request: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Get Yarn cache path 17 | id: yarn-cache 18 | run: echo "::set-output name=dir::$(yarn cache dir)" 19 | - uses: actions/checkout@v4 20 | - uses: actions/setup-node@v4 21 | with: 22 | node-version: '16.14.0' 23 | - name: Load Yarn cache 24 | uses: actions/cache@v4 25 | with: 26 | path: ${{ steps.yarn-cache.outputs.dir }} 27 | key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 28 | restore-keys: | 29 | ${{ runner.os }}-yarn- 30 | - name: Install dependencies 31 | run: yarn install --frozen-lockfile 32 | - name: install gulp 33 | run: yarn global add gulp-cli 34 | - name: Run test 35 | run: gulp testCI 36 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/__mocks__/numbers/expectedNumberNotContains.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Film 1", 5 | "year": 2009 6 | }, 7 | { 8 | "id": 2, 9 | "title": "Film 2", 10 | "year": 2015 11 | }, 12 | { 13 | "id": 5, 14 | "title": "Film 5", 15 | "year": 2001 16 | }, 17 | { 18 | "id": 6, 19 | "title": "Film 6", 20 | "year": 2000 21 | }, 22 | { 23 | "id": 7, 24 | "title": "Film 7", 25 | "year": 2009 26 | }, 27 | { 28 | "id": 8, 29 | "title": "Film 8", 30 | "year": 2015 31 | }, 32 | { 33 | "id": 9, 34 | "title": "Film 9", 35 | "year": 2020 36 | }, 37 | { 38 | "id": 10, 39 | "title": "Film 10", 40 | "year": 1997 41 | }, 42 | { 43 | "id": 11, 44 | "title": "Film 11", 45 | "year": 1992 46 | }, 47 | { 48 | "id": 12, 49 | "title": "Film 12", 50 | "year": 1990 51 | }, 52 | { 53 | "id": 13, 54 | "title": "Film Null", 55 | "year": null 56 | }, 57 | { 58 | "id": 14, 59 | "title": "Film empty", 60 | "year": "" 61 | } 62 | ] 63 | -------------------------------------------------------------------------------- /__mocks__/items.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 11, 4 | "title": "perfume Oil", 5 | "price": 13, 6 | "colors": "Blue" 7 | }, 8 | { 9 | "id": 12, 10 | "title": "Brown Perfume", 11 | "price": 40, 12 | "colors": null 13 | }, 14 | { 15 | "id": 13, 16 | "title": "Fog Scent Xpressio Perfume", 17 | "price": 13, 18 | "colors": "" 19 | }, 20 | { 21 | "id": 14, 22 | "title": "Non-Alcoholic Concentrated Perfume Oil", 23 | "price": 120, 24 | "colors": "" 25 | }, 26 | { 27 | "id": 15, 28 | "title": "Eau De Perfume Spray", 29 | "price": 30, 30 | "colors": [] 31 | }, 32 | { 33 | "id": 16, 34 | "title": "Hyaluronic Acid Serum", 35 | "price": 19, 36 | "colors": "" 37 | }, 38 | { 39 | "id": 17, 40 | "title": "Tree Oil 30ml", 41 | "price": 12, 42 | "colors": "red" 43 | }, 44 | { 45 | "id": 18, 46 | "title": "Oil Free Moisturizer 100ml", 47 | "price": 40, 48 | "colors": "" 49 | }, 50 | { 51 | "id": 19, 52 | "title": "Skin Beauty Serum.", 53 | "price": 46, 54 | "colors": "" 55 | } 56 | ] 57 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/components/Controlled.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { IInputComponentProps } from '../../types' 3 | 4 | export const CurrencyInputControlled: React.FC = ({ 5 | inputProps, 6 | handleBlur, 7 | handleChange, 8 | value, 9 | testID = 'react-currency-input-controlled', 10 | }) => { 11 | const [cursor, setCursor] = React.useState(0) 12 | const ref = React.useRef(null) 13 | 14 | React.useEffect(() => { 15 | const input: any = ref.current 16 | if (input) { 17 | input.setSelectionRange(cursor, cursor) 18 | } 19 | }, [ref, cursor, value]) 20 | 21 | const handleChangeInput = (e: React.ChangeEvent) => { 22 | const caretEnd = e.target?.selectionEnd || 0 23 | setCursor(caretEnd) 24 | handleChange && handleChange(e) 25 | } 26 | 27 | return ( 28 | 36 | ) 37 | } 38 | 39 | export default CurrencyInputControlled 40 | -------------------------------------------------------------------------------- /apps/docs/src/css/custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Any CSS included here will be global. The classic template 3 | * bundles Infima by default. Infima is a CSS framework designed to 4 | * work well for content-centric websites. 5 | */ 6 | 7 | /* You can override the default Infima variables here. */ 8 | :root { 9 | --ifm-color-primary: #2e8555; 10 | --ifm-color-primary-dark: #29784c; 11 | --ifm-color-primary-darker: #277148; 12 | --ifm-color-primary-darkest: #205d3b; 13 | --ifm-color-primary-light: #33925d; 14 | --ifm-color-primary-lighter: #359962; 15 | --ifm-color-primary-lightest: #3cad6e; 16 | --ifm-code-font-size: 95%; 17 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1); 18 | } 19 | 20 | /* For readability concerns, you should choose a lighter palette in dark mode. */ 21 | [data-theme='dark'] { 22 | --ifm-color-primary: #25c2a0; 23 | --ifm-color-primary-dark: #21af90; 24 | --ifm-color-primary-darker: #1fa588; 25 | --ifm-color-primary-darkest: #1a8870; 26 | --ifm-color-primary-light: #29d5b0; 27 | --ifm-color-primary-lighter: #32d8b4; 28 | --ifm-color-primary-lightest: #4fddbf; 29 | --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3); 30 | } 31 | -------------------------------------------------------------------------------- /__mocks__/movies.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "title": "Film 1", 5 | "year": 2009 6 | }, 7 | { 8 | "id": 2, 9 | "title": "Film 2", 10 | "year": 2015 11 | }, 12 | { 13 | "id": 3, 14 | "title": "Film 3", 15 | "year": 2014 16 | }, 17 | { 18 | "id": 4, 19 | "title": "Film 4", 20 | "year": 2014 21 | }, 22 | { 23 | "id": 5, 24 | "title": "Film 5", 25 | "year": 2001 26 | }, 27 | { 28 | "id": 6, 29 | "title": "Film 6", 30 | "year": 2000 31 | }, 32 | { 33 | "id": 7, 34 | "title": "Film 7", 35 | "year": 2009 36 | }, 37 | { 38 | "id": 8, 39 | "title": "Film 8", 40 | "year": 2015 41 | }, 42 | { 43 | "id": 9, 44 | "title": "Film 9", 45 | "year": 2020 46 | }, 47 | { 48 | "id": 10, 49 | "title": "Film 10", 50 | "year": 1997 51 | }, 52 | { 53 | "id": 11, 54 | "title": "Film 11", 55 | "year": 1992 56 | }, 57 | { 58 | "id": 12, 59 | "title": "Film 12", 60 | "year": 1990 61 | }, 62 | { 63 | "id": 13, 64 | "title": "Film Null", 65 | "year": null 66 | }, 67 | { 68 | "id": 14, 69 | "title": "Film empty", 70 | "year": "" 71 | } 72 | ] 73 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/custom.test.ts: -------------------------------------------------------------------------------- 1 | import SearchEngine from '..' 2 | import { RuleOperator } from '../../interfaces' 3 | import collection from '../../../../__mocks__/movies.json' 4 | 5 | interface IMovie { 6 | id: number 7 | title: string 8 | year: number 9 | } 10 | 11 | describe('Should match strings', () => { 12 | it('[String]: Should cause exception', () => { 13 | const results = () => 14 | new SearchEngine(collection).search([ 15 | { 16 | type: 'custom', 17 | operator: RuleOperator.AND, 18 | }, 19 | ]) 20 | 21 | expect(results).toThrow('[flexysearch]: Custom filter not valid') 22 | }) 23 | it('[String]: Should cause exception', () => { 24 | const results = new SearchEngine(collection).search([ 25 | { 26 | type: 'custom', 27 | operator: RuleOperator.AND, 28 | filter: (datum: IMovie) => { 29 | return datum.year === 2009 30 | }, 31 | }, 32 | ]) 33 | 34 | expect(results).toStrictEqual([ 35 | { 36 | id: 1, 37 | title: 'Film 1', 38 | year: 2009, 39 | }, 40 | { 41 | id: 7, 42 | title: 'Film 7', 43 | year: 2009, 44 | }, 45 | ]) 46 | }) 47 | }) 48 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | const { exec } = require('child_process') 2 | const { parallel } = require('gulp') 3 | 4 | function testing(cb) { 5 | exec('yarn test:flexysearch', (err, stdout) => { 6 | if(err) { 7 | console.error(err) 8 | return 9 | } 10 | console.log(stdout) 11 | cb() 12 | }) 13 | exec('yarn test:react', (err, stdout) => { 14 | if(err) { 15 | console.error(err) 16 | return 17 | } 18 | console.log(stdout) 19 | cb() 20 | }) 21 | exec('yarn test:textfield', (err, stdout) => { 22 | if(err) { 23 | console.error(err) 24 | return 25 | } 26 | console.log(stdout) 27 | cb() 28 | }) 29 | } 30 | 31 | 32 | function buildAll(cb) { 33 | exec('yarn build:flexysearch', (err, stdout) => { 34 | if(err) { 35 | console.error(err) 36 | return 37 | } 38 | console.log(stdout) 39 | cb() 40 | }) 41 | exec('yarn build:react', (err, stdout) => { 42 | if(err) { 43 | console.error(err) 44 | return 45 | } 46 | console.log(stdout) 47 | cb() 48 | }) 49 | exec('yarn build:textfield', (err, stdout) => { 50 | if(err) { 51 | console.error(err) 52 | return 53 | } 54 | console.log(stdout) 55 | cb() 56 | }) 57 | } 58 | 59 | 60 | exports.testCI = parallel(testing, buildAll) 61 | -------------------------------------------------------------------------------- /packages/flexysearch/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@flexysearch/core", 3 | "$schema": "../../node_modules/nx/schemas/project-schema.json", 4 | "sourceRoot": "packages/flexysearch/src", 5 | "projectType": "library", 6 | "targets": { 7 | "build": { 8 | "executor": "@nx/js:tsc", 9 | "outputs": ["{options.outputPath}"], 10 | "options": { 11 | "outputPath": "dist/packages/flexysearch", 12 | "main": "packages/flexysearch/src/index.ts", 13 | "tsConfig": "packages/flexysearch/tsconfig.lib.json", 14 | "assets": ["packages/flexysearch/*.md"] 15 | } 16 | }, 17 | "publish": { 18 | "executor": "nx:run-commands", 19 | "options": { 20 | "command": "node tools/scripts/publish.mjs flexysearch {args.ver} {args.tag}" 21 | }, 22 | "dependsOn": ["build"] 23 | }, 24 | "lint": { 25 | "executor": "@nx/eslint:lint", 26 | "outputs": ["{options.outputFile}"], 27 | "options": { 28 | "lintFilePatterns": ["packages/flexysearch/**/*.ts"] 29 | } 30 | }, 31 | "test": { 32 | "executor": "@nx/jest:jest", 33 | "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], 34 | "options": { 35 | "jestConfig": "packages/flexysearch/jest.config.ts" 36 | } 37 | } 38 | }, 39 | "tags": [] 40 | } 41 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/types/index.ts: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export interface ChangeCurrencyEventProps { 4 | cents: number; 5 | float: number; 6 | formatted: string; 7 | value: string; 8 | } 9 | 10 | export type InputSize = "sm" | "md" | "lg"; 11 | export interface IInputProps { 12 | defaultValue?: string | number; 13 | value?: string | number; 14 | testID?: string; 15 | inputProps?: React.InputHTMLAttributes; 16 | onChangeCurrency?: (data: ChangeCurrencyEventProps) => void; 17 | onBlurCurrency?: (data: ChangeCurrencyEventProps) => void; 18 | showCurrencyIcon?: boolean; 19 | error?: boolean; 20 | helperText?: string | React.ReactElement; 21 | size?: InputSize; 22 | label?: string | React.ReactElement; 23 | minValue?: number; 24 | maxValue?: number; 25 | maximumFractionDigits?: number; 26 | } 27 | export interface IInputComponentProps { 28 | value: string; 29 | handleChange: (event: React.ChangeEvent) => void; 30 | handleBlur: (event: React.FocusEvent) => void; 31 | inputProps?: React.InputHTMLAttributes; 32 | setInputValue: React.Dispatch>; 33 | testID?: string; 34 | } 35 | 36 | export interface IUncontrolledProps extends IInputComponentProps { 37 | defaultValue: string; 38 | } 39 | -------------------------------------------------------------------------------- /apps/docs/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import clsx from 'clsx'; 3 | import Link from '@docusaurus/Link'; 4 | import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; 5 | import Layout from '@theme/Layout'; 6 | import HomepageFeatures from '@site/src/components/HomepageFeatures'; 7 | 8 | import styles from './index.module.css'; 9 | 10 | function HomepageHeader() { 11 | const {siteConfig} = useDocusaurusContext(); 12 | return ( 13 |
14 |
15 |

{siteConfig.title}

16 |

{siteConfig.tagline}

17 |
18 | 21 | Start with Flexysearch 22 | 23 |
24 |
25 |
26 | ); 27 | } 28 | 29 | export default function Home() { 30 | const {siteConfig} = useDocusaurusContext(); 31 | return ( 32 | 35 | 36 |
37 | 38 |
39 |
40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /apps/docs/docs/intro.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 1 3 | --- 4 | 5 | # Get Stated 6 | 7 | Only node or only engine 8 | 9 | React hook 10 | 11 | ```bash 12 | npm i flexysearch-react 13 | ``` 14 | 15 | Only engine ( just if you dont want the react hook ) 16 | 17 | ```bash 18 | npm i flexysearch 19 | ``` 20 | 21 | # Documentation 22 | 23 | For more detailed documentation on how to use Flexysearch, please visit our documentation website. It provides a comprehensive guide on how to install, configure, and use Flexysearch to its full potential. 24 | 25 | Support and Community 26 | We have a Discord group dedicated to Flexysearch where you can connect with other developers and get support when you need it. 27 | 28 | # Why Flexysearch? 29 | 30 | We created Flexysearch because we were looking for a simple solution for table searching that could handle strings, numbers, and dates. We couldn't find an existing solution that met our needs, so we decided to create our own. 31 | 32 | # Contributing 33 | 34 | We welcome contributions from the community! If you want to contribute to Flexysearch, please start by checking our issues or creating a new one. Then, fork the project and submit a pull request to the dev branch. 35 | 36 | We appreciate it if you could include unit tests for any code changes you submit. 37 | 38 | # License 39 | 40 | Flexysearch is licensed under the MIT License. See the LICENSE file for more information. 41 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/operators.test.ts: -------------------------------------------------------------------------------- 1 | import { RuleNumberOptions } from './../../interfaces/index' 2 | import SearchEngine from '..' 3 | import { IRuleType, RuleOperator, RuleStringOptions } from '../../interfaces' 4 | import collection from '../../../../__mocks__/movies.json' 5 | 6 | describe('Should match strings', () => { 7 | it('[Number]: Should cause exception', () => { 8 | const results = () => 9 | new SearchEngine(collection).search([ 10 | { 11 | field: 'title', 12 | term: 'film 3', 13 | role: RuleStringOptions.contains, 14 | type: 'dateee' as IRuleType, 15 | operator: RuleOperator.AND, 16 | }, 17 | ]) 18 | 19 | expect(results).toThrow('[flexysearch]: Processor not found') 20 | }) 21 | it('[Operators]: Contains', () => { 22 | const results = new SearchEngine(collection).search([ 23 | { 24 | field: 'title', 25 | term: 'film 3', 26 | role: RuleStringOptions.contains, 27 | type: 'string', 28 | operator: RuleOperator.AND, 29 | }, 30 | { 31 | field: 'year', 32 | term: '2014', 33 | role: RuleNumberOptions.equals, 34 | type: 'number', 35 | operator: RuleOperator.OR, 36 | }, 37 | ]) 38 | 39 | expect(results).toStrictEqual([ 40 | { 41 | id: 3, 42 | title: 'Film 3', 43 | year: 2014, 44 | }, 45 | { 46 | id: 4, 47 | title: 'Film 4', 48 | year: 2014, 49 | }, 50 | ]) 51 | }) 52 | }) 53 | -------------------------------------------------------------------------------- /packages/flexysearch-react/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flexysearch-react", 3 | "$schema": "../../node_modules/nx/schemas/project-schema.json", 4 | "sourceRoot": "packages/flexysearch-react/src", 5 | "projectType": "library", 6 | "tags": [], 7 | "targets": { 8 | "lint": { 9 | "executor": "@nx/eslint:lint", 10 | "outputs": ["{options.outputFile}"], 11 | "options": { 12 | "lintFilePatterns": ["packages/flexysearch-react/**/*.{ts,tsx,js,jsx}"] 13 | } 14 | }, 15 | "build": { 16 | "executor": "@nx/rollup:rollup", 17 | "outputs": ["{options.outputPath}"], 18 | "options": { 19 | "outputPath": "dist/packages/flexysearch-react", 20 | "tsConfig": "packages/flexysearch-react/tsconfig.lib.json", 21 | "project": "packages/flexysearch-react/package.json", 22 | "entryFile": "packages/flexysearch-react/src/index.ts", 23 | "external": ["react/jsx-runtime"], 24 | "rollupConfig": "@nx/react/plugins/bundle-rollup", 25 | "compiler": "babel", 26 | "assets": [ 27 | { 28 | "glob": "packages/flexysearch-react/README.md", 29 | "input": ".", 30 | "output": "." 31 | } 32 | ], 33 | "babelUpwardRootMode": true, 34 | "updateBuildableProjectDepsInPackageJson": true 35 | } 36 | }, 37 | "test": { 38 | "executor": "@nx/jest:jest", 39 | "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], 40 | "options": { 41 | "jestConfig": "packages/flexysearch-react/jest.config.ts" 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/flexysearch/README.md: -------------------------------------------------------------------------------- 1 | Welcome to Flexysearch! Flexysearch is a simple and customizable search library that allows you to search for strings, numbers, and dates in tables. It's easy to use, and it provides a beautiful React hook that implements Flexysearch, saving you time and energy. 2 | 3 | # Get Stated 4 | 5 | Only node or only engine 6 | 7 | React hook 8 | 9 | ```bash 10 | npm i flexysearch-react 11 | ``` 12 | 13 | Only engine ( just if you dont want the react hook ) 14 | 15 | ```bash 16 | npm i flexysearch 17 | ``` 18 | 19 | # Documentation 20 | 21 | For more detailed documentation on how to use Flexysearch, please visit our documentation website. It provides a comprehensive guide on how to install, configure, and use Flexysearch to its full potential. 22 | 23 | Support and Community 24 | We have a Discord group dedicated to Flexysearch where you can connect with other developers and get support when you need it. 25 | 26 | # Why Flexysearch? 27 | 28 | We created Flexysearch because we were looking for a simple solution for table searching that could handle strings, numbers, and dates. We couldn't find an existing solution that met our needs, so we decided to create our own. 29 | 30 | # Contributing 31 | 32 | We welcome contributions from the community! If you want to contribute to Flexysearch, please start by checking our issues or creating a new one. Then, fork the project and submit a pull request to the dev branch. 33 | 34 | We appreciate it if you could include unit tests for any code changes you submit. 35 | 36 | # License 37 | 38 | Flexysearch is licensed under the MIT License. See the LICENSE file for more information. 39 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-accounting-textfield", 3 | "$schema": "../../node_modules/nx/schemas/project-schema.json", 4 | "sourceRoot": "packages/react-accounting-textfield/src", 5 | "projectType": "library", 6 | "tags": [], 7 | "targets": { 8 | "lint": { 9 | "executor": "@nx/eslint:lint", 10 | "outputs": [ 11 | "{options.outputFile}" 12 | ], 13 | "options": { 14 | "lintFilePatterns": [ 15 | "packages/react-accounting-textfield/**/*.{ts,tsx,js,jsx}" 16 | ] 17 | } 18 | }, 19 | "build": { 20 | "executor": "@nx/rollup:rollup", 21 | "outputs": [ 22 | "{options.outputPath}" 23 | ], 24 | "options": { 25 | "outputPath": "dist/packages/react-accounting-textfield", 26 | "tsConfig": "packages/react-accounting-textfield/tsconfig.lib.json", 27 | "project": "packages/react-accounting-textfield/package.json", 28 | "entryFile": "packages/react-accounting-textfield/index.ts", 29 | "external": [ 30 | "react/jsx-runtime" 31 | ], 32 | "rollupConfig": "@nx/react/plugins/bundle-rollup", 33 | "compiler": "babel", 34 | "assets": [ 35 | { 36 | "glob": "packages/react-accounting-textfield/README.md", 37 | "input": ".", 38 | "output": "." 39 | } 40 | ], 41 | "babelUpwardRootMode": true, 42 | "updateBuildableProjectDepsInPackageJson": true 43 | } 44 | }, 45 | "test": { 46 | "executor": "@nx/jest:jest", 47 | "outputs": [ 48 | "{workspaceRoot}/coverage/{projectRoot}" 49 | ], 50 | "options": { 51 | "jestConfig": "packages/react-accounting-textfield/jest.config.ts" 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /packages/flexysearch/src/features/Paginator.ts: -------------------------------------------------------------------------------- 1 | import { IPaginator } from '..' 2 | 3 | class Paginator implements IPaginator { 4 | perPage = 10 5 | currentPage = 1 6 | total = 0 7 | firstPage = 1 8 | 9 | constructor(data: Partial) { 10 | Object.assign(this, data) 11 | } 12 | 13 | get isEmpty() { 14 | return this.total === 0 15 | } 16 | 17 | get hasTotal() { 18 | return this.total > 0 19 | } 20 | 21 | get hasMorePages() { 22 | return this.currentPage < this.lastPage 23 | } 24 | 25 | get hasPages() { 26 | return this.total > this.perPage 27 | } 28 | 29 | get lastPage() { 30 | return Math.ceil(this.total / this.perPage) 31 | } 32 | 33 | get offset() { 34 | return this.perPage * (this.currentPage - 1) 35 | } 36 | } 37 | 38 | class Paginate { 39 | data: T[] 40 | meta: Paginator 41 | 42 | constructor(data: T[], limit: number) { 43 | this.data = data 44 | this.meta = new Paginator({ perPage: limit, total: data.length }) 45 | } 46 | 47 | page(page: number) { 48 | this.meta.currentPage = page 49 | return this 50 | } 51 | 52 | get metaObject(): IPaginator { 53 | return { 54 | perPage: this.meta.perPage, 55 | currentPage: this.meta.currentPage, 56 | total: this.meta.total, 57 | firstPage: this.meta.firstPage, 58 | isEmpty: this.meta.isEmpty, 59 | hasTotal: this.meta.hasTotal, 60 | hasMorePages: this.meta.hasMorePages, 61 | hasPages: this.meta.hasPages, 62 | lastPage: this.meta.lastPage, 63 | offset: this.meta.offset, 64 | } 65 | } 66 | 67 | get all() { 68 | return { 69 | data: this.data.slice( 70 | this.meta.offset, 71 | this.meta.offset + this.meta.perPage 72 | ), 73 | meta: this.metaObject, 74 | } 75 | } 76 | } 77 | 78 | export default Paginate 79 | -------------------------------------------------------------------------------- /packages/flexysearch/interfaces/index.ts: -------------------------------------------------------------------------------- 1 | export type IRuleType = 'string' | 'number' | 'date' | 'custom' 2 | 3 | export enum RuleStringOptions { 4 | contains = 'contains', 5 | notContains = 'not_contains', 6 | equals = 'equals', 7 | isEmpty = 'is_empty', 8 | isNotEmpty = 'is_not_empty', 9 | startsWith = 'starts_with', 10 | endsWith = 'ends_with', 11 | } 12 | 13 | export enum RuleNumberOptions { 14 | contains = 'contains', 15 | notContains = 'not_contains', 16 | equals = 'equals', 17 | isEmpty = 'is_empty', 18 | isNotEmpty = 'is_not_empty', 19 | isNotEquals = 'is_not_equals', 20 | biggerThan = 'bigger_than', 21 | smallerThan = 'smaller_than', 22 | biggerOrEquals = 'bigger_or_equals', 23 | smallerOrEquals = 'smaller_or_equals', 24 | } 25 | 26 | export enum RuleDateOptions { 27 | equals = 'equals', 28 | isNotEquals = 'is_not_equals', 29 | isAfter = 'after', 30 | isBefore = 'before', 31 | isOnOrAfter = 'on_or_after', 32 | isOnOrBefore = 'on_or_before', 33 | isBetween = 'is_between', 34 | empty = 'is_empty', 35 | isNotEmpty = 'is_not_empty', 36 | } 37 | 38 | export enum RuleOperator { 39 | AND = '@and', 40 | OR = '@or', 41 | } 42 | 43 | export type IRoles = RuleStringOptions | RuleNumberOptions | RuleDateOptions 44 | 45 | export type IRuleFilter = (datum: T) => boolean 46 | 47 | export interface IRule { 48 | type: IRuleType 49 | operator: RuleOperator 50 | field?: string 51 | term?: any 52 | role?: IRoles 53 | caseSensitive?: boolean 54 | filter?: IRuleFilter 55 | } 56 | 57 | export interface IPaginator { 58 | perPage: number 59 | currentPage: number 60 | firstPage: number 61 | isEmpty: boolean 62 | total: number 63 | hasTotal: boolean 64 | lastPage: number 65 | hasMorePages: boolean 66 | hasPages: boolean 67 | offset: number 68 | } 69 | 70 | export interface IPaginateResult { 71 | data: T[] 72 | meta: IPaginator 73 | } 74 | -------------------------------------------------------------------------------- /apps/docs/docs/changelogs/Changelogs-Textfield.md: -------------------------------------------------------------------------------- 1 | --- 2 | sidebar_position: 3 3 | --- 4 | 5 | # Package Textfield 6 | 7 | ## [Unreleased] 8 | 9 | ## [1.2.11] 10 | 11 | ### Changes 12 | 13 | - pad when number are too small 14 | 15 | ## [1.2.10] 16 | 17 | ### Added 18 | 19 | - Gulp for tasks 20 | - Add padDecimal to utils 21 | 22 | ### Changes 23 | 24 | - Improving testing of precision 25 | 26 | ## [1.2.9] 27 | ## [1.2.8] 28 | ## [1.2.7] 29 | ## [1.2.6] 30 | 31 | ### Changes 32 | 33 | - Fix types from require import (NextJS) 34 | 35 | ## [1.2.5] 36 | 37 | ### Changes 38 | 39 | - Change code to index.tsx 40 | 41 | ## [1.2.4] 42 | 43 | ### Changes 44 | 45 | - Expose typings 46 | 47 | ## [1.2.3] 48 | 49 | ### Changes 50 | 51 | - remove accounting from dependency 52 | 53 | ## [1.2.2] 54 | 55 | ### Added 56 | 57 | - Unit test with testing library 58 | - Testing for utils 59 | - Expose all utils used in the component 60 | 61 | ### Fix 62 | 63 | - Importing 64 | 65 | ### Changes 66 | 67 | - Repository location 68 | - prepare to remove accounting depedency 69 | - remove export default, let just CurrencyInput 70 | 71 | ## [1.2.1] 72 | 73 | ### Fix 74 | 75 | - Fix types 76 | 77 | ## [1.2.0] 78 | 79 | ### Added 80 | 81 | - onBlurCurrency now accepts decimal places, if you pass 1,1234, it will emit a object with 82 | `{ value: '1,1234', float: 1.12, formatted: '1,12', cents: 112 }` 83 | 84 | ## [1.0.1] 85 | 86 | ### Added 87 | 88 | - onBlurCurrency that emit the same prop of onChangeCurrency 89 | 90 | ## [1.0.0] 91 | 92 | - Only released 93 | 94 | ## [0.2.4] - 2022-07-19 95 | 96 | - Fixed input controller 97 | 98 | ## [0.2.3] - 2022-07-18 99 | 100 | - Added integration tests 101 | - Added Max and Min Value 102 | 103 | ## [0.2.2] - 2022-07-18 104 | 105 | - Added css files 106 | - update readme.md 107 | 108 | ## [0.2.1] - 2022-07-18 109 | 110 | - Export component types 111 | 112 | ## [0.2.0] - 2022-07-16 113 | 114 | - Release version 115 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/README.md: -------------------------------------------------------------------------------- 1 | # Docs 2 | 3 | [Documentation / Preview](https://alexcastrodev.github.io/flexysearch/docs/packages/react-accounting-textfield/) 4 | 5 | # Package 6 | 7 | NPM package 8 | 9 | # Quick Start 10 | 11 | If you want to use `npm`, you can use this command. 12 | 13 | ```bash 14 | npm i react-accounting-textfield 15 | ``` 16 | 17 | Maybe you want to use `yarn`. 18 | 19 | ```bash 20 | yarn add react-accounting-textfield 21 | ``` 22 | 23 | ## imports 24 | 25 | Import this module 26 | 27 | ```javascript 28 | import CurrencyInput from 'react-accounting-textfield' 29 | ``` 30 | 31 | ## Styles 32 | 33 | If you want a default stylesheet, you should import the style: 34 | 35 | ```javascript 36 | import 'react-accounting-textfield/dist/styles.css' 37 | ``` 38 | 39 | If you want a flecto theme stylesheet, you should import the style: 40 | 41 | ```javascript 42 | import 'react-accounting-textfield/dist/theme/flecto.css' 43 | ``` 44 | 45 | ## Tests 46 | 47 | Storybook provides a clean-room environment for testing components in isolation. Stories make it easy to explore a component in all its variations, no matter how complex. 48 | 49 | That means stories are a pragmatic starting point for your UI testing strategy. You already write stories as a natural part of UI development, testing those stories is a low-effort way to prevent UI bugs over time. 50 | 51 | ```bash 52 | yarn test-storybook 53 | ``` 54 | 55 | Docs: https://storybook.js.org/docs/react/writing-tests/introduction 56 | 57 | ## How to contribute 58 | 59 | ### Start 60 | 61 | You can check our Issues, or you can create a new one, and fork this project, finally open a PR to `dev` branch. 62 | 63 | I'll be quick to implement and improve this package, and if you open a pull request, i'll help you with a new release as soon as possible. 64 | 65 | ### Changelog 66 | 67 | follow this pattern: 68 | 69 | https://keepachangelog.com/en/1.0.0/ 70 | -------------------------------------------------------------------------------- /apps/docs/examples/Textfield.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { CurrencyInput } from "react-accounting-textfield" 3 | import { ScrollArea, Box, Text } from '@mantine/core' 4 | 5 | interface Events { 6 | eventname: string; 7 | payload: any; 8 | } 9 | 10 | export default function App() { 11 | const [events, setEvents] = React.useState>([]); 12 | const [value, setValue] = React.useState('0'); 13 | 14 | const pushEvent = (eventname, payload) => { 15 | setEvents((events) => [{ eventname, payload }, ...events]); 16 | } 17 | 18 | return ( 19 | <> 20 | 2 Point floating 21 | { 24 | pushEvent('onBlurCurrency', data) 25 | }} 26 | onChangeCurrency={(data) => { 27 | pushEvent('onChangeCurrency', data) 28 | setValue(data.value)} 29 | } 30 | /> 31 | 32 | 4 Point floating 33 | { 36 | pushEvent('onBlurCurrency', data) 37 | }} 38 | onChangeCurrency={(data) => { 39 | pushEvent('onChangeCurrency', data) 40 | setValue(data.value)} 41 | } 42 | maximumFractionDigits={4} 43 | /> 44 | 45 | Uncontrolled 46 | { 49 | pushEvent('onBlurCurrency', data) 50 | }} 51 | onChangeCurrency={(data) => { 52 | pushEvent('onChangeCurrency', data) 53 | setValue(data.value)} 54 | } 55 | /> 56 | 57 | 58 | Events will show here: 59 | 60 | { 61 | events.map((event, index) => ( 62 |
63 | {event.eventname} - {events.length - index} 64 |
{JSON.stringify(event.payload, null, 2)}
65 |
66 | )) 67 | } 68 |
69 |
70 | 71 | ); 72 | } 73 | -------------------------------------------------------------------------------- /packages/flexysearch-react/README.md: -------------------------------------------------------------------------------- 1 | [![DeepSource](https://deepsource.io/gh/AlexcastroDev/flexysearch.svg/?label=active+issues&show_trend=true&token=1wKwpordCvhMLaZczotKat_y)](https://deepsource.io/gh/AlexcastroDev/flexysearch/?ref=repository-badge) 2 | 3 | [![DeepSource](https://deepsource.io/gh/AlexcastroDev/flexysearch.svg/?label=resolved+issues&show_trend=true&token=1wKwpordCvhMLaZczotKat_y)](https://deepsource.io/gh/AlexcastroDev/flexysearch/?ref=repository-badge) 4 | 5 | Welcome to Flexysearch! Flexysearch is a simple and customizable search library that allows you to search for strings, numbers, and dates in tables. It's easy to use, and it provides a beautiful React hook that implements Flexysearch, saving you time and energy. 6 | 7 | # Get Stated 8 | 9 | Only node or only engine 10 | 11 | React hook 12 | 13 | ```bash 14 | npm i flexysearch-react 15 | ``` 16 | 17 | Only engine ( just if you dont want the react hook ) 18 | 19 | ```bash 20 | npm i flexysearch 21 | ``` 22 | 23 | # Documentation 24 | 25 | For more detailed documentation on how to use Flexysearch, please visit our documentation website. It provides a comprehensive guide on how to install, configure, and use Flexysearch to its full potential. 26 | 27 | Support and Community 28 | We have a Discord group dedicated to Flexysearch where you can connect with other developers and get support when you need it. 29 | 30 | # Why Flexysearch? 31 | 32 | We created Flexysearch because we were looking for a simple solution for table searching that could handle strings, numbers, and dates. We couldn't find an existing solution that met our needs, so we decided to create our own. 33 | 34 | # Contributing 35 | 36 | We welcome contributions from the community! If you want to contribute to Flexysearch, please start by checking our issues or creating a new one. Then, fork the project and submit a pull request to the dev branch. 37 | 38 | We appreciate it if you could include unit tests for any code changes you submit. 39 | 40 | # License 41 | 42 | Flexysearch is licensed under the MIT License. See the LICENSE file for more information. 43 | -------------------------------------------------------------------------------- /tools/scripts/publish.mjs: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a minimal script to publish your package to "npm". 3 | * This is meant to be used as-is or customize as you see fit. 4 | * 5 | * This script is executed on "dist/path/to/library" as "cwd" by default. 6 | * 7 | * You might need to authenticate with NPM before running this script. 8 | */ 9 | 10 | import { readCachedProjectGraph } from '@nrwl/devkit'; 11 | import { execSync } from 'child_process'; 12 | import { readFileSync, writeFileSync } from 'fs'; 13 | import chalk from 'chalk'; 14 | 15 | function invariant(condition, message) { 16 | if (!condition) { 17 | console.error(chalk.bold.red(message)); 18 | process.exit(1); 19 | } 20 | } 21 | 22 | // Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag} 23 | // Default "tag" to "next" so we won't publish the "latest" tag by accident. 24 | const [, , name, version, tag = 'next'] = process.argv; 25 | 26 | // A simple SemVer validation to validate the version 27 | const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/; 28 | invariant( 29 | version && validVersion.test(version), 30 | `No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got ${version}.` 31 | ); 32 | 33 | const graph = readCachedProjectGraph(); 34 | const project = graph.nodes[name]; 35 | 36 | invariant( 37 | project, 38 | `Could not find project "${name}" in the workspace. Is the project.json configured correctly?` 39 | ); 40 | 41 | const outputPath = project.data?.targets?.build?.options?.outputPath; 42 | invariant( 43 | outputPath, 44 | `Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?` 45 | ); 46 | 47 | process.chdir(outputPath); 48 | 49 | // Updating the version in "package.json" before publishing 50 | try { 51 | const json = JSON.parse(readFileSync(`package.json`).toString()); 52 | json.version = version; 53 | writeFileSync(`package.json`, JSON.stringify(json, null, 2)); 54 | } catch (e) { 55 | console.error( 56 | chalk.bold.red(`Error reading package.json file from library build output.`) 57 | ); 58 | } 59 | 60 | // Execute "npm publish" to publish 61 | execSync(`npm publish --access public --tag ${tag}`); 62 | -------------------------------------------------------------------------------- /packages/flexysearch/src/utils/number.ts: -------------------------------------------------------------------------------- 1 | import { RuleNumberOptions } from '../../interfaces/index' 2 | import { IRoles } from '../../interfaces' 3 | 4 | export class NumberProcessor { 5 | private term: number 6 | private role: IRoles 7 | 8 | constructor(value: number, role?: IRoles) { 9 | this.term = Number(value) 10 | this.role = role as RuleNumberOptions 11 | } 12 | 13 | private getRegexValue(value: string) { 14 | return new RegExp(value, 'gi') 15 | } 16 | 17 | private checkContains(valueToBeCompared: string) { 18 | const regexpMatches = ( 19 | String(valueToBeCompared).match(this.getRegexValue(String(this.term))) || 20 | [] 21 | ).length 22 | 23 | if (this.role === RuleNumberOptions.notContains) { 24 | return regexpMatches === 0 25 | } 26 | 27 | return regexpMatches > 0 28 | } 29 | 30 | private checkisEmpty(numberValue: number, valueToBeCompared: string) { 31 | if (!valueToBeCompared || valueToBeCompared === null) { 32 | return true 33 | } 34 | return !Number.isSafeInteger(numberValue) 35 | } 36 | 37 | compareWith(valueToBeCompared: string) { 38 | const numberValue = Number(valueToBeCompared) 39 | 40 | switch (this.role) { 41 | case RuleNumberOptions.equals: 42 | return numberValue === this.term 43 | case RuleNumberOptions.isNotEquals: 44 | return numberValue !== this.term 45 | case RuleNumberOptions.biggerThan: 46 | return numberValue > this.term && !!valueToBeCompared 47 | case RuleNumberOptions.biggerOrEquals: 48 | return numberValue >= this.term && !!valueToBeCompared 49 | case RuleNumberOptions.smallerThan: 50 | return numberValue < this.term && !!valueToBeCompared 51 | case RuleNumberOptions.smallerOrEquals: 52 | return numberValue <= this.term && !!valueToBeCompared 53 | case RuleNumberOptions.contains: 54 | case RuleNumberOptions.notContains: 55 | return this.checkContains(valueToBeCompared) 56 | case RuleNumberOptions.isEmpty: 57 | return this.checkisEmpty(numberValue, valueToBeCompared) 58 | case RuleNumberOptions.isNotEmpty: 59 | return !this.checkisEmpty(numberValue, valueToBeCompared) 60 | default: 61 | throw new Error('[flexysearch]: Invalid role in Numbers') 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ## [0.1.1] - 2023-03-21-flexysearch-react 11 | 12 | ### Changes 13 | 14 | - Improve global search with pattern regexp 15 | 16 | ## [0.1.0] - 2023-03-21-flexysearch-react 17 | 18 | ### Added 19 | 20 | - Start project and testing 21 | 22 | ## [1.0.0] - 2022-10-09 23 | 24 | ### Added 25 | 26 | - Search strings starts with 27 | 28 | - Search strings ends with 29 | 30 | ## [0.4.1] - 2022-09-22 31 | 32 | - Added date filter: is on or after, ois on or before 33 | 34 | Thanks to @marcooli 35 | 36 | ## [0.4.0] - 2022-09-22 37 | 38 | - Added number filter: Different from, bigger than, smaller than, bigger or equals and smaller or equals. 39 | 40 | ## [0.3.0] - 2022-09-19 41 | 42 | ### Added 43 | 44 | - Added all filter by dates (https://github.com/AlexcastroDev/flexysearch/issues/4) 45 | 46 | - Added custom filter (https://github.com/AlexcastroDev/flexysearch/issues/4) 47 | 48 | ## [0.2.2] - 2022-08-07 49 | 50 | ### Fixes 51 | 52 | - Remove duplicate object when using OR operator 53 | 54 | ## [0.2.1] - 2022-08-03 55 | 56 | ### Fixes 57 | 58 | - Fix build after CI automate release 59 | 60 | ## [0.2.0] - 2022-08-03 61 | 62 | ### Added 63 | 64 | - Added optional case sensitive parameters (https://github.com/AlexcastroDev/flexysearch/issues/13) 65 | 66 | - Added search by number not empty (https://github.com/AlexcastroDev/flexysearch/issues/12) 67 | 68 | - Added search by number empty (https://github.com/AlexcastroDev/flexysearch/issues/11) 69 | - 70 | - Added search by string not empty (https://github.com/AlexcastroDev/flexysearch/issues/10) 71 | 72 | - Added search by string empty (https://github.com/AlexcastroDev/flexysearch/issues/9) 73 | 74 | ### Docs 75 | 76 | - [Docs] Change documentation to Notion page and change readme 77 | 78 | ## [0.1.2] - 2022-07-17 79 | 80 | ### Added 81 | 82 | - Added Not contains (https://github.com/AlexcastroDev/flexysearch/issues/7) 83 | 84 | ## [0.1.1] - 2022-07-11 85 | 86 | - [Docs] Update docs on NPM 87 | 88 | ## [0.1.0] - 2022-07-08 - (Beta) 89 | 90 | - Release first version with string and number searcher 91 | -------------------------------------------------------------------------------- /packages/flexysearch/src/utils/strings.ts: -------------------------------------------------------------------------------- 1 | import { IRoles, RuleStringOptions } from '../../interfaces' 2 | 3 | export class StringProcessor { 4 | private term = '' 5 | private caseSensitive = false 6 | private role: IRoles 7 | 8 | constructor(value: string, role?: IRoles) { 9 | this.term = value 10 | this.role = role as RuleStringOptions 11 | } 12 | 13 | private getRegexValue(value: string) { 14 | const flags = this.caseSensitive ? 'g' : 'gi' 15 | return new RegExp(value, flags) 16 | } 17 | 18 | private checkContains(valueToBeCompared: string) { 19 | const term = this.getRegexValue(String(this.term)) 20 | 21 | const regexpMatches = (valueToBeCompared.match(term) || []).length 22 | 23 | if (this.role === RuleStringOptions.notContains) { 24 | return regexpMatches === 0 25 | } 26 | 27 | return regexpMatches > 0 28 | } 29 | 30 | private checkEquals(valueToBeCompared: string) { 31 | if (!this.caseSensitive) { 32 | return valueToBeCompared.toLowerCase() === this.term.toLowerCase() 33 | } 34 | 35 | return valueToBeCompared === this.term 36 | } 37 | 38 | private checkisEmpty(valueToBeCompared: string) { 39 | return !valueToBeCompared 40 | } 41 | 42 | private startsWithTerm(valueToBeCompared: string) { 43 | if (!this.caseSensitive) { 44 | return valueToBeCompared.toLowerCase().startsWith(this.term.toLowerCase()) 45 | } 46 | 47 | return valueToBeCompared.startsWith(this.term) 48 | } 49 | 50 | private endsWithTerm(valueToBeCompared: string) { 51 | if (!this.caseSensitive) { 52 | return valueToBeCompared.toLowerCase().endsWith(this.term.toLowerCase()) 53 | } 54 | 55 | return valueToBeCompared.endsWith(this.term) 56 | } 57 | 58 | compareWith(valueToBeCompared: string, caseSensitive: boolean) { 59 | this.caseSensitive = caseSensitive 60 | 61 | if (typeof valueToBeCompared !== 'string') { 62 | return false 63 | } 64 | 65 | switch (this.role) { 66 | case RuleStringOptions.equals: 67 | return this.checkEquals(valueToBeCompared) 68 | case RuleStringOptions.contains: 69 | case RuleStringOptions.notContains: 70 | return this.checkContains(valueToBeCompared) 71 | case RuleStringOptions.isEmpty: 72 | return this.checkisEmpty(valueToBeCompared) 73 | case RuleStringOptions.isNotEmpty: 74 | return !this.checkisEmpty(valueToBeCompared) 75 | case RuleStringOptions.startsWith: 76 | return this.startsWithTerm(valueToBeCompared) 77 | case RuleStringOptions.endsWith: 78 | return this.endsWithTerm(valueToBeCompared) 79 | default: 80 | throw new Error('[flexysearch]: Invalid role in String') 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/Textfield.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render, screen, act, fireEvent } from '@testing-library/react'; 3 | import userEvent from '@testing-library/user-event' 4 | 5 | import { CurrencyInput } from '.'; 6 | 7 | describe('Textfield', () => { 8 | it('Should emit correct payload on Blur', () => { 9 | const onBlur = jest.fn(); 10 | render(); 11 | 12 | const input = screen.getByTestId('react-currency-input-uncontrolled'); 13 | 14 | act(() => { 15 | input.focus(); 16 | input.blur(); 17 | }) 18 | 19 | expect(onBlur).toHaveBeenCalledWith({ 20 | cents: 123, 21 | value: '1,23', 22 | float: 1.23, 23 | formatted: '1,23', 24 | }); 25 | }) 26 | it('Should emit decimal in value blur', () => { 27 | const onBlur = jest.fn(); 28 | render(); 29 | const input = screen.getByTestId('react-currency-input-controlled'); 30 | 31 | act(() => { 32 | input.focus(); 33 | input.blur(); 34 | }) 35 | 36 | expect(onBlur).toHaveBeenCalledWith({ 37 | cents: 110023, 38 | value: '1.100,23', 39 | float: 1100.23, 40 | formatted: '1.100,23', 41 | }); 42 | }) 43 | it('Should emit correct payload on change', async () => { 44 | const onChange = jest.fn(); 45 | render(); 46 | const input = screen.getByTestId('react-currency-input-controlled'); 47 | await userEvent.clear(input); 48 | fireEvent.change(input, { target: { value: '1100,2333' } }); 49 | 50 | const lastCall = onChange.mock.calls.at(-1).at(0); 51 | 52 | expect(lastCall).toEqual({ 53 | "cents": 110023, 54 | "float": 1100.23, 55 | "formatted": "1.100,23", 56 | "value": "1100,2333" 57 | }); 58 | }) 59 | it('Should emit and zero fill cents if are zeros', async () => { 60 | const onChange = jest.fn(); 61 | render(); 62 | const input = screen.getByTestId('react-currency-input-controlled'); 63 | await userEvent.clear(input); 64 | fireEvent.change(input, { target: { value: '1100' } }); 65 | 66 | const lastCall = onChange.mock.calls.at(-1).at(0); 67 | 68 | expect(lastCall).toEqual({ 69 | "cents": 110000, 70 | "float": 1100, 71 | "formatted": "1.100,00", 72 | "value": "1100" 73 | }); 74 | }) 75 | }) 76 | 77 | describe('Currency decimal', () => { 78 | it('Should emit and zero fill cents if are zeros - decimal', async () => { 79 | const onChange = jest.fn(); 80 | render(); 81 | const input = screen.getByTestId('react-currency-input-controlled'); 82 | await userEvent.clear(input); 83 | fireEvent.change(input, { target: { value: '1100,0099' } }); 84 | 85 | const lastCall = onChange.mock.calls.at(-1).at(0); 86 | 87 | expect(lastCall).toEqual({ 88 | "cents": 11000099, 89 | "float": 1100.0099, 90 | "formatted": "1.100,0099", 91 | "value": "1100,0099" 92 | }); 93 | }) 94 | }) 95 | -------------------------------------------------------------------------------- /apps/docs/docusaurus.config.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Note: type annotations allow type checking and IDEs autocompletion 3 | 4 | const lightCodeTheme = require('prism-react-renderer/themes/github'); 5 | const darkCodeTheme = require('prism-react-renderer/themes/dracula'); 6 | const RepositoryURL = 'https://github.com/AlexcastroDev/flexysearch' 7 | const projectName = 'Flexysearch' 8 | 9 | /** @type {import('@docusaurus/types').Config} */ 10 | const config = { 11 | title: projectName, 12 | tagline: 'Flexysearch is a search engine for your website', 13 | favicon: 'img/favicon.ico', 14 | 15 | // Set the production url of your site here 16 | url: 'https://alexcastrodev.github.io', 17 | // Set the // pathname under which your site is served 18 | // For GitHub pages deployment, it is often '//' 19 | baseUrl: '/flexysearch', 20 | 21 | // GitHub pages deployment config. 22 | // If you aren't using GitHub pages, you don't need these. 23 | organizationName: 'alexcastrodev', 24 | projectName: 'flexysearch', 25 | 26 | onBrokenLinks: 'throw', 27 | onBrokenMarkdownLinks: 'warn', 28 | 29 | // Even if you don't use internalization, you can use this field to set useful 30 | // metadata like html lang. For example, if your site is Chinese, you may want 31 | // to replace "en" with "zh-Hans". 32 | i18n: { 33 | defaultLocale: 'en', 34 | locales: ['en'], 35 | }, 36 | 37 | presets: [ 38 | [ 39 | 'classic', 40 | /** @type {import('@docusaurus/preset-classic').Options} */ 41 | ({ 42 | docs: { 43 | sidebarPath: require.resolve('./sidebars.js'), 44 | // Please change this to your repo. 45 | // Remove this to remove the "edit this page" links. 46 | editUrl: 47 | 'https://github.com/AlexcastroDev/flexysearch', 48 | }, 49 | theme: { 50 | customCss: require.resolve('./src/css/custom.css'), 51 | }, 52 | }), 53 | ], 54 | ], 55 | 56 | themeConfig: 57 | /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ 58 | ({ 59 | // Replace with your project's social card 60 | image: 'img/docusaurus-social-card.jpg', 61 | navbar: { 62 | title: 'Flexysearch', 63 | logo: { 64 | alt: 'flexysearch home', 65 | src: 'img/logo.svg', 66 | }, 67 | items: [ 68 | { 69 | type: 'doc', 70 | docId: 'intro', 71 | position: 'left', 72 | label: 'Get Started', 73 | }, 74 | { 75 | href: RepositoryURL, 76 | label: 'GitHub', 77 | position: 'right', 78 | }, 79 | ], 80 | }, 81 | footer: { 82 | style: 'dark', 83 | links: [ 84 | { 85 | title: 'Community', 86 | items: [ 87 | { 88 | label: 'Discord', 89 | href: 'https://discord.gg/t3vYGUuK6P', 90 | }, 91 | ], 92 | }, 93 | ], 94 | copyright: `Copyright © ${new Date().getFullYear()} ${projectName}.`, 95 | }, 96 | prism: { 97 | theme: lightCodeTheme, 98 | darkTheme: darkCodeTheme, 99 | }, 100 | }), 101 | }; 102 | 103 | module.exports = config; 104 | -------------------------------------------------------------------------------- /apps/docs/examples/TableWithSSRdata.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Card, Grid, Input, Table } from '@mantine/core'; 2 | import React from 'react'; 3 | import { useFlexysearch, FlexysearchProvider } from 'flexysearch-react'; 4 | import { IRule, RuleNumberOptions, RuleOperator } from 'flexysearch'; 5 | 6 | interface Element { 7 | name: string; 8 | power: number; 9 | } 10 | 11 | const mockDataServ = [ 12 | { name: 'Madara', power: 100 }, 13 | { name: 'Naruto', power: 60 }, 14 | { name: 'Sasuke', power: 48 }, 15 | { name: 'Sakura', power: 10 }, 16 | ]; 17 | 18 | export default function Module() { 19 | return ( 20 | 21 | 22 | 23 | ); 24 | } 25 | 26 | function TableWithGlobalFilter() { 27 | const { 28 | filtered_data, 29 | updateGlobalSearch, 30 | updateFilterRules, 31 | searchValue, 32 | rules, 33 | handleClearFilter, 34 | } = useFlexysearch(); 35 | 36 | const rows = filtered_data.map((element) => ( 37 | 38 | {element.name} 39 | {element.power} 40 | 41 | )); 42 | 43 | const handleSearchChange = (event: React.ChangeEvent) => { 44 | const value = event.currentTarget.value; 45 | updateGlobalSearch(value); 46 | }; 47 | 48 | const handleFilterUpper = () => { 49 | const rules: IRule[] = [ 50 | { 51 | field: 'power', 52 | type: 'number', 53 | term: 50, 54 | role: RuleNumberOptions.biggerOrEquals, 55 | operator: RuleOperator.AND, 56 | }, 57 | ]; 58 | updateFilterRules(rules); 59 | }; 60 | 61 | const handleFilterLower = () => { 62 | const rules: IRule[] = [ 63 | { 64 | field: 'power', 65 | type: 'number', 66 | term: 50, 67 | role: RuleNumberOptions.smallerOrEquals, 68 | operator: RuleOperator.AND, 69 | }, 70 | ]; 71 | updateFilterRules(rules); 72 | }; 73 | 74 | return ( 75 | 76 | 77 | 78 | 83 | 84 | 85 | 94 | 102 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | {rows} 115 |
Namepower
116 |
117 | ); 118 | } 119 | -------------------------------------------------------------------------------- /apps/docs/examples/TableWithGlobalFilter.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Card, Grid, Input, Table } from '@mantine/core'; 2 | import React from 'react'; 3 | import { useFlexysearch, FlexysearchProvider } from 'flexysearch-react'; 4 | import { IRule, RuleNumberOptions, RuleOperator } from 'flexysearch'; 5 | 6 | interface Element { 7 | name: string; 8 | power: number; 9 | } 10 | 11 | const mockDataServ = [ 12 | { name: 'Madara', power: 100 }, 13 | { name: 'Naruto', power: 60 }, 14 | { name: 'Sasuke', power: 48 }, 15 | { name: 'Sakura', power: 10 }, 16 | ]; 17 | 18 | export default function Module() { 19 | return ( 20 | 21 | 22 | 23 | ); 24 | } 25 | 26 | function TableWithGlobalFilter() { 27 | const { 28 | filtered_data, 29 | updateGlobalSearch, 30 | setData, 31 | updateFilterRules, 32 | searchValue, 33 | rules, 34 | handleClearFilter, 35 | } = useFlexysearch(); 36 | 37 | React.useEffect(() => { 38 | setData(mockDataServ); 39 | }, []); 40 | 41 | const rows = filtered_data.map((element) => ( 42 | 43 | {element.name} 44 | {element.power} 45 | 46 | )); 47 | 48 | const handleSearchChange = (event: React.ChangeEvent) => { 49 | const value = event.currentTarget.value; 50 | updateGlobalSearch(value); 51 | }; 52 | 53 | const handleFilterUpper = () => { 54 | const rules: IRule[] = [ 55 | { 56 | field: 'power', 57 | type: 'number', 58 | term: 50, 59 | role: RuleNumberOptions.biggerOrEquals, 60 | operator: RuleOperator.AND, 61 | }, 62 | ]; 63 | updateFilterRules(rules); 64 | }; 65 | 66 | const handleFilterLower = () => { 67 | const rules: IRule[] = [ 68 | { 69 | field: 'power', 70 | type: 'number', 71 | term: 50, 72 | role: RuleNumberOptions.smallerOrEquals, 73 | operator: RuleOperator.AND, 74 | }, 75 | ]; 76 | updateFilterRules(rules); 77 | }; 78 | 79 | return ( 80 | 81 | 82 | 83 | 88 | 89 | 90 | 99 | 107 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | {rows} 120 |
Namepower
121 |
122 | ); 123 | } 124 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@flexysearch/workspace", 3 | "version": "2.1.1", 4 | "license": "MIT", 5 | "scripts": { 6 | "start:docs": "nx start flexysearch-docs", 7 | "build:docs": "cd apps/docs && npm run build", 8 | "test:flexysearch": "nx test @flexysearch/core", 9 | "lint:flexysearch": "nx lint @flexysearch/core", 10 | "build:flexysearch": "nx build @flexysearch/core", 11 | "test:textfield": "nx test react-accounting-textfield", 12 | "lint:textfield": "nx lint react-accounting-textfield", 13 | "build:textfield": "nx build react-accounting-textfield", 14 | "lint:react": "nx lint flexysearch-react", 15 | "test:react": "nx test flexysearch-react", 16 | "build:react": "nx build flexysearch-react", 17 | "publish:flexysearch:dev": "npm run build:flexysearch && cd dist/packages/flexysearch && npm publish --registry http://localhost:4873", 18 | "publish:flexysearch:production": "npm run build:flexysearch && cd dist/packages/flexysearch && npm publish --registry https://registry.npmjs.org/", 19 | "publish:react:dev": "npm run build:react && cd dist/packages/flexysearch-react && npm publish --registry http://localhost:4873", 20 | "publish:react:production": "npm run build:react && cd dist/packages/flexysearch-react && npm publish --registry https://registry.npmjs.org/", 21 | "publish:textfield:production": "npm run build:textfield && cd dist/packages/react-accounting-textfield && npm publish --registry https://registry.npmjs.org/", 22 | "deploy": "npm run build:docs && npx gh-pages -d apps/docs/build" 23 | }, 24 | "private": true, 25 | "devDependencies": { 26 | "@babel/core": "^7.14.5", 27 | "@babel/preset-react": "^7.14.5", 28 | "@docusaurus/core": "2.3.1", 29 | "@docusaurus/module-type-aliases": "2.3.1", 30 | "@docusaurus/preset-classic": "2.3.1", 31 | "@emotion/react": "11.11.1", 32 | "@mantine/core": "^6.0.2", 33 | "@mantine/hooks": "^6.0.2", 34 | "@mdx-js/react": "^1.6.22", 35 | "@nx/eslint": "17.1.3", 36 | "@nx/eslint-plugin": "17.1.3", 37 | "@nx/jest": "17.1.3", 38 | "@nx/js": "17.1.3", 39 | "@nx/react": "17.1.3", 40 | "@nx/rollup": "17.1.3", 41 | "@rollup/plugin-url": "^7.0.0", 42 | "@svgr/rollup": "8.1.0", 43 | "@swc-node/register": "~1.6.7", 44 | "@swc/core": "~1.3.85", 45 | "@testing-library/react": "14.0.0", 46 | "@testing-library/user-event": "^14.5.1", 47 | "@types/jest": "^29.4.0", 48 | "@types/node": "18.14.2", 49 | "@types/react": "18.2.33", 50 | "@types/react-dom": "18.2.14", 51 | "@typescript-eslint/eslint-plugin": "6.12.0", 52 | "@typescript-eslint/parser": "6.12.0", 53 | "babel-jest": "^29.7.0", 54 | "clsx": "^1.2.1", 55 | "eslint": "8.46.0", 56 | "eslint-config-prettier": "9.0.0", 57 | "eslint-plugin-import": "2.27.5", 58 | "eslint-plugin-jsx-a11y": "6.7.1", 59 | "eslint-plugin-react": "7.32.2", 60 | "eslint-plugin-react-hooks": "4.6.0", 61 | "flexysearch": "^1.0.0", 62 | "gh-pages": "^5.0.0", 63 | "gulp": "^4.0.2", 64 | "jest": "^29.4.1", 65 | "jest-environment-jsdom": "^29.4.1", 66 | "nx": "17.1.3", 67 | "prettier": "^2.6.2", 68 | "prism-react-renderer": "^1.3.5", 69 | "react": "18.2.0", 70 | "react-accounting-textfield": "*", 71 | "react-dom": "18.2.0", 72 | "ts-jest": "29.1.1", 73 | "ts-node": "10.9.1", 74 | "tslib": "^2.3.0", 75 | "typescript": "5.2.2" 76 | }, 77 | "workspaces": [ 78 | "packages/react-accounting-textfield", 79 | "packages/flexysearch-react", 80 | "apps/*" 81 | ], 82 | "dependencies": {} 83 | } -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | const defaultOptions = { 2 | minimumFractionDigits: 2, 3 | useGrouping: true, 4 | style: "decimal", 5 | maximumFractionDigits: 2, 6 | }; 7 | 8 | /** 9 | * Prepares the payload for an input change event. 10 | * 11 | * @param event - The input change event. 12 | * @returns The prepared payload object. 13 | */ 14 | export const preparePayload = ( 15 | event: React.ChangeEvent, 16 | maximumFractionDigits: number, 17 | ) => { 18 | const { value } = event.target; 19 | const floatValue = moneyToFloat(value, maximumFractionDigits); 20 | const parsedValue = formatMoney(floatValue, { 21 | maximumFractionDigits, 22 | }); 23 | 24 | const newValue = (value || "").replace(/[^0-9.,]/g, ""); 25 | const props = { 26 | float: floatValue, 27 | formatted: parsedValue, 28 | cents: formatNumberToCents(value, { 29 | maximumFractionDigits, 30 | }), 31 | value: newValue, 32 | }; 33 | 34 | return props; 35 | }; 36 | 37 | /** 38 | * Converts a money value represented as a string to a floating-point number. 39 | * 40 | * @param value - The money value to convert. 41 | * @returns The converted floating-point number. 42 | */ 43 | export function moneyToFloat(value: string, fixed = 2) { 44 | const newValue = value.replace(".", "").replace(",", "."); 45 | const floatValue = parseFloat(newValue)?.toFixed(fixed) || 0; 46 | return Number(floatValue); 47 | } 48 | 49 | /** 50 | * Formats a number as a money value. 51 | * 52 | * @param value - The number to format as money. 53 | * @returns The formatted money value. 54 | */ 55 | export function formatMoney( 56 | value: number, 57 | options?: Intl.NumberFormatOptions, 58 | ) { 59 | const t = new Intl.NumberFormat("pt-BR", { 60 | ...defaultOptions, 61 | ...(options || {}), 62 | }); 63 | return t.format(value); 64 | } 65 | 66 | export function padDecimal(input: string, padLength: number): string { 67 | let currentInput = input; 68 | // Split the input into integer and decimal parts 69 | let [integerPart, decimalPart] = input.split(","); 70 | if (!decimalPart) { 71 | currentInput = `${currentInput},00`; 72 | decimalPart = "00"; 73 | } 74 | 75 | // Pad the decimal part with zeros up to the specified length 76 | const paddedDecimal = decimalPart.padEnd(padLength, "0").slice(0, padLength); 77 | 78 | // Combine the integer and padded decimal parts 79 | const result = `${integerPart},${paddedDecimal}`; 80 | 81 | return result; 82 | } 83 | 84 | /** 85 | * Formats a number string to cents. 86 | * 87 | * @param data - The number string to format. 88 | * @param options - The options for formatting the number. 89 | * @returns The number formatted as cents. 90 | */ 91 | export function formatNumberToCents( 92 | data: string, 93 | options: Intl.NumberFormatOptions, 94 | ) { 95 | const maximumFractionDigits = options.maximumFractionDigits ?? 2; 96 | const currentInput = padDecimal(data, maximumFractionDigits); 97 | 98 | const numberWithoutFormatting = currentInput.replace(/[.,]/g, ""); 99 | 100 | const amountInCents = parseInt(numberWithoutFormatting, 10); 101 | 102 | return amountInCents; 103 | } 104 | 105 | /** 106 | * Converts an input value to a currency format. 107 | * @param value - The input value to be converted. 108 | * @param fixed - The number of decimal places to round the converted value to. Default is 2. 109 | * @returns The converted currency value as a string. 110 | */ 111 | export function eventInputToCurrency(value: string, fixed = 2) { 112 | const newValue = value.replace(".", "").replace(",", "."); 113 | const floatValue = parseFloat(newValue)?.toFixed(fixed) || "0"; 114 | return formatMoney(Number(floatValue), { 115 | maximumFractionDigits: fixed, 116 | }); 117 | } 118 | -------------------------------------------------------------------------------- /packages/flexysearch-react/src/provider/FlexysearchProvider.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import reducer from '../state/reducer'; 3 | import { FlexysearchHookProps, FlexysearchHookProvider } from '../../types'; 4 | import initialState from '../state/state'; 5 | import { Kind } from '../state/actions'; 6 | import Flexysearch, { IRule } from 'flexysearch'; 7 | 8 | export default function FlexysearchProvider({ 9 | children, 10 | data, 11 | }: React.PropsWithChildren>) { 12 | type DataType = InferDataPropType; 13 | 14 | const [state, dispatch] = React.useReducer(reducer, initialState); 15 | const [localSearch, setLocalSearch] = React.useState(null); 16 | const [rules, setRules] = React.useState([]); 17 | const debounceSearch = React.useDeferredValue(localSearch); 18 | 19 | const getFilteredData = (newRules = rules) => { 20 | let collection = new Flexysearch(state.data); 21 | 22 | if (localSearch) { 23 | const filtered = state.data.filter((item: any) => { 24 | const values = Object.values(item).join(' ').toLowerCase(); 25 | const pattern = new RegExp(localSearch.toLowerCase()); 26 | return pattern.test(values); 27 | }); 28 | collection = new Flexysearch(filtered); 29 | } 30 | 31 | if (newRules && newRules.length !== 0) { 32 | collection.search(newRules); 33 | } 34 | 35 | return collection; 36 | }; 37 | 38 | const setData = (payload: DataType[]) => { 39 | dispatch({ kind: Kind.SET_DATA_ACTION, payload }); 40 | dispatch({ 41 | kind: Kind.SET_FILTERED_DATA_ACTION, 42 | payload, 43 | }); 44 | }; 45 | 46 | React.useEffect(() => { 47 | data?.length && setData(data as DataType[]); 48 | }, [data]); 49 | 50 | React.useEffect(() => { 51 | if (rules.length === 0 && !state.filtered_data.length) return; 52 | React.startTransition(() => { 53 | dispatch({ 54 | kind: Kind.SET_FILTERED_DATA_ACTION, 55 | payload: getFilteredData(rules).all as DataType[], 56 | }); 57 | }); 58 | }, [rules]); 59 | 60 | React.useEffect(() => { 61 | if (typeof debounceSearch === 'string') { 62 | React.startTransition(() => { 63 | dispatch({ 64 | kind: Kind.SET_FILTERED_DATA_ACTION, 65 | payload: getFilteredData(rules).all as DataType[], 66 | }); 67 | }); 68 | } 69 | }, [debounceSearch]); 70 | 71 | const flexysearch = React.useMemo(() => { 72 | return { 73 | data: state.data as DataType[], 74 | filtered_data: state.filtered_data as DataType[], 75 | searchValue: localSearch, 76 | setData, 77 | rules, 78 | updateGlobalSearch: (value: string) => { 79 | setLocalSearch(value); 80 | }, 81 | updateFilterRules: (rules: IRule[]) => { 82 | setRules(rules); 83 | }, 84 | handleClearFilter: () => { 85 | const rules: IRule[] = []; 86 | setRules(rules); 87 | setLocalSearch(''); 88 | dispatch({ 89 | kind: Kind.SET_FILTERED_DATA_ACTION, 90 | payload: state.data, 91 | }); 92 | }, 93 | } as FlexysearchHookProvider; 94 | }, [setData, setRules, state, localSearch, rules, data]); 95 | 96 | return ( 97 | 98 | {children} 99 | 100 | ); 101 | } 102 | 103 | type InferDataPropType = T extends FlexysearchHookProps 104 | ? U 105 | : unknown; 106 | 107 | const FlexysearchContext = 108 | React.createContext | null>(null); 109 | 110 | export function useFlexysearchProvider() { 111 | const context = React.useContext( 112 | FlexysearchContext 113 | ) as FlexysearchHookProvider; 114 | if (!context) { 115 | throw new Error( 116 | 'useFlexysearchProvider must be used within a FlexysearchProvider' 117 | ); 118 | } 119 | return context; 120 | } 121 | -------------------------------------------------------------------------------- /packages/flexysearch/src/index.ts: -------------------------------------------------------------------------------- 1 | import { StringProcessor } from './utils/strings' 2 | import { IPaginateResult, IRule, RuleOperator } from '../interfaces' 3 | import { NumberProcessor } from './utils/number' 4 | import { hashCode } from './utils/hash' 5 | import { DateProcessor } from './utils/dates' 6 | import { omit } from './utils/helpers/objects' 7 | import Paginate from './features/Paginator' 8 | class SearchEngine { 9 | private shouldHave: any[] = [] 10 | private mustHave: any[] = [] 11 | private initialData: any[] = [] 12 | 13 | constructor(collection: any[]) { 14 | if (!Array.isArray(collection)) { 15 | return 16 | } 17 | const collectionToBeStored = collection.map((item) => ({ 18 | fs_uuid: hashCode(JSON.stringify(item)), 19 | ...item, 20 | })) 21 | this.initialData = collectionToBeStored 22 | this.mustHave = collectionToBeStored 23 | } 24 | 25 | public search(queries: IRule[]) { 26 | const query = { 27 | '@or': queries.filter((item) => item.operator === RuleOperator.OR), 28 | '@and': queries.filter((item) => item.operator === RuleOperator.AND), 29 | } 30 | 31 | this.processShouldArraySearch(query[RuleOperator.OR]) 32 | this.processMustArraySearch(query[RuleOperator.AND]) 33 | 34 | return this.all 35 | } 36 | 37 | public searchQuery(queries: IRule[]) { 38 | this.search(queries) 39 | return this 40 | } 41 | 42 | private processShouldArraySearch(queryArray: IRule[]) { 43 | this.shouldHave = this.initialData.filter((data) => 44 | this.filterData(data, queryArray) 45 | ) 46 | } 47 | 48 | private processMustArraySearch(queryArray: IRule[]) { 49 | this.mustHave = this.mustHave.filter((data) => 50 | this.filterMustArrayData(data, queryArray) 51 | ) 52 | } 53 | 54 | private filterData(data: Record, queryArray: IRule[]) { 55 | return queryArray.some((queryCurrent) => { 56 | return this.someDataIsValid(queryCurrent, data) 57 | }) 58 | } 59 | 60 | private filterMustArrayData( 61 | data: Record, 62 | queryArray: IRule[] 63 | ) { 64 | const checkedsRoles = queryArray.map((queryCurrent) => { 65 | return this.someDataIsValid(queryCurrent, data) 66 | }) 67 | return !checkedsRoles.some((item) => item === false) 68 | } 69 | 70 | private someDataIsValid(queryCurrent: IRule, data: Record) { 71 | const field = queryCurrent.field || '' 72 | switch (queryCurrent.type) { 73 | case 'string': 74 | return new StringProcessor( 75 | queryCurrent?.term || null, 76 | queryCurrent.role 77 | ).compareWith(data[field], queryCurrent.caseSensitive || false) 78 | case 'number': 79 | return new NumberProcessor( 80 | queryCurrent?.term || null, 81 | queryCurrent.role 82 | ).compareWith(data[field]) 83 | case 'date': 84 | return new DateProcessor( 85 | queryCurrent?.term || null, 86 | queryCurrent.role 87 | ).compareWith(data[field]) 88 | case 'custom': 89 | if (queryCurrent.filter && typeof queryCurrent.filter === 'function') { 90 | const datum = omit(data, ['fs_uuid']) 91 | 92 | return queryCurrent.filter(datum) 93 | } 94 | throw new Error('[flexysearch]: Custom filter not valid') 95 | default: 96 | throw new Error('[flexysearch]: Processor not found') 97 | } 98 | } 99 | 100 | get all() { 101 | const data = this.mustHave.concat(this.shouldHave) 102 | return ( 103 | data 104 | .filter((char, index) => { 105 | return data.indexOf(char) === index 106 | }) 107 | // eslint-disable-next-line @typescript-eslint/no-unused-vars 108 | .map(({ fs_uuid, ...rest }) => rest) 109 | ) 110 | } 111 | 112 | paginate(page: number, perPage = 10): IPaginateResult { 113 | try { 114 | return new Paginate(this.all, perPage).page(page).all 115 | } catch { 116 | return new Paginate([], perPage).page(page).all 117 | } 118 | } 119 | } 120 | 121 | export default SearchEngine 122 | export * from '../interfaces' 123 | -------------------------------------------------------------------------------- /packages/flexysearch/src/utils/dates.ts: -------------------------------------------------------------------------------- 1 | import { RuleDateOptions } from '../../interfaces/index' 2 | import { IRoles } from '../../interfaces' 3 | import { VALIDATE_DATE_REGEXP } from './helpers/regexp' 4 | 5 | export class DateProcessor { 6 | private term: string 7 | private role: IRoles 8 | 9 | constructor(value: string, role?: IRoles) { 10 | this.term = value 11 | this.role = role as RuleDateOptions 12 | } 13 | 14 | private checkIsValid(valueToBeCompared: string): boolean { 15 | return !!String(valueToBeCompared).match(VALIDATE_DATE_REGEXP) 16 | } 17 | 18 | private checkisEmpty(valueToBeCompared: string) { 19 | return !this.checkIsValid(valueToBeCompared) 20 | } 21 | 22 | private checkIsEqualDate(valueToBeCompared: string) { 23 | if ( 24 | !this.checkIsValid(valueToBeCompared) || 25 | !this.checkIsValid(this.term) 26 | ) { 27 | return false 28 | } 29 | 30 | const date = new Date(valueToBeCompared as string) 31 | const dateTerm = new Date(this.term) 32 | 33 | const date1 = [date.getDate(), date.getMonth(), date.getFullYear()].join('') 34 | const date2 = [ 35 | dateTerm.getDate(), 36 | dateTerm.getMonth(), 37 | dateTerm.getFullYear(), 38 | ].join('') 39 | 40 | return date1 === date2 41 | } 42 | 43 | private checkIsNotEqualDate(valueToBeCompared: string) { 44 | if ( 45 | !this.checkIsValid(valueToBeCompared) || 46 | !this.checkIsValid(this.term) 47 | ) { 48 | return true 49 | } 50 | 51 | const date = new Date(valueToBeCompared as string) 52 | const dateTerm = new Date(this.term) 53 | 54 | const date1 = [date.getDate(), date.getMonth(), date.getFullYear()].join('') 55 | const date2 = [ 56 | dateTerm.getDate(), 57 | dateTerm.getMonth(), 58 | dateTerm.getFullYear(), 59 | ].join('') 60 | 61 | return date1 !== date2 62 | } 63 | 64 | private isAfterOrBefore( 65 | valueToBeCompared: string, 66 | isBefore = false, 67 | includeOn = false 68 | ) { 69 | if ( 70 | !this.checkIsValid(valueToBeCompared) || 71 | !this.checkIsValid(this.term) 72 | ) { 73 | return false 74 | } 75 | 76 | const date = new Date(valueToBeCompared as string).getTime() 77 | const dateTerm = new Date(this.term).getTime() 78 | 79 | if (includeOn) { 80 | return isBefore ? dateTerm >= date : dateTerm <= date 81 | } 82 | 83 | return isBefore ? dateTerm > date : dateTerm < date 84 | } 85 | 86 | private isBetween(valueToBeCompared: string) { 87 | if ((this.term || []).length !== 2) { 88 | return false 89 | } 90 | 91 | const isInvalidStart = !this.checkIsValid(this.term[0]) 92 | const isInvalidEnd = !this.checkIsValid(this.term[1]) 93 | 94 | if ( 95 | isInvalidStart || 96 | isInvalidEnd || 97 | !this.checkIsValid(valueToBeCompared) 98 | ) { 99 | return false 100 | } 101 | 102 | const dateStart = new Date(this.term[0]).getTime() 103 | const dateEnd = new Date(this.term[1]).getTime() 104 | const dateTerm = new Date(valueToBeCompared).getTime() 105 | 106 | return dateTerm >= dateStart && dateTerm <= dateEnd 107 | } 108 | 109 | compareWith(valueToBeCompared: string) { 110 | switch (this.role) { 111 | case RuleDateOptions.equals: 112 | return this.checkIsEqualDate(valueToBeCompared) 113 | case RuleDateOptions.isNotEquals: 114 | return this.checkIsNotEqualDate(valueToBeCompared) 115 | case RuleDateOptions.isNotEmpty: 116 | return !this.checkisEmpty(valueToBeCompared) 117 | case RuleDateOptions.empty: 118 | return this.checkisEmpty(valueToBeCompared) 119 | case RuleDateOptions.isAfter: 120 | return this.isAfterOrBefore(valueToBeCompared) 121 | case RuleDateOptions.isOnOrAfter: 122 | return this.isAfterOrBefore(valueToBeCompared, false, true) 123 | case RuleDateOptions.isBefore: 124 | return this.isAfterOrBefore(valueToBeCompared, true) 125 | case RuleDateOptions.isOnOrBefore: 126 | return this.isAfterOrBefore(valueToBeCompared, true, true) 127 | case RuleDateOptions.isBetween: 128 | return this.isBetween(valueToBeCompared) 129 | default: 130 | throw new Error('[flexysearch]: Invalid role in Dates') 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/utils/utils.test.ts: -------------------------------------------------------------------------------- 1 | import { 2 | eventInputToCurrency, 3 | formatMoney, 4 | formatNumberToCents, 5 | moneyToFloat, 6 | preparePayload, 7 | } from "."; 8 | 9 | describe("Prepare Payload", () => { 10 | it("should receive event and return a payload", async () => { 11 | const event = { 12 | target: { 13 | value: "56,91", 14 | }, 15 | } as React.ChangeEvent; 16 | 17 | const payload = preparePayload(event, 2); 18 | 19 | expect(payload).toEqual({ 20 | float: 56.91, 21 | formatted: "56,91", 22 | cents: 5691, 23 | value: "56,91", 24 | }); 25 | }); 26 | it("should receive event and return a payload - Decimals of 4", async () => { 27 | const event = { 28 | target: { 29 | value: "56,91", 30 | }, 31 | } as React.ChangeEvent; 32 | 33 | const payload = preparePayload(event, 4); 34 | 35 | expect(payload).toEqual({ 36 | float: 56.91, 37 | formatted: "56,91", 38 | cents: 569100, 39 | value: "56,91", 40 | }); 41 | }); 42 | it("should fill with zero on payload - Decimals of 4", async () => { 43 | const event = { 44 | target: { 45 | value: "56,910", 46 | }, 47 | } as React.ChangeEvent; 48 | 49 | let payload = preparePayload(event, 4); 50 | 51 | expect(payload).toEqual({ 52 | float: 56.91, 53 | formatted: "56,91", 54 | cents: 569100, 55 | value: "56,910", 56 | }); 57 | 58 | const event2 = { 59 | target: { 60 | value: "56,9102", 61 | }, 62 | } as React.ChangeEvent; 63 | payload = preparePayload(event2, 4); 64 | 65 | expect(payload).toEqual({ 66 | float: 56.9102, 67 | formatted: "56,9102", 68 | cents: 569102, 69 | value: "56,9102", 70 | }); 71 | }); 72 | it("should receive event and return a payload - Decimals of 6", async () => { 73 | const event = { 74 | target: { 75 | value: "56,91", 76 | }, 77 | } as React.ChangeEvent; 78 | 79 | const payload = preparePayload(event, 6); 80 | 81 | expect(payload).toEqual({ 82 | float: 56.91, 83 | formatted: "56,91", 84 | cents: 56910000, 85 | value: "56,91", 86 | }); 87 | }); 88 | }); 89 | 90 | describe("Money To Float", () => { 91 | it("Should unformat a string", () => { 92 | const value = "1234,56"; 93 | const unformatted = moneyToFloat(value); 94 | expect(unformatted).toEqual(1234.56); 95 | }); 96 | it("Should unformat a string - decimals", () => { 97 | const value = "1123,9934"; 98 | const unformatted = moneyToFloat(value, 4); 99 | expect(unformatted).toEqual(1123.9934); 100 | }); 101 | }); 102 | 103 | describe("Format Money", () => { 104 | it("Should format a string", () => { 105 | const value = 123; 106 | const unformatted = formatMoney(value); 107 | expect(unformatted).toEqual("123,00"); 108 | }); 109 | 110 | it("Should format a string - decimals", () => { 111 | const value = 1123.9934; 112 | const unformatted = formatMoney(value, { 113 | maximumFractionDigits: 4, 114 | }); 115 | expect(unformatted).toEqual("1.123,9934"); 116 | }); 117 | }); 118 | 119 | describe("Event Input To Currency", () => { 120 | it("Should format a string", () => { 121 | const input = "123,321321"; 122 | const unformatted = eventInputToCurrency(input); 123 | expect(unformatted).toEqual("123,32"); 124 | }); 125 | it("Should format a string - crazy edge case", () => { 126 | const input = "1.1.1,12345"; 127 | const unformatted = eventInputToCurrency(input); 128 | expect(unformatted).toEqual("11,10"); 129 | }); 130 | }); 131 | 132 | describe("Format input to cents", () => { 133 | it("get correct 111023 cents", () => { 134 | const input = "1100,2333"; 135 | const cents = formatNumberToCents(input, { 136 | maximumFractionDigits: 2, 137 | }); 138 | expect(cents).toEqual(110023); 139 | }); 140 | it("get correct cents - decimal", () => { 141 | const input = "1100,2333"; 142 | const cents = formatNumberToCents(input, { 143 | maximumFractionDigits: 4, 144 | }); 145 | expect(cents).toEqual(11002333); 146 | }); 147 | it("get correct cents - small values", () => { 148 | const input = "20"; 149 | const cents = formatNumberToCents(input, { 150 | maximumFractionDigits: 2, 151 | }); 152 | const cents2 = formatNumberToCents(input, { 153 | maximumFractionDigits: 4, 154 | }); 155 | expect(cents).toEqual(2000); 156 | expect(cents2).toEqual(200000); 157 | }); 158 | }); 159 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/paginate.test.ts: -------------------------------------------------------------------------------- 1 | import SearchEngine, { RuleOperator, RuleStringOptions } from '..' 2 | import collection from '../../../../__mocks__/movies.json' 3 | 4 | describe('Paginate', () => { 5 | it('Should paginate without search', () => { 6 | const results = new SearchEngine(collection).paginate(1, 5) 7 | 8 | expect(results).toEqual({ 9 | data: [ 10 | { id: 1, title: 'Film 1', year: 2009 }, 11 | { id: 2, title: 'Film 2', year: 2015 }, 12 | { id: 3, title: 'Film 3', year: 2014 }, 13 | { id: 4, title: 'Film 4', year: 2014 }, 14 | { id: 5, title: 'Film 5', year: 2001 }, 15 | ], 16 | meta: { 17 | perPage: 5, 18 | currentPage: 1, 19 | firstPage: 1, 20 | offset: 0, 21 | total: 14, 22 | lastPage: 3, 23 | hasPages: true, 24 | hasTotal: true, 25 | hasMorePages: true, 26 | isEmpty: false, 27 | }, 28 | }) 29 | }) 30 | it('Should paginate without search', () => { 31 | const results = new SearchEngine(collection).searchQuery([ 32 | { 33 | field: 'title', 34 | term: 'film 3', 35 | role: RuleStringOptions.equals, 36 | type: 'string', 37 | operator: RuleOperator.AND, 38 | }, 39 | { 40 | field: 'title', 41 | term: 'film 1', 42 | role: RuleStringOptions.equals, 43 | type: 'string', 44 | operator: RuleOperator.OR, 45 | }, 46 | ]) 47 | 48 | expect(results.all).toEqual([ 49 | { id: 3, title: 'Film 3', year: 2014 }, 50 | { id: 1, title: 'Film 1', year: 2009 }, 51 | ]) 52 | 53 | const resultsPaginated = results.paginate(1, 1) 54 | 55 | expect(resultsPaginated).toEqual({ 56 | data: [{ id: 3, title: 'Film 3', year: 2014 }], 57 | meta: { 58 | perPage: 1, 59 | currentPage: 1, 60 | firstPage: 1, 61 | total: 2, 62 | offset: 0, 63 | lastPage: 2, 64 | hasPages: true, 65 | hasTotal: true, 66 | hasMorePages: true, 67 | isEmpty: false, 68 | }, 69 | }) 70 | const resultsPaginatedUpdated = results.paginate(1, 2) 71 | 72 | expect(resultsPaginatedUpdated).toEqual({ 73 | data: [ 74 | { id: 3, title: 'Film 3', year: 2014 }, 75 | { id: 1, title: 'Film 1', year: 2009 }, 76 | ], 77 | meta: { 78 | perPage: 2, 79 | currentPage: 1, 80 | firstPage: 1, 81 | total: 2, 82 | offset: 0, 83 | lastPage: 1, 84 | hasPages: false, 85 | hasTotal: true, 86 | hasMorePages: false, 87 | isEmpty: false, 88 | }, 89 | }) 90 | }) 91 | it('Get invalid page', () => { 92 | const results = new SearchEngine(collection).searchQuery([ 93 | { 94 | field: 'title', 95 | term: 'film 3', 96 | role: RuleStringOptions.equals, 97 | type: 'string', 98 | operator: RuleOperator.AND, 99 | }, 100 | { 101 | field: 'title', 102 | term: 'film 1', 103 | role: RuleStringOptions.equals, 104 | type: 'string', 105 | operator: RuleOperator.OR, 106 | }, 107 | ]) 108 | 109 | const resultsPaginated = results.paginate<{ 110 | id: number 111 | title: string 112 | year: number 113 | }>(2, 2) 114 | 115 | // Check types :) 116 | expect(resultsPaginated.data.at(0)?.title).not.toBeDefined() 117 | 118 | expect(resultsPaginated).toEqual({ 119 | data: [], 120 | meta: { 121 | perPage: 2, 122 | currentPage: 2, 123 | firstPage: 1, 124 | total: 2, 125 | lastPage: 1, 126 | offset: 2, 127 | hasPages: false, 128 | hasTotal: true, 129 | hasMorePages: false, 130 | isEmpty: false, 131 | }, 132 | }) 133 | }) 134 | }) 135 | 136 | describe('Handlers', () => { 137 | it('Should handle null or undefined data', () => { 138 | // @ts-expect-error Testing purpose 139 | const results = new SearchEngine(undefined).searchQuery([ 140 | { 141 | field: 'title', 142 | term: 'film 3', 143 | role: RuleStringOptions.equals, 144 | type: 'string', 145 | operator: RuleOperator.AND, 146 | }, 147 | ]) 148 | 149 | const resultsPaginated = results.paginate<{ 150 | id: number 151 | title: string 152 | year: number 153 | }>(2, 2) 154 | 155 | expect(resultsPaginated).toEqual({ 156 | data: [], 157 | meta: { 158 | perPage: 2, 159 | currentPage: 2, 160 | firstPage: 1, 161 | total: 0, 162 | lastPage: 0, 163 | offset: 2, 164 | hasPages: false, 165 | hasTotal: false, 166 | hasMorePages: false, 167 | isEmpty: true, 168 | }, 169 | }) 170 | }) 171 | }) 172 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/strings.test.ts: -------------------------------------------------------------------------------- 1 | import SearchEngine from '..' 2 | import { RuleOperator, RuleStringOptions } from '../../interfaces' 3 | import collection from '../../../../__mocks__/movies.json' 4 | import collectionItems from '../../../../__mocks__/items.json' 5 | import expectedNotContains from './__mocks__/strings/expectedNotContains.json' 6 | import expectedEquals from './__mocks__/strings/expectedEquals.json' 7 | import expectedEmpty from './__mocks__/strings/expectedEmpty.json' 8 | 9 | describe('Should match strings', () => { 10 | it('[String]: Should cause exception', () => { 11 | const results = () => 12 | new SearchEngine(collection).search([ 13 | { 14 | field: 'title', 15 | term: 'film 3', 16 | role: 'notExist' as RuleStringOptions, 17 | type: 'string', 18 | operator: RuleOperator.AND, 19 | }, 20 | ]) 21 | 22 | expect(results).toThrow('[flexysearch]: Invalid role in String') 23 | }) 24 | 25 | it('[String]: Contains', () => { 26 | const results = new SearchEngine(collection).search([ 27 | { 28 | field: 'title', 29 | term: 'film 3', 30 | role: RuleStringOptions.contains, 31 | type: 'string', 32 | operator: RuleOperator.AND, 33 | }, 34 | ]) 35 | 36 | expect(results).toStrictEqual([ 37 | { 38 | id: 3, 39 | title: 'Film 3', 40 | year: 2014, 41 | }, 42 | ]) 43 | }) 44 | it('[String]: Not Contains', () => { 45 | const results = new SearchEngine(collection).search([ 46 | { 47 | field: 'title', 48 | term: 'Film 1', 49 | role: RuleStringOptions.notContains, 50 | type: 'string', 51 | operator: RuleOperator.AND, 52 | }, 53 | ]) 54 | 55 | expect(results).toStrictEqual(expectedNotContains) 56 | }) 57 | it('[String]: Equals', () => { 58 | const resultsCaseInsentive = new SearchEngine(collection).search([ 59 | { 60 | field: 'title', 61 | role: RuleStringOptions.equals, 62 | term: 'fiLM 1', 63 | type: 'string', 64 | operator: RuleOperator.AND, 65 | }, 66 | ]) 67 | 68 | expect(resultsCaseInsentive.length).toBe(1) 69 | 70 | const results_caseSensitive = new SearchEngine(collection).search([ 71 | { 72 | field: 'title', 73 | role: RuleStringOptions.equals, 74 | term: 'Film 1', 75 | type: 'string', 76 | operator: RuleOperator.AND, 77 | caseSensitive: true, 78 | }, 79 | ]) 80 | const resultscaseSensitiveFailed = new SearchEngine(collection).search([ 81 | { 82 | field: 'title', 83 | role: RuleStringOptions.equals, 84 | term: 'film 1', 85 | type: 'string', 86 | operator: RuleOperator.AND, 87 | caseSensitive: true, 88 | }, 89 | ]) 90 | 91 | expect(results_caseSensitive.length).toBe(1) 92 | expect(resultscaseSensitiveFailed.length).toBe(0) 93 | expect(results_caseSensitive).toStrictEqual(expectedEquals) 94 | }) 95 | it('[String]: Empty', () => { 96 | const results = new SearchEngine(collectionItems).search([ 97 | { 98 | field: 'colors', 99 | role: RuleStringOptions.isEmpty, 100 | type: 'string', 101 | operator: RuleOperator.AND, 102 | }, 103 | ]) 104 | 105 | expect(results.length).toBe(5) 106 | expect(results).toStrictEqual(expectedEmpty) 107 | }) 108 | it('[String]: Is not empty', () => { 109 | const results = new SearchEngine(collectionItems).search([ 110 | { 111 | field: 'colors', 112 | role: RuleStringOptions.isNotEmpty, 113 | type: 'string', 114 | operator: RuleOperator.AND, 115 | }, 116 | ]) 117 | 118 | expect(results.length).toBe(2) 119 | }) 120 | it('[String]: search case sensitive', () => { 121 | const results = new SearchEngine(collectionItems).search([ 122 | { 123 | field: 'colors', 124 | role: RuleStringOptions.contains, 125 | term: 'Blue', 126 | type: 'string', 127 | operator: RuleOperator.AND, 128 | caseSensitive: true, 129 | }, 130 | ]) 131 | 132 | expect(results.length).toBe(1) 133 | }) 134 | it('[String]: search starts with', () => { 135 | const results = new SearchEngine(collectionItems).search([ 136 | { 137 | field: 'colors', 138 | role: RuleStringOptions.startsWith, 139 | term: 'Bl', 140 | type: 'string', 141 | operator: RuleOperator.AND, 142 | caseSensitive: true, 143 | }, 144 | ]) 145 | 146 | expect(results.length).toBe(1) 147 | }) 148 | it('[String]: search ends with', () => { 149 | const results = new SearchEngine(collectionItems).search([ 150 | { 151 | field: 'colors', 152 | role: RuleStringOptions.endsWith, 153 | term: 'ue', 154 | type: 'string', 155 | operator: RuleOperator.AND, 156 | caseSensitive: true, 157 | }, 158 | ]) 159 | 160 | expect(results.length).toBe(1) 161 | }) 162 | }) 163 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/dates.test.ts: -------------------------------------------------------------------------------- 1 | import SearchEngine from '..' 2 | import { RuleDateOptions, RuleOperator } from '../../interfaces' 3 | import collection from '../../../../__mocks__/babyBorns.json' 4 | import babyBornsSequencial from '../../../../__mocks__/babyBornsSequencial.json' 5 | import expectEmpty from './__mocks__/dates/expectEmpty.json' 6 | import expectNotEmpty from './__mocks__/dates/expectNotEmpty.json' 7 | import expectIs from './__mocks__/dates/expectIs.json' 8 | import expectisNot from './__mocks__/dates/expectNotEquals.json' 9 | import expectAfter from './__mocks__/dates/expectAfter.json' 10 | import expectBefore from './__mocks__/dates/expectBefore.json' 11 | import expectBetween from './__mocks__/dates/expectBetween.json' 12 | 13 | describe('Should match Date', () => { 14 | it('[Date]: Should cause exception', () => { 15 | const results = () => 16 | new SearchEngine(collection).search([ 17 | { 18 | field: 'born_at', 19 | role: 'notExist' as RuleDateOptions, 20 | type: 'date', 21 | operator: RuleOperator.AND, 22 | }, 23 | ]) 24 | 25 | expect(results).toThrow('[flexysearch]: Invalid role in Dates') 26 | }) 27 | it('[Date]: Should find empty dates on collection', () => { 28 | const results = new SearchEngine(collection).search([ 29 | { 30 | field: 'born_at', 31 | role: RuleDateOptions.empty, 32 | type: 'date', 33 | operator: RuleOperator.AND, 34 | }, 35 | ]) 36 | 37 | expect(results).toStrictEqual(expectEmpty) 38 | }) 39 | it('[Date]: Should find not empty dates on collection', () => { 40 | const data = collection.slice(0, 5) 41 | 42 | const results = new SearchEngine(data).search([ 43 | { 44 | field: 'born_at', 45 | role: RuleDateOptions.isNotEmpty, 46 | type: 'date', 47 | operator: RuleOperator.AND, 48 | }, 49 | ]) 50 | 51 | expect(results).toStrictEqual(expectNotEmpty) 52 | }) 53 | it('[Date]: Should find is equals dates on collection', () => { 54 | const results = new SearchEngine(collection).search([ 55 | { 56 | field: 'born_at', 57 | term: '2021-12-27', 58 | role: RuleDateOptions.equals, 59 | type: 'date', 60 | operator: RuleOperator.AND, 61 | }, 62 | ]) 63 | 64 | expect(results).toStrictEqual(expectIs) 65 | }) 66 | it('[Date]: Should find is not equals dates on collection', () => { 67 | const data = collection.slice(0, 10) 68 | 69 | const results = new SearchEngine(data).search([ 70 | { 71 | field: 'born_at', 72 | term: '2021-12-27', 73 | role: RuleDateOptions.isNotEquals, 74 | type: 'date', 75 | operator: RuleOperator.AND, 76 | }, 77 | ]) 78 | 79 | expect(results).toStrictEqual(expectisNot) 80 | }) 81 | it('[Date]: Should find after dates on collection', () => { 82 | const data = collection.slice(0, 10) 83 | const results = new SearchEngine(data).search([ 84 | { 85 | field: 'born_at', 86 | term: '2021-12-01', 87 | role: RuleDateOptions.isAfter, 88 | type: 'date', 89 | operator: RuleOperator.AND, 90 | }, 91 | ]) 92 | 93 | expect(results).toStrictEqual(expectAfter) 94 | }) 95 | it('[Date]: Should find on or after dates on collection', () => { 96 | const data = collection.slice(0, 10) 97 | const results = new SearchEngine(data).search([ 98 | { 99 | field: 'born_at', 100 | term: '2021-12-05', 101 | role: RuleDateOptions.isOnOrAfter, 102 | type: 'date', 103 | operator: RuleOperator.AND, 104 | }, 105 | ]) 106 | 107 | expect(results).toStrictEqual(expectAfter) 108 | }) 109 | it('[Date]: Should find before dates on collection', () => { 110 | const data = collection.slice(0, 10) 111 | const results = new SearchEngine(data).search([ 112 | { 113 | field: 'born_at', 114 | term: '2022-05-01', 115 | role: RuleDateOptions.isBefore, 116 | type: 'date', 117 | operator: RuleOperator.AND, 118 | }, 119 | ]) 120 | expect(results).toStrictEqual(expectBefore) 121 | }) 122 | it('[Date]: Should find on or before dates on collection', () => { 123 | const data = collection.slice(0, 10) 124 | const results = new SearchEngine(data).search([ 125 | { 126 | field: 'born_at', 127 | term: '2022-03-22', 128 | role: RuleDateOptions.isOnOrBefore, 129 | type: 'date', 130 | operator: RuleOperator.AND, 131 | }, 132 | ]) 133 | expect(results).toStrictEqual(expectBefore) 134 | }) 135 | it('[Date]: Should find between dates on collection', () => { 136 | const results = new SearchEngine(babyBornsSequencial).search([ 137 | { 138 | field: 'born_at', 139 | term: ['2022-01-02', '2022-01-04'], 140 | role: RuleDateOptions.isBetween, 141 | type: 'date', 142 | operator: RuleOperator.AND, 143 | }, 144 | ]) 145 | const results2 = new SearchEngine(babyBornsSequencial).search([ 146 | { 147 | field: 'born_at', 148 | term: ['2022-01-01', '2022-01-05'], 149 | role: RuleDateOptions.isBetween, 150 | type: 'date', 151 | operator: RuleOperator.AND, 152 | }, 153 | ]) 154 | expect(results).toStrictEqual(expectBetween) 155 | expect(babyBornsSequencial).toStrictEqual(results2) 156 | }) 157 | }) 158 | -------------------------------------------------------------------------------- /packages/flexysearch/src/tests/numbers.test.ts: -------------------------------------------------------------------------------- 1 | import SearchEngine from '..' 2 | import { RuleNumberOptions, RuleOperator } from '../../interfaces' 3 | import collection from '../../../../__mocks__/movies.json' 4 | import expectedNumberNotContains from './__mocks__/numbers/expectedNumberNotContains.json' 5 | import expectedNumberNotEmpty from './__mocks__/numbers/expectedNumberNotEmpty.json' 6 | import expectedNumberEmpty from './__mocks__/numbers/expectedNumberEmpty.json' 7 | import expectDifferentFrom from './__mocks__/numbers/expectDifferentFrom.json' 8 | import expectBiggerThan from './__mocks__/numbers/expectBiggerThan.json' 9 | import expectBiggerOrEquals from './__mocks__/numbers/expectBiggerOrEquals.json' 10 | import expectSmallerOrEquals from './__mocks__/numbers/expectSmallerOrEquals.json' 11 | import expectSmallerThan from './__mocks__/numbers/expectSmallerThan.json' 12 | 13 | describe('Should match number', () => { 14 | it('[Number]: Should cause exception', () => { 15 | const results = () => 16 | new SearchEngine(collection).search([ 17 | { 18 | field: 'title', 19 | term: 'film 3', 20 | role: 'notExist' as RuleNumberOptions, 21 | type: 'number', 22 | operator: RuleOperator.AND, 23 | }, 24 | ]) 25 | 26 | expect(results).toThrow('[flexysearch]: Invalid role in Numbers') 27 | }) 28 | it('[Number]: Contains', () => { 29 | const results = new SearchEngine(collection).search([ 30 | { 31 | field: 'year', 32 | term: 2014, 33 | role: RuleNumberOptions.contains, 34 | type: 'number', 35 | operator: RuleOperator.AND, 36 | }, 37 | ]) 38 | 39 | expect(results).toStrictEqual([ 40 | { 41 | id: 3, 42 | title: 'Film 3', 43 | year: 2014, 44 | }, 45 | { 46 | id: 4, 47 | title: 'Film 4', 48 | year: 2014, 49 | }, 50 | ]) 51 | }) 52 | it('[Number]: Not Contains', () => { 53 | const results = new SearchEngine(collection).search([ 54 | { 55 | field: 'year', 56 | term: 2014, 57 | role: RuleNumberOptions.notContains, 58 | type: 'number', 59 | operator: RuleOperator.AND, 60 | }, 61 | ]) 62 | 63 | expect(results).toStrictEqual(expectedNumberNotContains) 64 | }) 65 | it('[Number]: equals', () => { 66 | const results = new SearchEngine(collection).search([ 67 | { 68 | field: 'year', 69 | term: 2014, 70 | role: RuleNumberOptions.equals, 71 | type: 'number', 72 | operator: RuleOperator.AND, 73 | }, 74 | ]) 75 | 76 | expect(results).toStrictEqual([ 77 | { 78 | id: 3, 79 | title: 'Film 3', 80 | year: 2014, 81 | }, 82 | { 83 | id: 4, 84 | title: 'Film 4', 85 | year: 2014, 86 | }, 87 | ]) 88 | }) 89 | it('[Number]: Empty', () => { 90 | const results = new SearchEngine(collection).search([ 91 | { 92 | field: 'year', 93 | role: RuleNumberOptions.isEmpty, 94 | type: 'number', 95 | operator: RuleOperator.AND, 96 | }, 97 | ]) 98 | 99 | expect(results).toStrictEqual(expectedNumberEmpty) 100 | }) 101 | it('[Number]: Not Empty', () => { 102 | const results = new SearchEngine(collection).search([ 103 | { 104 | field: 'year', 105 | role: RuleNumberOptions.isNotEmpty, 106 | type: 'number', 107 | operator: RuleOperator.AND, 108 | }, 109 | ]) 110 | 111 | expect(results).toStrictEqual(expectedNumberNotEmpty) 112 | }) 113 | it('[Number]: Different from', () => { 114 | const results = new SearchEngine(collection).search([ 115 | { 116 | field: 'year', 117 | role: RuleNumberOptions.isNotEquals, 118 | term: 2014, 119 | type: 'number', 120 | operator: RuleOperator.AND, 121 | }, 122 | ]) 123 | 124 | expect(results).toStrictEqual(expectDifferentFrom) 125 | }) 126 | it('[Number]: bigger than', () => { 127 | const results = new SearchEngine(collection).search([ 128 | { 129 | field: 'year', 130 | role: RuleNumberOptions.biggerThan, 131 | term: 2014, 132 | type: 'number', 133 | operator: RuleOperator.AND, 134 | }, 135 | ]) 136 | 137 | expect(results).toStrictEqual(expectBiggerThan) 138 | }) 139 | it('[Number]: smaller than', () => { 140 | const results = new SearchEngine(collection).search([ 141 | { 142 | field: 'year', 143 | role: RuleNumberOptions.smallerThan, 144 | term: 2014, 145 | type: 'number', 146 | operator: RuleOperator.AND, 147 | }, 148 | ]) 149 | 150 | expect(results).toStrictEqual(expectSmallerThan) 151 | }) 152 | 153 | it('[Number]: bigger or equals', () => { 154 | const results = new SearchEngine(collection).search([ 155 | { 156 | field: 'year', 157 | role: RuleNumberOptions.biggerOrEquals, 158 | term: 2014, 159 | type: 'number', 160 | operator: RuleOperator.AND, 161 | }, 162 | ]) 163 | 164 | expect(results).toStrictEqual(expectBiggerOrEquals) 165 | }) 166 | it('[Number]: smaller or equals', () => { 167 | const results = new SearchEngine(collection).search([ 168 | { 169 | field: 'year', 170 | role: RuleNumberOptions.smallerOrEquals, 171 | term: 2014, 172 | type: 'number', 173 | operator: RuleOperator.AND, 174 | }, 175 | ]) 176 | 177 | expect(results).toStrictEqual(expectSmallerOrEquals) 178 | }) 179 | }) 180 | -------------------------------------------------------------------------------- /packages/flexysearch-react/src/provider/useFlexysearchProvider.test.tsx: -------------------------------------------------------------------------------- 1 | import { act, renderHook, waitFor } from '@testing-library/react'; 2 | 3 | import FlexysearchProvider, { 4 | useFlexysearchProvider, 5 | } from '../provider/FlexysearchProvider'; 6 | import tableDataMock from '../../../../__mocks__/movies.json'; 7 | import { RuleOperator, RuleStringOptions } from 'flexysearch'; 8 | 9 | describe('FlexysearchReact', () => { 10 | it('should mount Hook', () => { 11 | const { result } = renderHook(() => useFlexysearchProvider(), { 12 | wrapper: (props) => , 13 | }); 14 | 15 | expect(result.current.data).toEqual([]); 16 | }); 17 | }); 18 | 19 | describe('FlexysearchReact - Mount data', () => { 20 | it('should mount with Hook with Collection', () => { 21 | const dataState = [{ id: 1, name: 'test' }]; 22 | const { result } = renderHook(() => useFlexysearchProvider(), { 23 | wrapper: (props) => , 24 | }); 25 | expect(result.current.data).toEqual(dataState); 26 | }); 27 | it('Update collection', () => { 28 | const stateToUpdate = [{ id: 1, name: 'test' }]; 29 | const { result } = renderHook(() => useFlexysearchProvider(), { 30 | wrapper: (props) => , 31 | }); 32 | 33 | act(() => { 34 | result.current.setData(stateToUpdate); 35 | }); 36 | 37 | expect(result.current.data).toEqual(stateToUpdate); 38 | }); 39 | }); 40 | 41 | describe('FlexysearchReact - Filters', () => { 42 | beforeEach(() => { 43 | jest.resetAllMocks(); 44 | }); 45 | it('Search by term', () => { 46 | const dataToFindSearch = [{ id: 14, title: 'Film empty', year: '' }]; 47 | const { result } = renderHook(() => useFlexysearchProvider(), { 48 | wrapper: (props) => ( 49 | 50 | ), 51 | }); 52 | 53 | act(() => { 54 | result.current.updateGlobalSearch('Film empty'); 55 | }); 56 | 57 | waitFor(() => { 58 | expect(result.current.filtered_data).toEqual(dataToFindSearch); 59 | }); 60 | }); 61 | it('Search by Flexysearch integration', () => { 62 | const dataToFindSearch = [{ id: 14, title: 'Film empty', year: '' }]; 63 | const { result } = renderHook(() => useFlexysearchProvider(), { 64 | wrapper: (props) => ( 65 | 66 | ), 67 | }); 68 | 69 | act(() => { 70 | result.current.updateFilterRules([ 71 | { 72 | field: 'title', 73 | operator: RuleOperator.AND, 74 | term: 'Film empty', 75 | type: 'string', 76 | role: RuleStringOptions.equals, 77 | caseSensitive: false, 78 | }, 79 | ]); 80 | }); 81 | 82 | waitFor(() => { 83 | expect(result.current.filtered_data).toEqual(dataToFindSearch); 84 | }); 85 | }); 86 | it('Search by Flexysearch integration with global search', () => { 87 | const { result } = renderHook(() => useFlexysearchProvider(), { 88 | wrapper: (props) => ( 89 | 90 | ), 91 | }); 92 | 93 | act(() => { 94 | result.current.updateFilterRules([ 95 | { 96 | field: 'title', 97 | operator: RuleOperator.AND, 98 | term: 'Film empty', 99 | type: 'string', 100 | role: RuleStringOptions.equals, 101 | caseSensitive: false, 102 | }, 103 | ]); 104 | 105 | result.current.updateGlobalSearch('no match'); 106 | waitFor(() => { 107 | expect(result.current.filtered_data).toEqual([]); 108 | }); 109 | }); 110 | 111 | // Clear search term 112 | act(() => { 113 | result.current.updateGlobalSearch(''); 114 | }); 115 | 116 | waitFor(() => { 117 | expect(result.current.filtered_data).toEqual(tableDataMock); 118 | }); 119 | }); 120 | it('Integration flexysearch with reverse logic with search term', () => { 121 | const dataToFindSearch = [{ id: 14, title: 'Film empty', year: '' }]; 122 | const { result } = renderHook(() => useFlexysearchProvider(), { 123 | wrapper: (props) => ( 124 | 125 | ), 126 | }); 127 | 128 | act(() => { 129 | result.current.updateGlobalSearch('Film 1'); 130 | 131 | result.current.updateFilterRules([ 132 | { 133 | field: 'title', 134 | operator: RuleOperator.AND, 135 | term: 'Film empty', 136 | type: 'string', 137 | role: RuleStringOptions.equals, 138 | caseSensitive: false, 139 | }, 140 | ]); 141 | }); 142 | 143 | waitFor(() => { 144 | expect(result.current.filtered_data).toEqual([]); 145 | }); 146 | 147 | // Clear search term 148 | act(() => { 149 | result.current.updateGlobalSearch(''); 150 | }); 151 | 152 | waitFor(() => { 153 | expect(result.current.filtered_data).toEqual(dataToFindSearch); 154 | }); 155 | }); 156 | }); 157 | 158 | describe('Edges cases', () => { 159 | it('Should return empty array when not match', () => { 160 | const searchTerm = 'aaaaa'; 161 | const data = [{ name: 'test', mass: 100 }]; 162 | const { result } = renderHook(() => useFlexysearchProvider(), { 163 | wrapper: (props) => , 164 | }); 165 | 166 | act(() => { 167 | result.current.updateGlobalSearch(searchTerm); 168 | }); 169 | 170 | waitFor(() => { 171 | expect(result.current.filtered_data).toEqual([]); 172 | }); 173 | }); 174 | }); 175 | -------------------------------------------------------------------------------- /packages/react-accounting-textfield/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { ChangeCurrencyEventProps, IInputProps } from '../types' 3 | import { CurrencyInputControlled } from './components/Controlled' 4 | import { CurrencyInputUncontrolled } from './components/Uncontrolled' 5 | import { EuroSignIcon } from './assets/icons/euro' 6 | import classnames from 'clsx' 7 | import { ExclamationCircleIcon } from './assets/icons/exclamationCircle' 8 | import { formatMoney, moneyToFloat, eventInputToCurrency, preparePayload } from './utils' 9 | 10 | export type * from '../types' 11 | export * from './utils' 12 | 13 | export const CurrencyInput: React.FC = ({ 14 | inputProps, 15 | defaultValue, 16 | value, 17 | testID, 18 | onChangeCurrency, 19 | onBlurCurrency, 20 | showCurrencyIcon, 21 | size = 'md', 22 | label, 23 | error, 24 | helperText, 25 | minValue, 26 | maxValue, 27 | maximumFractionDigits = 2, 28 | }) => { 29 | const [inputValue, setInputValue] = React.useState('') 30 | 31 | React.useEffect(() => { 32 | typeof value !== 'undefined' && setInputValue(String(value)) 33 | }, [value]) 34 | 35 | React.useEffect(() => { 36 | if (value) { 37 | const localValue = moneyToFloat(String(value), maximumFractionDigits) 38 | setInputValue(formatMoney(localValue)) 39 | } 40 | if (defaultValue && value) { 41 | console.warn( 42 | 'You are trying to use controlled and uncontrolled at the same time. Just used inputProps.value or just defaultValue' 43 | ) 44 | } 45 | }, []) 46 | 47 | const emitChanges = ( 48 | currentValue: string, 49 | event: React.ChangeEvent, 50 | props: ChangeCurrencyEventProps 51 | ) => { 52 | !value && setInputValue(currentValue) 53 | inputProps?.onChange && inputProps.onChange(event) 54 | 55 | onChangeCurrency && onChangeCurrency(props) 56 | } 57 | 58 | const handleChange = (event: React.ChangeEvent) => { 59 | const props = preparePayload(event, maximumFractionDigits) 60 | const { value, float } = props 61 | 62 | if (!maxValue && !minValue) { 63 | emitChanges(value, event, props) 64 | } 65 | 66 | const isTestedMaxValue = maxValue && float <= maxValue 67 | const isTestedMinValue = minValue && float >= minValue 68 | 69 | if (minValue && !maxValue && isTestedMinValue) { 70 | emitChanges(value, event, props) 71 | } 72 | 73 | if (maxValue && !minValue && isTestedMaxValue) { 74 | emitChanges(value, event, props) 75 | } 76 | 77 | if (maxValue && minValue && isTestedMinValue && isTestedMaxValue) { 78 | emitChanges(value, event, props) 79 | } 80 | } 81 | 82 | const onBlurCurrencyHandler = (event: React.FocusEvent) => { 83 | const props = preparePayload(event, maximumFractionDigits) 84 | 85 | onBlurCurrency?.(props) 86 | } 87 | 88 | const handleBlur = React.useCallback( 89 | (event: React.FocusEvent) => { 90 | if (!inputValue) return 91 | const localValue = eventInputToCurrency(inputValue) 92 | setInputValue(localValue) 93 | 94 | inputProps?.onBlur && inputProps.onBlur(event) 95 | onBlurCurrencyHandler(event) 96 | }, 97 | [inputValue] 98 | ) 99 | 100 | return ( 101 |
108 | {label && ( 109 | 110 | )} 111 |
122 | {showCurrencyIcon && ( 123 |
128 | 129 |
130 | )} 131 | 132 | {typeof value !== 'undefined' && ( 133 | 141 | )} 142 | 143 | {typeof value === 'undefined' && ( 144 | 153 | )} 154 |
155 | {helperText && ( 156 |
157 | {error && ( 158 | 159 | 160 | 161 | )} 162 | 163 | {helperText} 164 | 165 |
166 | )} 167 |
168 | ) 169 | } 170 | -------------------------------------------------------------------------------- /apps/docs/static/img/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /techstack.md: -------------------------------------------------------------------------------- 1 | 42 |
43 | 44 | # Tech Stack File 45 | ![](https://img.stackshare.io/repo.svg "repo") [AlexcastroDev/flexysearch](https://github.com/AlexcastroDev/flexysearch)![](https://img.stackshare.io/public_badge.svg "public") 46 |

47 | |37
Tools used|02/29/24
Report generated| 48 | |------|------| 49 |
50 | 51 | ## Languages (3) 52 | 53 | 60 | 61 | 68 | 69 | 76 | 77 | 78 |
54 | CSS 3 55 |
56 | CSS 3 57 |
58 | 59 |
62 | JavaScript 63 |
64 | JavaScript 65 |
66 | 67 |
70 | TypeScript 71 |
72 | TypeScript 73 |
74 | 75 |
79 | 80 | ## Frameworks (2) 81 | 82 | 89 | 90 | 97 | 98 | 99 |
83 | Node.js 84 |
85 | Node.js 86 |
87 | 88 |
91 | React 92 |
93 | React 94 |
95 | v18.2.0 96 |
100 | 101 | ## DevOps (9) 102 | 103 | 110 | 111 | 118 | 119 | 126 | 127 | 134 | 135 | 142 | 143 | 150 | 151 | 158 | 159 | 166 | 167 | 168 | 169 | 176 | 177 | 178 |
104 | Babel 105 |
106 | Babel 107 |
108 | v7.12.9 109 |
112 | ESLint 113 |
114 | ESLint 115 |
116 | 117 |
120 | Git 121 |
122 | Git 123 |
124 | 125 |
128 | GitHub Actions 129 |
130 | GitHub Actions 131 |
132 | 133 |
136 | Jest 137 |
138 | Jest 139 |
140 | v29.7.0 141 |
144 | Prettier 145 |
146 | Prettier 147 |
148 | v2.8.8 149 |
152 | Yarn 153 |
154 | Yarn 155 |
156 | 157 |
160 | gulp 161 |
162 | gulp 163 |
164 | v4.0.2 165 |
170 | npm 171 |
172 | npm 173 |
174 | 175 |
179 | 180 | 181 | ## Open source packages (23) 182 | 183 | ## npm (23) 184 | 185 | |NAME|VERSION|LAST UPDATED|LAST UPDATED BY|LICENSE|VULNERABILITIES| 186 | |:------|:------|:------|:------|:------|:------| 187 | |[@babel/core](https://www.npmjs.com/@babel/core)|v7.12.9|11/27/23|Alex Oliveira |MIT|N/A| 188 | |[@babel/preset-react](https://www.npmjs.com/@babel/preset-react)|v7.18.6|11/28/23|Alex Oliveira |MIT|N/A| 189 | |[@mdx-js/react](https://www.npmjs.com/@mdx-js/react)|v1.6.22|11/28/23|Alex Oliveira |MIT|N/A| 190 | |[@svgr/rollup](https://www.npmjs.com/@svgr/rollup)|v8.1.0|11/27/23|Alex Oliveira |MIT|N/A| 191 | |[@testing-library/react](https://www.npmjs.com/@testing-library/react)|v14.0.0|11/28/23|Alex Oliveira |MIT|N/A| 192 | |[@types/jest](https://www.npmjs.com/@types/jest)|v29.5.10|11/28/23|Alex Oliveira |MIT|N/A| 193 | |[@types/node](https://www.npmjs.com/@types/node)|v18.15.4|11/28/23|Alex Oliveira |MIT|N/A| 194 | |[@types/react](https://www.npmjs.com/@types/react)|v18.0.28|11/28/23|Alex Oliveira |MIT|N/A| 195 | |[@types/react-dom](https://www.npmjs.com/@types/react-dom)|v18.2.14|11/28/23|Alex Oliveira |MIT|N/A| 196 | |[@typescript-eslint/eslint-plugin](https://www.npmjs.com/@typescript-eslint/eslint-plugin)|v6.12.0|11/28/23|Alex Oliveira |MIT|N/A| 197 | |[@typescript-eslint/parser](https://www.npmjs.com/@typescript-eslint/parser)|v6.12.0|11/28/23|Alex Oliveira |BSD-2-Clause|N/A| 198 | |[babel-jest](https://www.npmjs.com/babel-jest)|v29.7.0|11/27/23|Alex Oliveira |MIT|N/A| 199 | |[eslint-config-prettier](https://www.npmjs.com/eslint-config-prettier)|v9.0.0|11/27/23|Alex Oliveira |MIT|N/A| 200 | |[eslint-plugin-import](https://www.npmjs.com/eslint-plugin-import)|v2.27.5|11/27/23|Alex Oliveira |MIT|N/A| 201 | |[eslint-plugin-jsx-a11y](https://www.npmjs.com/eslint-plugin-jsx-a11y)|v6.7.1|11/27/23|Alex Oliveira |MIT|N/A| 202 | |[eslint-plugin-react](https://www.npmjs.com/eslint-plugin-react)|v7.32.2|11/28/23|Alex Oliveira |MIT|N/A| 203 | |[eslint-plugin-react-hooks](https://www.npmjs.com/eslint-plugin-react-hooks)|v4.6.0|11/28/23|Alex Oliveira |MIT|N/A| 204 | |[gh-pages](https://www.npmjs.com/gh-pages)|v5.0.0|11/27/23|Alex Oliveira |MIT|N/A| 205 | |[jest-environment-jsdom](https://www.npmjs.com/jest-environment-jsdom)|v29.7.0|11/27/23|Alex Oliveira |MIT|N/A| 206 | |[react-dom](https://www.npmjs.com/react-dom)|v18.2.0|11/28/23|Alex Oliveira |MIT|N/A| 207 | |[ts-jest](https://www.npmjs.com/ts-jest)|v29.1.1|11/27/23|Alex Oliveira |MIT|N/A| 208 | |[ts-node](https://www.npmjs.com/ts-node)|v10.9.1|11/27/23|Alex Oliveira |MIT|N/A| 209 | |[tslib](https://www.npmjs.com/tslib)|v2.5.0|11/27/23|Alex Oliveira |0BSD|N/A| 210 | 211 |
212 |
213 | 214 | Generated via [Stack File](https://github.com/marketplace/stack-file) 215 | -------------------------------------------------------------------------------- /apps/docs/static/img/undraw_docusaurus_tree.svg: -------------------------------------------------------------------------------- 1 | 2 | Focus on What Matters 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /__mocks__/babyBorns.json: -------------------------------------------------------------------------------- 1 | [{ 2 | "id": 1, 3 | "first_name": "Amber", 4 | "last_name": "Pockey", 5 | "born_at": "2022-08-12" 6 | }, { 7 | "id": 2, 8 | "first_name": "Marcile", 9 | "last_name": "Wesson", 10 | "born_at": "2021-10-23" 11 | }, { 12 | "id": 3, 13 | "first_name": "Druci", 14 | "last_name": "Braune", 15 | "born_at": null 16 | }, { 17 | "id": 4, 18 | "first_name": "Andreas", 19 | "last_name": "Casassa", 20 | "born_at": "" 21 | }, { 22 | "id": 5, 23 | "first_name": "Harriette", 24 | "last_name": "Jeffers", 25 | "born_at": "null" 26 | }, { 27 | "id": 6, 28 | "first_name": "Penny", 29 | "last_name": "Caslane", 30 | "born_at": "2022-03-22" 31 | }, { 32 | "id": 7, 33 | "first_name": "Kris", 34 | "last_name": "Royse", 35 | "born_at": "2021-12-05" 36 | }, { 37 | "id": 8, 38 | "first_name": "Delinda", 39 | "last_name": "Sydall", 40 | "born_at": "2022-07-30" 41 | }, { 42 | "id": 9, 43 | "first_name": "Nisse", 44 | "last_name": "Reeson", 45 | "born_at": "2022-03-07" 46 | }, { 47 | "id": 10, 48 | "first_name": "Kincaid", 49 | "last_name": "Dautry", 50 | "born_at": "2021-12-27" 51 | }, { 52 | "id": 11, 53 | "first_name": "Kurtis", 54 | "last_name": "Merrell", 55 | "born_at": "2022-05-19" 56 | }, { 57 | "id": 12, 58 | "first_name": "Trumann", 59 | "last_name": "Cuncarr", 60 | "born_at": "2022-08-25" 61 | }, { 62 | "id": 13, 63 | "first_name": "Wake", 64 | "last_name": "Clawe", 65 | "born_at": "2021-10-05" 66 | }, { 67 | "id": 14, 68 | "first_name": "Carson", 69 | "last_name": "Kalderon", 70 | "born_at": "2022-04-16" 71 | }, { 72 | "id": 15, 73 | "first_name": "Veronike", 74 | "last_name": "MacConnel", 75 | "born_at": "2022-05-18" 76 | }, { 77 | "id": 16, 78 | "first_name": "Rozina", 79 | "last_name": "Francais", 80 | "born_at": "2021-12-26" 81 | }, { 82 | "id": 17, 83 | "first_name": "Nicolis", 84 | "last_name": "Sein", 85 | "born_at": "2021-12-07" 86 | }, { 87 | "id": 18, 88 | "first_name": "Davita", 89 | "last_name": "McDill", 90 | "born_at": "2022-07-22" 91 | }, { 92 | "id": 19, 93 | "first_name": "Sanford", 94 | "last_name": "Victor", 95 | "born_at": "2021-09-26" 96 | }, { 97 | "id": 20, 98 | "first_name": "Micky", 99 | "last_name": "Kinge", 100 | "born_at": "2022-07-21" 101 | }, { 102 | "id": 21, 103 | "first_name": "Merridie", 104 | "last_name": "Hockell", 105 | "born_at": "2022-01-18" 106 | }, { 107 | "id": 22, 108 | "first_name": "Lilith", 109 | "last_name": "Ashwood", 110 | "born_at": "2022-03-13" 111 | }, { 112 | "id": 23, 113 | "first_name": "Michal", 114 | "last_name": "Benoiton", 115 | "born_at": "2022-04-14" 116 | }, { 117 | "id": 24, 118 | "first_name": "Killy", 119 | "last_name": "Duer", 120 | "born_at": "2021-10-03" 121 | }, { 122 | "id": 25, 123 | "first_name": "Jayme", 124 | "last_name": "Kemble", 125 | "born_at": "2021-11-14" 126 | }, { 127 | "id": 26, 128 | "first_name": "Susanna", 129 | "last_name": "Jessop", 130 | "born_at": "2022-01-23" 131 | }, { 132 | "id": 27, 133 | "first_name": "Gayelord", 134 | "last_name": "Sabbins", 135 | "born_at": "2022-02-25" 136 | }, { 137 | "id": 28, 138 | "first_name": "Shelby", 139 | "last_name": "Alenichicov", 140 | "born_at": "2022-07-09" 141 | }, { 142 | "id": 29, 143 | "first_name": "Lorenza", 144 | "last_name": "MacNeachtain", 145 | "born_at": "2021-11-25" 146 | }, { 147 | "id": 30, 148 | "first_name": "Georgetta", 149 | "last_name": "Huleatt", 150 | "born_at": "2022-07-17" 151 | }, { 152 | "id": 31, 153 | "first_name": "Evaleen", 154 | "last_name": "Dury", 155 | "born_at": "2022-03-15" 156 | }, { 157 | "id": 32, 158 | "first_name": "Briano", 159 | "last_name": "Defond", 160 | "born_at": "2021-12-26" 161 | }, { 162 | "id": 33, 163 | "first_name": "Codie", 164 | "last_name": "Pentecost", 165 | "born_at": "2022-08-25" 166 | }, { 167 | "id": 34, 168 | "first_name": "Beth", 169 | "last_name": "Grandison", 170 | "born_at": "2021-11-23" 171 | }, { 172 | "id": 35, 173 | "first_name": "Wilek", 174 | "last_name": "Kegan", 175 | "born_at": "2022-03-18" 176 | }, { 177 | "id": 36, 178 | "first_name": "Steffie", 179 | "last_name": "Vernazza", 180 | "born_at": "2022-07-09" 181 | }, { 182 | "id": 37, 183 | "first_name": "Sher", 184 | "last_name": "Avramchik", 185 | "born_at": "2021-11-30" 186 | }, { 187 | "id": 38, 188 | "first_name": "Ardine", 189 | "last_name": "Nowell", 190 | "born_at": "2021-09-27" 191 | }, { 192 | "id": 39, 193 | "first_name": "Neilla", 194 | "last_name": "Conboy", 195 | "born_at": "2022-04-17" 196 | }, { 197 | "id": 40, 198 | "first_name": "Morganica", 199 | "last_name": "Seger", 200 | "born_at": "2021-10-11" 201 | }, { 202 | "id": 41, 203 | "first_name": "Jodi", 204 | "last_name": "Eversfield", 205 | "born_at": "2022-06-26" 206 | }, { 207 | "id": 42, 208 | "first_name": "Cosette", 209 | "last_name": "Rayburn", 210 | "born_at": "2022-08-30" 211 | }, { 212 | "id": 43, 213 | "first_name": "Benedict", 214 | "last_name": "Tellenbach", 215 | "born_at": "2022-03-03" 216 | }, { 217 | "id": 44, 218 | "first_name": "Beaufort", 219 | "last_name": "Blaise", 220 | "born_at": "2022-04-23" 221 | }, { 222 | "id": 45, 223 | "first_name": "Paulie", 224 | "last_name": "Chattaway", 225 | "born_at": "2022-01-18" 226 | }, { 227 | "id": 46, 228 | "first_name": "Merrile", 229 | "last_name": "Bestwerthick", 230 | "born_at": "2022-07-17" 231 | }, { 232 | "id": 47, 233 | "first_name": "Lucie", 234 | "last_name": "Haddleston", 235 | "born_at": "2022-01-08" 236 | }, { 237 | "id": 48, 238 | "first_name": "Esra", 239 | "last_name": "Petrussi", 240 | "born_at": "2022-01-31" 241 | }, { 242 | "id": 49, 243 | "first_name": "Shanan", 244 | "last_name": "Beverage", 245 | "born_at": "2022-06-19" 246 | }, { 247 | "id": 50, 248 | "first_name": "Hunfredo", 249 | "last_name": "Scott", 250 | "born_at": "2022-04-29" 251 | }, { 252 | "id": 51, 253 | "first_name": "Nadya", 254 | "last_name": "MacKaile", 255 | "born_at": "2022-04-17" 256 | }, { 257 | "id": 52, 258 | "first_name": "Clemence", 259 | "last_name": "Yerrell", 260 | "born_at": "2022-06-12" 261 | }, { 262 | "id": 53, 263 | "first_name": "Frankie", 264 | "last_name": "Buffy", 265 | "born_at": "2022-03-02" 266 | }, { 267 | "id": 54, 268 | "first_name": "Deane", 269 | "last_name": "Quigg", 270 | "born_at": "2022-01-05" 271 | }, { 272 | "id": 55, 273 | "first_name": "Hanan", 274 | "last_name": "Baurerich", 275 | "born_at": "2022-01-09" 276 | }, { 277 | "id": 56, 278 | "first_name": "Darby", 279 | "last_name": "Wooles", 280 | "born_at": "2021-12-06" 281 | }, { 282 | "id": 57, 283 | "first_name": "Franklyn", 284 | "last_name": "Lynnitt", 285 | "born_at": "2022-03-29" 286 | }, { 287 | "id": 58, 288 | "first_name": "Candide", 289 | "last_name": "Bogace", 290 | "born_at": "2022-07-01" 291 | }, { 292 | "id": 59, 293 | "first_name": "Hakeem", 294 | "last_name": "Rivett", 295 | "born_at": "2021-10-31" 296 | }, { 297 | "id": 60, 298 | "first_name": "Nathanil", 299 | "last_name": "Carnie", 300 | "born_at": "2022-07-06" 301 | }, { 302 | "id": 61, 303 | "first_name": "Birgitta", 304 | "last_name": "Orhtmann", 305 | "born_at": "2021-12-07" 306 | }, { 307 | "id": 62, 308 | "first_name": "Andros", 309 | "last_name": "Spellward", 310 | "born_at": "2022-07-01" 311 | }, { 312 | "id": 63, 313 | "first_name": "Jorgan", 314 | "last_name": "Wyllis", 315 | "born_at": "2022-07-08" 316 | }, { 317 | "id": 64, 318 | "first_name": "Bess", 319 | "last_name": "Yewman", 320 | "born_at": "2021-12-17" 321 | }, { 322 | "id": 65, 323 | "first_name": "Anna-diana", 324 | "last_name": "Roxburgh", 325 | "born_at": "2021-10-01" 326 | }, { 327 | "id": 66, 328 | "first_name": "Alexandr", 329 | "last_name": "Woolston", 330 | "born_at": "2022-07-24" 331 | }, { 332 | "id": 67, 333 | "first_name": "Neda", 334 | "last_name": "Colicot", 335 | "born_at": "2022-06-16" 336 | }, { 337 | "id": 68, 338 | "first_name": "Laurette", 339 | "last_name": "Heisler", 340 | "born_at": "2021-10-20" 341 | }, { 342 | "id": 69, 343 | "first_name": "Rodrique", 344 | "last_name": "Deignan", 345 | "born_at": "2022-08-14" 346 | }, { 347 | "id": 70, 348 | "first_name": "Michaelina", 349 | "last_name": "Gillingwater", 350 | "born_at": "2021-10-23" 351 | }, { 352 | "id": 71, 353 | "first_name": "Jonathon", 354 | "last_name": "Rodolico", 355 | "born_at": "2022-07-20" 356 | }, { 357 | "id": 72, 358 | "first_name": "L;urette", 359 | "last_name": "Pinxton", 360 | "born_at": "2022-02-27" 361 | }, { 362 | "id": 73, 363 | "first_name": "Almeda", 364 | "last_name": "Whitworth", 365 | "born_at": "2021-12-25" 366 | }, { 367 | "id": 74, 368 | "first_name": "Rebeca", 369 | "last_name": "Davies", 370 | "born_at": "2022-01-26" 371 | }, { 372 | "id": 75, 373 | "first_name": "Winn", 374 | "last_name": "Liddel", 375 | "born_at": "2022-08-31" 376 | }, { 377 | "id": 76, 378 | "first_name": "Jaclin", 379 | "last_name": "Dello", 380 | "born_at": "2022-03-23" 381 | }, { 382 | "id": 77, 383 | "first_name": "Ivan", 384 | "last_name": "Winmill", 385 | "born_at": "2022-09-12" 386 | }, { 387 | "id": 78, 388 | "first_name": "Frants", 389 | "last_name": "Mitchenson", 390 | "born_at": "2021-09-21" 391 | }, { 392 | "id": 79, 393 | "first_name": "Nerty", 394 | "last_name": "Greenhow", 395 | "born_at": "2021-10-19" 396 | }, { 397 | "id": 80, 398 | "first_name": "Arabel", 399 | "last_name": "Pickton", 400 | "born_at": "2022-04-29" 401 | }, { 402 | "id": 81, 403 | "first_name": "Arney", 404 | "last_name": "Muzzall", 405 | "born_at": "2022-01-01" 406 | }, { 407 | "id": 82, 408 | "first_name": "Hartley", 409 | "last_name": "Billows", 410 | "born_at": "2021-09-26" 411 | }, { 412 | "id": 83, 413 | "first_name": "Anica", 414 | "last_name": "Amorts", 415 | "born_at": "2022-05-02" 416 | }, { 417 | "id": 84, 418 | "first_name": "Sherilyn", 419 | "last_name": "Checchetelli", 420 | "born_at": "2022-01-02" 421 | }, { 422 | "id": 85, 423 | "first_name": "Doe", 424 | "last_name": "Brixey", 425 | "born_at": "2022-01-28" 426 | }, { 427 | "id": 86, 428 | "first_name": "Hinze", 429 | "last_name": "Haskey", 430 | "born_at": "2021-12-31" 431 | }, { 432 | "id": 87, 433 | "first_name": "Elden", 434 | "last_name": "Blabey", 435 | "born_at": "2022-04-24" 436 | }, { 437 | "id": 88, 438 | "first_name": "Pryce", 439 | "last_name": "Addess", 440 | "born_at": "2022-04-01" 441 | }, { 442 | "id": 89, 443 | "first_name": "Missie", 444 | "last_name": "Muffin", 445 | "born_at": "2021-09-21" 446 | }, { 447 | "id": 90, 448 | "first_name": "Queenie", 449 | "last_name": "Cino", 450 | "born_at": "2022-01-08" 451 | }, { 452 | "id": 91, 453 | "first_name": "Candie", 454 | "last_name": "Mollindinia", 455 | "born_at": "2022-08-12" 456 | }, { 457 | "id": 92, 458 | "first_name": "Stormi", 459 | "last_name": "Mariyushkin", 460 | "born_at": "2022-06-10" 461 | }, { 462 | "id": 93, 463 | "first_name": "Larisa", 464 | "last_name": "Brierly", 465 | "born_at": "2022-08-29" 466 | }, { 467 | "id": 94, 468 | "first_name": "Evania", 469 | "last_name": "Kleint", 470 | "born_at": "2021-11-21" 471 | }, { 472 | "id": 95, 473 | "first_name": "Alejandra", 474 | "last_name": "Bavester", 475 | "born_at": "2022-04-18" 476 | }, { 477 | "id": 96, 478 | "first_name": "Parrnell", 479 | "last_name": "Woodley", 480 | "born_at": "2021-09-27" 481 | }, { 482 | "id": 97, 483 | "first_name": "Annabella", 484 | "last_name": "Rapelli", 485 | "born_at": "2022-02-20" 486 | }, { 487 | "id": 98, 488 | "first_name": "Jedd", 489 | "last_name": "MacDavitt", 490 | "born_at": "2022-09-14" 491 | }, { 492 | "id": 99, 493 | "first_name": "Penni", 494 | "last_name": "Lockhart", 495 | "born_at": "2022-07-12" 496 | }, { 497 | "id": 100, 498 | "first_name": "Tammara", 499 | "last_name": "Toupe", 500 | "born_at": "2022-06-23" 501 | }] 502 | --------------------------------------------------------------------------------