@grampro/kit 0.0.0-stage → 2.4.0
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 +139 -0
- package/LICENSE +15 -0
- package/README.md +193 -2
- package/index.cjs +1370 -0
- package/package.json +74 -4
- 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,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Important!!!!
|
|
3
|
+
* Work In Progress Code
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Grampro Business Services and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
12
|
+
import { upload, circleCheck } from "../icon/iconPaths";
|
|
13
|
+
import Icon from "../icon/Icon";
|
|
14
|
+
import AestheticProcessingAnimationWithStyles from "./ProgressAnimation";
|
|
15
|
+
import { getFilesById, sendFiles } from "./uploaderService";
|
|
16
|
+
import type { FileUploadProps } from "./types";
|
|
17
|
+
import UploadedFilePreview from "./UploadedFilePreview";
|
|
18
|
+
|
|
19
|
+
export const FileUploader = ({
|
|
20
|
+
showImagePreview = false,
|
|
21
|
+
multiple = false,
|
|
22
|
+
onChange,
|
|
23
|
+
selectedFiles = [],
|
|
24
|
+
accept,
|
|
25
|
+
fileCount = Infinity,
|
|
26
|
+
disabled = false,
|
|
27
|
+
inputFileSize, // Max file size in MB
|
|
28
|
+
startUpload = false,
|
|
29
|
+
apiURL = "",
|
|
30
|
+
chunk_size = 1024 * 1024,
|
|
31
|
+
uploadedFileIdArray = () => {},
|
|
32
|
+
documentId = [],
|
|
33
|
+
isRemovable = true,
|
|
34
|
+
removedIds,
|
|
35
|
+
}: FileUploadProps) => {
|
|
36
|
+
const [files, setFiles] = useState<any[]>([]);
|
|
37
|
+
const [previewUrls, setPreviewUrls] = useState<{ [key: string]: string }>({});
|
|
38
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
39
|
+
const [fileCountError, setFileCountError] = useState(false);
|
|
40
|
+
const [fileSizeErrors, setFileSizeErrors] = useState<string[]>([]); // Array for file size errors
|
|
41
|
+
const [isUploading, setIsUploading] = useState(false);
|
|
42
|
+
const [fileUploadStatus, setFileUploadStatus] = useState<string | undefined>(
|
|
43
|
+
undefined
|
|
44
|
+
);
|
|
45
|
+
const [progress, setProgress] = useState(0);
|
|
46
|
+
const [fileData, setFileData] = useState<any[]>([]);
|
|
47
|
+
const fileInputRef = useRef<any>(null);
|
|
48
|
+
const dropZoneRef = useRef<any>(null);
|
|
49
|
+
|
|
50
|
+
// Upload Handler
|
|
51
|
+
const handleUpload = async () => {
|
|
52
|
+
if (files.length > 0) {
|
|
53
|
+
setFileUploadStatus(undefined);
|
|
54
|
+
await sendFiles(
|
|
55
|
+
files,
|
|
56
|
+
chunk_size,
|
|
57
|
+
apiURL,
|
|
58
|
+
({ uploading, progress, uploadedFileIds }) => {
|
|
59
|
+
setIsUploading(uploading);
|
|
60
|
+
if (progress !== undefined) setProgress(progress);
|
|
61
|
+
// Returns Uploaded File ID's
|
|
62
|
+
if (uploadedFileIds) uploadedFileIdArray(uploadedFileIds);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
setFileUploadStatus("Upload completed");
|
|
66
|
+
setFiles([]);
|
|
67
|
+
} else {
|
|
68
|
+
setFileUploadStatus("No files selected");
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Getting Files by ID
|
|
73
|
+
const getFiles = async () => {
|
|
74
|
+
const files = await getFilesById(apiURL, documentId);
|
|
75
|
+
setFileData(files);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Fetching by FileId
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (documentId.length) {
|
|
81
|
+
getFiles();
|
|
82
|
+
}
|
|
83
|
+
}, [documentId]);
|
|
84
|
+
|
|
85
|
+
// Starts uploads to server
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (startUpload) {
|
|
88
|
+
handleUpload();
|
|
89
|
+
}
|
|
90
|
+
}, [startUpload]);
|
|
91
|
+
|
|
92
|
+
// For Binding values on edit
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (selectedFiles && selectedFiles.length > 0) {
|
|
95
|
+
setFiles(multiple ? selectedFiles : [selectedFiles[0]]);
|
|
96
|
+
}
|
|
97
|
+
}, [selectedFiles, multiple]);
|
|
98
|
+
|
|
99
|
+
// Adds files to file array
|
|
100
|
+
const handleFileChange = (newFiles: File[]) => {
|
|
101
|
+
// First check for duplicates
|
|
102
|
+
const duplicateFiles: string[] = [];
|
|
103
|
+
const nonDuplicateFiles = newFiles.filter((newFile) => {
|
|
104
|
+
const isDuplicate = files.some(
|
|
105
|
+
(existingFile) => existingFile.name === newFile.name
|
|
106
|
+
);
|
|
107
|
+
if (isDuplicate) {
|
|
108
|
+
duplicateFiles.push(newFile.name);
|
|
109
|
+
}
|
|
110
|
+
return !isDuplicate;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// If there are duplicates, set error messages
|
|
114
|
+
if (duplicateFiles.length > 0) {
|
|
115
|
+
setFileSizeErrors((prev) => [
|
|
116
|
+
...prev,
|
|
117
|
+
...duplicateFiles.map(
|
|
118
|
+
(fileName) => `File "${fileName}" has already been uploaded`
|
|
119
|
+
),
|
|
120
|
+
]);
|
|
121
|
+
|
|
122
|
+
// If all files are duplicates, exit early
|
|
123
|
+
if (nonDuplicateFiles.length === 0) return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let updatedFiles: File[] = multiple
|
|
127
|
+
? [...files, ...nonDuplicateFiles]
|
|
128
|
+
: [nonDuplicateFiles[0]];
|
|
129
|
+
|
|
130
|
+
// Ensure the total number of files doesn't exceed the fileCount limit
|
|
131
|
+
if (updatedFiles.length > fileCount) {
|
|
132
|
+
setFileCountError(true);
|
|
133
|
+
updatedFiles = updatedFiles.slice(0, fileCount); // Limit the number of files to fileCount
|
|
134
|
+
} else {
|
|
135
|
+
setFileCountError(false);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// File size validation
|
|
139
|
+
const validFiles: any = [];
|
|
140
|
+
const newErrors: string[] = [];
|
|
141
|
+
|
|
142
|
+
updatedFiles.forEach((file) => {
|
|
143
|
+
const fileSizeInMB = file.size / 1024 / 1024; // Convert bytes to MB
|
|
144
|
+
if (inputFileSize && fileSizeInMB > inputFileSize) {
|
|
145
|
+
newErrors.push(
|
|
146
|
+
`File ${file.name} exceeds the size limit of ${inputFileSize} MB`
|
|
147
|
+
);
|
|
148
|
+
} else {
|
|
149
|
+
validFiles.push(file);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Update state with valid files and set errors for oversized files
|
|
154
|
+
if (validFiles.length > 0) {
|
|
155
|
+
setFiles(validFiles);
|
|
156
|
+
setPreviewUrls({});
|
|
157
|
+
validFiles.forEach((file: any) => {
|
|
158
|
+
if (showImagePreview && file.type.startsWith("image/")) {
|
|
159
|
+
const reader = new FileReader();
|
|
160
|
+
reader.onload = () => {
|
|
161
|
+
setPreviewUrls((prev) => ({
|
|
162
|
+
...prev,
|
|
163
|
+
[file.name]: reader.result as string,
|
|
164
|
+
}));
|
|
165
|
+
};
|
|
166
|
+
reader.readAsDataURL(file);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
if (onChange) onChange(validFiles);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Set file size errors (now includes both size and duplicate errors)
|
|
173
|
+
setFileSizeErrors(newErrors);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// Removes the file from file array
|
|
177
|
+
const removeFile = (index: number) => {
|
|
178
|
+
const updatedFiles: any = files.filter((_, i) => i !== index);
|
|
179
|
+
setFiles(updatedFiles);
|
|
180
|
+
setPreviewUrls((prevPreviews) => {
|
|
181
|
+
const { [files[index].name]: _, ...rest } = prevPreviews;
|
|
182
|
+
return rest;
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Reset file input to allow re-selecting the same file
|
|
186
|
+
if (fileInputRef.current) {
|
|
187
|
+
fileInputRef.current.value = "";
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (onChange) onChange(updatedFiles);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// Drag and drop handling
|
|
194
|
+
const handleDragEnter = (e: React.DragEvent<HTMLDivElement>) => {
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
e.stopPropagation();
|
|
197
|
+
setIsDragging(true);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const handleDragLeave = (e: React.DragEvent<HTMLDivElement>) => {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
e.stopPropagation();
|
|
203
|
+
setIsDragging(false);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const handleDragOver = (e: React.DragEvent<HTMLDivElement>) => {
|
|
207
|
+
e.preventDefault();
|
|
208
|
+
e.stopPropagation();
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const handleDrop = (e: React.DragEvent<HTMLDivElement>) => {
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
e.stopPropagation();
|
|
214
|
+
setIsDragging(false);
|
|
215
|
+
|
|
216
|
+
const droppedFiles = Array.from(e.dataTransfer.files);
|
|
217
|
+
handleFileChange(multiple ? droppedFiles : [droppedFiles[0]]);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<div className="w-full max-w-md mx-auto">
|
|
222
|
+
<div
|
|
223
|
+
ref={dropZoneRef}
|
|
224
|
+
className={`flex flex-col items-center border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${
|
|
225
|
+
isDragging
|
|
226
|
+
? "border-black bg-zinc-50 dark:border-white dark:bg-zinc-900"
|
|
227
|
+
: "border-gray-300 hover:border-gray-400"
|
|
228
|
+
}`}
|
|
229
|
+
onClick={() => fileInputRef.current.click()}
|
|
230
|
+
onDragEnter={handleDragEnter}
|
|
231
|
+
onDragOver={handleDragOver}
|
|
232
|
+
onDragLeave={handleDragLeave}
|
|
233
|
+
onDrop={handleDrop}
|
|
234
|
+
>
|
|
235
|
+
<Icon
|
|
236
|
+
dimensions={{ width: "36", height: "36" }}
|
|
237
|
+
elements={upload}
|
|
238
|
+
svgClass={"stroke-gray-400 fill-none dark:stroke-white"}
|
|
239
|
+
/>
|
|
240
|
+
<p className="mt-2 text-sm text-gray-500">
|
|
241
|
+
Click to upload or drag and drop
|
|
242
|
+
</p>
|
|
243
|
+
<p className="text-xs text-gray-400">
|
|
244
|
+
{multiple
|
|
245
|
+
? "Supports multiple file uploads"
|
|
246
|
+
: "Single file upload only"}
|
|
247
|
+
</p>
|
|
248
|
+
|
|
249
|
+
{/* Shows FileUpload Status Here */}
|
|
250
|
+
{fileUploadStatus && (
|
|
251
|
+
<p className="text-xs mt-2 text-green-500 flex gap-1">
|
|
252
|
+
<Icon
|
|
253
|
+
dimensions={{ width: "16", height: "16" }}
|
|
254
|
+
elements={circleCheck}
|
|
255
|
+
svgClass={"stroke-green-500 fill-none dark:stroke-white"}
|
|
256
|
+
/>
|
|
257
|
+
{fileUploadStatus}
|
|
258
|
+
</p>
|
|
259
|
+
)}
|
|
260
|
+
|
|
261
|
+
{/* Display file size errors */}
|
|
262
|
+
{fileSizeErrors.length > 0 && (
|
|
263
|
+
<div className="mt-2 space-y-1">
|
|
264
|
+
{fileSizeErrors.map((error, index) => (
|
|
265
|
+
<span key={index} className="text-xs text-red-500">
|
|
266
|
+
{error}
|
|
267
|
+
<br />
|
|
268
|
+
</span>
|
|
269
|
+
))}
|
|
270
|
+
</div>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
<input
|
|
274
|
+
type="file"
|
|
275
|
+
ref={fileInputRef}
|
|
276
|
+
className="hidden"
|
|
277
|
+
onChange={(e) => handleFileChange(Array.from(e.target.files || []))}
|
|
278
|
+
multiple={multiple}
|
|
279
|
+
accept={accept}
|
|
280
|
+
disabled={disabled}
|
|
281
|
+
/>
|
|
282
|
+
|
|
283
|
+
{/* Display file count error */}
|
|
284
|
+
{fileCountError && (
|
|
285
|
+
<span className="text-xs text-red-500">
|
|
286
|
+
Maximum file count is set to {fileCount}
|
|
287
|
+
</span>
|
|
288
|
+
)}
|
|
289
|
+
|
|
290
|
+
{/* Loading Animation */}
|
|
291
|
+
{isUploading && (
|
|
292
|
+
<AestheticProcessingAnimationWithStyles progressPercentage={progress} />
|
|
293
|
+
)}
|
|
294
|
+
|
|
295
|
+
<UploadedFilePreview
|
|
296
|
+
UploadedFileData={fileData}
|
|
297
|
+
apiURL={apiURL}
|
|
298
|
+
files={files}
|
|
299
|
+
showImagePreview={showImagePreview}
|
|
300
|
+
previewUrls={previewUrls}
|
|
301
|
+
onFileRemove={(index: any) => {
|
|
302
|
+
removeFile(index);
|
|
303
|
+
}}
|
|
304
|
+
isRemovable={isRemovable}
|
|
305
|
+
removedId={(fileId: any) => {
|
|
306
|
+
if (removedIds) removedIds(fileId);
|
|
307
|
+
}}
|
|
308
|
+
/>
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type FileUploadProps = {
|
|
2
|
+
showImagePreview?: boolean;
|
|
3
|
+
multiple?: boolean;
|
|
4
|
+
onChange?: (files: FileList | null) => void;
|
|
5
|
+
selectedFiles?: File[];
|
|
6
|
+
accept?: string;
|
|
7
|
+
fileCount?: number;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
inputFileSize?: number;
|
|
10
|
+
startUpload?: boolean;
|
|
11
|
+
apiURL?: string;
|
|
12
|
+
chunk_size?: number;
|
|
13
|
+
uploadedFileIdArray?: (ids: string[]) => void;
|
|
14
|
+
fileData?: File[];
|
|
15
|
+
documentId?: string[];
|
|
16
|
+
isRemovable?: boolean;
|
|
17
|
+
removedIds?: (fileId: string | null) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type UploadedFilePreview = {
|
|
21
|
+
files?: any[];
|
|
22
|
+
UploadedFileData: any[];
|
|
23
|
+
apiURL: string;
|
|
24
|
+
previewType?: boolean;
|
|
25
|
+
showImagePreview: boolean;
|
|
26
|
+
previewUrls: { [key: string]: string };
|
|
27
|
+
onFileRemove: any;
|
|
28
|
+
isRemovable: boolean;
|
|
29
|
+
removedId?: any;
|
|
30
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Grampro Business Services and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
fileimage,
|
|
10
|
+
filespreadsheet,
|
|
11
|
+
filetext,
|
|
12
|
+
film,
|
|
13
|
+
music,
|
|
14
|
+
} from "../icon/iconPaths";
|
|
15
|
+
import Icon from "../icon/Icon";
|
|
16
|
+
|
|
17
|
+
// returns an icon based on the selected file type
|
|
18
|
+
export const GetFileIcon = ({ file, showImagePreview, previewUrls }: any) => {
|
|
19
|
+
if (file.type.startsWith("image/"))
|
|
20
|
+
return showImagePreview ? (
|
|
21
|
+
<img
|
|
22
|
+
src={previewUrls[file.name]}
|
|
23
|
+
alt={file.name}
|
|
24
|
+
className="mt-2 w-8 h-8 object-cover rounded-lg"
|
|
25
|
+
/>
|
|
26
|
+
) : (
|
|
27
|
+
<Icon
|
|
28
|
+
dimensions={{ width: "26", height: "26" }}
|
|
29
|
+
elements={fileimage}
|
|
30
|
+
svgClass={"stroke-zinc-500 fill-none dark:stroke-white"}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
if (file.type === "application/pdf" || file.type.includes("pdf"))
|
|
34
|
+
return (
|
|
35
|
+
<Icon
|
|
36
|
+
dimensions={{ width: "26", height: "26" }}
|
|
37
|
+
elements={filetext}
|
|
38
|
+
svgClass={"stroke-red-500 fill-none dark:stroke-white"}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
if (file.type.includes("spreadsheet") || file.type.includes("excel"))
|
|
42
|
+
return (
|
|
43
|
+
<Icon
|
|
44
|
+
dimensions={{ width: "26", height: "26" }}
|
|
45
|
+
elements={filespreadsheet}
|
|
46
|
+
svgClass={"stroke-green-500 fill-none dark:stroke-white"}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
if (file.type.startsWith("video/"))
|
|
50
|
+
return (
|
|
51
|
+
<Icon
|
|
52
|
+
dimensions={{ width: "26", height: "26" }}
|
|
53
|
+
elements={film}
|
|
54
|
+
svgClass={"stroke-purple-500 fill-none dark:stroke-white"}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
if (file.type.startsWith("audio/"))
|
|
58
|
+
return (
|
|
59
|
+
<Icon
|
|
60
|
+
dimensions={{ width: "26", height: "26" }}
|
|
61
|
+
elements={music}
|
|
62
|
+
svgClass={"stroke-yellow-500 fill-none dark:stroke-white"}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
return (
|
|
66
|
+
<Icon
|
|
67
|
+
dimensions={{ width: "16", height: "16" }}
|
|
68
|
+
elements={filetext}
|
|
69
|
+
svgClass={"stroke-red-500 fill-none dark:stroke-white"}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
function processFiles(files: File[], chunkSize: number) {
|
|
2
|
+
const finalFiles: { file: Blob; originalFile: File }[] = [];
|
|
3
|
+
|
|
4
|
+
files.forEach((file) => {
|
|
5
|
+
if (file.size > chunkSize) {
|
|
6
|
+
let offset = 0;
|
|
7
|
+
while (offset < file.size) {
|
|
8
|
+
const chunk = file.slice(offset, offset + chunkSize);
|
|
9
|
+
finalFiles.push({ file: chunk, originalFile: file });
|
|
10
|
+
offset += chunkSize;
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
finalFiles.push({ file, originalFile: file });
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return finalFiles;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function sendFiles(
|
|
21
|
+
files: File[],
|
|
22
|
+
chunkSize: number,
|
|
23
|
+
apiUrl = "http://localhost:8080/upload",
|
|
24
|
+
isUploading = (status: {
|
|
25
|
+
uploading: boolean;
|
|
26
|
+
progress?: number;
|
|
27
|
+
file?: string;
|
|
28
|
+
uploadedFileIds?: string[];
|
|
29
|
+
}) => {}
|
|
30
|
+
) {
|
|
31
|
+
const processedFiles = processFiles(files, chunkSize);
|
|
32
|
+
|
|
33
|
+
// Track how many chunks belong to the current file being processed
|
|
34
|
+
const fileChunkCounts: { [key: string]: number } = {};
|
|
35
|
+
files.forEach((file) => {
|
|
36
|
+
fileChunkCounts[file.name] = Math.ceil(file.size / chunkSize);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// To track chunk index per file
|
|
40
|
+
const chunkIndexTracker: { [key: string]: number } = {};
|
|
41
|
+
|
|
42
|
+
let totalChunks = processedFiles.length;
|
|
43
|
+
let uploadedChunks = 0;
|
|
44
|
+
const uploadedFileIds: string[] = [];
|
|
45
|
+
|
|
46
|
+
for (let i = 0; i < processedFiles.length; i++) {
|
|
47
|
+
const { file, originalFile } = processedFiles[i];
|
|
48
|
+
const formData = new FormData();
|
|
49
|
+
formData.append("file", file, originalFile.name);
|
|
50
|
+
formData.append("originalname", originalFile.name);
|
|
51
|
+
formData.append("originalFileSize", originalFile.size.toString());
|
|
52
|
+
|
|
53
|
+
const chunkCount = fileChunkCounts[originalFile.name];
|
|
54
|
+
const isChunked = chunkCount > 1;
|
|
55
|
+
|
|
56
|
+
// Initialize or reset chunkIndex per file
|
|
57
|
+
if (!chunkIndexTracker[originalFile.name]) {
|
|
58
|
+
chunkIndexTracker[originalFile.name] = 0; // Start at 0 for each file
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const chunkIndex = isChunked
|
|
62
|
+
? chunkIndexTracker[originalFile.name].toString()
|
|
63
|
+
: "";
|
|
64
|
+
formData.append("chunkIndex", chunkIndex);
|
|
65
|
+
formData.append("totalChunks", isChunked ? chunkCount.toString() : "");
|
|
66
|
+
|
|
67
|
+
// Increment chunkIndex for the current file
|
|
68
|
+
if (isChunked) {
|
|
69
|
+
chunkIndexTracker[originalFile.name]++;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
isUploading({
|
|
74
|
+
uploading: true,
|
|
75
|
+
progress: (uploadedChunks / totalChunks) * 100,
|
|
76
|
+
file: originalFile.name,
|
|
77
|
+
});
|
|
78
|
+
const response = await fetch(apiUrl, {
|
|
79
|
+
method: "POST",
|
|
80
|
+
body: formData,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (!response.ok) {
|
|
84
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const data = await response.json();
|
|
88
|
+
if (data.documentId) uploadedFileIds.push(data.documentId);
|
|
89
|
+
|
|
90
|
+
uploadedChunks++;
|
|
91
|
+
isUploading({
|
|
92
|
+
uploading: true,
|
|
93
|
+
progress: (uploadedChunks / totalChunks) * 100,
|
|
94
|
+
file: originalFile.name,
|
|
95
|
+
});
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error("Error uploading file chunk:", error);
|
|
98
|
+
isUploading({
|
|
99
|
+
uploading: false,
|
|
100
|
+
progress: (uploadedChunks / totalChunks) * 100,
|
|
101
|
+
file: originalFile.name,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Indicate that the upload is complete
|
|
107
|
+
isUploading({
|
|
108
|
+
uploading: false,
|
|
109
|
+
progress: 100,
|
|
110
|
+
uploadedFileIds: uploadedFileIds,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// returns all files
|
|
115
|
+
export async function getAllFiles(apiUrl: string) {
|
|
116
|
+
let files: any[] = [];
|
|
117
|
+
return files;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// returns files by ID
|
|
121
|
+
export async function getFilesById(
|
|
122
|
+
apiUrl: string,
|
|
123
|
+
documentIds: string[]
|
|
124
|
+
): Promise<any[]> {
|
|
125
|
+
return Promise.all(
|
|
126
|
+
documentIds.map(async (id) => {
|
|
127
|
+
const response = await fetch(`${apiUrl}?id=${id}`);
|
|
128
|
+
if (!response.ok) {
|
|
129
|
+
throw new Error(`Failed to fetch document with ID: ${id}`);
|
|
130
|
+
}
|
|
131
|
+
return response.json();
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
}
|