@bettercms-ai/kit 0.1.1 → 1.0.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/_virtual/_rolldown/runtime.js +13 -0
- package/adapters/icons.d.ts +15 -0
- package/adapters/icons.js +27 -0
- package/adapters/icons.js.map +1 -0
- package/adapters/lossy.d.ts +267 -0
- package/adapters/lossy.js +233 -0
- package/adapters/lossy.js.map +1 -0
- package/adapters/prod-types.d.ts +468 -0
- package/adapters/prod-types.js +646 -0
- package/adapters/prod-types.js.map +1 -0
- package/adapters/schema.d.ts +115 -0
- package/adapters/schema.js +2203 -0
- package/adapters/schema.js.map +1 -0
- package/adapters/values.d.ts +200 -0
- package/adapters/values.js +553 -0
- package/adapters/values.js.map +1 -0
- package/brand/logo.d.ts +17 -0
- package/brand/logo.js +9 -0
- package/brand/logo.js.map +1 -0
- package/context.d.ts +269 -0
- package/context.js +214 -0
- package/context.js.map +1 -0
- package/controls/button.d.ts +58 -0
- package/controls/button.js +507 -0
- package/controls/button.js.map +1 -0
- package/controls/c1.d.ts +11 -0
- package/controls/c1.js +24 -0
- package/controls/c1.js.map +1 -0
- package/controls/c2.d.ts +10 -0
- package/controls/c2.js +19 -0
- package/controls/c2.js.map +1 -0
- package/controls/choice.d.ts +39 -0
- package/controls/choice.js +410 -0
- package/controls/choice.js.map +1 -0
- package/controls/code-register.d.ts +1 -0
- package/controls/code-register.js +8 -0
- package/controls/code-register.js.map +1 -0
- package/controls/code.d.ts +42 -0
- package/controls/code.js +396 -0
- package/controls/code.js.map +1 -0
- package/controls/color.d.ts +5 -0
- package/controls/color.js +130 -0
- package/controls/color.js.map +1 -0
- package/controls/component-services.d.ts +114 -0
- package/controls/date-register.d.ts +1 -0
- package/controls/date-register.js +9 -0
- package/controls/date-register.js.map +1 -0
- package/controls/date-zone.d.ts +104 -0
- package/controls/date-zone.js +272 -0
- package/controls/date-zone.js.map +1 -0
- package/controls/date.d.ts +7 -0
- package/controls/date.js +458 -0
- package/controls/date.js.map +1 -0
- package/controls/form-picker-register.d.ts +1 -0
- package/controls/form-picker-register.js +19 -0
- package/controls/form-picker-register.js.map +1 -0
- package/controls/form-picker.d.ts +43 -0
- package/controls/form-picker.js +83 -0
- package/controls/form-picker.js.map +1 -0
- package/controls/icon-register.d.ts +1 -0
- package/controls/icon-register.js +8 -0
- package/controls/icon-register.js.map +1 -0
- package/controls/icon.d.ts +38 -0
- package/controls/icon.js +355 -0
- package/controls/icon.js.map +1 -0
- package/controls/index.d.ts +5 -0
- package/controls/index.js +37 -0
- package/controls/index.js.map +1 -0
- package/controls/json-register.d.ts +1 -0
- package/controls/json-register.js +8 -0
- package/controls/json-register.js.map +1 -0
- package/controls/json.d.ts +2 -0
- package/controls/json.js +72 -0
- package/controls/json.js.map +1 -0
- package/controls/link.d.ts +260 -0
- package/controls/link.js +1186 -0
- package/controls/link.js.map +1 -0
- package/controls/location-register.d.ts +1 -0
- package/controls/location-register.js +8 -0
- package/controls/location-register.js.map +1 -0
- package/controls/location.d.ts +16 -0
- package/controls/location.js +197 -0
- package/controls/location.js.map +1 -0
- package/controls/media-register.d.ts +1 -0
- package/controls/media-register.js +12 -0
- package/controls/media-register.js.map +1 -0
- package/controls/media-services.d.ts +40 -0
- package/controls/media.d.ts +73 -0
- package/controls/media.js +1076 -0
- package/controls/media.js.map +1 -0
- package/controls/number.d.ts +22 -0
- package/controls/number.js +195 -0
- package/controls/number.js.map +1 -0
- package/controls/reference-register.d.ts +1 -0
- package/controls/reference-register.js +10 -0
- package/controls/reference-register.js.map +1 -0
- package/controls/reference-services.d.ts +54 -0
- package/controls/reference.d.ts +23 -0
- package/controls/reference.js +761 -0
- package/controls/reference.js.map +1 -0
- package/controls/rich-text/blocks.d.ts +28 -0
- package/controls/rich-text/blocks.js +1532 -0
- package/controls/rich-text/blocks.js.map +1 -0
- package/controls/rich-text/catalog.d.ts +98 -0
- package/controls/rich-text/catalog.js +613 -0
- package/controls/rich-text/catalog.js.map +1 -0
- package/controls/rich-text/codec.d.ts +56 -0
- package/controls/rich-text/codec.js +32 -0
- package/controls/rich-text/codec.js.map +1 -0
- package/controls/rich-text/component-card.d.ts +14 -0
- package/controls/rich-text/component-card.js +706 -0
- package/controls/rich-text/component-card.js.map +1 -0
- package/controls/rich-text/control.d.ts +21 -0
- package/controls/rich-text/control.js +254 -0
- package/controls/rich-text/control.js.map +1 -0
- package/controls/rich-text/dom.d.ts +190 -0
- package/controls/rich-text/dom.js +690 -0
- package/controls/rich-text/dom.js.map +1 -0
- package/controls/rich-text/editor.d.ts +50 -0
- package/controls/rich-text/editor.js +1530 -0
- package/controls/rich-text/editor.js.map +1 -0
- package/controls/rich-text/floating.d.ts +23 -0
- package/controls/rich-text/floating.js +137 -0
- package/controls/rich-text/floating.js.map +1 -0
- package/controls/rich-text/index.d.ts +1 -0
- package/controls/rich-text/index.js +12 -0
- package/controls/rich-text/index.js.map +1 -0
- package/controls/rich-text/link-form.d.ts +13 -0
- package/controls/rich-text/link-form.js +111 -0
- package/controls/rich-text/link-form.js.map +1 -0
- package/controls/rich-text/markdown.d.ts +6 -0
- package/controls/rich-text/markdown.js +179 -0
- package/controls/rich-text/markdown.js.map +1 -0
- package/controls/rich-text/ops.d.ts +35 -0
- package/controls/rich-text/ops.js +314 -0
- package/controls/rich-text/ops.js.map +1 -0
- package/controls/rich-text/toolbar.d.ts +85 -0
- package/controls/rich-text/toolbar.js +338 -0
- package/controls/rich-text/toolbar.js.map +1 -0
- package/controls/scale.d.ts +56 -0
- package/controls/scale.js +563 -0
- package/controls/scale.js.map +1 -0
- package/controls/slot-register.d.ts +1 -0
- package/controls/slot-register.js +16 -0
- package/controls/slot-register.js.map +1 -0
- package/controls/slot-services.d.ts +97 -0
- package/controls/slot-services.js +38 -0
- package/controls/slot-services.js.map +1 -0
- package/controls/slot.d.ts +33 -0
- package/controls/slot.js +348 -0
- package/controls/slot.js.map +1 -0
- package/controls/table/index.d.ts +1 -0
- package/controls/table/index.js +12 -0
- package/controls/table/index.js.map +1 -0
- package/controls/table/prod.d.ts +21 -0
- package/controls/table/prod.js +79 -0
- package/controls/table/prod.js.map +1 -0
- package/controls/table/refs.d.ts +50 -0
- package/controls/table/refs.js +68 -0
- package/controls/table/refs.js.map +1 -0
- package/controls/table/stored.d.ts +15 -0
- package/controls/table/stored.js +44 -0
- package/controls/table/stored.js.map +1 -0
- package/controls/table/table-editor.d.ts +103 -0
- package/controls/table/table-editor.js +2722 -0
- package/controls/table/table-editor.js.map +1 -0
- package/controls/table/table-link.d.ts +24 -0
- package/controls/table/table-link.js +180 -0
- package/controls/table/table-link.js.map +1 -0
- package/controls/table/table.d.ts +9 -0
- package/controls/table/table.js +103 -0
- package/controls/table/table.js.map +1 -0
- package/controls/text.d.ts +17 -0
- package/controls/text.js +287 -0
- package/controls/text.js.map +1 -0
- package/engine/array.d.ts +101 -0
- package/engine/array.js +893 -0
- package/engine/array.js.map +1 -0
- package/engine/bits.d.ts +24 -0
- package/engine/bits.js +60 -0
- package/engine/bits.js.map +1 -0
- package/engine/breadcrumb.d.ts +45 -0
- package/engine/breadcrumb.js +87 -0
- package/engine/breadcrumb.js.map +1 -0
- package/engine/expand.d.ts +68 -0
- package/engine/expand.js +170 -0
- package/engine/expand.js.map +1 -0
- package/engine/field-list.d.ts +20 -0
- package/engine/field-list.js +19 -0
- package/engine/field-list.js.map +1 -0
- package/engine/field-shell.d.ts +49 -0
- package/engine/field-shell.js +860 -0
- package/engine/field-shell.js.map +1 -0
- package/engine/frame.d.ts +120 -0
- package/engine/frame.js +599 -0
- package/engine/frame.js.map +1 -0
- package/engine/group-summary.d.ts +4 -0
- package/engine/group-summary.js +66 -0
- package/engine/group-summary.js.map +1 -0
- package/engine/grouping.d.ts +224 -0
- package/engine/grouping.js +824 -0
- package/engine/grouping.js.map +1 -0
- package/engine/item-list.d.ts +89 -0
- package/engine/item-list.js +703 -0
- package/engine/item-list.js.map +1 -0
- package/engine/kit-field.d.ts +72 -0
- package/engine/kit-field.js +523 -0
- package/engine/kit-field.js.map +1 -0
- package/engine/schema-form.d.ts +91 -0
- package/engine/schema-form.js +320 -0
- package/engine/schema-form.js.map +1 -0
- package/engine/slot.d.ts +13 -0
- package/engine/slot.js +226 -0
- package/engine/slot.js.map +1 -0
- package/index.d.ts +46 -0
- package/index.js +55 -0
- package/index.js.map +1 -0
- package/kit.css +56 -0
- package/lib/cn.d.ts +4 -0
- package/lib/cn.js +53 -0
- package/lib/cn.js.map +1 -0
- package/lib/columns.d.ts +14 -0
- package/lib/columns.js +27 -0
- package/lib/columns.js.map +1 -0
- package/lib/frames.d.ts +36 -0
- package/lib/frames.js +214 -0
- package/lib/frames.js.map +1 -0
- package/lib/icons.d.ts +16 -0
- package/lib/icons.js +172 -0
- package/lib/icons.js.map +1 -0
- package/lib/path.d.ts +29 -0
- package/lib/path.js +64 -0
- package/lib/path.js.map +1 -0
- package/lib/schema.d.ts +49 -0
- package/lib/schema.js +287 -0
- package/lib/schema.js.map +1 -0
- package/lib/utils.d.ts +7 -0
- package/lib/utils.js +37 -0
- package/lib/utils.js.map +1 -0
- package/lib/validate.d.ts +20 -0
- package/lib/validate.js +150 -0
- package/lib/validate.js.map +1 -0
- package/package.json +31 -59
- package/schema/adapters.d.ts +28 -0
- package/schema/adapters.js +493 -0
- package/schema/adapters.js.map +1 -0
- package/schema/help.d.ts +25 -0
- package/schema/help.js +54 -0
- package/schema/help.js.map +1 -0
- package/schema/scale.d.ts +69 -0
- package/schema/scale.js +250 -0
- package/schema/scale.js.map +1 -0
- package/schema/sources.d.ts +103 -0
- package/schema/sources.js +65 -0
- package/schema/sources.js.map +1 -0
- package/schema/table.d.ts +319 -0
- package/schema/table.js +1198 -0
- package/schema/table.js.map +1 -0
- package/schema/types.d.ts +269 -0
- package/schema/types.js +14 -0
- package/schema/types.js.map +1 -0
- package/types.d.ts +17 -0
- package/ui/action-tray.d.ts +54 -0
- package/ui/action-tray.js +153 -0
- package/ui/action-tray.js.map +1 -0
- package/ui/button.d.ts +57 -0
- package/ui/button.js +202 -0
- package/ui/button.js.map +1 -0
- package/ui/choice-switch.d.ts +36 -0
- package/ui/choice-switch.js +57 -0
- package/ui/choice-switch.js.map +1 -0
- package/ui/controls.d.ts +83 -0
- package/ui/controls.js +319 -0
- package/ui/controls.js.map +1 -0
- package/ui/display.d.ts +156 -0
- package/ui/display.js +444 -0
- package/ui/display.js.map +1 -0
- package/ui/expanded-editor-modal.d.ts +26 -0
- package/ui/expanded-editor-modal.js +140 -0
- package/ui/expanded-editor-modal.js.map +1 -0
- package/ui/field-context.d.ts +12 -0
- package/ui/field-context.js +23 -0
- package/ui/field-context.js.map +1 -0
- package/ui/floating-panel.d.ts +152 -0
- package/ui/floating-panel.js +912 -0
- package/ui/floating-panel.js.map +1 -0
- package/ui/index.d.ts +12 -0
- package/ui/index.js +13 -0
- package/ui/input.d.ts +78 -0
- package/ui/input.js +250 -0
- package/ui/input.js.map +1 -0
- package/ui/mode-bar.d.ts +31 -0
- package/ui/mode-bar.js +65 -0
- package/ui/mode-bar.js.map +1 -0
- package/ui/overlay.d.ts +123 -0
- package/ui/overlay.js +378 -0
- package/ui/overlay.js.map +1 -0
- package/ui/path-crumbs.d.ts +90 -0
- package/ui/path-crumbs.js +532 -0
- package/ui/path-crumbs.js.map +1 -0
- package/ui/presence.d.ts +16 -0
- package/ui/presence.js +65 -0
- package/ui/presence.js.map +1 -0
- package/ui/select.d.ts +66 -0
- package/ui/select.js +405 -0
- package/ui/select.js.map +1 -0
- package/ui/shortcut-hint.d.ts +14 -0
- package/ui/shortcut-hint.js +35 -0
- package/ui/shortcut-hint.js.map +1 -0
- package/ui/surfaces.d.ts +23 -0
- package/ui/surfaces.js +26 -0
- package/ui/surfaces.js.map +1 -0
- package/ui/tooltip-root.d.ts +12 -0
- package/ui/tooltip-root.js +76 -0
- package/ui/tooltip-root.js.map +1 -0
- package/ui/variants.d.ts +15 -0
- package/ui/variants.js +14 -0
- package/ui/variants.js.map +1 -0
- package/LICENSE +0 -21
- package/README.md +0 -27
- package/dist/_chunks-cjs/_visual-editing.js +0 -5898
- package/dist/_chunks-cjs/refractor.js +0 -22
- package/dist/_chunks-es/_visual-editing.mjs +0 -5904
- package/dist/_chunks-es/refractor.mjs +0 -25
- package/dist/_color.d.mts +0 -119
- package/dist/_color.d.ts +0 -119
- package/dist/_color.js +0 -1412
- package/dist/_color.mjs +0 -1411
- package/dist/_visual-editing.d.mts +0 -1126
- package/dist/_visual-editing.d.ts +0 -1126
- package/dist/_visual-editing.js +0 -30
- package/dist/_visual-editing.mjs +0 -30
- package/dist/index.d.mts +0 -3140
- package/dist/index.d.ts +0 -3140
- package/dist/index.js +0 -2036
- package/dist/index.mjs +0 -2044
- package/dist/theme.d.mts +0 -1506
- package/dist/theme.d.ts +0 -1506
- package/dist/theme.js +0 -4126
- package/dist/theme.mjs +0 -4126
- package/exports/_visual-editing.ts +0 -31
- package/exports/index.ts +0 -1
- package/exports/theme.ts +0 -1
- package/src/color/index.d.mts +0 -119
- package/src/color/index.mjs +0 -1411
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/_compat.ts +0 -264
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
- package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
- package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
- package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
- package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
- package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
- package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/core/components/autocomplete/autocomplete.styles.tsx +0 -39
- package/src/core/components/autocomplete/autocomplete.tsx +0 -767
- package/src/core/components/autocomplete/autocompleteOption.tsx +0 -45
- package/src/core/components/autocomplete/autocompleteReducer.ts +0 -47
- package/src/core/components/autocomplete/constants.ts +0 -28
- package/src/core/components/autocomplete/index.ts +0 -2
- package/src/core/components/autocomplete/types.ts +0 -108
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +0 -18
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +0 -51
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +0 -133
- package/src/core/components/breadcrumbs/index.ts +0 -1
- package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
- package/src/core/components/dialog/__workshop__/index.ts +0 -19
- package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
- package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
- package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
- package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
- package/src/core/components/dialog/__workshop__/position.tsx +0 -30
- package/src/core/components/dialog/__workshop__/props.tsx +0 -75
- package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
- package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
- package/src/core/components/dialog/dialog.tsx +0 -430
- package/src/core/components/dialog/dialogContext.ts +0 -20
- package/src/core/components/dialog/dialogProvider.tsx +0 -35
- package/src/core/components/dialog/index.ts +0 -4
- package/src/core/components/dialog/styles.ts +0 -77
- package/src/core/components/dialog/useDialog.ts +0 -11
- package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/hotkeys/hotkeys.test.tsx +0 -42
- package/src/core/components/hotkeys/hotkeys.tsx +0 -66
- package/src/core/components/hotkeys/index.ts +0 -1
- package/src/core/components/index.ts +0 -9
- package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
- package/src/core/components/menu/__workshop__/groups.tsx +0 -156
- package/src/core/components/menu/__workshop__/index.ts +0 -89
- package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -58
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
- package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
- package/src/core/components/menu/__workshop__/tones.tsx +0 -25
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
- package/src/core/components/menu/helpers.ts +0 -82
- package/src/core/components/menu/index.ts +0 -5
- package/src/core/components/menu/menu.spacing.test.tsx +0 -63
- package/src/core/components/menu/menu.test.tsx +0 -125
- package/src/core/components/menu/menu.tsx +0 -178
- package/src/core/components/menu/menuButton.tsx +0 -268
- package/src/core/components/menu/menuContext.ts +0 -18
- package/src/core/components/menu/menuDivider.ts +0 -23
- package/src/core/components/menu/menuGroup.spacing.test.tsx +0 -63
- package/src/core/components/menu/menuGroup.tsx +0 -233
- package/src/core/components/menu/menuItem.spacing.test.tsx +0 -59
- package/src/core/components/menu/menuItem.tsx +0 -197
- package/src/core/components/menu/useMenu.ts +0 -21
- package/src/core/components/menu/useMenuController.ts +0 -231
- package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
- package/src/core/components/skeleton/__workshop__/index.ts +0 -11
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
- package/src/core/components/skeleton/index.ts +0 -2
- package/src/core/components/skeleton/skeleton.tsx +0 -57
- package/src/core/components/skeleton/styles.ts +0 -50
- package/src/core/components/skeleton/textSkeleton.tsx +0 -122
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/tab/index.ts +0 -3
- package/src/core/components/tab/tab.tsx +0 -101
- package/src/core/components/tab/tabList.test.tsx +0 -48
- package/src/core/components/tab/tabList.tsx +0 -70
- package/src/core/components/tab/tabPanel.tsx +0 -39
- package/src/core/components/toast/__workshop__/hook.tsx +0 -71
- package/src/core/components/toast/__workshop__/index.ts +0 -19
- package/src/core/components/toast/__workshop__/toast.tsx +0 -26
- package/src/core/components/toast/index.ts +0 -4
- package/src/core/components/toast/styles.ts +0 -77
- package/src/core/components/toast/toast.test.tsx +0 -101
- package/src/core/components/toast/toast.tsx +0 -198
- package/src/core/components/toast/toastContext.ts +0 -7
- package/src/core/components/toast/toastLayer.tsx +0 -51
- package/src/core/components/toast/toastProvider.tsx +0 -113
- package/src/core/components/toast/toastState.ts +0 -6
- package/src/core/components/toast/types.ts +0 -26
- package/src/core/components/toast/useToast.ts +0 -25
- package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/core/components/tree/__workshop__/basic.tsx +0 -105
- package/src/core/components/tree/__workshop__/index.ts +0 -21
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
- package/src/core/components/tree/helpers.ts +0 -105
- package/src/core/components/tree/index.ts +0 -4
- package/src/core/components/tree/style.ts +0 -105
- package/src/core/components/tree/tree.test.tsx +0 -55
- package/src/core/components/tree/tree.tsx +0 -240
- package/src/core/components/tree/treeContext.ts +0 -10
- package/src/core/components/tree/treeGroup.tsx +0 -28
- package/src/core/components/tree/treeItem.test.tsx +0 -65
- package/src/core/components/tree/treeItem.tsx +0 -224
- package/src/core/components/tree/types.ts +0 -25
- package/src/core/components/tree/useTree.ts +0 -17
- package/src/core/constants.ts +0 -79
- package/src/core/helpers/animation.ts +0 -27
- package/src/core/helpers/element.ts +0 -55
- package/src/core/helpers/focus.ts +0 -100
- package/src/core/helpers/index.ts +0 -4
- package/src/core/helpers/scroll.ts +0 -15
- package/src/core/hooks/index.ts +0 -12
- package/src/core/hooks/useArrayProp.ts +0 -17
- package/src/core/hooks/useClickOutside.test.tsx +0 -482
- package/src/core/hooks/useClickOutside.ts +0 -118
- package/src/core/hooks/useClickOutsideEvent.test.tsx +0 -115
- package/src/core/hooks/useClickOutsideEvent.ts +0 -73
- package/src/core/hooks/useCustomValidity.ts +0 -13
- package/src/core/hooks/useDelayed.test.ts +0 -88
- package/src/core/hooks/useDelayedState.ts +0 -36
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useElementRect/index.ts +0 -1
- package/src/core/hooks/useElementRect/useElementRect.ts +0 -13
- package/src/core/hooks/useElementSize.ts +0 -19
- package/src/core/hooks/useForwardedRef.ts +0 -19
- package/src/core/hooks/useGlobalKeyDown.ts +0 -24
- package/src/core/hooks/useIsomorphicEffect.ts +0 -7
- package/src/core/hooks/useMatchMedia.ts +0 -28
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/hooks/useMediaIndex/index.ts +0 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +0 -36
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +0 -102
- package/src/core/hooks/useMounted.ts +0 -15
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +0 -56
- package/src/core/hooks/usePrefersDark.test.tsx +0 -19
- package/src/core/hooks/usePrefersDark.ts +0 -16
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -56
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +0 -19
- package/src/core/hooks/usePrefersReducedMotion.ts +0 -16
- package/src/core/index.ts +0 -10
- package/src/core/lib/createGlobalScopedContext.ts +0 -36
- package/src/core/lib/globalScope.ts +0 -19
- package/src/core/lib/isRecord.ts +0 -3
- package/src/core/middleware/origin.ts +0 -47
- package/src/core/observers/elementSizeObserver.ts +0 -116
- package/src/core/observers/index.ts +0 -2
- package/src/core/observers/resizeObserver.ts +0 -9
- package/src/core/primitives/_selectable/index.ts +0 -1
- package/src/core/primitives/_selectable/selectable.tsx +0 -15
- package/src/core/primitives/_selectable/style.ts +0 -115
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
- package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
- package/src/core/primitives/avatar/avatar.tsx +0 -200
- package/src/core/primitives/avatar/avatarCounter.tsx +0 -91
- package/src/core/primitives/avatar/avatarStack.tsx +0 -100
- package/src/core/primitives/avatar/index.ts +0 -4
- package/src/core/primitives/avatar/styles.ts +0 -167
- package/src/core/primitives/avatar/types.ts +0 -17
- package/src/core/primitives/badge/__workshop__/index.ts +0 -19
- package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
- package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
- package/src/core/primitives/badge/badge.test.tsx +0 -16
- package/src/core/primitives/badge/badge.tsx +0 -70
- package/src/core/primitives/badge/index.ts +0 -1
- package/src/core/primitives/badge/styles.ts +0 -20
- package/src/core/primitives/badge/types.ts +0 -8
- package/src/core/primitives/box/__workshop__/asComponent.tsx +0 -31
- package/src/core/primitives/box/__workshop__/index.ts +0 -24
- package/src/core/primitives/box/__workshop__/props.tsx +0 -20
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
- package/src/core/primitives/box/box.test.tsx +0 -142
- package/src/core/primitives/box/box.tsx +0 -154
- package/src/core/primitives/box/index.ts +0 -1
- package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
- package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
- package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
- package/src/core/primitives/button/__workshop__/index.ts +0 -59
- package/src/core/primitives/button/__workshop__/labelUploadButton.tsx +0 -36
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
- package/src/core/primitives/button/__workshop__/props.tsx +0 -55
- package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
- package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
- package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
- package/src/core/primitives/button/button.test.tsx +0 -82
- package/src/core/primitives/button/button.tsx +0 -210
- package/src/core/primitives/button/index.ts +0 -1
- package/src/core/primitives/button/styles.ts +0 -117
- package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
- package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
- package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
- package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
- package/src/core/primitives/card/__workshop__/index.ts +0 -18
- package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
- package/src/core/primitives/card/__workshop__/props.tsx +0 -53
- package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
- package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
- package/src/core/primitives/card/card.tsx +0 -128
- package/src/core/primitives/card/index.ts +0 -2
- package/src/core/primitives/card/styles.ts +0 -147
- package/src/core/primitives/card/types.ts +0 -11
- package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
- package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
- package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
- package/src/core/primitives/checkbox/checkbox.tsx +0 -73
- package/src/core/primitives/checkbox/index.ts +0 -1
- package/src/core/primitives/checkbox/styles.ts +0 -128
- package/src/core/primitives/code/__workshop__/index.ts +0 -19
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/code/__workshop__/props.tsx +0 -21
- package/src/core/primitives/code/code.tsx +0 -55
- package/src/core/primitives/code/index.ts +0 -1
- package/src/core/primitives/code/refractor.tsx +0 -20
- package/src/core/primitives/code/styles.ts +0 -77
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/container/container.tsx +0 -54
- package/src/core/primitives/container/index.ts +0 -2
- package/src/core/primitives/container/styles.ts +0 -23
- package/src/core/primitives/container/types.ts +0 -6
- package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
- package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
- package/src/core/primitives/flex/__workshop__/index.ts +0 -11
- package/src/core/primitives/flex/flex.tsx +0 -64
- package/src/core/primitives/flex/index.ts +0 -1
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/grid/grid.test.tsx +0 -80
- package/src/core/primitives/grid/grid.tsx +0 -74
- package/src/core/primitives/grid/index.ts +0 -1
- package/src/core/primitives/heading/__workshop__/index.ts +0 -19
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/heading/heading.tsx +0 -88
- package/src/core/primitives/heading/index.ts +0 -1
- package/src/core/primitives/heading/styles.ts +0 -64
- package/src/core/primitives/heading/types.ts +0 -7
- package/src/core/primitives/index.ts +0 -27
- package/src/core/primitives/inline/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/inline/index.ts +0 -1
- package/src/core/primitives/inline/inline.test.tsx +0 -51
- package/src/core/primitives/inline/inline.tsx +0 -63
- package/src/core/primitives/inline/styles.ts +0 -32
- package/src/core/primitives/inline/types.ts +0 -6
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/kbd/index.ts +0 -1
- package/src/core/primitives/kbd/kbd.tsx +0 -69
- package/src/core/primitives/label/__workshop__/index.ts +0 -19
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
- package/src/core/primitives/label/index.ts +0 -1
- package/src/core/primitives/label/label.tsx +0 -87
- package/src/core/primitives/label/styles.ts +0 -45
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/core/primitives/popover/__workshop__/index.ts +0 -49
- package/src/core/primitives/popover/constants.ts +0 -22
- package/src/core/primitives/popover/floating-ui/size.ts +0 -99
- package/src/core/primitives/popover/helpers.ts +0 -31
- package/src/core/primitives/popover/index.ts +0 -2
- package/src/core/primitives/popover/popover.tsx +0 -511
- package/src/core/primitives/popover/popoverCard.tsx +0 -166
- package/src/core/primitives/popover/types.ts +0 -7
- package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
- package/src/core/primitives/radio/__workshop__/index.ts +0 -11
- package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
- package/src/core/primitives/radio/index.ts +0 -1
- package/src/core/primitives/radio/radio.tsx +0 -51
- package/src/core/primitives/radio/styles.ts +0 -117
- package/src/core/primitives/select/__workshop__/index.ts +0 -11
- package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
- package/src/core/primitives/select/index.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +0 -52
- package/src/core/primitives/select/select.tsx +0 -94
- package/src/core/primitives/select/styles.ts +0 -166
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/spinner/index.ts +0 -1
- package/src/core/primitives/spinner/spinner.tsx +0 -46
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/stack/index.ts +0 -1
- package/src/core/primitives/stack/stack.test.tsx +0 -57
- package/src/core/primitives/stack/stack.tsx +0 -57
- package/src/core/primitives/stack/styles.ts +0 -32
- package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
- package/src/core/primitives/switch/__workshop__/index.ts +0 -11
- package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
- package/src/core/primitives/switch/index.ts +0 -1
- package/src/core/primitives/switch/styles.ts +0 -173
- package/src/core/primitives/switch/switch.tsx +0 -68
- package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
- package/src/core/primitives/text/__workshop__/example.tsx +0 -39
- package/src/core/primitives/text/__workshop__/index.ts +0 -24
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/text/index.ts +0 -1
- package/src/core/primitives/text/styles.ts +0 -74
- package/src/core/primitives/text/text.tsx +0 -89
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textArea/index.ts +0 -1
- package/src/core/primitives/textArea/textArea.tsx +0 -120
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
- package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
- package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
- package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
- package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
- package/src/core/primitives/textInput/index.ts +0 -1
- package/src/core/primitives/textInput/textInput.test.tsx +0 -48
- package/src/core/primitives/textInput/textInput.tsx +0 -395
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
- package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
- package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
- package/src/core/primitives/tooltip/constants.ts +0 -23
- package/src/core/primitives/tooltip/index.ts +0 -2
- package/src/core/primitives/tooltip/tooltip.test.tsx +0 -452
- package/src/core/primitives/tooltip/tooltip.tsx +0 -495
- package/src/core/primitives/tooltip/tooltipCard.tsx +0 -109
- package/src/core/primitives/tooltip/tooltipDelayGroup/index.ts +0 -4
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +0 -11
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +0 -57
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +0 -10
- package/src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +0 -13
- package/src/core/primitives/types.ts +0 -179
- package/src/core/styles/border/borderStyle.ts +0 -56
- package/src/core/styles/border/index.ts +0 -2
- package/src/core/styles/border/types.ts +0 -10
- package/src/core/styles/box/boxStyle.ts +0 -69
- package/src/core/styles/box/index.ts +0 -2
- package/src/core/styles/box/types.ts +0 -11
- package/src/core/styles/card/_cardColorStyle.ts +0 -108
- package/src/core/styles/card/index.ts +0 -1
- package/src/core/styles/flex/flexItemStyle.ts +0 -27
- package/src/core/styles/flex/flexStyle.ts +0 -70
- package/src/core/styles/flex/index.ts +0 -3
- package/src/core/styles/flex/types.ts +0 -25
- package/src/core/styles/focusRing/index.ts +0 -25
- package/src/core/styles/font/codeFontStyle.ts +0 -13
- package/src/core/styles/font/headingFontStyle.ts +0 -13
- package/src/core/styles/font/index.ts +0 -6
- package/src/core/styles/font/labelFontStyle.ts +0 -13
- package/src/core/styles/font/responsiveFont.ts +0 -103
- package/src/core/styles/font/textAlignStyle.ts +0 -19
- package/src/core/styles/font/textFontStyle.ts +0 -13
- package/src/core/styles/font/types.ts +0 -35
- package/src/core/styles/grid/gridItemStyle.ts +0 -82
- package/src/core/styles/grid/gridStyle.ts +0 -108
- package/src/core/styles/grid/index.ts +0 -3
- package/src/core/styles/grid/types.ts +0 -37
- package/src/core/styles/helpers.ts +0 -72
- package/src/core/styles/index.ts +0 -5
- package/src/core/styles/input/index.ts +0 -2
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +0 -78
- package/src/core/styles/input/textInputStyle.ts +0 -263
- package/src/core/styles/internal.ts +0 -12
- package/src/core/styles/margin/index.ts +0 -2
- package/src/core/styles/margin/marginStyle.ts +0 -21
- package/src/core/styles/margin/marginsStyle.test.ts +0 -33
- package/src/core/styles/margin/types.ts +0 -9
- package/src/core/styles/padding/index.ts +0 -2
- package/src/core/styles/padding/paddingStyle.test.ts +0 -33
- package/src/core/styles/padding/paddingStyle.ts +0 -21
- package/src/core/styles/padding/types.ts +0 -12
- package/src/core/styles/radius/index.ts +0 -2
- package/src/core/styles/radius/radiusStyle.ts +0 -23
- package/src/core/styles/radius/types.ts +0 -8
- package/src/core/styles/shadow/index.ts +0 -2
- package/src/core/styles/shadow/shadowStyle.ts +0 -29
- package/src/core/styles/shadow/types.ts +0 -6
- package/src/core/styles/types.ts +0 -8
- package/src/core/theme/__workshop__/build/Root.tsx +0 -367
- package/src/core/theme/__workshop__/build/helpers.ts +0 -46
- package/src/core/theme/__workshop__/build/story.tsx +0 -465
- package/src/core/theme/__workshop__/canvas.tsx +0 -352
- package/src/core/theme/__workshop__/color.tsx +0 -62
- package/src/core/theme/__workshop__/debug/story.tsx +0 -408
- package/src/core/theme/__workshop__/index.ts +0 -39
- package/src/core/theme/__workshop__/layer.tsx +0 -78
- package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
- package/src/core/theme/index.ts +0 -5
- package/src/core/theme/theme.test.tsx +0 -73
- package/src/core/theme/themeColorProvider.tsx +0 -29
- package/src/core/theme/themeContext.ts +0 -10
- package/src/core/theme/themeProvider.tsx +0 -62
- package/src/core/theme/types.ts +0 -12
- package/src/core/theme/useRootTheme.ts +0 -17
- package/src/core/theme/useTheme.ts +0 -16
- package/src/core/types/avatar.ts +0 -14
- package/src/core/types/badge.ts +0 -12
- package/src/core/types/box.ts +0 -19
- package/src/core/types/button.ts +0 -21
- package/src/core/types/card.ts +0 -6
- package/src/core/types/component.ts +0 -32
- package/src/core/types/dialog.ts +0 -4
- package/src/core/types/flex.ts +0 -30
- package/src/core/types/grid.ts +0 -14
- package/src/core/types/gridItem.ts +0 -29
- package/src/core/types/index.ts +0 -15
- package/src/core/types/placement.ts +0 -18
- package/src/core/types/popover.ts +0 -4
- package/src/core/types/radius.ts +0 -4
- package/src/core/types/selectable.ts +0 -6
- package/src/core/types/text.ts +0 -4
- package/src/core/utils/arrow/arrow.tsx +0 -123
- package/src/core/utils/arrow/cmds.ts +0 -91
- package/src/core/utils/arrow/index.ts +0 -1
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +0 -100
- package/src/core/utils/boundaryElement/boundaryElementContext.ts +0 -7
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +0 -24
- package/src/core/utils/boundaryElement/index.ts +0 -3
- package/src/core/utils/boundaryElement/types.ts +0 -7
- package/src/core/utils/boundaryElement/useBoundaryElement.ts +0 -26
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +0 -21
- package/src/core/utils/conditionalWrapper/index.ts +0 -1
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- package/src/core/utils/elementQuery/elementQuery.tsx +0 -53
- package/src/core/utils/elementQuery/helpers.ts +0 -27
- package/src/core/utils/elementQuery/index.ts +0 -1
- package/src/core/utils/errorBoundary.tsx +0 -48
- package/src/core/utils/getElementRef.ts +0 -26
- package/src/core/utils/index.ts +0 -9
- package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
- package/src/core/utils/layer/__workshop__/index.ts +0 -24
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
- package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
- package/src/core/utils/layer/getLayerContext.test.ts +0 -30
- package/src/core/utils/layer/getLayerContext.ts +0 -21
- package/src/core/utils/layer/index.ts +0 -4
- package/src/core/utils/layer/layer.test.tsx +0 -108
- package/src/core/utils/layer/layer.tsx +0 -98
- package/src/core/utils/layer/layerContext.ts +0 -7
- package/src/core/utils/layer/layerProvider.tsx +0 -111
- package/src/core/utils/layer/types.ts +0 -9
- package/src/core/utils/layer/useLayer.ts +0 -26
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/portal/index.ts +0 -4
- package/src/core/utils/portal/portal.test.tsx +0 -103
- package/src/core/utils/portal/portal.ts +0 -32
- package/src/core/utils/portal/portalContext.ts +0 -31
- package/src/core/utils/portal/portalProvider.tsx +0 -47
- package/src/core/utils/portal/types.ts +0 -9
- package/src/core/utils/portal/usePortal.ts +0 -25
- package/src/core/utils/spanWithTextOverflow.tsx +0 -10
- package/src/core/utils/srOnly/index.ts +0 -1
- package/src/core/utils/srOnly/srOnly.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
- package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
- package/src/core/utils/virtualList/index.ts +0 -1
- package/src/core/utils/virtualList/virtualList.tsx +0 -200
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +0 -76
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +0 -54
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +0 -22
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +0 -55
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +0 -60
- package/src/theme/build/_deprecated/color/color.test.ts +0 -63
- package/src/theme/build/_deprecated/color/defaults.ts +0 -390
- package/src/theme/build/_deprecated/color/factory.ts +0 -142
- package/src/theme/build/_deprecated/color/index.ts +0 -1
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +0 -81
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +0 -54
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +0 -20
- package/src/theme/build/buildColorTheme.test.ts +0 -183
- package/src/theme/build/buildColorTheme.ts +0 -499
- package/src/theme/build/buildTheme.test.ts +0 -87
- package/src/theme/build/buildTheme.ts +0 -36
- package/src/theme/build/colorToken/colorToken.ts +0 -19
- package/src/theme/build/colorToken/compileColorToken.ts +0 -21
- package/src/theme/build/colorToken/index.ts +0 -2
- package/src/theme/build/colorToken/types.ts +0 -6
- package/src/theme/build/index.ts +0 -3
- package/src/theme/build/lib/color-fns/blend/index.ts +0 -3
- package/src/theme/build/lib/color-fns/blend/mix.ts +0 -21
- package/src/theme/build/lib/color-fns/blend/multiply.ts +0 -18
- package/src/theme/build/lib/color-fns/blend/screen.ts +0 -18
- package/src/theme/build/lib/color-fns/color-fns.test.ts +0 -68
- package/src/theme/build/lib/color-fns/contrastRatio.ts +0 -31
- package/src/theme/build/lib/color-fns/convert.ts +0 -150
- package/src/theme/build/lib/color-fns/index.ts +0 -6
- package/src/theme/build/lib/color-fns/parse.ts +0 -60
- package/src/theme/build/lib/color-fns/rgba.ts +0 -10
- package/src/theme/build/lib/color-fns/types.ts +0 -28
- package/src/theme/build/lib/isRecord.ts +0 -3
- package/src/theme/build/lib/lazy.ts +0 -30
- package/src/theme/build/lib/utils.ts +0 -19
- package/src/theme/build/merge.ts +0 -26
- package/src/theme/build/mixThemeColor.test.ts +0 -21
- package/src/theme/build/mixThemeColor.ts +0 -53
- package/src/theme/build/renderColorTheme.ts +0 -532
- package/src/theme/build/renderColorValue.ts +0 -85
- package/src/theme/build/resolveColorTokens.ts +0 -268
- package/src/theme/build/theme.test.ts +0 -27
- package/src/theme/config/helpers.ts +0 -55
- package/src/theme/config/index.ts +0 -4
- package/src/theme/config/system.ts +0 -115
- package/src/theme/config/tokens/color/index.ts +0 -1
- package/src/theme/config/tokens/color/types.ts +0 -133
- package/src/theme/config/tokens/index.ts +0 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +0 -64
- package/src/theme/config/tokens/parseTokenKey.ts +0 -67
- package/src/theme/config/tokens/parseTokenValue.test.ts +0 -42
- package/src/theme/config/tokens/parseTokenValue.ts +0 -133
- package/src/theme/config/tokens/types.ts +0 -53
- package/src/theme/config/types.ts +0 -46
- package/src/theme/defaults/colorPalette.ts +0 -5
- package/src/theme/defaults/colorTokens.ts +0 -648
- package/src/theme/defaults/config.ts +0 -84
- package/src/theme/defaults/fonts.ts +0 -227
- package/src/theme/getScopedTheme.ts +0 -98
- package/src/theme/index.ts +0 -5
- package/src/theme/system/avatar.ts +0 -14
- package/src/theme/system/color/_constants.ts +0 -45
- package/src/theme/system/color/_helpers.ts +0 -24
- package/src/theme/system/color/_system.ts +0 -40
- package/src/theme/system/color/avatar.ts +0 -15
- package/src/theme/system/color/badge.ts +0 -16
- package/src/theme/system/color/button.ts +0 -17
- package/src/theme/system/color/color.ts +0 -34
- package/src/theme/system/color/index.ts +0 -13
- package/src/theme/system/color/input.ts +0 -25
- package/src/theme/system/color/kbd.ts +0 -8
- package/src/theme/system/color/selectable.ts +0 -12
- package/src/theme/system/color/shadow.ts +0 -7
- package/src/theme/system/color/state.ts +0 -43
- package/src/theme/system/color/syntax.ts +0 -41
- package/src/theme/system/css.ts +0 -14
- package/src/theme/system/focusRing.ts +0 -7
- package/src/theme/system/font.ts +0 -52
- package/src/theme/system/index.ts +0 -11
- package/src/theme/system/input.ts +0 -33
- package/src/theme/system/layer.ts +0 -8
- package/src/theme/system/shadow.ts +0 -19
- package/src/theme/system/styles.ts +0 -13
- package/src/theme/system/theme.ts +0 -138
- package/src/theme/system/v0/avatar.ts +0 -10
- package/src/theme/system/v0/color/_generic.ts +0 -35
- package/src/theme/system/v0/color/_system.ts +0 -17
- package/src/theme/system/v0/color/base.ts +0 -21
- package/src/theme/system/v0/color/button.ts +0 -42
- package/src/theme/system/v0/color/card.ts +0 -19
- package/src/theme/system/v0/color/color.ts +0 -40
- package/src/theme/system/v0/color/index.ts +0 -11
- package/src/theme/system/v0/color/input.ts +0 -34
- package/src/theme/system/v0/color/muted.ts +0 -26
- package/src/theme/system/v0/color/selectable.ts +0 -31
- package/src/theme/system/v0/color/solid.ts +0 -26
- package/src/theme/system/v0/color/spot.ts +0 -13
- package/src/theme/system/v0/index.ts +0 -3
- package/src/theme/system/v0/input.ts +0 -23
- package/src/theme/versioning/getTheme_v2.ts +0 -57
- package/src/theme/versioning/index.ts +0 -5
- package/src/theme/versioning/is_v0.ts +0 -6
- package/src/theme/versioning/is_v2.ts +0 -6
- package/src/theme/versioning/themeColor_v0_v2.ts +0 -243
- package/src/theme/versioning/themeColor_v2_v2_9.ts +0 -49
- package/src/theme/versioning/v0_v2.ts +0 -94
- package/src/theme/versioning/v2_v0.ts +0 -135
package/schema/table.js
ADDED
|
@@ -0,0 +1,1198 @@
|
|
|
1
|
+
//#region src/kit/schema/table.ts
|
|
2
|
+
var TABLE_COLUMN_TYPES = [
|
|
3
|
+
{
|
|
4
|
+
value: "text",
|
|
5
|
+
label: "Text",
|
|
6
|
+
description: "Plain words"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
value: "number",
|
|
10
|
+
label: "Number",
|
|
11
|
+
description: "With an optional unit (kg, %, min)"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
value: "money",
|
|
15
|
+
label: "Money",
|
|
16
|
+
description: "An amount in one currency"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: "boolean",
|
|
20
|
+
label: "Yes / no",
|
|
21
|
+
description: "Written as Included / Not included"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: "rating",
|
|
25
|
+
label: "Rating",
|
|
26
|
+
description: "Out of 5"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: "link",
|
|
30
|
+
label: "Link",
|
|
31
|
+
description: "Label + URL"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: "richtext-inline",
|
|
35
|
+
label: "Rich text",
|
|
36
|
+
description: "Bold, italic, links, code"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
value: "reference",
|
|
40
|
+
label: "Reference",
|
|
41
|
+
description: "A page or entry, by id"
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* CPO D52: a table with no `table` options (a rich-text table, the Visuals Table block, a schema field without `table`) is a
|
|
46
|
+
* general table of any kind, so every setting is offered. Setting `table` on a field narrows it to that kind.
|
|
47
|
+
*/
|
|
48
|
+
var GENERAL_TABLE = {
|
|
49
|
+
jsonLd: [
|
|
50
|
+
"ItemList",
|
|
51
|
+
"Dataset",
|
|
52
|
+
"Offers"
|
|
53
|
+
],
|
|
54
|
+
settings: {
|
|
55
|
+
sort: true,
|
|
56
|
+
search: true
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var seq = 0;
|
|
60
|
+
var tkey = (p) => `${p}${Date.now().toString(36).slice(-4)}${(seq++).toString(36)}${Math.random().toString(36).slice(2, 5)}`;
|
|
61
|
+
function emptyTable(cols = 3, rows = 2) {
|
|
62
|
+
const columns = Array.from({ length: cols }, () => ({
|
|
63
|
+
_key: tkey("c"),
|
|
64
|
+
label: "",
|
|
65
|
+
type: "text"
|
|
66
|
+
}));
|
|
67
|
+
return {
|
|
68
|
+
id: tkey("tbl"),
|
|
69
|
+
caption: "",
|
|
70
|
+
headerRow: true,
|
|
71
|
+
headerColumn: false,
|
|
72
|
+
columns,
|
|
73
|
+
rows: Array.from({ length: rows }, () => ({
|
|
74
|
+
_key: tkey("r"),
|
|
75
|
+
cells: {}
|
|
76
|
+
})),
|
|
77
|
+
design: { responsive: "scroll" }
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
var isObjLike = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
81
|
+
var isCellObject = (c) => isObjLike(c) && "value" in c;
|
|
82
|
+
var isTableValue = (v) => isObjLike(v) && Array.isArray(v.columns) && Array.isArray(v.rows);
|
|
83
|
+
/** Repair anything loaded (missing keys, missing arrays) so editors and renderers can trust the shape. */
|
|
84
|
+
function normalizeTable(v) {
|
|
85
|
+
if (!isTableValue(v)) return emptyTable();
|
|
86
|
+
const used = /* @__PURE__ */ new Set();
|
|
87
|
+
const uniq = (k, p) => {
|
|
88
|
+
let key = typeof k === "string" && k ? k : tkey(p);
|
|
89
|
+
while (used.has(key)) key = tkey(p);
|
|
90
|
+
used.add(key);
|
|
91
|
+
return key;
|
|
92
|
+
};
|
|
93
|
+
const columns = v.columns.filter(isObjLike).map((c) => ({
|
|
94
|
+
...c,
|
|
95
|
+
_key: uniq(c._key, "c"),
|
|
96
|
+
label: String(c.label ?? ""),
|
|
97
|
+
type: TABLE_COLUMN_TYPES.some((t) => t.value === c.type) ? c.type : "text"
|
|
98
|
+
}));
|
|
99
|
+
const rows = v.rows.filter(isObjLike).map((r) => ({
|
|
100
|
+
...r,
|
|
101
|
+
_key: uniq(r._key, "r"),
|
|
102
|
+
cells: isObjLike(r.cells) ? r.cells : {}
|
|
103
|
+
}));
|
|
104
|
+
return {
|
|
105
|
+
...v,
|
|
106
|
+
id: typeof v.id === "string" && v.id ? v.id : tkey("tbl"),
|
|
107
|
+
caption: String(v.caption ?? ""),
|
|
108
|
+
headerRow: v.headerRow !== false,
|
|
109
|
+
headerColumn: !!v.headerColumn,
|
|
110
|
+
columns,
|
|
111
|
+
rows,
|
|
112
|
+
columnGroups: (v.columnGroups ?? []).filter(isObjLike).map((g) => ({
|
|
113
|
+
...g,
|
|
114
|
+
_key: uniq(g._key, "g")
|
|
115
|
+
})),
|
|
116
|
+
rowGroups: (v.rowGroups ?? []).filter(isObjLike).map((g) => ({
|
|
117
|
+
...g,
|
|
118
|
+
_key: uniq(g._key, "rg")
|
|
119
|
+
})),
|
|
120
|
+
footnotes: (v.footnotes ?? []).filter(isObjLike).map((f) => ({
|
|
121
|
+
...f,
|
|
122
|
+
_key: uniq(f._key, "f")
|
|
123
|
+
}))
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
var cellValue = (c) => c === void 0 ? null : isCellObject(c) ? c.value : c;
|
|
127
|
+
var cellNote = (c) => isCellObject(c) ? c.note : void 0;
|
|
128
|
+
var cellType = (col, row, c) => isCellObject(c) && c.type || row?.type || col.type;
|
|
129
|
+
/** Write a value back, keeping the cell's per-cell type and footnote. */
|
|
130
|
+
function withValue(c, value) {
|
|
131
|
+
if (isCellObject(c)) return {
|
|
132
|
+
...c,
|
|
133
|
+
value
|
|
134
|
+
};
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
var isEmptyCell = (v) => v == null || v === "" || isObjLike(v) && !("ref" in v ? v.ref : v.label || v.href);
|
|
138
|
+
var strip = (s) => s.replace(/<[^>]*>/g, "").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'/g, "'");
|
|
139
|
+
function boolLabels(col) {
|
|
140
|
+
return {
|
|
141
|
+
yes: col.trueLabel || "Included",
|
|
142
|
+
no: col.falseLabel || "Not included"
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function formatNumber(n, decimals) {
|
|
146
|
+
return new Intl.NumberFormat("en-US", decimals != null ? {
|
|
147
|
+
minimumFractionDigits: decimals,
|
|
148
|
+
maximumFractionDigits: decimals
|
|
149
|
+
} : { maximumFractionDigits: 6 }).format(n);
|
|
150
|
+
}
|
|
151
|
+
function formatMoney(n, currency = "USD", decimals) {
|
|
152
|
+
try {
|
|
153
|
+
const whole = Number.isInteger(n) && decimals == null;
|
|
154
|
+
return new Intl.NumberFormat("en-US", {
|
|
155
|
+
style: "currency",
|
|
156
|
+
currency,
|
|
157
|
+
minimumFractionDigits: whole ? 0 : decimals ?? 2,
|
|
158
|
+
maximumFractionDigits: whole ? 0 : decimals ?? 2
|
|
159
|
+
}).format(n);
|
|
160
|
+
} catch {
|
|
161
|
+
return `${formatNumber(n, decimals)} ${currency}`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
var toNumber = (v) => {
|
|
165
|
+
if (typeof v === "number") return Number.isFinite(v) ? v : null;
|
|
166
|
+
if (typeof v !== "string") return null;
|
|
167
|
+
const s = v.replace(/[,\s]/g, "").replace(/[^\d.+-]/g, "");
|
|
168
|
+
if (!s || !/^[+-]?\d*\.?\d+$/.test(s)) return null;
|
|
169
|
+
return Number(s);
|
|
170
|
+
};
|
|
171
|
+
/** The words a cell says, for Markdown, CSV, sorting, search and screen readers. Empty → "". */
|
|
172
|
+
function cellText(col, row, c, resolveRef) {
|
|
173
|
+
const v = cellValue(c);
|
|
174
|
+
if (isEmptyCell(v)) return "";
|
|
175
|
+
switch (cellType(col, row, c)) {
|
|
176
|
+
case "boolean": {
|
|
177
|
+
const b = toBool(v);
|
|
178
|
+
return b == null ? strip(String(v)) : b ? boolLabels(col).yes : boolLabels(col).no;
|
|
179
|
+
}
|
|
180
|
+
case "number": {
|
|
181
|
+
const n = toNumber(v);
|
|
182
|
+
return n == null ? strip(String(v)) : `${formatNumber(n, col.decimals)}${col.unit ? /^[%°]/.test(col.unit) ? col.unit : ` ${col.unit}` : ""}`;
|
|
183
|
+
}
|
|
184
|
+
case "money": {
|
|
185
|
+
const n = toNumber(v);
|
|
186
|
+
return n == null ? strip(String(v)) : formatMoney(n, col.currency || "USD", col.decimals);
|
|
187
|
+
}
|
|
188
|
+
case "rating": {
|
|
189
|
+
const n = toNumber(v);
|
|
190
|
+
return n == null ? strip(String(v)) : `${formatNumber(n, 1).replace(/\.0$/, "")} out of ${col.max ?? 5}`;
|
|
191
|
+
}
|
|
192
|
+
case "link": return isObjLike(v) ? String(v.label || v.href || "") : strip(String(v));
|
|
193
|
+
case "reference": {
|
|
194
|
+
if (!isObjLike(v)) return strip(String(v));
|
|
195
|
+
const r = v;
|
|
196
|
+
return resolveRef?.(r.ref)?.label ?? r.label ?? r.ref;
|
|
197
|
+
}
|
|
198
|
+
default: return isObjLike(v) ? String(v.label ?? "") : strip(String(v)).replace(/\s+/g, " ").trim();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function toBool(v) {
|
|
202
|
+
if (typeof v === "boolean") return v;
|
|
203
|
+
if (typeof v !== "string") return null;
|
|
204
|
+
const s = strip(v).trim().toLowerCase();
|
|
205
|
+
if (TRUE_WORDS.has(s)) return true;
|
|
206
|
+
if (FALSE_WORDS.has(s)) return false;
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
var TRUE_WORDS = new Set([
|
|
210
|
+
"✓",
|
|
211
|
+
"✔",
|
|
212
|
+
"✔️",
|
|
213
|
+
"☑",
|
|
214
|
+
"✅",
|
|
215
|
+
"yes",
|
|
216
|
+
"y",
|
|
217
|
+
"true",
|
|
218
|
+
"included",
|
|
219
|
+
"available",
|
|
220
|
+
"supported",
|
|
221
|
+
"x ✓",
|
|
222
|
+
"check",
|
|
223
|
+
"●"
|
|
224
|
+
]);
|
|
225
|
+
var FALSE_WORDS = new Set([
|
|
226
|
+
"✗",
|
|
227
|
+
"✕",
|
|
228
|
+
"✖",
|
|
229
|
+
"❌",
|
|
230
|
+
"×",
|
|
231
|
+
"x",
|
|
232
|
+
"no",
|
|
233
|
+
"n",
|
|
234
|
+
"false",
|
|
235
|
+
"not included",
|
|
236
|
+
"unavailable",
|
|
237
|
+
"not available",
|
|
238
|
+
"unsupported",
|
|
239
|
+
"—",
|
|
240
|
+
"–",
|
|
241
|
+
"-",
|
|
242
|
+
"○"
|
|
243
|
+
]);
|
|
244
|
+
var esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
245
|
+
var escAttr = (s) => esc(s).replace(/"/g, """);
|
|
246
|
+
var safeHref = (h) => /^\s*(javascript|vbscript|data):/i.test(h) ? "#" : h;
|
|
247
|
+
var INLINE_TAGS = new Set([
|
|
248
|
+
"strong",
|
|
249
|
+
"b",
|
|
250
|
+
"em",
|
|
251
|
+
"i",
|
|
252
|
+
"u",
|
|
253
|
+
"s",
|
|
254
|
+
"del",
|
|
255
|
+
"code",
|
|
256
|
+
"a",
|
|
257
|
+
"br",
|
|
258
|
+
"sup",
|
|
259
|
+
"sub",
|
|
260
|
+
"mark",
|
|
261
|
+
"small",
|
|
262
|
+
"abbr"
|
|
263
|
+
]);
|
|
264
|
+
/** Inline rich text in a cell: only inline marks and safe links survive (string-based, no DOM). */
|
|
265
|
+
function sanitizeInline(html) {
|
|
266
|
+
return html.replace(/<(script|style|iframe|object|embed|template)\b[\s\S]*?<\/\1>/gi, "").replace(/<\/?([a-z][a-z0-9]*)\b([^>]*)>/gi, (m, tag, attrs) => {
|
|
267
|
+
const t = tag.toLowerCase();
|
|
268
|
+
if (!INLINE_TAGS.has(t)) return "";
|
|
269
|
+
if (m.startsWith("</")) return `</${t === "b" ? "strong" : t === "i" ? "em" : t}>`;
|
|
270
|
+
if (t === "a") {
|
|
271
|
+
const href = attrs.match(/href\s*=\s*("([^"]*)"|'([^']*)')/i);
|
|
272
|
+
return `<a href="${escAttr(safeHref(href ? href[2] ?? href[3] ?? "" : ""))}">`;
|
|
273
|
+
}
|
|
274
|
+
if (t === "abbr") {
|
|
275
|
+
const title = attrs.match(/title\s*=\s*"([^"]*)"/i);
|
|
276
|
+
return title ? `<abbr title="${escAttr(title[1])}">` : "<abbr>";
|
|
277
|
+
}
|
|
278
|
+
return `<${t === "b" ? "strong" : t === "i" ? "em" : t}>`;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
var alignOf = (col, t) => col.align ?? (t === "number" || t === "money" || t === "rating" ? "end" : "start");
|
|
282
|
+
var footnoteIndex = (t) => new Map((t.footnotes ?? []).map((f, i) => [f._key, i + 1]));
|
|
283
|
+
/** Inner HTML of one cell + its typed attributes. */
|
|
284
|
+
function cellHtml(t, col, row, c, o, fn, asHeader) {
|
|
285
|
+
const v = cellValue(c);
|
|
286
|
+
const type = cellType(col, row, c);
|
|
287
|
+
const marks = o.marks !== false;
|
|
288
|
+
const typeAttr = marks && isCellObject(c) && c.type ? ` data-type="${c.type}"` : "";
|
|
289
|
+
const note = cellNote(c);
|
|
290
|
+
const n = note ? fn.get(note) : void 0;
|
|
291
|
+
const sup = n ? `<sup><a href="#${escAttr(t.id ?? "tbl")}-fn-${n}" aria-label="Note ${n}">${n}</a></sup>` : "";
|
|
292
|
+
const noteAttr = marks && note ? ` data-note="${escAttr(note)}"` : "";
|
|
293
|
+
let inner = "";
|
|
294
|
+
let valueAttr = "";
|
|
295
|
+
if (isEmptyCell(v)) {
|
|
296
|
+
inner = asHeader ? "" : `<span aria-hidden="true" class="bt-dash">—</span><span class="bt-sr">No value</span>`;
|
|
297
|
+
valueAttr = marks ? ` data-empty=""` : "";
|
|
298
|
+
} else switch (type) {
|
|
299
|
+
case "boolean": {
|
|
300
|
+
const b = toBool(v);
|
|
301
|
+
if (b == null) inner = esc(strip(String(v)));
|
|
302
|
+
else {
|
|
303
|
+
const { yes, no } = boolLabels(col);
|
|
304
|
+
inner = `<span aria-hidden="true" class="bt-bool" data-bool="${b}">${b ? "✓" : "–"}</span><span class="bt-sr">${esc(b ? yes : no)}</span>`;
|
|
305
|
+
valueAttr = marks ? ` data-value="${b}"` : "";
|
|
306
|
+
}
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
case "number":
|
|
310
|
+
case "money": {
|
|
311
|
+
const num = toNumber(v);
|
|
312
|
+
inner = esc(cellText(col, row, c));
|
|
313
|
+
if (num != null && marks) valueAttr = ` data-value="${num}"`;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
case "rating": {
|
|
317
|
+
const num = toNumber(v);
|
|
318
|
+
if (num == null) inner = esc(strip(String(v)));
|
|
319
|
+
else {
|
|
320
|
+
const max = col.max ?? 5;
|
|
321
|
+
inner = `<span aria-hidden="true" class="bt-star">★</span> ${esc(formatNumber(num, 1).replace(/\.0$/, ""))}<span class="bt-dim"> / ${max}</span>`;
|
|
322
|
+
if (marks) valueAttr = ` data-value="${num}"`;
|
|
323
|
+
}
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
case "link": {
|
|
327
|
+
const l = isObjLike(v) ? v : {
|
|
328
|
+
label: String(v),
|
|
329
|
+
href: ""
|
|
330
|
+
};
|
|
331
|
+
const rel = [l.newTab ? "noopener" : "", l.rel && l.rel !== "follow" ? l.rel : ""].filter(Boolean).join(" ");
|
|
332
|
+
inner = l.href ? `<a href="${escAttr(safeHref(l.href))}"${l.newTab ? " target=\"_blank\"" : ""}${rel ? ` rel="${rel}"` : ""}>${esc(l.label || l.href)}</a>` : esc(l.label);
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
case "reference": {
|
|
336
|
+
const r = isObjLike(v) ? v : { ref: String(v) };
|
|
337
|
+
const live = o.resolveRef?.(r.ref);
|
|
338
|
+
const label = live?.label ?? r.label ?? r.ref;
|
|
339
|
+
const href = live?.href ?? r.href;
|
|
340
|
+
inner = href ? `<a href="${escAttr(safeHref(href))}">${esc(label)}</a>` : esc(label);
|
|
341
|
+
if (marks) valueAttr = ` data-ref="${escAttr(r.ref)}"`;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case "richtext-inline":
|
|
345
|
+
inner = sanitizeInline(String(isObjLike(v) ? v.label ?? "" : v));
|
|
346
|
+
break;
|
|
347
|
+
default: inner = esc(isObjLike(v) ? String(v.label ?? "") : strip(String(v)));
|
|
348
|
+
}
|
|
349
|
+
const align = alignOf(col, type);
|
|
350
|
+
const alignAttr = align !== "start" ? ` data-align="${align}"` : "";
|
|
351
|
+
return {
|
|
352
|
+
inner: inner + sup,
|
|
353
|
+
attrs: `${typeAttr}${valueAttr}${noteAttr}${alignAttr}`
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
/** Rows in display order: body rows (ungrouped first, then each row group in its order), footer rows. */
|
|
357
|
+
function orderedRows(t) {
|
|
358
|
+
const groups = t.rowGroups ?? [];
|
|
359
|
+
const known = new Set(groups.map((g) => g._key));
|
|
360
|
+
const body = t.rows.filter((r) => !r.footer);
|
|
361
|
+
const loose = body.filter((r) => !r.group || !known.has(r.group));
|
|
362
|
+
const bodies = [];
|
|
363
|
+
if (loose.length || !groups.length) bodies.push({ rows: loose });
|
|
364
|
+
for (const g of groups) {
|
|
365
|
+
const rows = body.filter((r) => r.group === g._key);
|
|
366
|
+
if (rows.length) bodies.push({
|
|
367
|
+
group: g,
|
|
368
|
+
rows
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
bodies,
|
|
373
|
+
foot: t.rows.filter((r) => r.footer)
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
/** Sort comparator over a column (numbers numerically, booleans true first, text by locale). */
|
|
377
|
+
function sortRows(t, rows, key, dir) {
|
|
378
|
+
const col = t.columns.find((c) => c._key === key);
|
|
379
|
+
if (!col) return rows;
|
|
380
|
+
const val = (r) => {
|
|
381
|
+
const c = r.cells[key];
|
|
382
|
+
const ty = cellType(col, r, c);
|
|
383
|
+
const v = cellValue(c);
|
|
384
|
+
if (ty === "number" || ty === "money" || ty === "rating") return toNumber(v);
|
|
385
|
+
if (ty === "boolean") return toBool(v) == null ? null : toBool(v) ? 1 : 0;
|
|
386
|
+
return cellText(col, r, c).toLowerCase() || null;
|
|
387
|
+
};
|
|
388
|
+
return [...rows].sort((a, b) => {
|
|
389
|
+
const x = val(a);
|
|
390
|
+
const y = val(b);
|
|
391
|
+
if (x == null && y == null) return 0;
|
|
392
|
+
if (x == null) return 1;
|
|
393
|
+
if (y == null) return -1;
|
|
394
|
+
return (typeof x === "number" && typeof y === "number" ? x - y : String(x).localeCompare(String(y), "en", { numeric: true })) * dir;
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
/** The table as semantic HTML: <figure data-rt="table"> › <table> (caption, colgroup, thead, tbody…, tfoot) + notes. */
|
|
398
|
+
function renderTableHtml(input, o = {}) {
|
|
399
|
+
const t = normalizeTable(input);
|
|
400
|
+
const marks = o.marks !== false;
|
|
401
|
+
const id = t.id;
|
|
402
|
+
const cols = t.columns;
|
|
403
|
+
const n = cols.length;
|
|
404
|
+
const fn = footnoteIndex(t);
|
|
405
|
+
const groups = (t.columnGroups ?? []).filter((g) => cols.some((c) => c.group === g._key));
|
|
406
|
+
const describedBy = t.notes || (t.footnotes ?? []).length ? ` aria-describedby="${escAttr(id)}-notes"` : "";
|
|
407
|
+
const fig = [];
|
|
408
|
+
const figAttrs = [
|
|
409
|
+
`data-rt="table"`,
|
|
410
|
+
`data-id="${escAttr(id)}"`,
|
|
411
|
+
`class="bt-table"`,
|
|
412
|
+
marks ? `data-header-row="${t.headerRow}"` : "",
|
|
413
|
+
t.headerColumn ? `data-header-col="true"` : "",
|
|
414
|
+
`data-responsive="${t.design?.responsive ?? "scroll"}"`,
|
|
415
|
+
t.design?.sticky ? `data-sticky="true"` : "",
|
|
416
|
+
t.design?.striped ? `data-striped="true"` : "",
|
|
417
|
+
t.design?.density === "compact" ? `data-density="compact"` : "",
|
|
418
|
+
t.design?.hideCaption ? `data-caption="hidden"` : "",
|
|
419
|
+
marks && t.filterable ? `data-filter="true"` : "",
|
|
420
|
+
marks && t.jsonLd && t.jsonLd.type !== "none" ? `data-jsonld="${t.jsonLd.type}"${t.jsonLd.axis ? ` data-jsonld-axis="${t.jsonLd.axis}"` : ""}${t.jsonLd.priceRow ? ` data-jsonld-price="${escAttr(t.jsonLd.priceRow)}"` : ""}` : ""
|
|
421
|
+
].filter(Boolean);
|
|
422
|
+
fig.push(`<figure ${figAttrs.join(" ")}>`);
|
|
423
|
+
fig.push(`<div class="bt-scroll" role="region" tabindex="0" aria-labelledby="${escAttr(id)}-caption">`);
|
|
424
|
+
fig.push(`<table${describedBy}>`);
|
|
425
|
+
fig.push(`<caption id="${escAttr(id)}-caption"${t.design?.hideCaption ? ` class="bt-sr"` : ""}>${esc(t.caption || "Table")}</caption>`);
|
|
426
|
+
if (marks || groups.length) fig.push(`<colgroup>${cols.map((c) => {
|
|
427
|
+
if (!marks) return "<col>";
|
|
428
|
+
return `<col ${[
|
|
429
|
+
`data-key="${escAttr(c._key)}"`,
|
|
430
|
+
`data-type="${c.type}"`,
|
|
431
|
+
c.unit ? `data-unit="${escAttr(c.unit)}"` : "",
|
|
432
|
+
c.currency ? `data-currency="${escAttr(c.currency)}"` : "",
|
|
433
|
+
c.decimals != null ? `data-decimals="${c.decimals}"` : "",
|
|
434
|
+
c.align ? `data-align="${c.align}"` : "",
|
|
435
|
+
c.sortable ? `data-sortable="true"` : "",
|
|
436
|
+
c.group ? `data-group="${escAttr(c.group)}"` : "",
|
|
437
|
+
c.trueLabel ? `data-true="${escAttr(c.trueLabel)}"` : "",
|
|
438
|
+
c.falseLabel ? `data-false="${escAttr(c.falseLabel)}"` : "",
|
|
439
|
+
c.max != null ? `data-max="${c.max}"` : "",
|
|
440
|
+
c.refTo?.length ? `data-ref-to="${escAttr(c.refTo.join(","))}"` : "",
|
|
441
|
+
c.description ? `data-description="${escAttr(c.description)}"` : "",
|
|
442
|
+
c.highlight ? `data-highlight="true"` : ""
|
|
443
|
+
].filter(Boolean).join(" ")}>`;
|
|
444
|
+
}).join("")}</colgroup>`);
|
|
445
|
+
if (t.headerRow) {
|
|
446
|
+
fig.push("<thead>");
|
|
447
|
+
if (groups.length) {
|
|
448
|
+
const cells = [];
|
|
449
|
+
for (let i = 0; i < n;) {
|
|
450
|
+
const g = cols[i].group && groups.find((x) => x._key === cols[i].group);
|
|
451
|
+
if (!g) {
|
|
452
|
+
cells.push(`<td></td>`);
|
|
453
|
+
i++;
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
let span = 1;
|
|
457
|
+
while (i + span < n && cols[i + span].group === g._key) span++;
|
|
458
|
+
cells.push(`<th scope="colgroup"${span > 1 ? ` colspan="${span}"` : ""}${marks ? ` data-group="${escAttr(g._key)}"` : ""}>${esc(g.label)}</th>`);
|
|
459
|
+
i += span;
|
|
460
|
+
}
|
|
461
|
+
fig.push(`<tr${marks ? " data-groups" : ""}>${cells.join("")}</tr>`);
|
|
462
|
+
}
|
|
463
|
+
fig.push(`<tr>${cols.map((c, i) => {
|
|
464
|
+
const type = c.type;
|
|
465
|
+
const align = alignOf(c, type);
|
|
466
|
+
const sortable = o.interactive && c.sortable;
|
|
467
|
+
const dir = o.sort?.key === c._key ? o.sort.dir : 0;
|
|
468
|
+
const ariaSort = sortable ? ` aria-sort="${dir === 1 ? "ascending" : dir === -1 ? "descending" : "none"}"` : "";
|
|
469
|
+
if (i === 0 && t.headerColumn && !c.label.trim()) return `<td${marks ? ` data-col="${escAttr(c._key)}"` : ""}></td>`;
|
|
470
|
+
const label = esc(c.label || `Column ${i + 1}`);
|
|
471
|
+
const title = c.description ? ` title="${escAttr(c.description)}"` : "";
|
|
472
|
+
const content = sortable ? `<button type="button" class="bt-sort" data-sort-key="${escAttr(c._key)}">${label}<span aria-hidden="true" class="bt-sort-icon">${dir === 1 ? "↑" : dir === -1 ? "↓" : "↕"}</span></button>` : label;
|
|
473
|
+
return `<th scope="col"${marks ? ` data-col="${escAttr(c._key)}"` : ""}${align !== "start" ? ` data-align="${align}"` : ""}${c.highlight ? ` data-highlight="true"` : ""}${title}${ariaSort}>${content}</th>`;
|
|
474
|
+
}).join("")}</tr>`);
|
|
475
|
+
fig.push("</thead>");
|
|
476
|
+
}
|
|
477
|
+
const rowHtml = (r) => {
|
|
478
|
+
const cells = cols.map((c, i) => {
|
|
479
|
+
const asTh = t.headerColumn && i === 0;
|
|
480
|
+
const { inner, attrs } = cellHtml(t, c, r, r.cells[c._key], o, fn, asTh);
|
|
481
|
+
const label = ` data-label="${escAttr(c.label || `Column ${i + 1}`)}"${c.highlight ? ` data-highlight="true"` : ""}`;
|
|
482
|
+
return asTh ? `<th scope="row"${marks ? ` data-col="${escAttr(c._key)}"` : ""}${attrs}>${inner}</th>` : `<td${marks ? ` data-col="${escAttr(c._key)}"` : ""}${label}${attrs}>${inner}</td>`;
|
|
483
|
+
});
|
|
484
|
+
return `<tr${marks ? ` data-key="${escAttr(r._key)}"` : ""}${marks && r.type ? ` data-type="${r.type}"` : ""}${r.highlight ? ` data-highlight="true"` : ""}>${cells.join("")}</tr>`;
|
|
485
|
+
};
|
|
486
|
+
const { bodies, foot } = orderedRows(t);
|
|
487
|
+
const vis = (rows) => {
|
|
488
|
+
const kept = o.visibleRows ? rows.filter((r) => o.visibleRows.has(r._key)) : rows;
|
|
489
|
+
return o.sort ? sortRows(t, kept, o.sort.key, o.sort.dir) : kept;
|
|
490
|
+
};
|
|
491
|
+
for (const b of bodies) {
|
|
492
|
+
const rows = vis(b.rows);
|
|
493
|
+
if (b.group) {
|
|
494
|
+
fig.push(`<tbody${marks ? ` data-key="${escAttr(b.group._key)}" data-label="${escAttr(b.group.label)}"` : ""}>`);
|
|
495
|
+
fig.push(`<tr class="bt-group"${marks ? " data-group-row" : ""}><th scope="rowgroup" colspan="${n}">${esc(b.group.label)}</th></tr>`);
|
|
496
|
+
} else fig.push("<tbody>");
|
|
497
|
+
fig.push(rows.map(rowHtml).join(""));
|
|
498
|
+
fig.push("</tbody>");
|
|
499
|
+
}
|
|
500
|
+
if (foot.length) fig.push(`<tfoot>${foot.map(rowHtml).join("")}</tfoot>`);
|
|
501
|
+
fig.push("</table></div>");
|
|
502
|
+
if (t.notes || (t.footnotes ?? []).length) {
|
|
503
|
+
fig.push(`<div class="bt-notes" id="${escAttr(id)}-notes">`);
|
|
504
|
+
if (t.notes) fig.push(`<p${marks ? " data-notes" : ""}>${esc(t.notes)}</p>`);
|
|
505
|
+
if ((t.footnotes ?? []).length) fig.push(`<ol${marks ? " data-footnotes" : ""}>${t.footnotes.map((f, i) => `<li id="${escAttr(id)}-fn-${i + 1}"${marks ? ` data-key="${escAttr(f._key)}"` : ""}>${esc(f.text)}</li>`).join("")}</ol>`);
|
|
506
|
+
fig.push("</div>");
|
|
507
|
+
}
|
|
508
|
+
fig.push("</figure>");
|
|
509
|
+
const html = fig.join("");
|
|
510
|
+
return t.design?.responsive === "stack" || t.design?.responsive === "cards" ? withTableRoles(html) : html;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Stack / Cards change `display` on table parts, which makes some engines drop table semantics. The fix (Adrian
|
|
514
|
+
* Roselli, "Tables, CSS Display Properties, and ARIA") restates the SAME roles explicitly — semantics unchanged.
|
|
515
|
+
* Cell contents are sanitized inline HTML, so these tag patterns only ever match the table's own structure.
|
|
516
|
+
*/
|
|
517
|
+
function withTableRoles(html) {
|
|
518
|
+
return html.replace(/<table(?=[\s>])/, "<table role=\"table\"").replace(/<(thead|tbody|tfoot)(?=[\s>])/g, "<$1 role=\"rowgroup\"").replace(/<tr(?=[\s>])/g, "<tr role=\"row\"").replace(/<th scope="(col|colgroup)"/g, "<th role=\"columnheader\" scope=\"$1\"").replace(/<th scope="(row|rowgroup)"/g, "<th role=\"rowheader\" scope=\"$1\"").replace(/<td(?=[\s>])/g, "<td role=\"cell\"");
|
|
519
|
+
}
|
|
520
|
+
var mdCell = (s) => s.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ").trim();
|
|
521
|
+
function inlineMd(html) {
|
|
522
|
+
return strip(sanitizeInline(html).replace(/<(strong)>([\s\S]*?)<\/\1>/g, "**$2**").replace(/<(em)>([\s\S]*?)<\/\1>/g, "_$2_").replace(/<code>([\s\S]*?)<\/code>/g, "`$1`").replace(/<a href="([^"]*)">([\s\S]*?)<\/a>/g, (_m, h, l) => `[${l}](${h.replace(/&/g, "&")})`).replace(/<br>/g, " "));
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* GFM has one header row and no spans, so: column groups prefix their columns ("Sizes · Chest"), row groups become a
|
|
526
|
+
* bold label row, the caption is a bold line above, notes and footnotes follow. Booleans say their words, never ✓.
|
|
527
|
+
*/
|
|
528
|
+
function tableToMarkdown(input, o = {}) {
|
|
529
|
+
const t = normalizeTable(input);
|
|
530
|
+
const cols = t.columns;
|
|
531
|
+
if (!cols.length) return "";
|
|
532
|
+
const groups = new Map((t.columnGroups ?? []).map((g) => [g._key, g.label]));
|
|
533
|
+
const fn = footnoteIndex(t);
|
|
534
|
+
const pfx = (t.id ?? "t").replace(/[^\w-]/g, "");
|
|
535
|
+
const head = cols.map((c, i) => mdCell([c.group && groups.get(c.group), c.label || (i === 0 && t.headerColumn ? "" : `Column ${i + 1}`)].filter(Boolean).join(" · ")) || " ");
|
|
536
|
+
const sep = cols.map((c) => alignOf(c, c.type) === "end" ? "---:" : alignOf(c, c.type) === "center" ? ":---:" : "---");
|
|
537
|
+
const line = (cells) => `| ${cells.join(" | ")} |`;
|
|
538
|
+
const row = (r) => line(cols.map((c, i) => {
|
|
539
|
+
const cell = r.cells[c._key];
|
|
540
|
+
const v = cellValue(cell);
|
|
541
|
+
const ty = cellType(c, r, cell);
|
|
542
|
+
let s = ty === "richtext-inline" && typeof v === "string" ? inlineMd(v) : cellText(c, r, cell, o.resolveRef);
|
|
543
|
+
if (ty === "link" && isObjLike(v) && v.href) s = `[${s}](${o.abs ? o.abs(v.href) : v.href})`;
|
|
544
|
+
if (ty === "reference" && isObjLike(v)) {
|
|
545
|
+
const href = o.resolveRef?.(v.ref)?.href ?? v.href;
|
|
546
|
+
if (href) s = `[${s}](${o.abs ? o.abs(href) : href})`;
|
|
547
|
+
}
|
|
548
|
+
if (!s && !(t.headerColumn && i === 0)) s = "—";
|
|
549
|
+
if (t.headerColumn && i === 0 && s) s = `**${s}**`;
|
|
550
|
+
const note = cellNote(cell);
|
|
551
|
+
if (note && fn.get(note)) s += `[^${pfx}-${fn.get(note)}]`;
|
|
552
|
+
return mdCell(s) || " ";
|
|
553
|
+
}));
|
|
554
|
+
const out = [];
|
|
555
|
+
out.push(`**${mdCell(t.caption || "Table")}**`, "");
|
|
556
|
+
out.push(line(head), line(sep));
|
|
557
|
+
const { bodies, foot } = orderedRows(t);
|
|
558
|
+
for (const b of bodies) {
|
|
559
|
+
if (b.group) out.push(line([`**${mdCell(b.group.label)}**`, ...cols.slice(1).map(() => " ")]));
|
|
560
|
+
b.rows.forEach((r) => out.push(row(r)));
|
|
561
|
+
}
|
|
562
|
+
foot.forEach((r) => out.push(row(r)));
|
|
563
|
+
const after = [];
|
|
564
|
+
if (t.notes) after.push(t.notes);
|
|
565
|
+
const described = cols.filter((c) => c.description);
|
|
566
|
+
if (described.length) after.push(described.map((c) => `${c.label}: ${c.description}`).join(". ") + ".");
|
|
567
|
+
if ((t.footnotes ?? []).length) after.push(t.footnotes.map((f, i) => `[^${pfx}-${i + 1}]: ${f.text}`).join("\n"));
|
|
568
|
+
return [out.join("\n"), ...after].join("\n\n");
|
|
569
|
+
}
|
|
570
|
+
/** RFC 4180 parser; the delimiter is a tab when the text has one (Excel / Sheets copy), else `;` or `,` by count. */
|
|
571
|
+
function parseDelimited(text, delim) {
|
|
572
|
+
const src = text.replace(/\r\n?/g, "\n").replace(/\n+$/, "");
|
|
573
|
+
if (!src.trim()) return [];
|
|
574
|
+
const firstLine = src.split("\n")[0];
|
|
575
|
+
const d = delim ?? (firstLine.includes(" ") ? " " : (firstLine.match(/;/g)?.length ?? 0) > (firstLine.match(/,/g)?.length ?? 0) ? ";" : ",");
|
|
576
|
+
const rows = [];
|
|
577
|
+
let row = [];
|
|
578
|
+
let cell = "";
|
|
579
|
+
let q = false;
|
|
580
|
+
for (let i = 0; i < src.length; i++) {
|
|
581
|
+
const ch = src[i];
|
|
582
|
+
if (q) if (ch === "\"" && src[i + 1] === "\"") {
|
|
583
|
+
cell += "\"";
|
|
584
|
+
i++;
|
|
585
|
+
} else if (ch === "\"") q = false;
|
|
586
|
+
else cell += ch;
|
|
587
|
+
else if (ch === "\"" && cell === "") q = true;
|
|
588
|
+
else if (ch === d) {
|
|
589
|
+
row.push(cell);
|
|
590
|
+
cell = "";
|
|
591
|
+
} else if (ch === "\n") {
|
|
592
|
+
row.push(cell);
|
|
593
|
+
rows.push(row);
|
|
594
|
+
row = [];
|
|
595
|
+
cell = "";
|
|
596
|
+
} else cell += ch;
|
|
597
|
+
}
|
|
598
|
+
row.push(cell);
|
|
599
|
+
rows.push(row);
|
|
600
|
+
const w = Math.max(...rows.map((r) => r.length));
|
|
601
|
+
return rows.map((r) => [...r.map((c) => c.trim()), ...Array(w - r.length).fill("")]);
|
|
602
|
+
}
|
|
603
|
+
function toDelimited(rows, delim = ",") {
|
|
604
|
+
return rows.map((r) => r.map((c) => /[",\n\t;]/.test(c) ? `"${c.replace(/"/g, "\"\"")}"` : c).join(delim)).join("\n");
|
|
605
|
+
}
|
|
606
|
+
/** Header + body rows as text (CSV export, "Copy as CSV"). */
|
|
607
|
+
function tableToRows(input, resolveRef) {
|
|
608
|
+
const t = normalizeTable(input);
|
|
609
|
+
const { bodies, foot } = orderedRows(t);
|
|
610
|
+
const all = [...bodies.flatMap((b) => b.rows), ...foot];
|
|
611
|
+
return [t.columns.map((c) => c.label), ...all.map((r) => t.columns.map((c) => cellText(c, r, r.cells[c._key], resolveRef)))];
|
|
612
|
+
}
|
|
613
|
+
var CURRENCY = {
|
|
614
|
+
$: "USD",
|
|
615
|
+
"€": "EUR",
|
|
616
|
+
"£": "GBP",
|
|
617
|
+
"¥": "JPY",
|
|
618
|
+
"₹": "INR",
|
|
619
|
+
"A$": "AUD",
|
|
620
|
+
"C$": "CAD",
|
|
621
|
+
"CHF": "CHF"
|
|
622
|
+
};
|
|
623
|
+
var MONEY_RX = /^(A\$|C\$|CHF|[$€£¥₹])\s?-?[\d,]*\.?\d+$|^-?[\d,]*\.?\d+\s?(USD|EUR|GBP|JPY|INR|AUD|CAD|CHF)$/i;
|
|
624
|
+
var NUM_RX = /^([+-]?[\d,]*\.?\d+)\s?([a-zA-Z%°][a-zA-Z%°²³/]*)?$/;
|
|
625
|
+
var RATING_RX = /^(\d(?:\.\d)?)\s?(?:\/\s?(5|10)|★|stars?|out of (5|10))$/i;
|
|
626
|
+
/** Look at a column's non-empty values and pick the narrowest type every value fits. */
|
|
627
|
+
function inferColumn(values) {
|
|
628
|
+
const vs = values.map((v) => v.trim()).filter(Boolean);
|
|
629
|
+
if (!vs.length) return { type: "text" };
|
|
630
|
+
const txt = vs.map((v) => strip(v).trim());
|
|
631
|
+
if (txt.every((v) => toBool(v) != null) && txt.some((v) => toBool(v) === true)) return { type: "boolean" };
|
|
632
|
+
if (txt.every((v) => MONEY_RX.test(v))) {
|
|
633
|
+
const sym = txt[0].match(/^(A\$|C\$|CHF|[$€£¥₹])/)?.[1] ?? txt[0].match(/(USD|EUR|GBP|JPY|INR|AUD|CAD|CHF)$/i)?.[1]?.toUpperCase();
|
|
634
|
+
const cur = sym ? CURRENCY[sym] ?? sym : "USD";
|
|
635
|
+
if (txt.every((v) => (v.match(/^(A\$|C\$|CHF|[$€£¥₹])/)?.[1] ?? v.match(/(USD|EUR|GBP|JPY|INR|AUD|CAD|CHF)$/i)?.[1]?.toUpperCase()) === sym)) return {
|
|
636
|
+
type: "money",
|
|
637
|
+
currency: cur
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
const rating = txt.map((v) => v.match(RATING_RX));
|
|
641
|
+
if (rating.every(Boolean)) return {
|
|
642
|
+
type: "rating",
|
|
643
|
+
max: Number(rating[0][2] || rating[0][3] || 5)
|
|
644
|
+
};
|
|
645
|
+
const nums = txt.map((v) => v.match(NUM_RX));
|
|
646
|
+
if (nums.every(Boolean)) {
|
|
647
|
+
const units = new Set(nums.map((m) => m[2] ?? ""));
|
|
648
|
+
if (units.size === 1) return {
|
|
649
|
+
type: "number",
|
|
650
|
+
...[...units][0] ? { unit: [...units][0] } : {}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
if (vs.every((v) => /^<a\s[^>]*href=/i.test(v) && /<\/a>\s*$/i.test(v) && (v.match(/<a\s/gi)?.length ?? 0) === 1)) return { type: "link" };
|
|
654
|
+
if (vs.some((v) => /<(strong|b|em|i|a|code|sup|sub|br)\b/i.test(v))) return { type: "richtext-inline" };
|
|
655
|
+
return { type: "text" };
|
|
656
|
+
}
|
|
657
|
+
/** A raw string (CSV / paste / HTML cell) → a value of `type`. */
|
|
658
|
+
function coerce(raw, col) {
|
|
659
|
+
const s = raw.trim();
|
|
660
|
+
const plain = strip(s).trim();
|
|
661
|
+
if (!plain && col.type !== "richtext-inline") return null;
|
|
662
|
+
switch (col.type) {
|
|
663
|
+
case "boolean": return toBool(plain) ?? plain;
|
|
664
|
+
case "number":
|
|
665
|
+
case "money": return toNumber(plain.replace(/(USD|EUR|GBP|JPY|INR|AUD|CAD|CHF)$/i, "")) ?? plain;
|
|
666
|
+
case "rating": {
|
|
667
|
+
const m = plain.match(/(\d+(?:\.\d+)?)/);
|
|
668
|
+
return m ? Number(m[1]) : plain;
|
|
669
|
+
}
|
|
670
|
+
case "link": {
|
|
671
|
+
const m = s.match(/<a\s[^>]*href\s*=\s*"([^"]*)"[^>]*>([\s\S]*?)<\/a>/i);
|
|
672
|
+
if (m) return {
|
|
673
|
+
label: strip(m[2]).trim(),
|
|
674
|
+
href: m[1].replace(/&/g, "&")
|
|
675
|
+
};
|
|
676
|
+
return /^(https?:|\/|mailto:)/.test(plain) ? {
|
|
677
|
+
label: plain,
|
|
678
|
+
href: plain
|
|
679
|
+
} : {
|
|
680
|
+
label: plain,
|
|
681
|
+
href: ""
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
case "richtext-inline": return sanitizeInline(s);
|
|
685
|
+
default: return plain;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
/** Text rows (CSV, TSV, a pasted range) → a table. `header`: first row holds the column labels. */
|
|
689
|
+
function tableFromRows(rows, opts = {}) {
|
|
690
|
+
const header = opts.header ?? true;
|
|
691
|
+
const width = Math.max(1, ...rows.map((r) => r.length));
|
|
692
|
+
const labels = header ? rows[0] ?? [] : [];
|
|
693
|
+
const body = header ? rows.slice(1) : rows;
|
|
694
|
+
const columns = Array.from({ length: width }, (_, i) => {
|
|
695
|
+
const inf = inferColumn(body.map((r) => r[i] ?? ""));
|
|
696
|
+
return {
|
|
697
|
+
_key: tkey("c"),
|
|
698
|
+
label: strip(labels[i] ?? "").trim(),
|
|
699
|
+
...inf
|
|
700
|
+
};
|
|
701
|
+
});
|
|
702
|
+
const out = emptyTable(0, 0);
|
|
703
|
+
out.caption = opts.caption ?? "";
|
|
704
|
+
out.columns = columns;
|
|
705
|
+
out.headerColumn = header && !!rows.length && !strip(labels[0] ?? "").trim() && columns[0]?.type === "text" && width > 1;
|
|
706
|
+
out.rows = body.filter((r) => r.some((c) => c.trim())).map((r) => ({
|
|
707
|
+
_key: tkey("r"),
|
|
708
|
+
cells: Object.fromEntries(columns.map((c, i) => [c._key, coerce(r[i] ?? "", c)]))
|
|
709
|
+
}));
|
|
710
|
+
return out;
|
|
711
|
+
}
|
|
712
|
+
/** Paste a text range into a table at (row, col), growing rows / columns as needed. Values coerce to column types. */
|
|
713
|
+
function pasteRange(input, at, grid, opts = {}) {
|
|
714
|
+
const t = normalizeTable(input);
|
|
715
|
+
const columns = [...t.columns];
|
|
716
|
+
const rows = t.rows.map((r) => ({
|
|
717
|
+
...r,
|
|
718
|
+
cells: { ...r.cells }
|
|
719
|
+
}));
|
|
720
|
+
let r0 = at.row;
|
|
721
|
+
let g = grid;
|
|
722
|
+
if (r0 < 0) {
|
|
723
|
+
(g[0] ?? []).forEach((l, j) => {
|
|
724
|
+
const ci = at.col + j;
|
|
725
|
+
if (ci >= columns.length) {
|
|
726
|
+
if (opts.lockColumns) return;
|
|
727
|
+
columns.push({
|
|
728
|
+
_key: tkey("c"),
|
|
729
|
+
label: "",
|
|
730
|
+
type: "text"
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
columns[ci] = {
|
|
734
|
+
...columns[ci],
|
|
735
|
+
label: strip(l).trim()
|
|
736
|
+
};
|
|
737
|
+
});
|
|
738
|
+
g = g.slice(1);
|
|
739
|
+
r0 = 0;
|
|
740
|
+
}
|
|
741
|
+
const need = at.col + Math.max(0, ...g.map((r) => r.length));
|
|
742
|
+
while (!opts.lockColumns && columns.length < need) columns.push({
|
|
743
|
+
_key: tkey("c"),
|
|
744
|
+
label: "",
|
|
745
|
+
type: "text"
|
|
746
|
+
});
|
|
747
|
+
g.forEach((line, i) => {
|
|
748
|
+
const ri = r0 + i;
|
|
749
|
+
while (rows.length <= ri) rows.push({
|
|
750
|
+
_key: tkey("r"),
|
|
751
|
+
cells: {}
|
|
752
|
+
});
|
|
753
|
+
line.forEach((raw, j) => {
|
|
754
|
+
const col = columns[at.col + j];
|
|
755
|
+
if (!col) return;
|
|
756
|
+
rows[ri].cells[col._key] = withValue(rows[ri].cells[col._key], coerce(raw, {
|
|
757
|
+
type: cellType(col, rows[ri], rows[ri].cells[col._key]),
|
|
758
|
+
max: col.max
|
|
759
|
+
}));
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
return {
|
|
763
|
+
...t,
|
|
764
|
+
columns,
|
|
765
|
+
rows
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Read a DOM <table> (or our <figure data-rt="table">) into the model. Our own data-* marks round-trip losslessly;
|
|
770
|
+
* any other table is inferred: header rows from thead / th, row headers from tbody th[scope=row] or a th first cell,
|
|
771
|
+
* caption from <caption> / figcaption / aria-label, groups from thead colspans and multiple <tbody> / rowgroup rows,
|
|
772
|
+
* footer from <tfoot>, types from cell text (✓/✗ → boolean, $ → money, 4.5/5 → rating), footnote marks kept as notes.
|
|
773
|
+
* Body cells with colspan/rowspan are expanded (copied) — the model has no merged body cells.
|
|
774
|
+
*/
|
|
775
|
+
function parseTableElement(el) {
|
|
776
|
+
const fig = el.matches("figure") ? el : el.closest("figure[data-rt=table]");
|
|
777
|
+
const table = el.matches("table") ? el : el.querySelector("table");
|
|
778
|
+
const out = emptyTable(0, 0);
|
|
779
|
+
if (!table) return emptyTable();
|
|
780
|
+
const ds = fig?.dataset ?? {};
|
|
781
|
+
out.id = ds.id || out.id;
|
|
782
|
+
out.caption = (table.querySelector(":scope > caption")?.textContent ?? fig?.querySelector(":scope > figcaption")?.textContent ?? table.getAttribute("aria-label") ?? "").trim();
|
|
783
|
+
out.notes = (fig?.querySelector("[data-notes]")?.textContent ?? "").trim() || void 0;
|
|
784
|
+
out.footnotes = Array.from(fig?.querySelectorAll("[data-footnotes] > li") ?? []).map((li) => ({
|
|
785
|
+
_key: li.dataset.key || tkey("f"),
|
|
786
|
+
text: (li.textContent ?? "").trim()
|
|
787
|
+
}));
|
|
788
|
+
if (!out.footnotes.length) delete out.footnotes;
|
|
789
|
+
const fnByIndex = new Map((out.footnotes ?? []).map((f, i) => [i + 1, f._key]));
|
|
790
|
+
if (ds.responsive === "stack" || ds.responsive === "cards") out.design = {
|
|
791
|
+
...out.design,
|
|
792
|
+
responsive: ds.responsive
|
|
793
|
+
};
|
|
794
|
+
if (ds.sticky === "true") out.design = {
|
|
795
|
+
...out.design,
|
|
796
|
+
sticky: true
|
|
797
|
+
};
|
|
798
|
+
if (ds.striped === "true") out.design = {
|
|
799
|
+
...out.design,
|
|
800
|
+
striped: true
|
|
801
|
+
};
|
|
802
|
+
if (ds.density === "compact") out.design = {
|
|
803
|
+
...out.design,
|
|
804
|
+
density: "compact"
|
|
805
|
+
};
|
|
806
|
+
if (ds.caption === "hidden") out.design = {
|
|
807
|
+
...out.design,
|
|
808
|
+
hideCaption: true
|
|
809
|
+
};
|
|
810
|
+
if (ds.filter === "true") out.filterable = true;
|
|
811
|
+
if (ds.jsonld) out.jsonLd = {
|
|
812
|
+
type: ds.jsonld,
|
|
813
|
+
...ds.jsonldAxis ? { axis: ds.jsonldAxis } : {},
|
|
814
|
+
...ds.jsonldPrice ? { priceRow: ds.jsonldPrice } : {}
|
|
815
|
+
};
|
|
816
|
+
const expand = (trs) => {
|
|
817
|
+
const grid = [];
|
|
818
|
+
trs.forEach((tr, ri) => {
|
|
819
|
+
grid[ri] ??= [];
|
|
820
|
+
let ci = 0;
|
|
821
|
+
for (const c of Array.from(tr.cells)) {
|
|
822
|
+
while (grid[ri][ci]) ci++;
|
|
823
|
+
const cs = Math.max(1, Math.min(50, c.colSpan || 1));
|
|
824
|
+
const rs = Math.max(1, Math.min(200, c.rowSpan || 1));
|
|
825
|
+
for (let dr = 0; dr < rs; dr++) for (let dc = 0; dc < cs; dc++) {
|
|
826
|
+
grid[ri + dr] ??= [];
|
|
827
|
+
grid[ri + dr][ci + dc] = {
|
|
828
|
+
el: c,
|
|
829
|
+
th: c.tagName === "TH",
|
|
830
|
+
origin: dr === 0 && dc === 0
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
ci += cs;
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
return grid;
|
|
837
|
+
};
|
|
838
|
+
const theadRows = Array.from(table.tHead?.rows ?? []);
|
|
839
|
+
const bodies = Array.from(table.tBodies);
|
|
840
|
+
const footRows = Array.from(table.tFoot?.rows ?? []);
|
|
841
|
+
let bodyRows = bodies.flatMap((b) => Array.from(b.rows).map((tr) => ({
|
|
842
|
+
tr,
|
|
843
|
+
body: b
|
|
844
|
+
})));
|
|
845
|
+
const head = [...theadRows];
|
|
846
|
+
if (!head.length) while (bodyRows.length && Array.from(bodyRows[0].tr.cells).every((c) => c.tagName === "TH") && bodyRows[0].tr.cells.length > 1) {
|
|
847
|
+
head.push(bodyRows[0].tr);
|
|
848
|
+
bodyRows = bodyRows.slice(1);
|
|
849
|
+
}
|
|
850
|
+
const hgrid = expand(head);
|
|
851
|
+
const width = Math.max(1, ...hgrid.map((r) => r.length), ...expand(bodyRows.map((b) => b.tr)).map((r) => r.length));
|
|
852
|
+
out.headerRow = head.length > 0;
|
|
853
|
+
const cols = Array.from(table.querySelectorAll(":scope > colgroup > col"));
|
|
854
|
+
const lastHead = hgrid[hgrid.length - 1] ?? [];
|
|
855
|
+
const columns = Array.from({ length: width }, (_, i) => {
|
|
856
|
+
const d = cols[i]?.dataset ?? {};
|
|
857
|
+
const hc = lastHead[i]?.el;
|
|
858
|
+
const label = hc ? cleanText(hc) : "";
|
|
859
|
+
const c = {
|
|
860
|
+
_key: d.key || hc?.dataset?.col || tkey("c"),
|
|
861
|
+
label,
|
|
862
|
+
type: d.type || "text"
|
|
863
|
+
};
|
|
864
|
+
if (d.unit) c.unit = d.unit;
|
|
865
|
+
if (d.currency) c.currency = d.currency;
|
|
866
|
+
if (d.decimals) c.decimals = Number(d.decimals);
|
|
867
|
+
if (d.align) c.align = d.align;
|
|
868
|
+
if (d.sortable === "true") c.sortable = true;
|
|
869
|
+
if (d.true) c.trueLabel = d.true;
|
|
870
|
+
if (d.false) c.falseLabel = d.false;
|
|
871
|
+
if (d.max) c.max = Number(d.max);
|
|
872
|
+
if (d.refTo) c.refTo = d.refTo.split(",");
|
|
873
|
+
if (d.highlight === "true") c.highlight = true;
|
|
874
|
+
if (d.description) c.description = d.description;
|
|
875
|
+
else if (hc?.getAttribute("title")) c.description = hc.getAttribute("title");
|
|
876
|
+
return c;
|
|
877
|
+
});
|
|
878
|
+
if (hgrid.length > 1) {
|
|
879
|
+
const top = hgrid[0];
|
|
880
|
+
const groups = [];
|
|
881
|
+
for (let i = 0; i < width;) {
|
|
882
|
+
const cell = top[i];
|
|
883
|
+
let span = 1;
|
|
884
|
+
while (cell && i + span < width && top[i + span]?.el === cell.el) span++;
|
|
885
|
+
const text = cell && cell.el !== lastHead[i]?.el ? cleanText(cell.el) : "";
|
|
886
|
+
if (text) {
|
|
887
|
+
const key = cell.el.dataset.group || tkey("g");
|
|
888
|
+
groups.push({
|
|
889
|
+
_key: key,
|
|
890
|
+
label: text
|
|
891
|
+
});
|
|
892
|
+
for (let k = 0; k < span; k++) columns[i + k].group = key;
|
|
893
|
+
}
|
|
894
|
+
i += span;
|
|
895
|
+
}
|
|
896
|
+
if (groups.length) out.columnGroups = groups;
|
|
897
|
+
}
|
|
898
|
+
const rowGroups = [];
|
|
899
|
+
const known = !!cols.length && cols.some((c) => c.dataset.type);
|
|
900
|
+
const rawRows = [];
|
|
901
|
+
let currentGroup;
|
|
902
|
+
let lastBody = null;
|
|
903
|
+
const bgrid = expand(bodyRows.map((b) => b.tr));
|
|
904
|
+
bodyRows.forEach(({ tr, body }, ri) => {
|
|
905
|
+
if (body !== lastBody) {
|
|
906
|
+
lastBody = body;
|
|
907
|
+
const label = body.dataset.label;
|
|
908
|
+
currentGroup = label ? body.dataset.key || tkey("rg") : void 0;
|
|
909
|
+
if (label && currentGroup) rowGroups.push({
|
|
910
|
+
_key: currentGroup,
|
|
911
|
+
label
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
const cells = bgrid[ri] ?? [];
|
|
915
|
+
if (tr.cells.length === 1 && (tr.cells[0].colSpan >= width || tr.cells[0].getAttribute("scope") === "rowgroup") || tr.hasAttribute("data-group-row")) {
|
|
916
|
+
if (!(tr.hasAttribute("data-group-row") && body.dataset.label)) {
|
|
917
|
+
currentGroup = tkey("rg");
|
|
918
|
+
rowGroups.push({
|
|
919
|
+
_key: currentGroup,
|
|
920
|
+
label: cleanText(tr.cells[0])
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
rawRows.push({
|
|
926
|
+
key: tr.dataset.key || tkey("r"),
|
|
927
|
+
group: currentGroup,
|
|
928
|
+
type: tr.dataset.type || void 0,
|
|
929
|
+
highlight: tr.dataset.highlight === "true",
|
|
930
|
+
cells
|
|
931
|
+
});
|
|
932
|
+
});
|
|
933
|
+
expand(footRows).forEach((cells, i) => rawRows.push({
|
|
934
|
+
key: footRows[i].dataset.key || tkey("r"),
|
|
935
|
+
footer: true,
|
|
936
|
+
cells
|
|
937
|
+
}));
|
|
938
|
+
out.headerColumn = ds.headerCol === "true" || rawRows.length > 0 && rawRows.every((r) => r.cells[0]?.th && r.cells[0].el.getAttribute("scope") !== "col");
|
|
939
|
+
if (!known) columns.forEach((c, i) => {
|
|
940
|
+
if (out.headerColumn && i === 0) return;
|
|
941
|
+
const inf = inferColumn(rawRows.map((r) => r.cells[i] ? cellSource(r.cells[i].el) : ""));
|
|
942
|
+
Object.assign(c, inf);
|
|
943
|
+
});
|
|
944
|
+
out.columns = columns;
|
|
945
|
+
out.rows = rawRows.map((r) => ({
|
|
946
|
+
_key: r.key,
|
|
947
|
+
...r.group ? { group: r.group } : {},
|
|
948
|
+
...r.footer ? { footer: true } : {},
|
|
949
|
+
...r.type ? { type: r.type } : {},
|
|
950
|
+
...r.highlight ? { highlight: true } : {},
|
|
951
|
+
cells: Object.fromEntries(columns.map((c, i) => {
|
|
952
|
+
const cell = r.cells[i];
|
|
953
|
+
if (!cell) return [c._key, null];
|
|
954
|
+
return [c._key, readCell(cell.el, c, r.type, fnByIndex)];
|
|
955
|
+
}))
|
|
956
|
+
}));
|
|
957
|
+
if (rowGroups.length) out.rowGroups = rowGroups;
|
|
958
|
+
return out;
|
|
959
|
+
}
|
|
960
|
+
/** Visible text of a header/cell minus visually-hidden helpers and footnote marks. */
|
|
961
|
+
function cleanText(el) {
|
|
962
|
+
const c = el.cloneNode(true);
|
|
963
|
+
c.querySelectorAll("sup, .bt-sort-icon, [aria-hidden=true]").forEach((n) => n.remove());
|
|
964
|
+
return (c.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
965
|
+
}
|
|
966
|
+
/** A cell's source for inference: inner HTML minus footnote marks, decorative icons and sr helpers kept as words. */
|
|
967
|
+
function cellSource(el) {
|
|
968
|
+
const c = el.cloneNode(true);
|
|
969
|
+
c.querySelectorAll("sup").forEach((n) => n.remove());
|
|
970
|
+
const sr = c.querySelector(".bt-sr, .sr-only, .visually-hidden, .screen-reader-text");
|
|
971
|
+
if (sr && !(c.textContent ?? "").replace(sr.textContent ?? "", "").replace(/[✓✔✗✕–—\s]/g, "")) return (sr.textContent ?? "").trim();
|
|
972
|
+
const labelled = c.querySelector("[aria-label]");
|
|
973
|
+
if (labelled && !(c.textContent ?? "").trim()) return labelled.getAttribute("aria-label") ?? "";
|
|
974
|
+
const img = c.querySelector("img[alt]");
|
|
975
|
+
if (img && !(c.textContent ?? "").trim()) return img.getAttribute("alt") ?? "";
|
|
976
|
+
c.querySelectorAll("[aria-hidden=true]").forEach((n) => n.remove());
|
|
977
|
+
const html = c.innerHTML.trim();
|
|
978
|
+
return /<(a|strong|b|em|i|code|br)\b/i.test(html) ? html : (c.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
979
|
+
}
|
|
980
|
+
function readCell(el, col, rowType, fn) {
|
|
981
|
+
const d = el.dataset;
|
|
982
|
+
const type = d.type || rowType || col.type;
|
|
983
|
+
let value;
|
|
984
|
+
if (d.empty != null) value = null;
|
|
985
|
+
else if (d.ref) value = {
|
|
986
|
+
ref: d.ref,
|
|
987
|
+
label: cleanText(el) || void 0,
|
|
988
|
+
href: el.querySelector("a")?.getAttribute("href") ?? void 0
|
|
989
|
+
};
|
|
990
|
+
else if (d.value != null && (type === "boolean" || type === "number" || type === "money" || type === "rating")) value = type === "boolean" ? d.value === "true" : Number(d.value);
|
|
991
|
+
else if (type === "richtext-inline") {
|
|
992
|
+
const c = el.cloneNode(true);
|
|
993
|
+
c.querySelectorAll("sup").forEach((n) => n.remove());
|
|
994
|
+
value = sanitizeInline(c.innerHTML.trim());
|
|
995
|
+
} else value = coerce(cellSource(el), {
|
|
996
|
+
type,
|
|
997
|
+
max: col.max
|
|
998
|
+
});
|
|
999
|
+
const supN = Number(el.querySelector("sup a, sup")?.textContent?.trim());
|
|
1000
|
+
const note = d.note || (supN ? fn.get(supN) : void 0);
|
|
1001
|
+
if (d.type || note) return {
|
|
1002
|
+
value,
|
|
1003
|
+
...d.type ? { type: d.type } : {},
|
|
1004
|
+
...note ? { note } : {}
|
|
1005
|
+
};
|
|
1006
|
+
return value;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Dataset — a report or spec table (name = caption, description = notes, variableMeasured = columns).
|
|
1010
|
+
* ItemList — a comparison: the things compared (row headers, or column labels) in order.
|
|
1011
|
+
* Offers — a pricing matrix: one Offer per plan (columns), price from the money row `priceRow`.
|
|
1012
|
+
* Returns null when the table can't honestly support the type (no caption, no items, no prices).
|
|
1013
|
+
*/
|
|
1014
|
+
function tableJsonLd(input, o = {}) {
|
|
1015
|
+
const t = normalizeTable(input);
|
|
1016
|
+
const kind = t.jsonLd?.type ?? "none";
|
|
1017
|
+
if (kind === "none" || !t.caption.trim()) return null;
|
|
1018
|
+
const body = t.rows.filter((r) => !r.footer);
|
|
1019
|
+
if (kind === "Dataset") return {
|
|
1020
|
+
"@context": "https://schema.org",
|
|
1021
|
+
"@type": "Dataset",
|
|
1022
|
+
name: t.caption,
|
|
1023
|
+
description: t.notes || t.caption,
|
|
1024
|
+
...o.url ? { url: o.url } : {},
|
|
1025
|
+
variableMeasured: t.columns.filter((_c, i) => !(t.headerColumn && i === 0)).map((c) => ({
|
|
1026
|
+
"@type": "PropertyValue",
|
|
1027
|
+
name: c.label,
|
|
1028
|
+
...c.unit ? { unitText: c.unit } : {},
|
|
1029
|
+
...c.description ? { description: c.description } : {}
|
|
1030
|
+
}))
|
|
1031
|
+
};
|
|
1032
|
+
const axis = t.jsonLd?.axis ?? "rows";
|
|
1033
|
+
if (kind === "ItemList") {
|
|
1034
|
+
const items = (axis === "rows" ? body.map((r) => cellText(t.columns[0], r, r.cells[t.columns[0]._key], o.resolveRef)) : t.columns.slice(t.headerColumn ? 1 : 0).map((c) => c.label)).filter(Boolean);
|
|
1035
|
+
if (!items.length) return null;
|
|
1036
|
+
return {
|
|
1037
|
+
"@context": "https://schema.org",
|
|
1038
|
+
"@type": "ItemList",
|
|
1039
|
+
name: t.caption,
|
|
1040
|
+
numberOfItems: items.length,
|
|
1041
|
+
itemListElement: items.map((name, i) => ({
|
|
1042
|
+
"@type": "ListItem",
|
|
1043
|
+
position: i + 1,
|
|
1044
|
+
name
|
|
1045
|
+
}))
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
const priceRow = t.rows.find((r) => r._key === t.jsonLd?.priceRow) ?? body.find((r) => t.columns.some((c) => cellType(c, r, r.cells[c._key]) === "money"));
|
|
1049
|
+
if (!priceRow) return null;
|
|
1050
|
+
const offers = t.columns.slice(t.headerColumn ? 1 : 0).map((c) => {
|
|
1051
|
+
const cell = priceRow.cells[c._key];
|
|
1052
|
+
const n = toNumber(cellValue(cell));
|
|
1053
|
+
return n == null ? null : {
|
|
1054
|
+
"@type": "Offer",
|
|
1055
|
+
name: c.label,
|
|
1056
|
+
price: n,
|
|
1057
|
+
priceCurrency: c.currency || "USD",
|
|
1058
|
+
...o.url ? { url: o.url } : {}
|
|
1059
|
+
};
|
|
1060
|
+
}).filter(Boolean);
|
|
1061
|
+
if (!offers.length) return null;
|
|
1062
|
+
const prices = offers.map((x) => x.price);
|
|
1063
|
+
return {
|
|
1064
|
+
"@context": "https://schema.org",
|
|
1065
|
+
"@type": "Product",
|
|
1066
|
+
name: t.caption,
|
|
1067
|
+
...t.notes ? { description: t.notes } : {},
|
|
1068
|
+
offers: {
|
|
1069
|
+
"@type": "AggregateOffer",
|
|
1070
|
+
lowPrice: Math.min(...prices),
|
|
1071
|
+
highPrice: Math.max(...prices),
|
|
1072
|
+
priceCurrency: offers[0].priceCurrency,
|
|
1073
|
+
offerCount: offers.length,
|
|
1074
|
+
offers
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
function tableIssues(input, opts = {}) {
|
|
1079
|
+
if (!isTableValue(input)) return [];
|
|
1080
|
+
const t = input;
|
|
1081
|
+
const out = [];
|
|
1082
|
+
if (!t.caption?.trim() && opts.requireCaption !== false) out.push({
|
|
1083
|
+
level: "error",
|
|
1084
|
+
message: "Give the table a title that says what it compares.",
|
|
1085
|
+
at: "caption"
|
|
1086
|
+
});
|
|
1087
|
+
if (!t.headerRow) out.push({
|
|
1088
|
+
level: "warning",
|
|
1089
|
+
message: "Show the column names: turn on Show column names in Table settings."
|
|
1090
|
+
});
|
|
1091
|
+
if (t.headerRow) {
|
|
1092
|
+
const empty = t.columns.filter((c, i) => !c.label.trim() && !(t.headerColumn && i === 0));
|
|
1093
|
+
if (empty.length) out.push({
|
|
1094
|
+
level: "error",
|
|
1095
|
+
message: `Name ${empty.length === 1 ? "the empty column" : `the ${empty.length} empty columns`}.`,
|
|
1096
|
+
at: `col:${empty[0]._key}`
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1100
|
+
for (const c of t.columns) {
|
|
1101
|
+
if (keys.has(c._key)) out.push({
|
|
1102
|
+
level: "error",
|
|
1103
|
+
message: "Two columns are the same column. Delete one and add it again.",
|
|
1104
|
+
at: `col:${c._key}`
|
|
1105
|
+
});
|
|
1106
|
+
keys.add(c._key);
|
|
1107
|
+
}
|
|
1108
|
+
if (opts.maxColumns && t.columns.length > opts.maxColumns) out.push({
|
|
1109
|
+
level: "error",
|
|
1110
|
+
message: `Use at most ${opts.maxColumns} columns.`
|
|
1111
|
+
});
|
|
1112
|
+
const body = t.rows.filter((r) => !r.footer);
|
|
1113
|
+
if (opts.minRows && body.length < opts.minRows) out.push({
|
|
1114
|
+
level: "error",
|
|
1115
|
+
message: `Add at least ${opts.minRows} rows.`
|
|
1116
|
+
});
|
|
1117
|
+
if (opts.maxRows && body.length > opts.maxRows) out.push({
|
|
1118
|
+
level: "error",
|
|
1119
|
+
message: `Use at most ${opts.maxRows} rows.`
|
|
1120
|
+
});
|
|
1121
|
+
let mismatch = null;
|
|
1122
|
+
let mismatches = 0;
|
|
1123
|
+
for (const r of t.rows) for (const c of t.columns) {
|
|
1124
|
+
const cell = r.cells?.[c._key];
|
|
1125
|
+
const v = cellValue(cell);
|
|
1126
|
+
if (isEmptyCell(v)) continue;
|
|
1127
|
+
const ty = cellType(c, r, cell);
|
|
1128
|
+
if ((ty === "number" || ty === "money" || ty === "rating") && toNumber(v) == null || ty === "boolean" && toBool(v) == null) {
|
|
1129
|
+
mismatches++;
|
|
1130
|
+
mismatch ??= {
|
|
1131
|
+
row: r._key,
|
|
1132
|
+
col: c._key,
|
|
1133
|
+
label: c.label
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
if (mismatch) out.push({
|
|
1138
|
+
level: "warning",
|
|
1139
|
+
message: `${mismatches} ${mismatches === 1 ? "cell doesn't" : "cells don't"} match the column type (first in “${mismatch.label || "a column"}”). Change the column type or set the cell's own type.`,
|
|
1140
|
+
at: `cell:${mismatch.row}:${mismatch.col}`
|
|
1141
|
+
});
|
|
1142
|
+
if (t.headerColumn && body.some((r) => isEmptyCell(cellValue(r.cells?.[t.columns[0]?._key])))) out.push({
|
|
1143
|
+
level: "warning",
|
|
1144
|
+
message: "Every row needs a name in the first column."
|
|
1145
|
+
});
|
|
1146
|
+
if (t.jsonLd?.type === "Dataset" && (t.notes ?? "").length < 50) out.push({
|
|
1147
|
+
level: "warning",
|
|
1148
|
+
message: "To be read as a data report, write a note under the table (a sentence or two)."
|
|
1149
|
+
});
|
|
1150
|
+
if (t.jsonLd?.type === "Offers" && !tableJsonLd(t)) out.push({
|
|
1151
|
+
level: "warning",
|
|
1152
|
+
message: "To be read as a price list, add a row of prices, one per plan column."
|
|
1153
|
+
});
|
|
1154
|
+
if (t.columns.length > 8 && t.design?.responsive !== "scroll") out.push({
|
|
1155
|
+
level: "warning",
|
|
1156
|
+
message: "More than 8 columns don't fit on phones as a list. In Table settings, set On phones to Scroll."
|
|
1157
|
+
});
|
|
1158
|
+
return out;
|
|
1159
|
+
}
|
|
1160
|
+
/** "4 rows × 3 columns" (array rows, summaries, breadcrumbs). */
|
|
1161
|
+
function tableSummary(v) {
|
|
1162
|
+
if (!isTableValue(v)) return "";
|
|
1163
|
+
const r = v.rows.length;
|
|
1164
|
+
const c = v.columns.length;
|
|
1165
|
+
return [v.caption?.trim(), `${r} ${r === 1 ? "row" : "rows"} × ${c} ${c === 1 ? "column" : "columns"}`].filter(Boolean).join(" · ");
|
|
1166
|
+
}
|
|
1167
|
+
/** Build a table in code (seed data, Kit Library, migrations): header labels + rows of display strings. */
|
|
1168
|
+
function tableFrom(caption, columns, rows, extra = {}) {
|
|
1169
|
+
const cols = columns.map((c, i) => ({
|
|
1170
|
+
type: "text",
|
|
1171
|
+
...c,
|
|
1172
|
+
_key: c._key ?? `c${i + 1}`
|
|
1173
|
+
}));
|
|
1174
|
+
return {
|
|
1175
|
+
id: extra.id ?? `tbl_${caption.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 32).replace(/-$/, "")}`,
|
|
1176
|
+
caption,
|
|
1177
|
+
headerRow: true,
|
|
1178
|
+
headerColumn: false,
|
|
1179
|
+
design: { responsive: "scroll" },
|
|
1180
|
+
...extra,
|
|
1181
|
+
columns: cols,
|
|
1182
|
+
rows: rows.map((r, ri) => {
|
|
1183
|
+
const def = Array.isArray(r) ? { cells: r } : r;
|
|
1184
|
+
return {
|
|
1185
|
+
_key: `r${ri + 1}`,
|
|
1186
|
+
...def.group ? { group: def.group } : {},
|
|
1187
|
+
...def.footer ? { footer: true } : {},
|
|
1188
|
+
...def.type ? { type: def.type } : {},
|
|
1189
|
+
...def.highlight ? { highlight: true } : {},
|
|
1190
|
+
cells: Object.fromEntries(cols.map((c, ci) => [c._key, def.cells[ci] ?? null]))
|
|
1191
|
+
};
|
|
1192
|
+
})
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
//#endregion
|
|
1196
|
+
export { GENERAL_TABLE, TABLE_COLUMN_TYPES, boolLabels, cellNote, cellText, cellType, cellValue, coerce, emptyTable, formatMoney, formatNumber, inferColumn, isCellObject, isEmptyCell, isObjLike, isTableValue, normalizeTable, orderedRows, parseDelimited, parseTableElement, pasteRange, renderTableHtml, sanitizeInline, sortRows, tableFrom, tableFromRows, tableIssues, tableJsonLd, tableSummary, tableToMarkdown, tableToRows, tkey, toBool, toDelimited, toNumber, withValue };
|
|
1197
|
+
|
|
1198
|
+
//# sourceMappingURL=table.js.map
|