torch-glare 2.5.6 → 2.6.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/README.md +4 -3
- package/dist/bin/index.js +9 -24
- package/dist/bin/index.js.map +1 -1
- package/dist/src/commands/add.d.ts +2 -2
- package/dist/src/commands/add.d.ts.map +1 -1
- package/dist/src/commands/add.js +4 -70
- package/dist/src/commands/add.js.map +1 -1
- package/dist/src/commands/hook.d.ts +5 -4
- package/dist/src/commands/hook.d.ts.map +1 -1
- package/dist/src/commands/hook.js +7 -75
- package/dist/src/commands/hook.js.map +1 -1
- package/dist/src/commands/init.js +1 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/layout.d.ts +5 -4
- package/dist/src/commands/layout.d.ts.map +1 -1
- package/dist/src/commands/layout.js +7 -75
- package/dist/src/commands/layout.js.map +1 -1
- package/dist/src/commands/provider.d.ts +5 -4
- package/dist/src/commands/provider.d.ts.map +1 -1
- package/dist/src/commands/provider.js +7 -75
- package/dist/src/commands/provider.js.map +1 -1
- package/dist/src/commands/update.d.ts.map +1 -1
- package/dist/src/commands/update.js +78 -43
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/utils.d.ts +5 -4
- package/dist/src/commands/utils.d.ts.map +1 -1
- package/dist/src/commands/utils.js +7 -80
- package/dist/src/commands/utils.js.map +1 -1
- package/dist/src/shared/addFromRegistry.d.ts +16 -0
- package/dist/src/shared/addFromRegistry.d.ts.map +1 -0
- package/dist/src/shared/addFromRegistry.js +88 -0
- package/dist/src/shared/addFromRegistry.js.map +1 -0
- package/dist/src/shared/getInstallCommand.d.ts.map +1 -1
- package/dist/src/shared/getInstallCommand.js +5 -0
- package/dist/src/shared/getInstallCommand.js.map +1 -1
- package/dist/src/shared/installDependencies.d.ts +0 -10
- package/dist/src/shared/installDependencies.d.ts.map +1 -1
- package/dist/src/shared/installDependencies.js +0 -17
- package/dist/src/shared/installDependencies.js.map +1 -1
- package/dist/src/shared/installFromPlan.d.ts +7 -5
- package/dist/src/shared/installFromPlan.d.ts.map +1 -1
- package/dist/src/shared/installFromPlan.js +103 -36
- package/dist/src/shared/installFromPlan.js.map +1 -1
- package/dist/src/shared/loadRegistry.d.ts +12 -3
- package/dist/src/shared/loadRegistry.d.ts.map +1 -1
- package/dist/src/shared/loadRegistry.js +19 -20
- package/dist/src/shared/loadRegistry.js.map +1 -1
- package/dist/src/shared/registryClient.d.ts +19 -0
- package/dist/src/shared/registryClient.d.ts.map +1 -0
- package/dist/src/shared/registryClient.js +128 -0
- package/dist/src/shared/registryClient.js.map +1 -0
- package/dist/src/shared/resolveEntry.d.ts +10 -7
- package/dist/src/shared/resolveEntry.d.ts.map +1 -1
- package/dist/src/shared/resolveEntry.js +18 -13
- package/dist/src/shared/resolveEntry.js.map +1 -1
- package/dist/src/shared/suggestOtherCommand.d.ts +7 -1
- package/dist/src/shared/suggestOtherCommand.d.ts.map +1 -1
- package/dist/src/shared/suggestOtherCommand.js +29 -23
- package/dist/src/shared/suggestOtherCommand.js.map +1 -1
- package/dist/src/types/main.d.ts +31 -2
- package/dist/src/types/main.d.ts.map +1 -1
- package/package.json +6 -11
- package/apps/lib/components/ActionButton.tsx +0 -93
- package/apps/lib/components/ActionsGroup.tsx +0 -27
- package/apps/lib/components/AlertDialog.tsx +0 -204
- package/apps/lib/components/Avatar.tsx +0 -46
- package/apps/lib/components/Badge.tsx +0 -250
- package/apps/lib/components/BadgeField.tsx +0 -403
- package/apps/lib/components/Breadcrumb.tsx +0 -280
- package/apps/lib/components/Button.tsx +0 -325
- package/apps/lib/components/ButtonGroup.tsx +0 -190
- package/apps/lib/components/Calendar.tsx +0 -115
- package/apps/lib/components/Card.tsx +0 -95
- package/apps/lib/components/Checkbox.tsx +0 -42
- package/apps/lib/components/ColorPicker.tsx +0 -441
- package/apps/lib/components/ConclusionHeader.tsx +0 -148
- package/apps/lib/components/ContextMenu.tsx +0 -571
- package/apps/lib/components/CountBadge.tsx +0 -52
- package/apps/lib/components/DataTable.tsx +0 -213
- package/apps/lib/components/DataViews/badge.ts +0 -49
- package/apps/lib/components/DataViews/cell.tsx +0 -324
- package/apps/lib/components/DataViews/context.ts +0 -144
- package/apps/lib/components/DataViews/data-views.tsx +0 -395
- package/apps/lib/components/DataViews/filters/children.tsx +0 -98
- package/apps/lib/components/DataViews/filters/custom.tsx +0 -34
- package/apps/lib/components/DataViews/filters/filters.tsx +0 -157
- package/apps/lib/components/DataViews/filters/index.ts +0 -4
- package/apps/lib/components/DataViews/filters/labelled.tsx +0 -20
- package/apps/lib/components/DataViews/filters/presets.tsx +0 -65
- package/apps/lib/components/DataViews/filters/sync.tsx +0 -35
- package/apps/lib/components/DataViews/filters/values.ts +0 -173
- package/apps/lib/components/DataViews/header.tsx +0 -220
- package/apps/lib/components/DataViews/hooks/index.ts +0 -5
- package/apps/lib/components/DataViews/hooks/useActiveRow.ts +0 -22
- package/apps/lib/components/DataViews/hooks/useControllable.ts +0 -52
- package/apps/lib/components/DataViews/index.ts +0 -88
- package/apps/lib/components/DataViews/panel/columns.tsx +0 -153
- package/apps/lib/components/DataViews/panel/controls.tsx +0 -106
- package/apps/lib/components/DataViews/panel/index.ts +0 -3
- package/apps/lib/components/DataViews/panel/panel.tsx +0 -164
- package/apps/lib/components/DataViews/panel/saved-views.tsx +0 -67
- package/apps/lib/components/DataViews/panel/section.tsx +0 -81
- package/apps/lib/components/DataViews/panel/sort.tsx +0 -42
- package/apps/lib/components/DataViews/panel/tab.tsx +0 -31
- package/apps/lib/components/DataViews/slots.ts +0 -72
- package/apps/lib/components/DataViews/states.tsx +0 -73
- package/apps/lib/components/DataViews/types.ts +0 -510
- package/apps/lib/components/DataViews/views/board-view.tsx +0 -381
- package/apps/lib/components/DataViews/views/card-rows.tsx +0 -36
- package/apps/lib/components/DataViews/views/inbox-view.tsx +0 -260
- package/apps/lib/components/DataViews/views/pane-views.tsx +0 -196
- package/apps/lib/components/DataViews/views/table-view.tsx +0 -493
- package/apps/lib/components/DataViews/views/tree-view.tsx +0 -367
- package/apps/lib/components/DatePicker.tsx +0 -232
- package/apps/lib/components/Dialog.tsx +0 -116
- package/apps/lib/components/Divider.tsx +0 -28
- package/apps/lib/components/Drawer.tsx +0 -451
- package/apps/lib/components/DropdownMenu.tsx +0 -554
- package/apps/lib/components/FieldHint.tsx +0 -69
- package/apps/lib/components/Form.tsx +0 -182
- package/apps/lib/components/FormBuilder/context.ts +0 -85
- package/apps/lib/components/FormBuilder/field-kind.ts +0 -28
- package/apps/lib/components/FormBuilder/fields/ChoiceFields.tsx +0 -60
- package/apps/lib/components/FormBuilder/fields/ColorField.tsx +0 -59
- package/apps/lib/components/FormBuilder/fields/CustomField.tsx +0 -11
- package/apps/lib/components/FormBuilder/fields/DateField.tsx +0 -32
- package/apps/lib/components/FormBuilder/fields/FieldArray.tsx +0 -74
- package/apps/lib/components/FormBuilder/fields/FieldShell.tsx +0 -168
- package/apps/lib/components/FormBuilder/fields/FileField.tsx +0 -39
- package/apps/lib/components/FormBuilder/fields/OptionListFields.tsx +0 -132
- package/apps/lib/components/FormBuilder/fields/OtpField.tsx +0 -31
- package/apps/lib/components/FormBuilder/fields/PhoneField.tsx +0 -109
- package/apps/lib/components/FormBuilder/fields/RichTextEditorField.tsx +0 -31
- package/apps/lib/components/FormBuilder/fields/SelectField.tsx +0 -114
- package/apps/lib/components/FormBuilder/fields/SignatureField.tsx +0 -157
- package/apps/lib/components/FormBuilder/fields/SliderField.tsx +0 -67
- package/apps/lib/components/FormBuilder/fields/SwitchBoxField.tsx +0 -41
- package/apps/lib/components/FormBuilder/fields/TableField.tsx +0 -336
- package/apps/lib/components/FormBuilder/fields/TextField.tsx +0 -213
- package/apps/lib/components/FormBuilder/fields/TreeSelectField.tsx +0 -43
- package/apps/lib/components/FormBuilder/fields/countries.ts +0 -303
- package/apps/lib/components/FormBuilder/fields/index.ts +0 -25
- package/apps/lib/components/FormBuilder/form-builder.tsx +0 -198
- package/apps/lib/components/FormBuilder/index.ts +0 -31
- package/apps/lib/components/FormBuilder/numberFormat.ts +0 -16
- package/apps/lib/components/FormBuilder/submit.tsx +0 -67
- package/apps/lib/components/FormBuilder/types.ts +0 -316
- package/apps/lib/components/FormRenderer/FormDrawer.tsx +0 -250
- package/apps/lib/components/FormRenderer/detail.tsx +0 -256
- package/apps/lib/components/FormRenderer/form-renderer.tsx +0 -358
- package/apps/lib/components/FormRenderer/header.tsx +0 -88
- package/apps/lib/components/FormRenderer/index.ts +0 -17
- package/apps/lib/components/FormRenderer/notch-action.tsx +0 -64
- package/apps/lib/components/FormRenderer/section.tsx +0 -39
- package/apps/lib/components/FormRenderer/stepper.tsx +0 -393
- package/apps/lib/components/FormRenderer/types.ts +0 -115
- package/apps/lib/components/FormSummary.tsx +0 -282
- package/apps/lib/components/HeaderBar.tsx +0 -117
- package/apps/lib/components/ImageAttachment.tsx +0 -209
- package/apps/lib/components/InnerLabelField.tsx +0 -154
- package/apps/lib/components/Input.tsx +0 -224
- package/apps/lib/components/InputField.tsx +0 -147
- package/apps/lib/components/InputOTP.tsx +0 -84
- package/apps/lib/components/Label.tsx +0 -129
- package/apps/lib/components/LabelField.tsx +0 -76
- package/apps/lib/components/LabeledCheckBox.tsx +0 -51
- package/apps/lib/components/LabeledRadio.tsx +0 -51
- package/apps/lib/components/LinkButton.tsx +0 -94
- package/apps/lib/components/LoginButton.tsx +0 -51
- package/apps/lib/components/PasswordLevel.tsx +0 -58
- package/apps/lib/components/Popover.tsx +0 -312
- package/apps/lib/components/ProfileMenu.tsx +0 -85
- package/apps/lib/components/Radio.tsx +0 -59
- package/apps/lib/components/RadioCard.tsx +0 -50
- package/apps/lib/components/ScrollArea.tsx +0 -54
- package/apps/lib/components/SearchField.tsx +0 -62
- package/apps/lib/components/SearchableSelect.tsx +0 -318
- package/apps/lib/components/SearchableTable.tsx +0 -344
- package/apps/lib/components/SearchableTree.tsx +0 -485
- package/apps/lib/components/SearchableTreeDialog.tsx +0 -502
- package/apps/lib/components/SectionBlock.tsx +0 -168
- package/apps/lib/components/Select.tsx +0 -347
- package/apps/lib/components/SimpleSelect.tsx +0 -225
- package/apps/lib/components/Skeleton.tsx +0 -12
- package/apps/lib/components/SlideDatePicker.tsx +0 -255
- package/apps/lib/components/SpinLoading.tsx +0 -174
- package/apps/lib/components/Stepper.tsx +0 -480
- package/apps/lib/components/Switch.tsx +0 -82
- package/apps/lib/components/TabFormItem.tsx +0 -153
- package/apps/lib/components/TabSwitch.tsx +0 -172
- package/apps/lib/components/Table.tsx +0 -597
- package/apps/lib/components/TextEditor/ChartBlockTool.ts +0 -676
- package/apps/lib/components/TextEditor/RichTextField.tsx +0 -46
- package/apps/lib/components/TextEditor/TableDnDWrapper.ts +0 -462
- package/apps/lib/components/TextEditor/TextEditor.tsx +0 -1164
- package/apps/lib/components/TextEditor/TextEditorToolbar.tsx +0 -429
- package/apps/lib/components/TextEditor/editor-tools/AlignmentTune.ts +0 -70
- package/apps/lib/components/TextEditor/editor-tools/ColorInlineTool.ts +0 -50
- package/apps/lib/components/TextEditor/editor-tools/StrikethroughInlineTool.ts +0 -48
- package/apps/lib/components/TextEditor/editor-tools/inlineFormat.ts +0 -98
- package/apps/lib/components/TextEditor/editorjs.d.ts +0 -60
- package/apps/lib/components/TextEditor/index.ts +0 -7
- package/apps/lib/components/TextEditor/markdownParser.ts +0 -346
- package/apps/lib/components/Textarea.tsx +0 -117
- package/apps/lib/components/Timeline.tsx +0 -263
- package/apps/lib/components/Toast.tsx +0 -87
- package/apps/lib/components/Toggle.tsx +0 -125
- package/apps/lib/components/ToggleButton.tsx +0 -140
- package/apps/lib/components/Tooltip.tsx +0 -116
- package/apps/lib/components/TransparentLabel.tsx +0 -71
- package/apps/lib/components/TreeDropDown.tsx +0 -115
- package/apps/lib/components/TreeFolder/TreeFolder.tsx +0 -380
- package/apps/lib/components/TreeFolder/TreeFolderBreadcrumb.tsx +0 -75
- package/apps/lib/components/TreeFolder/TreeFolderRow.tsx +0 -354
- package/apps/lib/components/TreeFolder/TreeFolderStyles.tsx +0 -60
- package/apps/lib/components/TreeFolder/icons.tsx +0 -60
- package/apps/lib/components/TreeFolder/index.ts +0 -24
- package/apps/lib/components/TreeFolder/treeFolderUtils.ts +0 -109
- package/apps/lib/components/TreeFolder/types.ts +0 -77
- package/apps/lib/components/TreeFolder/useTreeFolderDnD.ts +0 -118
- package/apps/lib/hooks/useActiveTreeItem.ts +0 -61
- package/apps/lib/hooks/useClickOutside.ts +0 -27
- package/apps/lib/hooks/useDragDrop.tsx +0 -365
- package/apps/lib/hooks/useHtmlDir.ts +0 -31
- package/apps/lib/hooks/useInfiniteScroll.ts +0 -108
- package/apps/lib/hooks/useIsMobile.ts +0 -21
- package/apps/lib/hooks/useResize.ts +0 -67
- package/apps/lib/hooks/useTagSelection.ts +0 -300
- package/apps/lib/layouts/CNLayout.tsx +0 -372
- package/apps/lib/layouts/DataViewCard.tsx +0 -62
- package/apps/lib/layouts/FieldSection.tsx +0 -91
- package/apps/lib/layouts/TreeSubLayout.tsx +0 -173
- package/apps/lib/providers/ThemeProvider.tsx +0 -84
- package/apps/lib/registry.json +0 -1217
- package/apps/lib/tsconfig.json +0 -9
- package/apps/lib/tsconfig.tsbuildinfo +0 -1
- package/apps/lib/utils/cn.ts +0 -6
- package/apps/lib/utils/color.ts +0 -175
- package/apps/lib/utils/dataViews/path.ts +0 -67
- package/apps/lib/utils/dataViews/query.ts +0 -73
- package/apps/lib/utils/dataViews/types.ts +0 -187
- package/apps/lib/utils/dateFormat.ts +0 -108
- package/apps/lib/utils/resize.ts +0 -31
- package/apps/lib/utils/scroller.ts +0 -26
- package/apps/lib/utils/types.ts +0 -16
- package/docs/BLOCKS.md +0 -129
- package/docs/CHANGELOG-1.1.16.md +0 -108
- package/docs/Cover.png +0 -0
- package/docs/README.md +0 -215
- package/docs/components/action-button.md +0 -638
- package/docs/components/actions-group.md +0 -708
- package/docs/components/alert-dialog.md +0 -920
- package/docs/components/avatar.md +0 -709
- package/docs/components/badge-field.md +0 -738
- package/docs/components/badge.md +0 -301
- package/docs/components/breadcrumb.md +0 -930
- package/docs/components/button-group.md +0 -650
- package/docs/components/button.md +0 -639
- package/docs/components/calendar.md +0 -555
- package/docs/components/card.md +0 -622
- package/docs/components/chart-block-tool.md +0 -129
- package/docs/components/checkbox.md +0 -699
- package/docs/components/cn-layout.md +0 -854
- package/docs/components/color-picker.md +0 -101
- package/docs/components/conclusion-header.md +0 -80
- package/docs/components/context-menu.md +0 -483
- package/docs/components/count-badge.md +0 -560
- package/docs/components/data-table.md +0 -854
- package/docs/components/data-views/backend-response.md +0 -324
- package/docs/components/data-views/examples/a11y-rtl.md +0 -250
- package/docs/components/data-views/examples/api-orders-route.md +0 -130
- package/docs/components/data-views/examples/fields.md +0 -362
- package/docs/components/data-views/examples/filters.md +0 -307
- package/docs/components/data-views/examples/inbox-routing.md +0 -218
- package/docs/components/data-views/examples/index.md +0 -29
- package/docs/components/data-views/examples/overview.md +0 -244
- package/docs/components/data-views/examples/panel.md +0 -212
- package/docs/components/data-views/examples/scale.md +0 -231
- package/docs/components/data-views/examples/server-side.md +0 -210
- package/docs/components/data-views/examples/state.md +0 -250
- package/docs/components/data-views/examples/tree-custom.md +0 -388
- package/docs/components/data-views/examples/view-registry.md +0 -313
- package/docs/components/data-views/examples/views.md +0 -534
- package/docs/components/data-views/guide.md +0 -405
- package/docs/components/data-views/index.md +0 -1521
- package/docs/components/data-views/migration.md +0 -81
- package/docs/components/date-picker.md +0 -857
- package/docs/components/dialog.md +0 -929
- package/docs/components/divider.md +0 -766
- package/docs/components/drawer.md +0 -654
- package/docs/components/dropdown-menu.md +0 -668
- package/docs/components/field-hint.md +0 -898
- package/docs/components/field-section.md +0 -781
- package/docs/components/form-builder.md +0 -284
- package/docs/components/form-renderer.md +0 -396
- package/docs/components/form-summary.md +0 -138
- package/docs/components/form.md +0 -785
- package/docs/components/header-bar.md +0 -188
- package/docs/components/image-attachment.md +0 -906
- package/docs/components/inner-label-field.md +0 -819
- package/docs/components/input-field.md +0 -623
- package/docs/components/input-otp.md +0 -756
- package/docs/components/input.md +0 -634
- package/docs/components/label-field.md +0 -770
- package/docs/components/label.md +0 -761
- package/docs/components/labeled-check-box.md +0 -642
- package/docs/components/labeled-radio.md +0 -796
- package/docs/components/link-button.md +0 -685
- package/docs/components/login-button.md +0 -872
- package/docs/components/password-level.md +0 -803
- package/docs/components/popover.md +0 -649
- package/docs/components/profile-menu.md +0 -656
- package/docs/components/radio-card.md +0 -801
- package/docs/components/radio.md +0 -735
- package/docs/components/scroll-area.md +0 -691
- package/docs/components/search-field.md +0 -702
- package/docs/components/searchable-select.md +0 -368
- package/docs/components/searchable-table.md +0 -438
- package/docs/components/searchable-tree-dialog.md +0 -190
- package/docs/components/searchable-tree.md +0 -200
- package/docs/components/section-block.md +0 -483
- package/docs/components/select.md +0 -709
- package/docs/components/simple-select.md +0 -741
- package/docs/components/skeleton.md +0 -706
- package/docs/components/slide-date-picker.md +0 -837
- package/docs/components/spin-loading.md +0 -696
- package/docs/components/stepper.md +0 -316
- package/docs/components/switch.md +0 -770
- package/docs/components/tab-form-item.md +0 -773
- package/docs/components/tab-switch.md +0 -170
- package/docs/components/table-dnd-wrapper.md +0 -107
- package/docs/components/table.md +0 -1088
- package/docs/components/text-editor.md +0 -735
- package/docs/components/textarea.md +0 -681
- package/docs/components/timeline.md +0 -254
- package/docs/components/toast.md +0 -773
- package/docs/components/toggle-button.md +0 -643
- package/docs/components/toggle.md +0 -882
- package/docs/components/tooltip.md +0 -513
- package/docs/components/transparent-label.md +0 -721
- package/docs/components/tree-drop-down.md +0 -740
- package/docs/components/tree-folder.md +0 -110
- package/docs/components/tree-sub-layout.md +0 -707
- package/docs/explanation/architecture.md +0 -54
- package/docs/explanation/design-system.md +0 -52
- package/docs/how-to/form-and-list-recipes.md +0 -386
- package/docs/how-to/forms-with-form-builder.md +0 -472
- package/docs/how-to/guides.md +0 -1027
- package/docs/migration/changelog.md +0 -60
- package/docs/migration/form-builder-2.5.2.md +0 -113
- package/docs/reference/cli.md +0 -112
- package/docs/reference/components.md +0 -572
- package/docs/reference/hooks.md +0 -1523
- package/docs/reference/providers.md +0 -866
- package/docs/reference/tailwind-plugins.md +0 -942
- package/docs/reference/theme.md +0 -85
- package/docs/reference/types.md +0 -1016
- package/docs/reference/utilities.md +0 -726
- package/docs/tutorials/building-first-form.md +0 -846
- package/docs/tutorials/component-composition.md +0 -882
- package/docs/tutorials/getting-started.md +0 -302
- package/docs/tutorials/theming-basics.md +0 -785
package/apps/lib/utils/cn.ts
DELETED
package/apps/lib/utils/color.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure color-math helpers for the `ColorPicker` component (and anything else that
|
|
3
|
-
* needs to move between hex, RGB, HSV and HSL). No dependencies, no DOM — safe to
|
|
4
|
-
* unit-test and to import on the server.
|
|
5
|
-
*
|
|
6
|
-
* Conventions:
|
|
7
|
-
* - `RGBA` channels are 0–255 (`r`,`g`,`b`) and 0–1 (`a`).
|
|
8
|
-
* - `HSV`/`HSL` use `h` 0–360, everything else 0–100.
|
|
9
|
-
* - Hex output is uppercase, `#rrggbb` when fully opaque and `#rrggbbaa` otherwise.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export interface RGBA {
|
|
13
|
-
r: number;
|
|
14
|
-
g: number;
|
|
15
|
-
b: number;
|
|
16
|
-
a: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface HSV {
|
|
20
|
-
h: number;
|
|
21
|
-
s: number;
|
|
22
|
-
v: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface HSL {
|
|
26
|
-
h: number;
|
|
27
|
-
s: number;
|
|
28
|
-
l: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Clamp `n` into the inclusive `[min, max]` range. */
|
|
32
|
-
export function clamp(n: number, min: number, max: number): number {
|
|
33
|
-
return n < min ? min : n > max ? max : n;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** Round to `digits` decimal places (default 0). */
|
|
37
|
-
export function round(n: number, digits = 0): number {
|
|
38
|
-
const f = 10 ** digits;
|
|
39
|
-
return Math.round(n * f) / f;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const toHex2 = (n: number) => clamp(Math.round(n), 0, 255).toString(16).padStart(2, "0");
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Parse a hex color into `RGBA`. Accepts `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`
|
|
46
|
-
* with or without the leading `#`. Returns `null` for anything unparseable.
|
|
47
|
-
*/
|
|
48
|
-
export function parseHex(input: string): RGBA | null {
|
|
49
|
-
if (typeof input !== "string") return null;
|
|
50
|
-
let hex = input.trim().replace(/^#/, "");
|
|
51
|
-
|
|
52
|
-
// Expand shorthand (#rgb / #rgba → #rrggbb(aa)).
|
|
53
|
-
if (hex.length === 3 || hex.length === 4) {
|
|
54
|
-
hex = hex
|
|
55
|
-
.split("")
|
|
56
|
-
.map((c) => c + c)
|
|
57
|
-
.join("");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (hex.length !== 6 && hex.length !== 8) return null;
|
|
61
|
-
if (!/^[0-9a-fA-F]+$/.test(hex)) return null;
|
|
62
|
-
|
|
63
|
-
const r = parseInt(hex.slice(0, 2), 16);
|
|
64
|
-
const g = parseInt(hex.slice(2, 4), 16);
|
|
65
|
-
const b = parseInt(hex.slice(4, 6), 16);
|
|
66
|
-
const a = hex.length === 8 ? parseInt(hex.slice(6, 8), 16) / 255 : 1;
|
|
67
|
-
return { r, g, b, a: round(a, 2) };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Format `RGBA` as an uppercase hex string — `#rrggbb` if opaque, else `#rrggbbaa`. */
|
|
71
|
-
export function formatHex({ r, g, b, a }: RGBA): string {
|
|
72
|
-
const base = `#${toHex2(r)}${toHex2(g)}${toHex2(b)}`.toUpperCase();
|
|
73
|
-
if (a >= 1) return base;
|
|
74
|
-
return `${base}${toHex2(clamp(a, 0, 1) * 255).toUpperCase()}`;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** RGB (0–255) → HSV (h 0–360, s/v 0–100). Alpha is carried through unchanged elsewhere. */
|
|
78
|
-
export function rgbToHsv({ r, g, b }: { r: number; g: number; b: number }): HSV {
|
|
79
|
-
const rn = r / 255;
|
|
80
|
-
const gn = g / 255;
|
|
81
|
-
const bn = b / 255;
|
|
82
|
-
const max = Math.max(rn, gn, bn);
|
|
83
|
-
const min = Math.min(rn, gn, bn);
|
|
84
|
-
const d = max - min;
|
|
85
|
-
|
|
86
|
-
let h = 0;
|
|
87
|
-
if (d !== 0) {
|
|
88
|
-
if (max === rn) h = ((gn - bn) / d) % 6;
|
|
89
|
-
else if (max === gn) h = (bn - rn) / d + 2;
|
|
90
|
-
else h = (rn - gn) / d + 4;
|
|
91
|
-
h *= 60;
|
|
92
|
-
if (h < 0) h += 360;
|
|
93
|
-
}
|
|
94
|
-
const s = max === 0 ? 0 : d / max;
|
|
95
|
-
// Keep 2 decimals: HSV is the picker's internal state, so rounding to whole degrees/percents
|
|
96
|
-
// here would visibly shift a color that was only ever passed in (e.g. #10B981 → #11BA82).
|
|
97
|
-
return { h: round(h, 2), s: round(s * 100, 2), v: round(max * 100, 2) };
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** HSV (h 0–360, s/v 0–100) → RGB (0–255). */
|
|
101
|
-
export function hsvToRgb({ h, s, v }: HSV): { r: number; g: number; b: number } {
|
|
102
|
-
const hn = ((h % 360) + 360) % 360;
|
|
103
|
-
const sn = clamp(s, 0, 100) / 100;
|
|
104
|
-
const vn = clamp(v, 0, 100) / 100;
|
|
105
|
-
|
|
106
|
-
const c = vn * sn;
|
|
107
|
-
const x = c * (1 - Math.abs(((hn / 60) % 2) - 1));
|
|
108
|
-
const m = vn - c;
|
|
109
|
-
|
|
110
|
-
let rp = 0;
|
|
111
|
-
let gp = 0;
|
|
112
|
-
let bp = 0;
|
|
113
|
-
if (hn < 60) [rp, gp, bp] = [c, x, 0];
|
|
114
|
-
else if (hn < 120) [rp, gp, bp] = [x, c, 0];
|
|
115
|
-
else if (hn < 180) [rp, gp, bp] = [0, c, x];
|
|
116
|
-
else if (hn < 240) [rp, gp, bp] = [0, x, c];
|
|
117
|
-
else if (hn < 300) [rp, gp, bp] = [x, 0, c];
|
|
118
|
-
else [rp, gp, bp] = [c, 0, x];
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
r: round((rp + m) * 255),
|
|
122
|
-
g: round((gp + m) * 255),
|
|
123
|
-
b: round((bp + m) * 255),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** RGB (0–255) → HSL (h 0–360, s/l 0–100). */
|
|
128
|
-
export function rgbToHsl({ r, g, b }: { r: number; g: number; b: number }): HSL {
|
|
129
|
-
const rn = r / 255;
|
|
130
|
-
const gn = g / 255;
|
|
131
|
-
const bn = b / 255;
|
|
132
|
-
const max = Math.max(rn, gn, bn);
|
|
133
|
-
const min = Math.min(rn, gn, bn);
|
|
134
|
-
const d = max - min;
|
|
135
|
-
const l = (max + min) / 2;
|
|
136
|
-
|
|
137
|
-
let h = 0;
|
|
138
|
-
let s = 0;
|
|
139
|
-
if (d !== 0) {
|
|
140
|
-
s = d / (1 - Math.abs(2 * l - 1));
|
|
141
|
-
if (max === rn) h = ((gn - bn) / d) % 6;
|
|
142
|
-
else if (max === gn) h = (bn - rn) / d + 2;
|
|
143
|
-
else h = (rn - gn) / d + 4;
|
|
144
|
-
h *= 60;
|
|
145
|
-
if (h < 0) h += 360;
|
|
146
|
-
}
|
|
147
|
-
return { h: round(h), s: round(s * 100), l: round(l * 100) };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/** HSL (h 0–360, s/l 0–100) → RGB (0–255). */
|
|
151
|
-
export function hslToRgb({ h, s, l }: HSL): { r: number; g: number; b: number } {
|
|
152
|
-
const hn = ((h % 360) + 360) % 360;
|
|
153
|
-
const sn = clamp(s, 0, 100) / 100;
|
|
154
|
-
const ln = clamp(l, 0, 100) / 100;
|
|
155
|
-
|
|
156
|
-
const c = (1 - Math.abs(2 * ln - 1)) * sn;
|
|
157
|
-
const x = c * (1 - Math.abs(((hn / 60) % 2) - 1));
|
|
158
|
-
const m = ln - c / 2;
|
|
159
|
-
|
|
160
|
-
let rp = 0;
|
|
161
|
-
let gp = 0;
|
|
162
|
-
let bp = 0;
|
|
163
|
-
if (hn < 60) [rp, gp, bp] = [c, x, 0];
|
|
164
|
-
else if (hn < 120) [rp, gp, bp] = [x, c, 0];
|
|
165
|
-
else if (hn < 180) [rp, gp, bp] = [0, c, x];
|
|
166
|
-
else if (hn < 240) [rp, gp, bp] = [0, x, c];
|
|
167
|
-
else if (hn < 300) [rp, gp, bp] = [x, 0, c];
|
|
168
|
-
else [rp, gp, bp] = [c, 0, x];
|
|
169
|
-
|
|
170
|
-
return {
|
|
171
|
-
r: round((rp + m) * 255),
|
|
172
|
-
g: round((gp + m) * 255),
|
|
173
|
-
b: round((bp + m) * 255),
|
|
174
|
-
};
|
|
175
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { Path, Row } from "./types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Split cache. Bounded on purpose — the previous implementation used an unbounded module-level
|
|
5
|
-
* `Map`, which in a long-lived app grows for every distinct path string it ever sees. Paths come
|
|
6
|
-
* from a fixed field config in practice, so a small cap costs nothing and removes the leak.
|
|
7
|
-
*/
|
|
8
|
-
const CACHE_LIMIT = 512;
|
|
9
|
-
const cache = new Map<string, string[]>();
|
|
10
|
-
|
|
11
|
-
function split(path: Path): string[] {
|
|
12
|
-
const hit = cache.get(path);
|
|
13
|
-
if (hit) return hit;
|
|
14
|
-
const parts = path.split(".");
|
|
15
|
-
if (cache.size >= CACHE_LIMIT) cache.clear();
|
|
16
|
-
cache.set(path, parts);
|
|
17
|
-
return parts;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Read a dotted path off a row. Returns `undefined` for any missing link in the chain. */
|
|
21
|
-
export function getByPath(obj: unknown, path: Path | undefined | null): unknown {
|
|
22
|
-
if (obj == null || path == null || path === "") return undefined;
|
|
23
|
-
if (typeof obj !== "object") return undefined;
|
|
24
|
-
let cur: unknown = obj;
|
|
25
|
-
for (const key of split(path)) {
|
|
26
|
-
if (cur == null) return undefined;
|
|
27
|
-
cur = (cur as Record<string, unknown>)[key];
|
|
28
|
-
}
|
|
29
|
-
return cur;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Read a path and coerce to string for display/compare. `undefined`/`null` become `""`. */
|
|
33
|
-
export function getString(obj: unknown, path: Path | undefined | null): string {
|
|
34
|
-
const v = getByPath(obj, path);
|
|
35
|
-
return v == null ? "" : String(v);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** `"created_at"` / `"createdAt"` → `"Created At"`. Uses the last segment of a dotted path. */
|
|
39
|
-
export function formatPathLabel(path: Path): string {
|
|
40
|
-
if (!path) return "";
|
|
41
|
-
const tail = path.includes(".") ? path.split(".").pop()! : path;
|
|
42
|
-
|
|
43
|
-
if (tail.includes("_")) {
|
|
44
|
-
return tail
|
|
45
|
-
.split("_")
|
|
46
|
-
.filter(Boolean)
|
|
47
|
-
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
48
|
-
.join(" ");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return tail
|
|
52
|
-
.replace(/([A-Z])/g, " $1")
|
|
53
|
-
.replace(/^./, (s) => s.toUpperCase())
|
|
54
|
-
.trim();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The default row identity: the first of `row.id`, `row._id`, `row.uuid`, else the array index.
|
|
59
|
-
*
|
|
60
|
-
* The previous implementation fell back through three candidates ending in the array index, so
|
|
61
|
-
* selection and drag-and-drop both broke the moment rows were reordered. Pass `getRowId` when
|
|
62
|
-
* your id lives elsewhere.
|
|
63
|
-
*/
|
|
64
|
-
export function defaultGetRowId(row: Row, index: number): string {
|
|
65
|
-
const id = row.id ?? row._id ?? row.uuid;
|
|
66
|
-
return id == null ? String(index) : String(id);
|
|
67
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import type { DataViewsQuery, FilterState, Sort } from "./types";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The wire format for a `DataViewsQuery`, both directions.
|
|
5
|
-
*
|
|
6
|
-
* A query is written in the browser and read on the server, and the two have to agree exactly.
|
|
7
|
-
* Keeping the encoder and the decoder in one file is what makes that true by construction —
|
|
8
|
-
* split across a page and a route handler, they drift the first time either side gains a field.
|
|
9
|
-
*
|
|
10
|
-
* No React here, like its neighbours `path.ts` and `types.ts`, so a route handler can import it.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/** A query nobody has touched yet: everything, first page. */
|
|
14
|
-
export function emptyQuery(overrides?: Partial<DataViewsQuery>): DataViewsQuery {
|
|
15
|
-
return { search: "", filters: {}, sort: null, page: 1, pageSize: 10, ...overrides };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Browser → wire.
|
|
20
|
-
*
|
|
21
|
-
* `filters` goes as JSON because it is a nested structure, not a flat list of values. `sort` goes
|
|
22
|
-
* as `total:desc` — one parameter rather than two, since neither half means anything alone.
|
|
23
|
-
*
|
|
24
|
-
* Extra parameters an endpoint of your own needs are yours to append:
|
|
25
|
-
*
|
|
26
|
-
* ```ts
|
|
27
|
-
* const params = queryToParams(query);
|
|
28
|
-
* params.set("shape", "wide");
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export function queryToParams(query: DataViewsQuery): URLSearchParams {
|
|
32
|
-
return new URLSearchParams({
|
|
33
|
-
search: query.search,
|
|
34
|
-
filters: JSON.stringify(query.filters),
|
|
35
|
-
sort: query.sort ? `${query.sort.path}:${query.sort.direction}` : "",
|
|
36
|
-
page: String(query.page),
|
|
37
|
-
pageSize: String(query.pageSize),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Wire → server.
|
|
43
|
-
*
|
|
44
|
-
* Malformed `filters` is treated as "no filters" rather than a 400: a filter you cannot parse
|
|
45
|
-
* should not take the page down. `pageSize` is clamped, because it arrives from the client and a
|
|
46
|
-
* request for a million rows is a request to fall over.
|
|
47
|
-
*/
|
|
48
|
-
export function parseQuery(url: URL): DataViewsQuery {
|
|
49
|
-
const params = url.searchParams;
|
|
50
|
-
|
|
51
|
-
let filters: FilterState = {};
|
|
52
|
-
const raw = params.get("filters");
|
|
53
|
-
if (raw) {
|
|
54
|
-
try {
|
|
55
|
-
filters = JSON.parse(raw) as FilterState;
|
|
56
|
-
} catch {
|
|
57
|
-
filters = {};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const [sortPath, sortDir] = (params.get("sort") ?? "").split(":");
|
|
62
|
-
const sort: Sort = sortPath
|
|
63
|
-
? { path: sortPath, direction: sortDir === "desc" ? "desc" : "asc" }
|
|
64
|
-
: null;
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
search: params.get("search") ?? "",
|
|
68
|
-
filters,
|
|
69
|
-
sort,
|
|
70
|
-
page: Math.max(1, Number(params.get("page")) || 1),
|
|
71
|
-
pageSize: Math.min(500, Math.max(1, Number(params.get("pageSize")) || 10)),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The vocabulary DataViews speaks — nothing more.
|
|
3
|
-
*
|
|
4
|
-
* DataViews does no data work: it never filters, searches, sorts, groups, or infers a schema.
|
|
5
|
-
* Those are the app's job, almost always server-side. What is described here is only what the
|
|
6
|
-
* component needs in order to **paint** rows and to **emit intent** back to you:
|
|
7
|
-
* `FilterState` and `Sort` are things it hands you so you can go and query, not things it applies.
|
|
8
|
-
*
|
|
9
|
-
* These types live in the utils layer so the dependency runs one way — the component imports its
|
|
10
|
-
* vocabulary from here, and nothing here imports React or any component.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import type { ReactNode } from "react";
|
|
14
|
-
|
|
15
|
-
/** A row is any record. DataViews never assumes a shape beyond the id resolved by `getRowId`. */
|
|
16
|
-
export type Row = Record<string, unknown>;
|
|
17
|
-
|
|
18
|
-
/** A dotted accessor into a row, e.g. `"customer.name"`. */
|
|
19
|
-
export type Path = string;
|
|
20
|
-
|
|
21
|
-
export type FieldType =
|
|
22
|
-
| "text"
|
|
23
|
-
| "number"
|
|
24
|
-
| "date"
|
|
25
|
-
| "boolean"
|
|
26
|
-
| "hidden"
|
|
27
|
-
| "enum-badge"
|
|
28
|
-
| "badge-array"
|
|
29
|
-
| "currency"
|
|
30
|
-
| "number-format"
|
|
31
|
-
| "progress-bar"
|
|
32
|
-
| "star-rating"
|
|
33
|
-
| "icon-text"
|
|
34
|
-
| "two-line"
|
|
35
|
-
| "avatar"
|
|
36
|
-
| "link"
|
|
37
|
-
| "image"
|
|
38
|
-
| "date-format";
|
|
39
|
-
|
|
40
|
-
export type BadgeVariant =
|
|
41
|
-
| "green"
|
|
42
|
-
| "greenLight"
|
|
43
|
-
| "cocktailGreen"
|
|
44
|
-
| "yellow"
|
|
45
|
-
| "redOrange"
|
|
46
|
-
| "redLight"
|
|
47
|
-
| "rose"
|
|
48
|
-
| "purple"
|
|
49
|
-
| "bluePurple"
|
|
50
|
-
| "blue"
|
|
51
|
-
| "navy"
|
|
52
|
-
| "gray"
|
|
53
|
-
| "highlight";
|
|
54
|
-
|
|
55
|
-
/** Palette keys for a board column pill. */
|
|
56
|
-
export type ColumnColor = "gray" | "purple" | "orange" | "blue" | "green" | "red";
|
|
57
|
-
|
|
58
|
-
export type CurrencyOptions = {
|
|
59
|
-
symbol?: string;
|
|
60
|
-
locale?: string;
|
|
61
|
-
decimals?: number;
|
|
62
|
-
code?: string;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/** How one field is read and painted. You author these — nothing is inferred from the data. */
|
|
66
|
-
export type FieldConfig = {
|
|
67
|
-
path: Path;
|
|
68
|
-
label?: string;
|
|
69
|
-
type?: FieldType;
|
|
70
|
-
visible?: boolean;
|
|
71
|
-
|
|
72
|
-
/** Value → badge colour, for `enum-badge` / `badge-array`. */
|
|
73
|
-
variants?: Record<string, BadgeVariant>;
|
|
74
|
-
defaultVariant?: BadgeVariant;
|
|
75
|
-
variant?: BadgeVariant;
|
|
76
|
-
|
|
77
|
-
limit?: number;
|
|
78
|
-
currency?: string | CurrencyOptions;
|
|
79
|
-
format?: Intl.NumberFormatOptions;
|
|
80
|
-
thresholds?: [number, number];
|
|
81
|
-
max?: number;
|
|
82
|
-
icon?: string;
|
|
83
|
-
iconPosition?: "before" | "after";
|
|
84
|
-
secondaryPath?: Path;
|
|
85
|
-
linkType?: "mailto" | "tel" | "url";
|
|
86
|
-
fallbackPath?: Path;
|
|
87
|
-
dateFormat?: string | Intl.DateTimeFormatOptions;
|
|
88
|
-
trueLabel?: string;
|
|
89
|
-
falseLabel?: string;
|
|
90
|
-
trueVariant?: BadgeVariant;
|
|
91
|
-
falseVariant?: BadgeVariant;
|
|
92
|
-
|
|
93
|
-
/** Paint this field yourself. Wins over `type`. */
|
|
94
|
-
render?: (value: unknown, row: Row) => ReactNode;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/** A column as the user has arranged it — the projection the config panel edits. */
|
|
98
|
-
export type ColumnState = {
|
|
99
|
-
path: Path;
|
|
100
|
-
label: string;
|
|
101
|
-
visible: boolean;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
type SortDirection = "asc" | "desc";
|
|
105
|
-
/** Which column the header shows as sorted. Emitted on click; the component never re-orders rows. */
|
|
106
|
-
export type Sort = { path: Path; direction: SortDirection } | null;
|
|
107
|
-
|
|
108
|
-
type NumericRange = { kind: "number"; min?: number; max?: number };
|
|
109
|
-
type DateRange = { kind: "date"; from?: string; to?: string };
|
|
110
|
-
type RangeValue = NumericRange | DateRange;
|
|
111
|
-
/** A categorical selection, or a range. */
|
|
112
|
-
export type FilterValue = string[] | RangeValue;
|
|
113
|
-
/** Keyed by field path. */
|
|
114
|
-
export type FilterState = Record<Path, FilterValue>;
|
|
115
|
-
|
|
116
|
-
/** A one-click shortcut on a numeric filter, e.g. "Under 500". */
|
|
117
|
-
export type NumberPreset = { label: string; min?: number; max?: number };
|
|
118
|
-
/** A one-click shortcut on a date filter, e.g. "Last 30 days". */
|
|
119
|
-
export type DatePreset = { label: string; from?: string; to?: string };
|
|
120
|
-
/** `Filters.Presets` takes both shapes; each control renders the ones it understands. */
|
|
121
|
-
export type Preset = NumberPreset | DatePreset;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Everything the user asked for, in one object.
|
|
125
|
-
*
|
|
126
|
-
* This is the whole contract between `DataViews` and your data layer. The component collects it —
|
|
127
|
-
* a search typed in the header, filters set in the rail, a column header clicked, a page turned —
|
|
128
|
-
* and hands it over whole; going and fetching the matching rows is your half.
|
|
129
|
-
*
|
|
130
|
-
* It is one object rather than five callbacks because it is one question. A query with a new
|
|
131
|
-
* filter and a stale page number is not a query anyone meant to ask, and keeping the parts
|
|
132
|
-
* together is what lets the component keep them consistent — changing a filter resets `page` to 1,
|
|
133
|
-
* because a different result set has no page 4 to stay on.
|
|
134
|
-
*/
|
|
135
|
-
export interface DataViewsQuery {
|
|
136
|
-
search: string;
|
|
137
|
-
filters: FilterState;
|
|
138
|
-
sort: Sort;
|
|
139
|
-
/** 1-based. */
|
|
140
|
-
page: number;
|
|
141
|
-
pageSize: number;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** How a filter maps between its control's value and `FilterState`. */
|
|
145
|
-
type FilterKind = "choice" | "number" | "date" | "text";
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* What `DataViews.Filters` learned about one of its children.
|
|
149
|
-
*
|
|
150
|
-
* You never write these: filters are authored as `FormBuilder` fields, and `Filters` reads each
|
|
151
|
-
* child's `name`, `label` and bounds off the element to build this. It exists because the mapping
|
|
152
|
-
* to `FilterState` needs to know a slider from a multi-select — a `[0, 500]` is a numeric range,
|
|
153
|
-
* while `["a", "b"]` is a selection, and the two are indistinguishable once they are just values.
|
|
154
|
-
*/
|
|
155
|
-
export type FilterFieldDescriptor = {
|
|
156
|
-
path: Path;
|
|
157
|
-
label?: string;
|
|
158
|
-
kind: FilterKind;
|
|
159
|
-
/** Single-valued choice (`FormBuilder.Select`) rather than multi (`.MultiSelect`). */
|
|
160
|
-
single?: boolean;
|
|
161
|
-
/** Slider bounds, read from the child. A slider resting on them emits no filter at all. */
|
|
162
|
-
min?: number;
|
|
163
|
-
max?: number;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export type TreeNode = {
|
|
167
|
-
id: string;
|
|
168
|
-
row: Row;
|
|
169
|
-
children: TreeNode[];
|
|
170
|
-
depth: number;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
/** Emitted by a board or tree drag. The component never applies it. */
|
|
174
|
-
export type MoveIntent = {
|
|
175
|
-
id: string;
|
|
176
|
-
from: string | null;
|
|
177
|
-
to: string | null;
|
|
178
|
-
index?: number;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
/** A pre-grouped column for the board view. You build these; the component only paints them. */
|
|
182
|
-
export type RowGroup = {
|
|
183
|
-
id: string;
|
|
184
|
-
label: string;
|
|
185
|
-
color?: ColumnColor;
|
|
186
|
-
rows: Row[];
|
|
187
|
-
};
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { DateRange } from "react-day-picker";
|
|
2
|
-
import { format } from "date-fns";
|
|
3
|
-
|
|
4
|
-
export type TimePickerValue = {
|
|
5
|
-
hour: string;
|
|
6
|
-
minute: string;
|
|
7
|
-
time: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Applies time from a picker value to a given date object
|
|
12
|
-
* @param {Date} date - The base date to apply time to
|
|
13
|
-
* @param {TimePickerValue} TimePickerValue - Object containing hour, minute, and time period (AM/PM)
|
|
14
|
-
* @returns {Date} A new Date object with the applied time
|
|
15
|
-
*/
|
|
16
|
-
export const applyTimeToDate = (date: Date, TimePickerValue: TimePickerValue): Date => {
|
|
17
|
-
const newDate = new Date(date);
|
|
18
|
-
let hours = parseInt(String(TimePickerValue.hour));
|
|
19
|
-
|
|
20
|
-
// Convert to 24-hour format
|
|
21
|
-
if (TimePickerValue.time === "PM" && hours < 12) {
|
|
22
|
-
hours += 12;
|
|
23
|
-
} else if (TimePickerValue.time === "AM" && hours === 12) {
|
|
24
|
-
hours = 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
newDate.setHours(hours);
|
|
28
|
-
newDate.setMinutes(parseInt(String(TimePickerValue.minute)));
|
|
29
|
-
return newDate;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Validates if a given value is a valid Date object
|
|
34
|
-
* @param {Date} date - The date to validate
|
|
35
|
-
* @returns {boolean} True if the value is a valid Date object, false otherwise
|
|
36
|
-
*/
|
|
37
|
-
export const isValidDateObject = (date: Date): boolean =>
|
|
38
|
-
date instanceof Date && !isNaN(date.getTime());
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Applies time from a picker value to various date value types
|
|
42
|
-
* @param {Date | Date[] | DateRange | undefined} dateValue - The date value to apply time to
|
|
43
|
-
* @param {TimePickerValue} TimePickerValue - Object containing hour, minute, and time period (AM/PM)
|
|
44
|
-
* @returns {Date | Date[] | DateRange | undefined} The date value with applied time, or undefined if invalid
|
|
45
|
-
*/
|
|
46
|
-
export const applyTimeToDateValue = (
|
|
47
|
-
dateValue: Date | Date[] | DateRange | undefined,
|
|
48
|
-
TimePickerValue: TimePickerValue,
|
|
49
|
-
): Date | Date[] | DateRange | undefined => {
|
|
50
|
-
if (!dateValue) return undefined;
|
|
51
|
-
|
|
52
|
-
// Handle array of dates
|
|
53
|
-
if (Array.isArray(dateValue)) {
|
|
54
|
-
return dateValue
|
|
55
|
-
.filter(isValidDateObject)
|
|
56
|
-
.map((date) => applyTimeToDate(date, TimePickerValue));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Handle date range
|
|
60
|
-
if (dateValue && "from" in dateValue) {
|
|
61
|
-
const from =
|
|
62
|
-
dateValue.from && isValidDateObject(dateValue.from as Date)
|
|
63
|
-
? applyTimeToDate(dateValue.from as Date, TimePickerValue)
|
|
64
|
-
: undefined;
|
|
65
|
-
const to =
|
|
66
|
-
dateValue.to && isValidDateObject(dateValue.to as Date)
|
|
67
|
-
? applyTimeToDate(dateValue.to as Date, TimePickerValue)
|
|
68
|
-
: undefined;
|
|
69
|
-
return { from, to };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Handle single date
|
|
73
|
-
return isValidDateObject(dateValue as Date)
|
|
74
|
-
? applyTimeToDate(dateValue as Date, TimePickerValue)
|
|
75
|
-
: undefined;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Formats a date value to a string based on the provided format
|
|
80
|
-
* @param {Date | Date[] | DateRange | undefined} date - The date value to format
|
|
81
|
-
* @param {TimePickerValue} TimePickerValue - Object containing hour, minute, and time period (AM/PM)
|
|
82
|
-
* @param {string} dateFormat - The format string to use for formatting (e.g., 'MM/dd/yyyy')
|
|
83
|
-
* @returns {string} Formatted date string, or empty string if date is undefined
|
|
84
|
-
*/
|
|
85
|
-
export const formatDateValueToString = (
|
|
86
|
-
date: Date | Date[] | DateRange | undefined,
|
|
87
|
-
TimePickerValue: TimePickerValue,
|
|
88
|
-
dateFormat: string,
|
|
89
|
-
): string => {
|
|
90
|
-
if (!date) return "";
|
|
91
|
-
|
|
92
|
-
// Handle array of dates
|
|
93
|
-
if (Array.isArray(date)) {
|
|
94
|
-
return date.map((d) => format(applyTimeToDate(d, TimePickerValue), dateFormat)).join(", ");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Handle date range
|
|
98
|
-
if ("from" in date) {
|
|
99
|
-
const from = date.from
|
|
100
|
-
? format(applyTimeToDate(date.from as Date, TimePickerValue), dateFormat)
|
|
101
|
-
: "";
|
|
102
|
-
const to = date.to ? format(applyTimeToDate(date.to as Date, TimePickerValue), dateFormat) : "";
|
|
103
|
-
return from && to ? `${from} - ${to}` : from || to;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Handle single date
|
|
107
|
-
return format(applyTimeToDate(date as Date, TimePickerValue), dateFormat);
|
|
108
|
-
};
|
package/apps/lib/utils/resize.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { MutableRefObject, RefObject } from "react";
|
|
2
|
-
|
|
3
|
-
// Extracted function to get the new width based on the mouse event
|
|
4
|
-
export const calculateNewWidthFromMouse = (
|
|
5
|
-
event: MouseEvent,
|
|
6
|
-
resizableRef: MutableRefObject<HTMLElement | null> | RefObject<HTMLElement | null>,
|
|
7
|
-
isRtl: boolean,
|
|
8
|
-
): number => {
|
|
9
|
-
if (resizableRef.current) {
|
|
10
|
-
const rect = resizableRef.current.getBoundingClientRect();
|
|
11
|
-
return isRtl
|
|
12
|
-
? rect.right - event.clientX // Reverse calculation for RTL
|
|
13
|
-
: event.clientX - rect.left;
|
|
14
|
-
}
|
|
15
|
-
return 0;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// Extracted function to get the new width based on the touch event
|
|
19
|
-
export const calculateNewWidthFromTouch = (
|
|
20
|
-
event: TouchEvent,
|
|
21
|
-
resizableRef: MutableRefObject<HTMLElement | null> | RefObject<HTMLElement | null>,
|
|
22
|
-
isRtl: boolean,
|
|
23
|
-
): number => {
|
|
24
|
-
if (resizableRef.current) {
|
|
25
|
-
const rect = resizableRef.current.getBoundingClientRect();
|
|
26
|
-
return isRtl
|
|
27
|
-
? rect.right - event.touches[0].clientX // Reverse calculation for RTL
|
|
28
|
-
: event.touches[0].clientX - rect.left;
|
|
29
|
-
}
|
|
30
|
-
return 0;
|
|
31
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LOCAL PATCH (Contact Center): the design's 14px horizontal scroller — a thin track that thickens
|
|
3
|
-
* and turns blue on hover.
|
|
4
|
-
*
|
|
5
|
-
* Lives here, not on `Table`, because two unrelated components wear it: `TableScroller` (the
|
|
6
|
-
* wrapper `FormBuilder.Table` puts around its grid) and `SectionBlock`'s body (which scrolls any
|
|
7
|
-
* wide content dropped into a section card). A section card should not have to import the table
|
|
8
|
-
* component — and its consumers should not pull in the table's dependencies — just to share a
|
|
9
|
-
* scrollbar.
|
|
10
|
-
*
|
|
11
|
-
* `overflow-y-hidden` is part of the set on purpose: CSS computes `overflow-y: visible` to `auto`
|
|
12
|
-
* whenever `overflow-x` is not `visible`, so omitting it gives every consumer a spurious vertical
|
|
13
|
-
* scrollbar.
|
|
14
|
-
*/
|
|
15
|
-
export const horizontalScrollerStyles = [
|
|
16
|
-
"overflow-x-auto overflow-y-hidden",
|
|
17
|
-
"[&::-webkit-scrollbar]:h-[14px]",
|
|
18
|
-
"[&::-webkit-scrollbar-track]:bg-transparent",
|
|
19
|
-
"[&::-webkit-scrollbar-thumb]:rounded-[7px]",
|
|
20
|
-
"[&::-webkit-scrollbar-thumb]:border-[5px] [&::-webkit-scrollbar-thumb]:border-solid",
|
|
21
|
-
"[&::-webkit-scrollbar-thumb]:border-transparent",
|
|
22
|
-
"[&::-webkit-scrollbar-thumb]:bg-clip-content",
|
|
23
|
-
"[&::-webkit-scrollbar-thumb]:bg-background-presentation-body-scroller-default",
|
|
24
|
-
"[&::-webkit-scrollbar-thumb:hover]:border-[3px]",
|
|
25
|
-
"[&::-webkit-scrollbar-thumb:hover]:bg-background-presentation-body-scroller-hover",
|
|
26
|
-
].join(" ");
|
package/apps/lib/utils/types.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type Themes = "dark" | "light" | "default";
|
|
2
|
-
|
|
3
|
-
export type ButtonVariant =
|
|
4
|
-
| "PrimeStyle"
|
|
5
|
-
| "BluSecStyle"
|
|
6
|
-
| "YelSecStyle"
|
|
7
|
-
| "RedSecStyle"
|
|
8
|
-
| "BorderStyle"
|
|
9
|
-
| "PrimeContStyle"
|
|
10
|
-
| "BluContStyle"
|
|
11
|
-
| "RedContStyle"
|
|
12
|
-
| "PrimeColStyle"
|
|
13
|
-
| "BluColStyle"
|
|
14
|
-
| "RedColStyle"
|
|
15
|
-
| "GreenColStyle"
|
|
16
|
-
| "YelColStyle";
|