@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,202 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
cloneElement,
|
|
5
|
+
isValidElement,
|
|
6
|
+
useCallback,
|
|
7
|
+
useId,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
type CSSProperties,
|
|
13
|
+
type MouseEvent,
|
|
14
|
+
type ReactElement,
|
|
15
|
+
type ReactNode,
|
|
16
|
+
type Ref,
|
|
17
|
+
} from "react";
|
|
18
|
+
import { AnchoredPopover } from "../../shared/react/Popover";
|
|
19
|
+
import { useControllableState } from "../../shared/react/useControllableState";
|
|
20
|
+
import type {
|
|
21
|
+
PopoverAlign,
|
|
22
|
+
PopoverCloseReason,
|
|
23
|
+
PopoverLocaleText,
|
|
24
|
+
PopoverSide,
|
|
25
|
+
PopoverSlot,
|
|
26
|
+
} from "../core/types";
|
|
27
|
+
import { defaultPopoverText } from "./locale";
|
|
28
|
+
import { cx } from "./props";
|
|
29
|
+
|
|
30
|
+
export interface PopoverHandle {
|
|
31
|
+
open(): void;
|
|
32
|
+
close(): void;
|
|
33
|
+
/** The panel, while it is open. */
|
|
34
|
+
getElement(): HTMLElement | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Given to `children` when it is a function. */
|
|
38
|
+
export interface PopoverRenderProps {
|
|
39
|
+
close(): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PopoverProps {
|
|
43
|
+
/**
|
|
44
|
+
* The element that opens it. It is cloned with a ref and the ARIA attributes
|
|
45
|
+
* that tie it to the panel, so pass a single element that forwards both — any
|
|
46
|
+
* button in this library does.
|
|
47
|
+
*/
|
|
48
|
+
trigger: ReactElement<{ ref?: Ref<HTMLElement>; [attribute: string]: unknown }>;
|
|
49
|
+
children?: ReactNode | ((props: PopoverRenderProps) => ReactNode);
|
|
50
|
+
open?: boolean;
|
|
51
|
+
defaultOpen?: boolean;
|
|
52
|
+
onOpenChange?(open: boolean, reason?: PopoverCloseReason): void;
|
|
53
|
+
/** Heading inside the panel, which also names it. */
|
|
54
|
+
title?: ReactNode;
|
|
55
|
+
description?: ReactNode;
|
|
56
|
+
/** Names the panel when there is no `title`. */
|
|
57
|
+
"aria-label"?: string;
|
|
58
|
+
/** Side of the trigger to open on, before flipping for space. Default `bottom`. */
|
|
59
|
+
side?: PopoverSide;
|
|
60
|
+
/** Default `start`. */
|
|
61
|
+
align?: PopoverAlign;
|
|
62
|
+
/** Distance from the trigger, in pixels. Default 6. */
|
|
63
|
+
gap?: number;
|
|
64
|
+
/** Cap the panel to the space available and let it scroll. Default false. */
|
|
65
|
+
scrollable?: boolean;
|
|
66
|
+
/** Move focus into the panel when it opens. Default true. */
|
|
67
|
+
autoFocus?: boolean;
|
|
68
|
+
id?: string;
|
|
69
|
+
className?: string;
|
|
70
|
+
classNames?: Partial<Record<PopoverSlot, string>>;
|
|
71
|
+
style?: CSSProperties;
|
|
72
|
+
localeText?: Partial<PopoverLocaleText>;
|
|
73
|
+
ref?: Ref<PopoverHandle>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A panel anchored to the element that opens it, in the top layer, so it is
|
|
78
|
+
* never clipped by a scrolling parent. The browser provides light dismiss and
|
|
79
|
+
* Escape; focus moves into the panel and returns to the trigger on close.
|
|
80
|
+
*
|
|
81
|
+
* For a list of commands use the Menu, and for a short label on hover use the
|
|
82
|
+
* Tooltip. This is for everything else: a filter form, a colour picker, a bit
|
|
83
|
+
* of help text too long for a tooltip.
|
|
84
|
+
*/
|
|
85
|
+
export function Popover(props: PopoverProps) {
|
|
86
|
+
const {
|
|
87
|
+
ref,
|
|
88
|
+
trigger,
|
|
89
|
+
children,
|
|
90
|
+
open: openProp,
|
|
91
|
+
defaultOpen = false,
|
|
92
|
+
onOpenChange,
|
|
93
|
+
title,
|
|
94
|
+
description,
|
|
95
|
+
"aria-label": ariaLabel,
|
|
96
|
+
side = "bottom",
|
|
97
|
+
align = "start",
|
|
98
|
+
gap = 6,
|
|
99
|
+
scrollable = false,
|
|
100
|
+
autoFocus = true,
|
|
101
|
+
id: idProp,
|
|
102
|
+
className,
|
|
103
|
+
classNames,
|
|
104
|
+
style,
|
|
105
|
+
localeText,
|
|
106
|
+
} = props;
|
|
107
|
+
|
|
108
|
+
const reactId = useId();
|
|
109
|
+
const id = idProp ?? reactId;
|
|
110
|
+
const text = useMemo(() => ({ ...defaultPopoverText, ...localeText }), [localeText]);
|
|
111
|
+
|
|
112
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
113
|
+
const [open, setOpenState] = useControllableState(openProp, defaultOpen);
|
|
114
|
+
|
|
115
|
+
const setOpen = useCallback(
|
|
116
|
+
(next: boolean, reason?: PopoverCloseReason) => {
|
|
117
|
+
setOpenState(next);
|
|
118
|
+
onOpenChange?.(next, reason);
|
|
119
|
+
},
|
|
120
|
+
[setOpenState, onOpenChange],
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
useImperativeHandle(
|
|
124
|
+
ref,
|
|
125
|
+
() => ({
|
|
126
|
+
open: () => setOpen(true),
|
|
127
|
+
close: () => setOpen(false, "api"),
|
|
128
|
+
getElement: () => panelRef.current,
|
|
129
|
+
}),
|
|
130
|
+
[setOpen],
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// The anchor is state, not a ref: the panel only renders once we have an
|
|
134
|
+
// element to position it against.
|
|
135
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
136
|
+
|
|
137
|
+
const renderProps: PopoverRenderProps = { close: () => setOpen(false, "api") };
|
|
138
|
+
const content = typeof children === "function" ? children(renderProps) : children;
|
|
139
|
+
|
|
140
|
+
if (!isValidElement(trigger)) {
|
|
141
|
+
throw new Error("Popover: `trigger` must be a single React element.");
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const triggerProps = {
|
|
145
|
+
"aria-haspopup": "dialog" as const,
|
|
146
|
+
"aria-expanded": open,
|
|
147
|
+
"aria-controls": open ? `${id}-panel` : undefined,
|
|
148
|
+
onClick: (event: MouseEvent<HTMLElement>) => {
|
|
149
|
+
(trigger.props as { onClick?: (event: MouseEvent<HTMLElement>) => void }).onClick?.(event);
|
|
150
|
+
if (event.defaultPrevented) return;
|
|
151
|
+
if (open) {
|
|
152
|
+
setOpen(false, "trigger");
|
|
153
|
+
} else {
|
|
154
|
+
setAnchor(event.currentTarget);
|
|
155
|
+
setOpen(true);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<>
|
|
162
|
+
{cloneElement(trigger, triggerProps)}
|
|
163
|
+
{open && anchor && (
|
|
164
|
+
<AnchoredPopover
|
|
165
|
+
anchor={anchor}
|
|
166
|
+
onClose={() => setOpen(false, "outside")}
|
|
167
|
+
id={`${id}-panel`}
|
|
168
|
+
label={title ? undefined : (ariaLabel ?? text.label)}
|
|
169
|
+
labelledBy={title ? `${id}-title` : undefined}
|
|
170
|
+
describedBy={description ? `${id}-description` : undefined}
|
|
171
|
+
side={side}
|
|
172
|
+
align={align}
|
|
173
|
+
gap={gap}
|
|
174
|
+
fitHeight={scrollable}
|
|
175
|
+
autoFocus={autoFocus}
|
|
176
|
+
observeResize="self"
|
|
177
|
+
returnFocus
|
|
178
|
+
className={cx("pv-root", classNames?.root, className)}
|
|
179
|
+
>
|
|
180
|
+
{/* The popover element itself is the dialog; this only draws it. */}
|
|
181
|
+
<div ref={panelRef} className={cx("pv-panel", classNames?.panel)} style={style}>
|
|
182
|
+
{(title || description) && (
|
|
183
|
+
<div className={cx("pv-header", classNames?.header)}>
|
|
184
|
+
{title && (
|
|
185
|
+
<p id={`${id}-title`} className={cx("pv-title", classNames?.title)}>
|
|
186
|
+
{title}
|
|
187
|
+
</p>
|
|
188
|
+
)}
|
|
189
|
+
{description && (
|
|
190
|
+
<p id={`${id}-description`} className={cx("pv-description", classNames?.description)}>
|
|
191
|
+
{description}
|
|
192
|
+
</p>
|
|
193
|
+
)}
|
|
194
|
+
</div>
|
|
195
|
+
)}
|
|
196
|
+
<div className={cx("pv-body", classNames?.body)}>{content}</div>
|
|
197
|
+
</div>
|
|
198
|
+
</AnchoredPopover>
|
|
199
|
+
)}
|
|
200
|
+
</>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Popover styles.
|
|
3
|
+
*
|
|
4
|
+
* Tokens read the shared --gbs-* variables when they are set on an ancestor
|
|
5
|
+
* (set them on :root to theme every component at once) and fall back to the
|
|
6
|
+
* same default palette otherwise. Rules are unlayered: they beat a framework
|
|
7
|
+
* reset on specificity, and lose to anything you pass through `className`.
|
|
8
|
+
* With Tailwind v4, import this file after the framework and inside its
|
|
9
|
+
* components layer - see the README.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
.pv-root {
|
|
13
|
+
--pv-bg: var(--gbs-bg, var(--dg-bg, light-dark(#ffffff, #0b0b0e)));
|
|
14
|
+
--pv-fg: var(--gbs-fg, var(--dg-fg, light-dark(#18181b, #f4f4f5)));
|
|
15
|
+
--pv-muted: var(--gbs-muted, var(--dg-muted, light-dark(#71717a, #a1a1aa)));
|
|
16
|
+
--pv-border: var(--gbs-border, var(--dg-border, light-dark(#e4e4e7, #27272a)));
|
|
17
|
+
--pv-focus: var(--gbs-focus, var(--dg-focus, light-dark(#2563eb, #60a5fa)));
|
|
18
|
+
--pv-shadow: var(--gbs-shadow, var(--dg-shadow, 0 10px 30px -8px light-dark(rgb(0 0 0 / 0.18), rgb(0 0 0 / 0.6))));
|
|
19
|
+
--pv-radius: var(--gbs-radius, var(--dg-radius, 8px));
|
|
20
|
+
--pv-font-size: var(--gbs-font-size, var(--dg-font-size, 13px));
|
|
21
|
+
--pv-px: 12px;
|
|
22
|
+
--pv-width: 280px;
|
|
23
|
+
--pv-duration: 140ms;
|
|
24
|
+
|
|
25
|
+
position: fixed;
|
|
26
|
+
inset: auto;
|
|
27
|
+
z-index: 60;
|
|
28
|
+
width: max-content;
|
|
29
|
+
max-width: min(var(--pv-width), calc(100vw - 16px));
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
overflow: auto;
|
|
33
|
+
overscroll-behavior: contain;
|
|
34
|
+
border: 1px solid var(--pv-border);
|
|
35
|
+
border-radius: var(--pv-radius);
|
|
36
|
+
background: var(--pv-bg);
|
|
37
|
+
color: var(--pv-fg);
|
|
38
|
+
box-shadow: var(--pv-shadow);
|
|
39
|
+
color-scheme: inherit;
|
|
40
|
+
font-size: var(--pv-font-size);
|
|
41
|
+
line-height: 1.5;
|
|
42
|
+
scrollbar-width: var(--gbs-scrollbar-width, thin);
|
|
43
|
+
scrollbar-color: var(--gbs-scrollbar-thumb, light-dark(#c4c4ca, #3f3f46))
|
|
44
|
+
var(--gbs-scrollbar-track, transparent);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:where(.dark, [data-theme="dark"]) .pv-root {
|
|
48
|
+
color-scheme: dark;
|
|
49
|
+
}
|
|
50
|
+
:where(.light, [data-theme="light"]) .pv-root {
|
|
51
|
+
color-scheme: light;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:where(.pv-root) *,
|
|
55
|
+
:where(.pv-root) *::before,
|
|
56
|
+
:where(.pv-root) *::after {
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* The panel is focused when it opens, which should not draw a ring unless
|
|
61
|
+
the person is actually navigating by keyboard. */
|
|
62
|
+
.pv-root:focus {
|
|
63
|
+
outline: none;
|
|
64
|
+
}
|
|
65
|
+
.pv-root:focus-visible {
|
|
66
|
+
outline: 2px solid var(--pv-focus);
|
|
67
|
+
outline-offset: 2px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.pv-root:popover-open {
|
|
71
|
+
animation: pv-in var(--pv-duration) ease;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Grows from the edge it is anchored to, so it reads as coming from the
|
|
75
|
+
trigger rather than appearing from nowhere. */
|
|
76
|
+
@keyframes pv-in {
|
|
77
|
+
from {
|
|
78
|
+
opacity: 0;
|
|
79
|
+
translate: 0 -2px;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
.pv-root[data-side="top"]:popover-open {
|
|
83
|
+
animation-name: pv-in-top;
|
|
84
|
+
}
|
|
85
|
+
@keyframes pv-in-top {
|
|
86
|
+
from {
|
|
87
|
+
opacity: 0;
|
|
88
|
+
translate: 0 2px;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
.pv-root[data-side="left"]:popover-open {
|
|
92
|
+
animation-name: pv-in-left;
|
|
93
|
+
}
|
|
94
|
+
@keyframes pv-in-left {
|
|
95
|
+
from {
|
|
96
|
+
opacity: 0;
|
|
97
|
+
translate: 2px 0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
.pv-root[data-side="right"]:popover-open {
|
|
101
|
+
animation-name: pv-in-right;
|
|
102
|
+
}
|
|
103
|
+
@keyframes pv-in-right {
|
|
104
|
+
from {
|
|
105
|
+
opacity: 0;
|
|
106
|
+
translate: -2px 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* -------------------------------------------------------------- content */
|
|
111
|
+
|
|
112
|
+
.pv-panel {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
gap: 8px;
|
|
116
|
+
padding: var(--pv-px);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.pv-header {
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: column;
|
|
122
|
+
gap: 2px;
|
|
123
|
+
}
|
|
124
|
+
.pv-title {
|
|
125
|
+
margin: 0;
|
|
126
|
+
font-size: 1.02em;
|
|
127
|
+
font-weight: 600;
|
|
128
|
+
}
|
|
129
|
+
.pv-description {
|
|
130
|
+
margin: 0;
|
|
131
|
+
color: var(--pv-muted);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.pv-body:empty {
|
|
135
|
+
display: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@media (prefers-reduced-motion: reduce) {
|
|
139
|
+
.pv-root:popover-open {
|
|
140
|
+
animation: none;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@media (forced-colors: active) {
|
|
145
|
+
.pv-root {
|
|
146
|
+
border: 1px solid CanvasText;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Progress and CircularProgress
|
|
2
|
+
|
|
3
|
+
A bar, or a ring, for something with a known end: an upload, an import, a
|
|
4
|
+
quota. For React 19, styled to match the rest of the library. No runtime
|
|
5
|
+
dependencies besides React.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { CircularProgress, Progress } from "@/components/progress";
|
|
9
|
+
import "@/components/progress/styles.css";
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
<Progress label="Uploading report.pdf" value={62} showValue />
|
|
14
|
+
<Progress value={null} label="Preparing export" /> {/* length unknown */}
|
|
15
|
+
<Progress value={92} max={100} variant="warning" label="Storage" size="sm" />
|
|
16
|
+
|
|
17
|
+
<CircularProgress value={62} size={56} showValue />
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Progress:** `value` (`number | null`), `max`, `label`, `showValue`,
|
|
21
|
+
`valueText`, `variant` (`accent` `success` `warning` `danger`), `size` (`sm`
|
|
22
|
+
`md` `lg`), `classNames` (`root` `header` `label` `value` `track` `bar`),
|
|
23
|
+
`localeText`, `ref`, and every `<div>` attribute.
|
|
24
|
+
|
|
25
|
+
**CircularProgress:** the same value props, plus `size` (pixels), `thickness`,
|
|
26
|
+
`showValue` or `children` for the middle.
|
|
27
|
+
|
|
28
|
+
`value={null}` means the length is not known yet, which is a different thing
|
|
29
|
+
from zero: the bar sweeps, and `aria-valuenow` is left off entirely, which is
|
|
30
|
+
what makes a screen reader say "busy" instead of reading out a zero.
|
|
31
|
+
|
|
32
|
+
Use a **Spinner** when there is nothing to measure at all. A progress bar that
|
|
33
|
+
spends its life indeterminate is a spinner drawn as a promise it cannot keep.
|
|
34
|
+
|
|
35
|
+
`describeProgress` and `stepFraction` are exported from the framework-free
|
|
36
|
+
`core`. `describeProgress` is where a `max` of zero stops being a division by
|
|
37
|
+
zero, and where the drawn fraction stays unrounded so a 99.6% bar does not
|
|
38
|
+
reach the end early.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ProgressState } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a progress bar knows about itself.
|
|
5
|
+
*
|
|
6
|
+
* Kept apart from the component because the two interesting cases are easy to
|
|
7
|
+
* get wrong and invisible when you do: a value of `null` is *unknown*, not
|
|
8
|
+
* zero, and a `max` of zero is a task with nothing in it, which must not become
|
|
9
|
+
* a division by zero shown as `NaN%`.
|
|
10
|
+
*/
|
|
11
|
+
export function describeProgress(
|
|
12
|
+
value: number | null | undefined,
|
|
13
|
+
max = 100,
|
|
14
|
+
): ProgressState {
|
|
15
|
+
if (value === null || value === undefined || !Number.isFinite(value)) {
|
|
16
|
+
return { indeterminate: true, value: null, fraction: 0, percent: 0 };
|
|
17
|
+
}
|
|
18
|
+
const top = Number.isFinite(max) && max > 0 ? max : 0;
|
|
19
|
+
const clamped = Math.min(Math.max(value, 0), top || value);
|
|
20
|
+
const fraction = top === 0 ? 0 : clamped / top;
|
|
21
|
+
return {
|
|
22
|
+
indeterminate: false,
|
|
23
|
+
value: clamped,
|
|
24
|
+
fraction,
|
|
25
|
+
// Rounded for display only; the bar itself is drawn from `fraction`, so a
|
|
26
|
+
// 99.6% bar does not snap to full while the last bytes are still moving.
|
|
27
|
+
percent: Math.round(fraction * 100),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A step counter's fraction: "step 2 of 5" is 40%, not 20%.
|
|
33
|
+
*
|
|
34
|
+
* Off-by-one here is the classic wizard bug — the first step showing an empty
|
|
35
|
+
* bar, or the last showing one still short of full.
|
|
36
|
+
*/
|
|
37
|
+
export function stepFraction(step: number, total: number): number {
|
|
38
|
+
if (!Number.isFinite(step) || !Number.isFinite(total) || total <= 0) return 0;
|
|
39
|
+
return Math.min(Math.max(step, 0), total) / total;
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type ProgressVariant = "accent" | "success" | "warning" | "danger";
|
|
2
|
+
|
|
3
|
+
export type ProgressSize = "sm" | "md" | "lg";
|
|
4
|
+
|
|
5
|
+
export interface ProgressState {
|
|
6
|
+
/** The task is running but its length is unknown. */
|
|
7
|
+
indeterminate: boolean;
|
|
8
|
+
/** Clamped into range, or null when indeterminate. */
|
|
9
|
+
value: number | null;
|
|
10
|
+
/** 0 to 1, for drawing. */
|
|
11
|
+
fraction: number;
|
|
12
|
+
/** 0 to 100, rounded, for reading. */
|
|
13
|
+
percent: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ProgressLocaleText {
|
|
17
|
+
/** The accessible name when none is given. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** What a screen reader reads instead of the raw number. */
|
|
20
|
+
valueText(percent: number): string;
|
|
21
|
+
/** Announced while the length is unknown. */
|
|
22
|
+
working: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Progress } from "./react/Progress";
|
|
2
|
+
export type { ProgressProps } from "./react/Progress";
|
|
3
|
+
export { CircularProgress } from "./react/CircularProgress";
|
|
4
|
+
export type { CircularProgressProps } from "./react/CircularProgress";
|
|
5
|
+
export { defaultProgressText } from "./react/locale";
|
|
6
|
+
export type { CircularProgressSlot, ProgressSlot } from "./react/props";
|
|
7
|
+
export * from "./core";
|