@grampro/kit 0.0.0-stage → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gbs/skills/gbs-components/SKILL.md +190 -0
- package/.gbs/skills/gbs-components/references/accessibility.md +102 -0
- package/.gbs/skills/gbs-components/references/data-display.md +185 -0
- package/.gbs/skills/gbs-components/references/data-grid.md +116 -0
- package/.gbs/skills/gbs-components/references/forms.md +202 -0
- package/.gbs/skills/gbs-components/references/install.md +211 -0
- package/.gbs/skills/gbs-components/references/overlays.md +206 -0
- package/.gbs/skills/gbs-components/references/pickers.md +83 -0
- package/.gbs/skills/gbs-components/references/styling.md +246 -0
- package/.gbs/skills/gbs-components/references/toaster.md +57 -0
- package/CHANGELOG.md +173 -0
- package/LICENSE +15 -0
- package/README.md +193 -2
- package/index.cjs +1410 -0
- package/package.json +77 -6
- package/schema/passport-v1.schema.json +204 -0
- package/source/components/accordion/README.md +45 -0
- package/source/components/accordion/core/index.ts +2 -0
- package/source/components/accordion/core/open.ts +56 -0
- package/source/components/accordion/core/types.ts +17 -0
- package/source/components/accordion/index.ts +8 -0
- package/source/components/accordion/passport.json +259 -0
- package/source/components/accordion/react/Accordion.tsx +133 -0
- package/source/components/accordion/react/AccordionItem.tsx +120 -0
- package/source/components/accordion/react/context.ts +20 -0
- package/source/components/accordion/react/props.ts +13 -0
- package/source/components/accordion/styles.css +207 -0
- package/source/components/alert/README.md +39 -0
- package/source/components/alert/core/index.ts +2 -0
- package/source/components/alert/core/live.ts +25 -0
- package/source/components/alert/core/types.ts +7 -0
- package/source/components/alert/index.ts +5 -0
- package/source/components/alert/passport.json +250 -0
- package/source/components/alert/react/Alert.tsx +113 -0
- package/source/components/alert/react/icons.tsx +21 -0
- package/source/components/alert/react/locale.ts +5 -0
- package/source/components/alert/react/props.ts +11 -0
- package/source/components/alert/styles.css +154 -0
- package/source/components/avatar/core/identity.ts +103 -0
- package/source/components/avatar/core/index.ts +2 -0
- package/source/components/avatar/core/types.ts +12 -0
- package/source/components/avatar/index.ts +7 -0
- package/source/components/avatar/passport.json +294 -0
- package/source/components/avatar/react/Avatar.tsx +118 -0
- package/source/components/avatar/react/AvatarGroup.tsx +74 -0
- package/source/components/avatar/react/locale.ts +11 -0
- package/source/components/avatar/react/props.ts +6 -0
- package/source/components/avatar/styles.css +225 -0
- package/source/components/badge/README.md +37 -0
- package/source/components/badge/core/count.ts +37 -0
- package/source/components/badge/core/index.ts +2 -0
- package/source/components/badge/core/types.ts +11 -0
- package/source/components/badge/index.ts +7 -0
- package/source/components/badge/passport.json +332 -0
- package/source/components/badge/react/Badge.tsx +89 -0
- package/source/components/badge/react/Tag.tsx +82 -0
- package/source/components/badge/react/locale.ts +5 -0
- package/source/components/badge/react/props.ts +6 -0
- package/source/components/badge/styles.css +203 -0
- package/source/components/breadcrumb/README.md +34 -0
- package/source/components/breadcrumb/core/index.ts +4 -0
- package/source/components/breadcrumb/core/trail.ts +42 -0
- package/source/components/breadcrumb/core/types.ts +20 -0
- package/source/components/breadcrumb/index.ts +5 -0
- package/source/components/breadcrumb/passport.json +243 -0
- package/source/components/breadcrumb/react/Breadcrumb.tsx +177 -0
- package/source/components/breadcrumb/react/locale.ts +6 -0
- package/source/components/breadcrumb/react/props.ts +14 -0
- package/source/components/breadcrumb/styles.css +138 -0
- package/source/components/button/README.md +32 -0
- package/source/components/button/core/index.ts +3 -0
- package/source/components/button/core/state.ts +16 -0
- package/source/components/button/core/types.ts +28 -0
- package/source/components/button/index.ts +5 -0
- package/source/components/button/passport.json +402 -0
- package/source/components/button/passport.manual.json +31 -0
- package/source/components/button/react/Button.tsx +173 -0
- package/source/components/button/react/locale.ts +5 -0
- package/source/components/button/react/props.ts +23 -0
- package/source/components/button/styles.css +232 -0
- package/source/components/card/README.md +60 -0
- package/source/components/card/core/index.ts +4 -0
- package/source/components/card/core/trend.ts +32 -0
- package/source/components/card/core/types.ts +5 -0
- package/source/components/card/index.ts +5 -0
- package/source/components/card/passport.json +337 -0
- package/source/components/card/react/Card.tsx +133 -0
- package/source/components/card/react/Stat.tsx +127 -0
- package/source/components/card/react/props.ts +4 -0
- package/source/components/card/styles.css +230 -0
- package/source/components/checkbox/README.md +36 -0
- package/source/components/checkbox/core/group.ts +30 -0
- package/source/components/checkbox/core/index.ts +3 -0
- package/source/components/checkbox/core/types.ts +17 -0
- package/source/components/checkbox/index.ts +9 -0
- package/source/components/checkbox/passport.json +456 -0
- package/source/components/checkbox/react/Checkbox.tsx +147 -0
- package/source/components/checkbox/react/CheckboxGroup.tsx +149 -0
- package/source/components/checkbox/react/context.ts +16 -0
- package/source/components/checkbox/react/locale.ts +5 -0
- package/source/components/checkbox/react/props.ts +6 -0
- package/source/components/checkbox/styles.css +211 -0
- package/source/components/combobox/README.md +170 -0
- package/source/components/combobox/core/filter.ts +155 -0
- package/source/components/combobox/core/index.ts +16 -0
- package/source/components/combobox/core/types.ts +48 -0
- package/source/components/combobox/core/virtual.ts +67 -0
- package/source/components/combobox/index.ts +13 -0
- package/source/components/combobox/passport.json +456 -0
- package/source/components/combobox/react/Listbox.tsx +310 -0
- package/source/components/combobox/react/MultiSelect.tsx +265 -0
- package/source/components/combobox/react/Popover.tsx +38 -0
- package/source/components/combobox/react/Select.tsx +200 -0
- package/source/components/combobox/react/icons.tsx +11 -0
- package/source/components/combobox/react/locale.ts +16 -0
- package/source/components/combobox/react/props.ts +88 -0
- package/source/components/combobox/react/useCombobox.ts +409 -0
- package/source/components/combobox/styles.css +419 -0
- package/source/components/data-grid/README.md +233 -0
- package/source/components/data-grid/agent/coerce.ts +368 -0
- package/source/components/data-grid/agent/contract.ts +410 -0
- package/source/components/data-grid/agent/dataset.ts +92 -0
- package/source/components/data-grid/agent/engine.ts +470 -0
- package/source/components/data-grid/agent/executors.ts +155 -0
- package/source/components/data-grid/agent/index.ts +79 -0
- package/source/components/data-grid/agent/intent.ts +324 -0
- package/source/components/data-grid/agent/operations.ts +335 -0
- package/source/components/data-grid/agent/validate.ts +630 -0
- package/source/components/data-grid/agent/webmcp.ts +107 -0
- package/source/components/data-grid/core/columnHelper.ts +21 -0
- package/source/components/data-grid/core/columns.ts +288 -0
- package/source/components/data-grid/core/filtering.ts +237 -0
- package/source/components/data-grid/core/grid.ts +638 -0
- package/source/components/data-grid/core/index.ts +14 -0
- package/source/components/data-grid/core/rows.ts +64 -0
- package/source/components/data-grid/core/sorting.ts +133 -0
- package/source/components/data-grid/core/state.ts +82 -0
- package/source/components/data-grid/core/store.ts +52 -0
- package/source/components/data-grid/core/types.ts +302 -0
- package/source/components/data-grid/core/values.ts +98 -0
- package/source/components/data-grid/core/virtual.ts +85 -0
- package/source/components/data-grid/export/csv.ts +32 -0
- package/source/components/data-grid/export/download.ts +12 -0
- package/source/components/data-grid/export/pdf-font.ts +139 -0
- package/source/components/data-grid/export/pdf-writer.ts +113 -0
- package/source/components/data-grid/export/pdf.ts +379 -0
- package/source/components/data-grid/export/table.ts +73 -0
- package/source/components/data-grid/export/xlsx.ts +145 -0
- package/source/components/data-grid/export/zip.ts +87 -0
- package/source/components/data-grid/index.ts +14 -0
- package/source/components/data-grid/passport.json +1051 -0
- package/source/components/data-grid/passport.manual.json +255 -0
- package/source/components/data-grid/react/AskGrid.tsx +164 -0
- package/source/components/data-grid/react/Cell.tsx +282 -0
- package/source/components/data-grid/react/ColumnMenu.tsx +135 -0
- package/source/components/data-grid/react/DataGrid.tsx +335 -0
- package/source/components/data-grid/react/FilterForm.tsx +142 -0
- package/source/components/data-grid/react/HeaderRow.tsx +332 -0
- package/source/components/data-grid/react/Pagination.tsx +107 -0
- package/source/components/data-grid/react/Popover.tsx +35 -0
- package/source/components/data-grid/react/Row.tsx +85 -0
- package/source/components/data-grid/react/Toolbar.tsx +267 -0
- package/source/components/data-grid/react/Viewport.tsx +167 -0
- package/source/components/data-grid/react/context.ts +57 -0
- package/source/components/data-grid/react/hooks.ts +83 -0
- package/source/components/data-grid/react/icons.tsx +45 -0
- package/source/components/data-grid/react/keyboard.ts +110 -0
- package/source/components/data-grid/react/locale.ts +130 -0
- package/source/components/data-grid/styles.css +874 -0
- package/source/components/date-picker/README.md +141 -0
- package/source/components/date-picker/core/calendar.ts +266 -0
- package/source/components/date-picker/core/format.ts +170 -0
- package/source/components/date-picker/core/index.ts +41 -0
- package/source/components/date-picker/core/today.ts +72 -0
- package/source/components/date-picker/core/types.ts +68 -0
- package/source/components/date-picker/index.ts +16 -0
- package/source/components/date-picker/passport.json +407 -0
- package/source/components/date-picker/react/Calendar.tsx +160 -0
- package/source/components/date-picker/react/CalendarPanel.tsx +170 -0
- package/source/components/date-picker/react/DatePicker.tsx +249 -0
- package/source/components/date-picker/react/DateRangePicker.tsx +291 -0
- package/source/components/date-picker/react/MonthYearPanels.tsx +123 -0
- package/source/components/date-picker/react/Popover.tsx +45 -0
- package/source/components/date-picker/react/icons.tsx +15 -0
- package/source/components/date-picker/react/locale.ts +23 -0
- package/source/components/date-picker/react/props.ts +76 -0
- package/source/components/date-picker/react/useDatePicker.ts +557 -0
- package/source/components/date-picker/styles.css +445 -0
- package/source/components/dialog/README.md +39 -0
- package/source/components/dialog/core/api.ts +34 -0
- package/source/components/dialog/core/dialog.ts +11 -0
- package/source/components/dialog/core/index.ts +7 -0
- package/source/components/dialog/core/store.ts +81 -0
- package/source/components/dialog/core/types.ts +59 -0
- package/source/components/dialog/index.ts +7 -0
- package/source/components/dialog/passport.json +344 -0
- package/source/components/dialog/react/Dialog.tsx +279 -0
- package/source/components/dialog/react/DialogHost.tsx +45 -0
- package/source/components/dialog/react/icons.tsx +20 -0
- package/source/components/dialog/react/locale.ts +8 -0
- package/source/components/dialog/react/props.ts +13 -0
- package/source/components/dialog/styles.css +280 -0
- package/source/components/file-uploader/README.md +99 -0
- package/source/components/file-uploader/core/format.ts +79 -0
- package/source/components/file-uploader/core/index.ts +26 -0
- package/source/components/file-uploader/core/store.ts +432 -0
- package/source/components/file-uploader/core/transport.ts +154 -0
- package/source/components/file-uploader/core/types.ts +126 -0
- package/source/components/file-uploader/core/validate.ts +83 -0
- package/source/components/file-uploader/index.ts +7 -0
- package/source/components/file-uploader/passport.json +518 -0
- package/source/components/file-uploader/react/FileRow.tsx +268 -0
- package/source/components/file-uploader/react/FileUploader.tsx +511 -0
- package/source/components/file-uploader/react/icons.tsx +60 -0
- package/source/components/file-uploader/react/locale.ts +33 -0
- package/source/components/file-uploader/react/props.ts +31 -0
- package/source/components/file-uploader/react/useFileUploader.ts +32 -0
- package/source/components/file-uploader/styles.css +394 -0
- package/source/components/input/README.md +44 -0
- package/source/components/input/core/count.ts +5 -0
- package/source/components/input/core/index.ts +11 -0
- package/source/components/input/core/otp.ts +64 -0
- package/source/components/input/core/types.ts +14 -0
- package/source/components/input/index.ts +8 -0
- package/source/components/input/passport.json +536 -0
- package/source/components/input/react/Input.tsx +219 -0
- package/source/components/input/react/OtpInput.tsx +256 -0
- package/source/components/input/react/dom.ts +10 -0
- package/source/components/input/react/icons.tsx +17 -0
- package/source/components/input/react/locale.ts +9 -0
- package/source/components/input/react/props.ts +6 -0
- package/source/components/input/styles.css +295 -0
- package/source/components/menu/README.md +68 -0
- package/source/components/menu/core/index.ts +11 -0
- package/source/components/menu/core/navigation.ts +84 -0
- package/source/components/menu/core/types.ts +32 -0
- package/source/components/menu/index.ts +19 -0
- package/source/components/menu/passport.json +322 -0
- package/source/components/menu/react/Menu.tsx +371 -0
- package/source/components/menu/react/context.ts +31 -0
- package/source/components/menu/react/items.tsx +268 -0
- package/source/components/menu/react/locale.ts +6 -0
- package/source/components/menu/react/props.ts +4 -0
- package/source/components/menu/react/useMenuKeys.ts +124 -0
- package/source/components/menu/styles.css +224 -0
- package/source/components/modal/README.md +51 -0
- package/source/components/modal/core/dismiss.ts +29 -0
- package/source/components/modal/core/index.ts +3 -0
- package/source/components/modal/core/types.ts +27 -0
- package/source/components/modal/index.ts +5 -0
- package/source/components/modal/passport.json +289 -0
- package/source/components/modal/react/Modal.tsx +242 -0
- package/source/components/modal/react/icons.tsx +1 -0
- package/source/components/modal/react/locale.ts +5 -0
- package/source/components/modal/react/props.ts +17 -0
- package/source/components/modal/styles.css +241 -0
- package/source/components/number-input/README.md +53 -0
- package/source/components/number-input/core/format.ts +37 -0
- package/source/components/number-input/core/index.ts +4 -0
- package/source/components/number-input/core/parse.ts +118 -0
- package/source/components/number-input/core/step.ts +73 -0
- package/source/components/number-input/core/types.ts +32 -0
- package/source/components/number-input/index.ts +5 -0
- package/source/components/number-input/passport.json +541 -0
- package/source/components/number-input/react/NumberInput.tsx +465 -0
- package/source/components/number-input/react/icons.tsx +17 -0
- package/source/components/number-input/react/locale.ts +7 -0
- package/source/components/number-input/react/props.ts +11 -0
- package/source/components/number-input/styles.css +230 -0
- package/source/components/popover/README.md +44 -0
- package/source/components/popover/core/index.ts +2 -0
- package/source/components/popover/core/types.ts +12 -0
- package/source/components/popover/index.ts +4 -0
- package/source/components/popover/passport.json +238 -0
- package/source/components/popover/react/Popover.tsx +202 -0
- package/source/components/popover/react/locale.ts +5 -0
- package/source/components/popover/react/props.ts +4 -0
- package/source/components/popover/styles.css +148 -0
- package/source/components/progress/README.md +38 -0
- package/source/components/progress/core/index.ts +2 -0
- package/source/components/progress/core/progress.ts +40 -0
- package/source/components/progress/core/types.ts +23 -0
- package/source/components/progress/index.ts +7 -0
- package/source/components/progress/passport.json +270 -0
- package/source/components/progress/react/CircularProgress.tsx +106 -0
- package/source/components/progress/react/Progress.tsx +113 -0
- package/source/components/progress/react/locale.ts +7 -0
- package/source/components/progress/react/props.ts +6 -0
- package/source/components/progress/styles.css +200 -0
- package/source/components/radio-group/README.md +58 -0
- package/source/components/radio-group/core/group.ts +36 -0
- package/source/components/radio-group/core/index.ts +2 -0
- package/source/components/radio-group/core/types.ts +20 -0
- package/source/components/radio-group/index.ts +9 -0
- package/source/components/radio-group/passport.json +477 -0
- package/source/components/radio-group/react/Radio.tsx +144 -0
- package/source/components/radio-group/react/RadioGroup.tsx +179 -0
- package/source/components/radio-group/react/context.ts +18 -0
- package/source/components/radio-group/react/locale.ts +5 -0
- package/source/components/radio-group/react/props.ts +12 -0
- package/source/components/radio-group/styles.css +269 -0
- package/source/components/shared/README.md +54 -0
- package/source/components/shared/core/agent/adapter.ts +65 -0
- package/source/components/shared/core/agent/history.ts +120 -0
- package/source/components/shared/core/agent/index.ts +46 -0
- package/source/components/shared/core/agent/numbers.ts +217 -0
- package/source/components/shared/core/agent/schema.ts +180 -0
- package/source/components/shared/core/agent/types.ts +169 -0
- package/source/components/shared/core/agent/webmcp.ts +328 -0
- package/source/components/shared/core/cx.ts +9 -0
- package/source/components/shared/core/field.ts +35 -0
- package/source/components/shared/core/position.ts +124 -0
- package/source/components/shared/core/text.ts +14 -0
- package/source/components/shared/index.ts +17 -0
- package/source/components/shared/react/GramproAIProvider.tsx +50 -0
- package/source/components/shared/react/Popover.tsx +189 -0
- package/source/components/shared/react/icons.tsx +74 -0
- package/source/components/shared/react/useAskAgent.ts +217 -0
- package/source/components/shared/react/useControllableState.ts +42 -0
- package/source/components/shared/styles.css +79 -0
- package/source/components/shared/version.json +4 -0
- package/source/components/shared/version.ts +6 -0
- package/source/components/skeleton/README.md +58 -0
- package/source/components/skeleton/core/index.ts +3 -0
- package/source/components/skeleton/core/lines.ts +25 -0
- package/source/components/skeleton/core/types.ts +5 -0
- package/source/components/skeleton/index.ts +5 -0
- package/source/components/skeleton/passport.json +251 -0
- package/source/components/skeleton/react/Empty.tsx +51 -0
- package/source/components/skeleton/react/Skeleton.tsx +92 -0
- package/source/components/skeleton/react/props.ts +4 -0
- package/source/components/skeleton/styles.css +185 -0
- package/source/components/spinner/README.md +29 -0
- package/source/components/spinner/core/index.ts +3 -0
- package/source/components/spinner/core/types.ts +28 -0
- package/source/components/spinner/core/visibility.ts +34 -0
- package/source/components/spinner/index.ts +6 -0
- package/source/components/spinner/passport.json +245 -0
- package/source/components/spinner/react/Spinner.tsx +96 -0
- package/source/components/spinner/react/locale.ts +5 -0
- package/source/components/spinner/react/props.ts +4 -0
- package/source/components/spinner/react/useDelayedLoading.ts +39 -0
- package/source/components/spinner/styles.css +173 -0
- package/source/components/switch/README.md +46 -0
- package/source/components/switch/core/index.ts +2 -0
- package/source/components/switch/core/toggle.ts +54 -0
- package/source/components/switch/core/types.ts +9 -0
- package/source/components/switch/index.ts +5 -0
- package/source/components/switch/passport.json +421 -0
- package/source/components/switch/react/Switch.tsx +219 -0
- package/source/components/switch/react/locale.ts +5 -0
- package/source/components/switch/react/props.ts +12 -0
- package/source/components/switch/styles.css +227 -0
- package/source/components/tabs/README.md +32 -0
- package/source/components/tabs/core/index.ts +3 -0
- package/source/components/tabs/core/navigation.ts +54 -0
- package/source/components/tabs/core/types.ts +16 -0
- package/source/components/tabs/index.ts +5 -0
- package/source/components/tabs/passport.json +315 -0
- package/source/components/tabs/react/Tabs.tsx +306 -0
- package/source/components/tabs/react/context.ts +21 -0
- package/source/components/tabs/styles.css +263 -0
- package/source/components/textarea/README.md +39 -0
- package/source/components/textarea/core/count.ts +5 -0
- package/source/components/textarea/core/index.ts +4 -0
- package/source/components/textarea/core/size.ts +23 -0
- package/source/components/textarea/core/types.ts +17 -0
- package/source/components/textarea/index.ts +5 -0
- package/source/components/textarea/passport.json +382 -0
- package/source/components/textarea/react/Textarea.tsx +208 -0
- package/source/components/textarea/react/locale.ts +5 -0
- package/source/components/textarea/react/props.ts +4 -0
- package/source/components/textarea/styles.css +158 -0
- package/source/components/toaster/README.md +128 -0
- package/source/components/toaster/core/api.ts +87 -0
- package/source/components/toaster/core/index.ts +14 -0
- package/source/components/toaster/core/store.ts +211 -0
- package/source/components/toaster/core/toast.ts +12 -0
- package/source/components/toaster/core/types.ts +78 -0
- package/source/components/toaster/index.ts +6 -0
- package/source/components/toaster/passport.json +221 -0
- package/source/components/toaster/react/ToastItem.tsx +164 -0
- package/source/components/toaster/react/Toaster.tsx +187 -0
- package/source/components/toaster/react/icons.tsx +23 -0
- package/source/components/toaster/react/locale.ts +6 -0
- package/source/components/toaster/react/props.ts +15 -0
- package/source/components/toaster/react/useToasts.ts +11 -0
- package/source/components/toaster/styles.css +282 -0
- package/source/components/tooltip/README.md +43 -0
- package/source/components/tooltip/core/index.ts +4 -0
- package/source/components/tooltip/core/types.ts +4 -0
- package/source/components/tooltip/core/visibility.ts +34 -0
- package/source/components/tooltip/index.ts +3 -0
- package/source/components/tooltip/passport.json +170 -0
- package/source/components/tooltip/react/Tooltip.tsx +196 -0
- package/source/components/tooltip/react/props.ts +4 -0
- package/source/components/tooltip/styles.css +71 -0
- package/source/fallback/index.tsx +11 -0
- package/source/globalStyle.ts +74 -0
- package/source/hooks/SelectionHooks/type.ts +4 -0
- package/source/hooks/SelectionHooks/useClickOutside.ts +22 -0
- package/source/hooks/SelectionHooks/useMultiSelectState.ts +64 -0
- package/source/hooks/SelectionHooks/useSelectData.ts +58 -0
- package/source/hooks/SelectionHooks/useSelectState.ts +36 -0
- package/source/icon/Icon.tsx +102 -0
- package/source/icon/iconPaths.ts +206 -0
- package/source/legacy-components/bargraph/index.tsx +95 -0
- package/source/legacy-components/bargraph/type.ts +12 -0
- package/source/legacy-components/breadcrumb/index.tsx +66 -0
- package/source/legacy-components/breadcrumb/types.ts +10 -0
- package/source/legacy-components/button/index.tsx +42 -0
- package/source/legacy-components/card/index.tsx +31 -0
- package/source/legacy-components/checkbox/index.tsx +25 -0
- package/source/legacy-components/contextmenu/ContextMenu.tsx +87 -0
- package/source/legacy-components/contextmenu/ContextMenuItem.tsx +30 -0
- package/source/legacy-components/contextmenu/index.ts +2 -0
- package/source/legacy-components/contextmenu/types.ts +19 -0
- package/source/legacy-components/darkmode/index.tsx +55 -0
- package/source/legacy-components/datagrid/context/GridContext.tsx +215 -0
- package/source/legacy-components/datagrid/createTemplate.tsx +82 -0
- package/source/legacy-components/datagrid/hooks/index.ts +6 -0
- package/source/legacy-components/datagrid/hooks/useColumns.ts +33 -0
- package/source/legacy-components/datagrid/hooks/useDataSource.ts +54 -0
- package/source/legacy-components/datagrid/hooks/useFiltering.ts +169 -0
- package/source/legacy-components/datagrid/hooks/usePagination.ts +112 -0
- package/source/legacy-components/datagrid/hooks/useRowSelection.ts +48 -0
- package/source/legacy-components/datagrid/hooks/useSearch.ts +90 -0
- package/source/legacy-components/datagrid/index.tsx +28 -0
- package/source/legacy-components/datagrid/layout/FilterPopup.tsx +92 -0
- package/source/legacy-components/datagrid/layout/GridBody.tsx +184 -0
- package/source/legacy-components/datagrid/layout/GridPagination.tsx +119 -0
- package/source/legacy-components/datagrid/layout/GridToolbar.tsx +109 -0
- package/source/legacy-components/datagrid/layout/index.tsx +68 -0
- package/source/legacy-components/datagrid/type.ts +198 -0
- package/source/legacy-components/datepicker/index.tsx +365 -0
- package/source/legacy-components/datepicker/types.ts +12 -0
- package/source/legacy-components/dialog/index.tsx +44 -0
- package/source/legacy-components/dialog/types.ts +12 -0
- package/source/legacy-components/formrenderer/componentHandles/CheckBoxHandles.tsx +80 -0
- package/source/legacy-components/formrenderer/componentHandles/DatePickerHandles.tsx +93 -0
- package/source/legacy-components/formrenderer/componentHandles/InputHandles.tsx +106 -0
- package/source/legacy-components/formrenderer/componentHandles/MultiHandles.tsx +93 -0
- package/source/legacy-components/formrenderer/componentHandles/SelectHandles.tsx +95 -0
- package/source/legacy-components/formrenderer/helperFunctions.ts +72 -0
- package/source/legacy-components/formrenderer/index.tsx +93 -0
- package/source/legacy-components/formrenderer/types.ts +127 -0
- package/source/legacy-components/input/index.tsx +142 -0
- package/source/legacy-components/input/types.ts +10 -0
- package/source/legacy-components/materialInput/index.tsx +138 -0
- package/source/legacy-components/materialInput/types.ts +16 -0
- package/source/legacy-components/modal/index.tsx +152 -0
- package/source/legacy-components/modal/types.ts +19 -0
- package/source/legacy-components/multiselect/PortalDropDown.tsx +44 -0
- package/source/legacy-components/multiselect/index.tsx +269 -0
- package/source/legacy-components/multiselect/types.ts +26 -0
- package/source/legacy-components/navbar/AuthSection.tsx +98 -0
- package/source/legacy-components/navbar/MobileToggle.tsx +31 -0
- package/source/legacy-components/navbar/NavItemComponent.tsx +119 -0
- package/source/legacy-components/navbar/SearchBar.tsx +55 -0
- package/source/legacy-components/navbar/helperFunctions.ts +27 -0
- package/source/legacy-components/navbar/index.tsx +156 -0
- package/source/legacy-components/navbar/types.ts +69 -0
- package/source/legacy-components/select/PortalDropDown.tsx +59 -0
- package/source/legacy-components/select/index.tsx +249 -0
- package/source/legacy-components/select/types.ts +29 -0
- package/source/legacy-components/sidebar/components/MenuItem.tsx +101 -0
- package/source/legacy-components/sidebar/components/MenuSection.tsx +34 -0
- package/source/legacy-components/sidebar/components/SidebarFooter.tsx +50 -0
- package/source/legacy-components/sidebar/components/SidebarLogo.tsx +24 -0
- package/source/legacy-components/sidebar/components/SidebarMenu.tsx +29 -0
- package/source/legacy-components/sidebar/components/UserProfile.tsx +31 -0
- package/source/legacy-components/sidebar/hooks/useSidebarState.ts +41 -0
- package/source/legacy-components/sidebar/index.tsx +77 -0
- package/source/legacy-components/sidebar/type.ts +42 -0
- package/source/legacy-components/spinner/Stroke.tsx +89 -0
- package/source/legacy-components/spinner/index.tsx +54 -0
- package/source/legacy-components/spinner/types.ts +9 -0
- package/source/legacy-components/tabs/index.tsx +71 -0
- package/source/legacy-components/tabs/types.ts +16 -0
- package/source/legacy-components/textarea/index.tsx +123 -0
- package/source/legacy-components/textarea/types.ts +15 -0
- package/source/legacy-components/toast/ToastComponent.tsx +101 -0
- package/source/legacy-components/toast/ToastIcon.tsx +61 -0
- package/source/legacy-components/toast/index.tsx +42 -0
- package/source/legacy-components/toast/toastStore.ts +42 -0
- package/source/legacy-components/toast/types.ts +18 -0
- package/source/legacy-components/toast/useToast.ts +12 -0
- package/source/legacy-components/uploader/ProgressAnimation.tsx +50 -0
- package/source/legacy-components/uploader/UploadedFilePreview.tsx +130 -0
- package/source/legacy-components/uploader/index.tsx +311 -0
- package/source/legacy-components/uploader/types.ts +30 -0
- package/source/legacy-components/uploader/uploaderIcon.tsx +72 -0
- package/source/legacy-components/uploader/uploaderService.ts +134 -0
- package/source/legacy-components/useUploader/useUploader.tsx +310 -0
- package/source/legacy-components/usepaginateddata/usePaginatedData.ts +174 -0
- package/source/theme.ts +40 -0
- package/source/utils.ts +10 -0
- package/tools/env.cjs +61 -0
- package/tools/passport/cli.cjs +79 -0
- package/tools/passport/extract.cjs +493 -0
- package/tools/passport/index.cjs +185 -0
- package/tools/passport/merge.cjs +131 -0
- package/tools/passport/policy.cjs +65 -0
- package/tools/passport/validate.cjs +277 -0
- package/tools/ts-require.cjs +79 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { GridOptions, GridRow, PaginationState, RowId } from "./types";
|
|
2
|
+
|
|
3
|
+
export type RowIdGetter<T> = (row: T, index: number) => RowId;
|
|
4
|
+
|
|
5
|
+
export function createRowIdGetter<T>(
|
|
6
|
+
getRowId: GridOptions<T>["getRowId"],
|
|
7
|
+
): RowIdGetter<T> {
|
|
8
|
+
if (typeof getRowId === "function") {
|
|
9
|
+
return (row, index) => String(getRowId(row, index));
|
|
10
|
+
}
|
|
11
|
+
if (typeof getRowId === "string") {
|
|
12
|
+
return (row) => String(row[getRowId]);
|
|
13
|
+
}
|
|
14
|
+
return (row, index) => {
|
|
15
|
+
const id = (row as { id?: unknown } | null)?.id;
|
|
16
|
+
return id === null || id === undefined ? String(index) : String(id);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function buildRows<T>(
|
|
21
|
+
data: readonly T[],
|
|
22
|
+
getRowId: RowIdGetter<T>,
|
|
23
|
+
): GridRow<T>[] {
|
|
24
|
+
return data.map((original, index) => ({
|
|
25
|
+
id: getRowId(original, index),
|
|
26
|
+
index,
|
|
27
|
+
original,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface PageResult<T> {
|
|
32
|
+
rows: GridRow<T>[];
|
|
33
|
+
pageIndex: number;
|
|
34
|
+
pageCount: number;
|
|
35
|
+
/** Total rows across all pages. */
|
|
36
|
+
rowCount: number;
|
|
37
|
+
/** Absolute index of the first row on the page. */
|
|
38
|
+
pageOffset: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function paginate<T>(
|
|
42
|
+
rows: GridRow<T>[],
|
|
43
|
+
pagination: PaginationState,
|
|
44
|
+
options: { enabled: boolean; server: boolean; rowCount?: number },
|
|
45
|
+
): PageResult<T> {
|
|
46
|
+
const total = options.server ? (options.rowCount ?? rows.length) : rows.length;
|
|
47
|
+
|
|
48
|
+
if (!options.enabled) {
|
|
49
|
+
return { rows, pageIndex: 0, pageCount: 1, rowCount: total, pageOffset: 0 };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const pageSize = Math.max(1, pagination.pageSize);
|
|
53
|
+
const pageCount = Math.max(1, Math.ceil(total / pageSize));
|
|
54
|
+
const pageIndex = Math.min(Math.max(0, pagination.pageIndex), pageCount - 1);
|
|
55
|
+
const pageOffset = pageIndex * pageSize;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
rows: options.server ? rows : rows.slice(pageOffset, pageOffset + pageSize),
|
|
59
|
+
pageIndex,
|
|
60
|
+
pageCount,
|
|
61
|
+
rowCount: total,
|
|
62
|
+
pageOffset,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { GridRow, ResolvedColumn, SortItem } from "./types";
|
|
2
|
+
import { toTime } from "./values";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One collator per locale. `undefined` means the runtime's own locale, which is
|
|
6
|
+
* what the grid used everywhere before it took a `locale` prop; passing the
|
|
7
|
+
* prop through keeps the order of the rows and the formatting of their values
|
|
8
|
+
* speaking the same language.
|
|
9
|
+
*/
|
|
10
|
+
const collators = new Map<string, Intl.Collator>();
|
|
11
|
+
|
|
12
|
+
function collatorFor(locale?: string): Intl.Collator {
|
|
13
|
+
const key = locale ?? "";
|
|
14
|
+
let found = collators.get(key);
|
|
15
|
+
if (!found) {
|
|
16
|
+
found = new Intl.Collator(locale, { numeric: true, sensitivity: "base" });
|
|
17
|
+
collators.set(key, found);
|
|
18
|
+
}
|
|
19
|
+
return found;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type SortKey = number | null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Converts a column's values into numbers once, so the sort itself only does
|
|
26
|
+
* numeric comparisons. Strings become their collation rank.
|
|
27
|
+
*/
|
|
28
|
+
function buildKeys<T>(
|
|
29
|
+
rows: GridRow<T>[],
|
|
30
|
+
column: ResolvedColumn<T>,
|
|
31
|
+
locale?: string,
|
|
32
|
+
): SortKey[] {
|
|
33
|
+
const values = rows.map((row) => column.getValue(row.original));
|
|
34
|
+
|
|
35
|
+
switch (column.type) {
|
|
36
|
+
case "number":
|
|
37
|
+
return values.map((v) => {
|
|
38
|
+
if (v === null || v === undefined || v === "") return null;
|
|
39
|
+
const n = Number(v);
|
|
40
|
+
return Number.isNaN(n) ? null : n;
|
|
41
|
+
});
|
|
42
|
+
case "date":
|
|
43
|
+
return values.map(toTime);
|
|
44
|
+
case "boolean":
|
|
45
|
+
return values.map((v) => (v === null || v === undefined ? null : v ? 1 : 0));
|
|
46
|
+
default: {
|
|
47
|
+
const { options } = column.def;
|
|
48
|
+
const labels = options && new Map(options.map((o) => [o.value, o.label]));
|
|
49
|
+
const strings = values.map((v) =>
|
|
50
|
+
v === null || v === undefined || v === ""
|
|
51
|
+
? null
|
|
52
|
+
: String(labels?.get(v as string | number) ?? v),
|
|
53
|
+
);
|
|
54
|
+
const collator = collatorFor(locale);
|
|
55
|
+
const unique = Array.from(new Set(strings.filter((s) => s !== null)));
|
|
56
|
+
unique.sort(collator.compare);
|
|
57
|
+
const rank = new Map<string, number>();
|
|
58
|
+
let current = 0;
|
|
59
|
+
unique.forEach((s, i) => {
|
|
60
|
+
if (i > 0 && collator.compare(unique[i - 1], s) !== 0) current = i;
|
|
61
|
+
rank.set(s, current);
|
|
62
|
+
});
|
|
63
|
+
return strings.map((s) => (s === null ? null : rank.get(s)!));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Stable multi-column sort. Empty values always sort last. */
|
|
69
|
+
export function sortRows<T>(
|
|
70
|
+
rows: GridRow<T>[],
|
|
71
|
+
columns: readonly ResolvedColumn<T>[],
|
|
72
|
+
sorting: readonly SortItem[],
|
|
73
|
+
locale?: string,
|
|
74
|
+
): GridRow<T>[] {
|
|
75
|
+
const byId = new Map(columns.map((c) => [c.id, c]));
|
|
76
|
+
const active = sorting
|
|
77
|
+
.map((item) => ({ column: byId.get(item.columnId), desc: item.desc }))
|
|
78
|
+
.filter(
|
|
79
|
+
(item): item is { column: ResolvedColumn<T>; desc: boolean } =>
|
|
80
|
+
item.column !== undefined && item.column.hasValue,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (active.length === 0 || rows.length < 2) return rows;
|
|
84
|
+
|
|
85
|
+
const comparators = active.map(({ column, desc }) => {
|
|
86
|
+
const direction = desc ? -1 : 1;
|
|
87
|
+
const { sortFn } = column.def;
|
|
88
|
+
if (sortFn) {
|
|
89
|
+
const values = rows.map((row) => column.getValue(row.original));
|
|
90
|
+
return (i: number, j: number) =>
|
|
91
|
+
direction * sortFn(values[i], values[j], rows[i].original, rows[j].original);
|
|
92
|
+
}
|
|
93
|
+
const keys = buildKeys(rows, column, locale);
|
|
94
|
+
return (i: number, j: number) => {
|
|
95
|
+
const a = keys[i];
|
|
96
|
+
const b = keys[j];
|
|
97
|
+
if (a === b) return 0;
|
|
98
|
+
if (a === null) return 1;
|
|
99
|
+
if (b === null) return -1;
|
|
100
|
+
return a < b ? -direction : direction;
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const indices = rows.map((_, i) => i);
|
|
105
|
+
indices.sort((i, j) => {
|
|
106
|
+
for (const compare of comparators) {
|
|
107
|
+
const result = compare(i, j);
|
|
108
|
+
if (result !== 0) return result;
|
|
109
|
+
}
|
|
110
|
+
return i - j;
|
|
111
|
+
});
|
|
112
|
+
return indices.map((i) => rows[i]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Click cycles asc → desc → off. With `multi`, other sorts are kept. */
|
|
116
|
+
export function toggleSorting(
|
|
117
|
+
sorting: readonly SortItem[],
|
|
118
|
+
columnId: string,
|
|
119
|
+
multi: boolean,
|
|
120
|
+
): SortItem[] {
|
|
121
|
+
const existing = sorting.find((s) => s.columnId === columnId);
|
|
122
|
+
const next: SortItem | null = !existing
|
|
123
|
+
? { columnId, desc: false }
|
|
124
|
+
: !existing.desc
|
|
125
|
+
? { columnId, desc: true }
|
|
126
|
+
: null;
|
|
127
|
+
|
|
128
|
+
if (!multi) return next ? [next] : [];
|
|
129
|
+
if (!existing) return [...sorting, next!];
|
|
130
|
+
return next
|
|
131
|
+
? sorting.map((s) => (s.columnId === columnId ? next : s))
|
|
132
|
+
: sorting.filter((s) => s.columnId !== columnId);
|
|
133
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { getColumnId } from "./columns";
|
|
2
|
+
import type { GridOptions, GridQuery, GridState } from "./types";
|
|
3
|
+
|
|
4
|
+
export const DEFAULT_PAGE_SIZE = 50;
|
|
5
|
+
|
|
6
|
+
export const STATE_KEYS = [
|
|
7
|
+
"sorting",
|
|
8
|
+
"filters",
|
|
9
|
+
"globalFilter",
|
|
10
|
+
"pagination",
|
|
11
|
+
"rowSelection",
|
|
12
|
+
"columnOrder",
|
|
13
|
+
"columnVisibility",
|
|
14
|
+
"columnSizing",
|
|
15
|
+
"columnPinning",
|
|
16
|
+
"density",
|
|
17
|
+
] as const satisfies readonly (keyof GridState)[];
|
|
18
|
+
|
|
19
|
+
const QUERY_KEYS = ["sorting", "filters", "globalFilter", "pagination"] as const;
|
|
20
|
+
|
|
21
|
+
/** Initial state, seeded from `initialState` and column-level `pin` / `hidden`. */
|
|
22
|
+
export function createInitialState<T>(options: GridOptions<T>): GridState {
|
|
23
|
+
const init = options.initialState ?? {};
|
|
24
|
+
const left: string[] = [];
|
|
25
|
+
const right: string[] = [];
|
|
26
|
+
const visibility: Record<string, boolean> = {};
|
|
27
|
+
|
|
28
|
+
for (const def of options.columns) {
|
|
29
|
+
const id = getColumnId(def);
|
|
30
|
+
if (def.pin === "left") left.push(id);
|
|
31
|
+
if (def.pin === "right") right.push(id);
|
|
32
|
+
if (def.hidden) visibility[id] = false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
sorting: init.sorting ?? [],
|
|
37
|
+
filters: init.filters ?? [],
|
|
38
|
+
globalFilter: init.globalFilter ?? "",
|
|
39
|
+
pagination: { pageIndex: 0, pageSize: DEFAULT_PAGE_SIZE, ...init.pagination },
|
|
40
|
+
rowSelection: init.rowSelection ?? {},
|
|
41
|
+
columnOrder: init.columnOrder ?? [],
|
|
42
|
+
columnVisibility: init.columnVisibility ?? visibility,
|
|
43
|
+
columnSizing: init.columnSizing ?? {},
|
|
44
|
+
columnPinning: init.columnPinning ?? { left, right },
|
|
45
|
+
density: init.density ?? "standard",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Controlled keys (not undefined) win over internal state. */
|
|
50
|
+
export function mergeState(
|
|
51
|
+
internal: GridState,
|
|
52
|
+
controlled: Partial<GridState> | undefined,
|
|
53
|
+
): GridState {
|
|
54
|
+
if (!controlled) return internal;
|
|
55
|
+
let merged: GridState | null = null;
|
|
56
|
+
for (const key of STATE_KEYS) {
|
|
57
|
+
const value = controlled[key];
|
|
58
|
+
if (value !== undefined && value !== internal[key]) {
|
|
59
|
+
merged ??= { ...internal };
|
|
60
|
+
(merged as unknown as Record<string, unknown>)[key] = value;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return merged ?? internal;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function pickQuery(state: GridState): GridQuery {
|
|
67
|
+
return {
|
|
68
|
+
sorting: state.sorting,
|
|
69
|
+
filters: state.filters,
|
|
70
|
+
globalFilter: state.globalFilter,
|
|
71
|
+
pagination: state.pagination,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function queryChanged(a: GridState, b: GridState): boolean {
|
|
76
|
+
return QUERY_KEYS.some((key) => a[key] !== b[key]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Filters, search and sort changes move the grid back to the first page. */
|
|
80
|
+
export function resetsPage(a: GridState, b: GridState): boolean {
|
|
81
|
+
return a.filters !== b.filters || a.globalFilter !== b.globalFilter || a.sorting !== b.sorting;
|
|
82
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface ReadableStore<S> {
|
|
2
|
+
getSnapshot(): S;
|
|
3
|
+
subscribe(listener: () => void): () => void;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface Store<S> extends ReadableStore<S> {
|
|
7
|
+
setState(updater: (prev: S) => S): void;
|
|
8
|
+
notify(): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Minimal external store for `useSyncExternalStore`. */
|
|
12
|
+
export function createStore<S>(initial: S): Store<S> {
|
|
13
|
+
let state = initial;
|
|
14
|
+
const listeners = new Set<() => void>();
|
|
15
|
+
|
|
16
|
+
const notify = () => {
|
|
17
|
+
for (const listener of listeners) listener();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
getSnapshot: () => state,
|
|
22
|
+
subscribe(listener) {
|
|
23
|
+
listeners.add(listener);
|
|
24
|
+
return () => listeners.delete(listener);
|
|
25
|
+
},
|
|
26
|
+
setState(updater) {
|
|
27
|
+
const next = updater(state);
|
|
28
|
+
if (Object.is(next, state)) return;
|
|
29
|
+
state = next;
|
|
30
|
+
notify();
|
|
31
|
+
},
|
|
32
|
+
notify,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function shallowEqual<T>(a: T, b: T): boolean {
|
|
37
|
+
if (Object.is(a, b)) return true;
|
|
38
|
+
if (
|
|
39
|
+
typeof a !== "object" ||
|
|
40
|
+
typeof b !== "object" ||
|
|
41
|
+
a === null ||
|
|
42
|
+
b === null
|
|
43
|
+
) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const keysA = Object.keys(a) as (keyof T)[];
|
|
47
|
+
if (keysA.length !== Object.keys(b).length) return false;
|
|
48
|
+
for (const key of keysA) {
|
|
49
|
+
if (!Object.is(a[key], b[key])) return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import type { MouseEvent, ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export type RowId = string;
|
|
4
|
+
|
|
5
|
+
export type ColumnType = "string" | "number" | "date" | "boolean";
|
|
6
|
+
|
|
7
|
+
export type Density = "compact" | "standard" | "comfortable";
|
|
8
|
+
|
|
9
|
+
export type PinSide = "left" | "right";
|
|
10
|
+
|
|
11
|
+
export interface SortItem {
|
|
12
|
+
columnId: string;
|
|
13
|
+
desc: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type FilterOperator =
|
|
17
|
+
| "contains"
|
|
18
|
+
| "notContains"
|
|
19
|
+
| "equals"
|
|
20
|
+
| "notEquals"
|
|
21
|
+
| "startsWith"
|
|
22
|
+
| "endsWith"
|
|
23
|
+
| "gt"
|
|
24
|
+
| "gte"
|
|
25
|
+
| "lt"
|
|
26
|
+
| "lte"
|
|
27
|
+
| "between"
|
|
28
|
+
| "before"
|
|
29
|
+
| "after"
|
|
30
|
+
| "in"
|
|
31
|
+
| "isEmpty"
|
|
32
|
+
| "isNotEmpty";
|
|
33
|
+
|
|
34
|
+
export type FilterValue =
|
|
35
|
+
| string
|
|
36
|
+
| number
|
|
37
|
+
| boolean
|
|
38
|
+
| ReadonlyArray<string | number>
|
|
39
|
+
| null;
|
|
40
|
+
|
|
41
|
+
export interface ColumnFilter {
|
|
42
|
+
columnId: string;
|
|
43
|
+
operator: FilterOperator;
|
|
44
|
+
value?: FilterValue;
|
|
45
|
+
/** Upper bound for the `between` operator. */
|
|
46
|
+
value2?: FilterValue;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface PaginationState {
|
|
50
|
+
pageIndex: number;
|
|
51
|
+
pageSize: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ColumnPinningState {
|
|
55
|
+
left: string[];
|
|
56
|
+
right: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Every piece of grid state that can be controlled from the outside. */
|
|
60
|
+
export interface GridState {
|
|
61
|
+
sorting: SortItem[];
|
|
62
|
+
filters: ColumnFilter[];
|
|
63
|
+
globalFilter: string;
|
|
64
|
+
pagination: PaginationState;
|
|
65
|
+
rowSelection: Record<RowId, boolean>;
|
|
66
|
+
columnOrder: string[];
|
|
67
|
+
columnVisibility: Record<string, boolean>;
|
|
68
|
+
columnSizing: Record<string, number>;
|
|
69
|
+
columnPinning: ColumnPinningState;
|
|
70
|
+
density: Density;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The subset of state a server needs to produce a page of rows. */
|
|
74
|
+
export interface GridQuery {
|
|
75
|
+
sorting: SortItem[];
|
|
76
|
+
filters: ColumnFilter[];
|
|
77
|
+
globalFilter: string;
|
|
78
|
+
pagination: PaginationState;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface GridRow<T> {
|
|
82
|
+
id: RowId;
|
|
83
|
+
/** Position in the original `data` array. */
|
|
84
|
+
index: number;
|
|
85
|
+
original: T;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface CellContext<T, V = unknown> {
|
|
89
|
+
row: T;
|
|
90
|
+
rowId: RowId;
|
|
91
|
+
/** Index within the rows currently displayed (the page). */
|
|
92
|
+
rowIndex: number;
|
|
93
|
+
value: V;
|
|
94
|
+
column: ResolvedColumn<T>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface EditorProps<T, V = unknown> {
|
|
98
|
+
value: V;
|
|
99
|
+
row: T;
|
|
100
|
+
column: ResolvedColumn<T>;
|
|
101
|
+
error: string | null;
|
|
102
|
+
onChange(value: V): void;
|
|
103
|
+
/** Commits the current draft, or `value` when given. */
|
|
104
|
+
commit(value?: V): void;
|
|
105
|
+
cancel(): void;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type BuiltInEditor = "text" | "number" | "date" | "select" | "checkbox";
|
|
109
|
+
|
|
110
|
+
export interface ColumnOption {
|
|
111
|
+
label: string;
|
|
112
|
+
value: string | number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type ExportCellValue = string | number | boolean | Date | null | undefined;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Column definition. Callbacks use method syntax so a `ColumnDef<T, number>`
|
|
119
|
+
* is assignable to `ColumnDef<T>`.
|
|
120
|
+
*/
|
|
121
|
+
export interface ColumnDef<T, V = unknown> {
|
|
122
|
+
/** Unique id. Defaults to `field`. Required for accessor and display columns. */
|
|
123
|
+
id?: string;
|
|
124
|
+
field?: Extract<keyof T, string>;
|
|
125
|
+
accessor?(row: T): V;
|
|
126
|
+
header?: string;
|
|
127
|
+
type?: ColumnType;
|
|
128
|
+
width?: number;
|
|
129
|
+
minWidth?: number;
|
|
130
|
+
maxWidth?: number;
|
|
131
|
+
align?: "start" | "center" | "end";
|
|
132
|
+
/** Initial pin side. */
|
|
133
|
+
pin?: PinSide;
|
|
134
|
+
/** Initially hidden. */
|
|
135
|
+
hidden?: boolean;
|
|
136
|
+
sortable?: boolean;
|
|
137
|
+
filterable?: boolean;
|
|
138
|
+
resizable?: boolean;
|
|
139
|
+
hideable?: boolean;
|
|
140
|
+
reorderable?: boolean;
|
|
141
|
+
pinnable?: boolean;
|
|
142
|
+
/** Included in the global search. Default true for data columns. */
|
|
143
|
+
searchable?: boolean;
|
|
144
|
+
/** Fixed choices: enables the `in` filter and the select editor. */
|
|
145
|
+
options?: ReadonlyArray<ColumnOption>;
|
|
146
|
+
/** Display text for the value; also used by search, CSV, PDF and copy. */
|
|
147
|
+
format?(value: V, row: T): string;
|
|
148
|
+
/** Custom cell renderer. */
|
|
149
|
+
cell?(ctx: CellContext<T, V>): ReactNode;
|
|
150
|
+
sortFn?(a: V, b: V, rowA: T, rowB: T): number;
|
|
151
|
+
filterFn?(value: V, filter: ColumnFilter, row: T): boolean;
|
|
152
|
+
editable?: boolean | ((row: T) => boolean);
|
|
153
|
+
editor?: BuiltInEditor | ((props: EditorProps<T, V>) => ReactNode);
|
|
154
|
+
/** Return an error message to reject an edit. */
|
|
155
|
+
validate?(value: V, row: T): string | null | undefined;
|
|
156
|
+
exportable?: boolean;
|
|
157
|
+
exportValue?(row: T): ExportCellValue;
|
|
158
|
+
headerClassName?: string;
|
|
159
|
+
cellClassName?: string | ((ctx: CellContext<T, V>) => string | undefined);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface ResolvedColumn<T> {
|
|
163
|
+
id: string;
|
|
164
|
+
def: ColumnDef<T>;
|
|
165
|
+
header: string;
|
|
166
|
+
type: ColumnType;
|
|
167
|
+
/** False for display-only columns (no field or accessor). */
|
|
168
|
+
hasValue: boolean;
|
|
169
|
+
getValue(row: T): unknown;
|
|
170
|
+
width: number;
|
|
171
|
+
minWidth: number;
|
|
172
|
+
maxWidth: number;
|
|
173
|
+
align: "start" | "center" | "end";
|
|
174
|
+
sortable: boolean;
|
|
175
|
+
filterable: boolean;
|
|
176
|
+
resizable: boolean;
|
|
177
|
+
hideable: boolean;
|
|
178
|
+
reorderable: boolean;
|
|
179
|
+
pinnable: boolean;
|
|
180
|
+
searchable: boolean;
|
|
181
|
+
exportable: boolean;
|
|
182
|
+
/** Internal columns (row selection) are never exported or listed in menus. */
|
|
183
|
+
internal: boolean;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface ColumnLayoutItem<T> {
|
|
187
|
+
column: ResolvedColumn<T>;
|
|
188
|
+
width: number;
|
|
189
|
+
pinned: PinSide | false;
|
|
190
|
+
/** Offset from the start of its section (left, center or right). */
|
|
191
|
+
offset: number;
|
|
192
|
+
/** Position in visual order, 0-based; also the CSS variable index. */
|
|
193
|
+
visibleIndex: number;
|
|
194
|
+
/** Last left-pinned or first right-pinned column (draws the pin shadow). */
|
|
195
|
+
pinEdge: boolean;
|
|
196
|
+
/** Stable style object for cells of this column. */
|
|
197
|
+
style: Record<string, string>;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export interface ColumnLayout<T> {
|
|
201
|
+
columns: ColumnLayoutItem<T>[];
|
|
202
|
+
left: ColumnLayoutItem<T>[];
|
|
203
|
+
center: ColumnLayoutItem<T>[];
|
|
204
|
+
right: ColumnLayoutItem<T>[];
|
|
205
|
+
leftWidth: number;
|
|
206
|
+
centerWidth: number;
|
|
207
|
+
rightWidth: number;
|
|
208
|
+
totalWidth: number;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface CellEditEvent<T> {
|
|
212
|
+
row: T;
|
|
213
|
+
rowId: RowId;
|
|
214
|
+
columnId: string;
|
|
215
|
+
value: unknown;
|
|
216
|
+
previousValue: unknown;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export type ExportScope = "filtered" | "all" | "selected" | "page";
|
|
220
|
+
|
|
221
|
+
export interface ExportOptions<T> {
|
|
222
|
+
fileName?: string;
|
|
223
|
+
scope?: ExportScope;
|
|
224
|
+
/** Export these rows instead of a scope, e.g. a full result set fetched from the server. */
|
|
225
|
+
rows?: readonly T[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export type PdfPaperSize = "A3" | "A4" | "A5" | "letter" | "legal";
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* A repeating page band. Each slot takes plain text with `{title}`, `{page}`,
|
|
232
|
+
* `{pages}`, `{date}` and `{time}` substituted as the page is drawn.
|
|
233
|
+
*/
|
|
234
|
+
export interface PdfBand {
|
|
235
|
+
left?: string;
|
|
236
|
+
center?: string;
|
|
237
|
+
right?: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Colors for the generated PDF, as `#rgb` or `#rrggbb`. */
|
|
241
|
+
export interface PdfTheme {
|
|
242
|
+
text: string;
|
|
243
|
+
/** Header and footer bands. */
|
|
244
|
+
muted: string;
|
|
245
|
+
border: string;
|
|
246
|
+
headerBg: string;
|
|
247
|
+
headerText: string;
|
|
248
|
+
/** Every other body row, or null for no striping. */
|
|
249
|
+
stripe: string | null;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface PrintExportOptions<T> extends ExportOptions<T> {
|
|
253
|
+
title?: string;
|
|
254
|
+
orientation?: "portrait" | "landscape";
|
|
255
|
+
paperSize?: PdfPaperSize;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export interface PdfExportOptions<T> extends PrintExportOptions<T> {
|
|
259
|
+
/** Page margin in points. 72 points to the inch; defaults to 36. */
|
|
260
|
+
margin?: number;
|
|
261
|
+
/** Body text size in points; defaults to 9. */
|
|
262
|
+
fontSize?: number;
|
|
263
|
+
/** Top of every page. Defaults to the title on the left; null removes it. */
|
|
264
|
+
header?: PdfBand | null;
|
|
265
|
+
/** Bottom of every page. Defaults to date and page numbers; null removes it. */
|
|
266
|
+
footer?: PdfBand | null;
|
|
267
|
+
theme?: Partial<PdfTheme>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface GridOptions<T> {
|
|
271
|
+
data: readonly T[];
|
|
272
|
+
columns: readonly ColumnDef<T>[];
|
|
273
|
+
/**
|
|
274
|
+
* Stable row id: a property name (recommended) or a function.
|
|
275
|
+
* Defaults to `row.id`, falling back to the array index.
|
|
276
|
+
*/
|
|
277
|
+
getRowId?: Extract<keyof T, string> | ((row: T, index: number) => RowId);
|
|
278
|
+
/** `client`: the grid sorts, filters and paginates. `server`: `data` is the current page. */
|
|
279
|
+
mode?: "client" | "server";
|
|
280
|
+
/** Total rows on the server (server mode). */
|
|
281
|
+
rowCount?: number;
|
|
282
|
+
state?: Partial<GridState>;
|
|
283
|
+
initialState?: Partial<GridState>;
|
|
284
|
+
onStateChange?(next: GridState, prev: GridState): void;
|
|
285
|
+
/** Fires when sorting, filters, search or pagination change. */
|
|
286
|
+
onQueryChange?(query: GridQuery): void;
|
|
287
|
+
enablePagination?: boolean;
|
|
288
|
+
enableSorting?: boolean;
|
|
289
|
+
enableMultiSort?: boolean;
|
|
290
|
+
enableFiltering?: boolean;
|
|
291
|
+
enableColumnResizing?: boolean;
|
|
292
|
+
enableColumnReordering?: boolean;
|
|
293
|
+
enableColumnPinning?: boolean;
|
|
294
|
+
enableColumnHiding?: boolean;
|
|
295
|
+
enableRowSelection?: boolean | ((row: T) => boolean);
|
|
296
|
+
selectionMode?: "single" | "multiple";
|
|
297
|
+
onCellEdit?(event: CellEditEvent<T>): void | Promise<void>;
|
|
298
|
+
/** Not fired for clicks on interactive content (buttons, inputs, links, checkboxes). */
|
|
299
|
+
onRowClick?(row: T, event: MouseEvent<HTMLElement>): void;
|
|
300
|
+
onRowDoubleClick?(row: T, event: MouseEvent<HTMLElement>): void;
|
|
301
|
+
exportFileName?: string;
|
|
302
|
+
}
|