@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
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import { cellText, cellValue, emptyTable, isCellObject, isObjLike, normalizeTable, parseTableElement, tkey } from "../../schema/table.js";
|
|
2
|
+
//#region src/kit/controls/rich-text/dom.ts
|
|
3
|
+
/**
|
|
4
|
+
* RICH TEXT · DOM layer (V2 HEAD controls/rich-text/dom.ts). The field value is clean, semantic HTML; rich blocks are
|
|
5
|
+
* "islands" while editing.
|
|
6
|
+
*
|
|
7
|
+
* Live DOM = the HTML, with every rich block swapped for a `div[data-rt-island="kind"]` (contenteditable=false) that
|
|
8
|
+
* React renders into through a portal. The island's model lives on the element (`el.__rt`).
|
|
9
|
+
* Stored = `serialize()` swaps each island back for its static HTML (`renderStatic`). The static form is the markup
|
|
10
|
+
* production's own renderer writes for the same block, so the host's ingest reads it back as that block.
|
|
11
|
+
* Loading = `hydrate()` turns that markup back into islands, so a re-mount restores them.
|
|
12
|
+
*
|
|
13
|
+
* Only the blocks production stores are islands here. Each one's markup is what the host's codec renders the stored
|
|
14
|
+
* block as and reads back (features/dock-v2/richTextCodec.ts); `data-extra` carries, opaque, whatever of the stored block
|
|
15
|
+
* the editor does not edit, so nothing it holds is dropped by an edit elsewhere.
|
|
16
|
+
* image `bcmsBlock` builtin:image: address, alt text, caption, alignment, size, link
|
|
17
|
+
* (`<figure data-rt="image" data-align data-size><a href><img src alt></a><figcaption>`)
|
|
18
|
+
* table production's Portable Text table (rows of cells, a header row, header cells, and the V2 table's caption,
|
|
19
|
+
* note, row groups and column groups), drawn with the kit's table editor (V2 TableBlock), stored as the markup
|
|
20
|
+
* production's renderer writes (`<caption>`, `th[scope=colgroup data-group]`, a `<tbody data-key>` per row
|
|
21
|
+
* group under a `th[scope=rowgroup]` row, `<figure data-rt="table">…<p data-notes>` for the note; footnotes
|
|
22
|
+
* fold into the note as `[1] …`, as production's ingest folds V2's). A cell's closing
|
|
23
|
+
* footnote markers (`<sup data-footnote>`) ride the cell as written (`marks`). A table whose cells hold
|
|
24
|
+
* other inline formatting the table value has no place for (a term, bold) is not an island: it stays
|
|
25
|
+
* markup in the body, edited in place, so the formatting survives.
|
|
26
|
+
* pullquote V2 article block (CPO D55), `<figure data-rt="pullquote">` → a `pullQuote` block.
|
|
27
|
+
* takeaways V2 article block (CPO D55), `<aside data-rt="takeaways"><p data-title>…<ul><li>…` → a `keyTakeaways` block
|
|
28
|
+
* {title?, points} (written in the text itself, V2 TakeawaysEditor).
|
|
29
|
+
* callout `bcmsBlock` builtin:callout {tone, title, message}: `<div data-rt="callout" data-callout><p data-title>…
|
|
30
|
+
* <div data-body><p>…` (the message is plain text: paragraphs and line breaks)
|
|
31
|
+
* toggle `bcmsBlock` builtin:toggle {title, body}: `<details data-rt="toggle"><summary>…<div data-body><p>…`
|
|
32
|
+
* video the `video` block {src, title}: `<div data-rt="video" data-url data-title>`
|
|
33
|
+
* file the `file` block {src, name, size}: `<div data-rt="file" data-url data-name data-size>`
|
|
34
|
+
* component `bcmsBlock` "component" {componentId, overrides, variant} (CPO D28): `<div data-rt="component" data-ref
|
|
35
|
+
* data-id data-name data-overrides data-variant>` — a linked instance of a project component, shown as a card.
|
|
36
|
+
* A separate copy (V2 instances.ts `detach`) adds {detached, props, blocks, sourcePublishedAt}:
|
|
37
|
+
* `data-detached="true" data-props data-blocks data-source-published-at`, and carries no overrides.
|
|
38
|
+
* A key the stored block holds is an attribute or element that is present; a key it lacks is absent, so an untouched
|
|
39
|
+
* block reads back exactly as stored.
|
|
40
|
+
* V2's gallery, embed, columns, footnotes, contents, related posts and author bio have no stored form in
|
|
41
|
+
* production and are not offered.
|
|
42
|
+
*/
|
|
43
|
+
var esc = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
44
|
+
var escAttr = (s) => esc(s).replace(/"/g, """);
|
|
45
|
+
var seq = 0;
|
|
46
|
+
var rid = (p = "r") => `${p}${Date.now().toString(36)}${(seq++).toString(36)}`;
|
|
47
|
+
var IMAGE_ALIGNS = [
|
|
48
|
+
"full",
|
|
49
|
+
"center",
|
|
50
|
+
"left",
|
|
51
|
+
"right"
|
|
52
|
+
];
|
|
53
|
+
var IMAGE_SIZES = [
|
|
54
|
+
"s",
|
|
55
|
+
"m",
|
|
56
|
+
"l",
|
|
57
|
+
"full"
|
|
58
|
+
];
|
|
59
|
+
var CALLOUT_TONES = [
|
|
60
|
+
"info",
|
|
61
|
+
"tip",
|
|
62
|
+
"warning"
|
|
63
|
+
];
|
|
64
|
+
var ISLAND_KINDS = [
|
|
65
|
+
"image",
|
|
66
|
+
"table",
|
|
67
|
+
"pullquote",
|
|
68
|
+
"takeaways",
|
|
69
|
+
"callout",
|
|
70
|
+
"toggle",
|
|
71
|
+
"video",
|
|
72
|
+
"file",
|
|
73
|
+
"component"
|
|
74
|
+
];
|
|
75
|
+
function defaultModel(kind, extra) {
|
|
76
|
+
const base = {
|
|
77
|
+
image: () => ({
|
|
78
|
+
src: "",
|
|
79
|
+
alt: ""
|
|
80
|
+
}),
|
|
81
|
+
table: () => emptyTable(3, 2),
|
|
82
|
+
pullquote: () => ({
|
|
83
|
+
quote: "",
|
|
84
|
+
name: "",
|
|
85
|
+
role: "",
|
|
86
|
+
link: ""
|
|
87
|
+
}),
|
|
88
|
+
takeaways: () => ({
|
|
89
|
+
title: "Key takeaways",
|
|
90
|
+
points: [""]
|
|
91
|
+
}),
|
|
92
|
+
callout: () => ({
|
|
93
|
+
tone: "info",
|
|
94
|
+
title: "",
|
|
95
|
+
body: ""
|
|
96
|
+
}),
|
|
97
|
+
toggle: () => ({
|
|
98
|
+
title: "",
|
|
99
|
+
body: ""
|
|
100
|
+
}),
|
|
101
|
+
video: () => ({ url: "" }),
|
|
102
|
+
file: () => ({
|
|
103
|
+
url: "",
|
|
104
|
+
name: ""
|
|
105
|
+
}),
|
|
106
|
+
component: () => ({
|
|
107
|
+
id: rid("ci"),
|
|
108
|
+
overrides: "{}"
|
|
109
|
+
})
|
|
110
|
+
};
|
|
111
|
+
if (kind === "table") return {
|
|
112
|
+
...base.table(),
|
|
113
|
+
...extra ?? {},
|
|
114
|
+
id: tkey("tbl")
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
...base[kind](),
|
|
118
|
+
...extra ?? {}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Deep copy (Duplicate). A copied table or component instance gets its own id. */
|
|
122
|
+
var cloneModel = (kind, m) => {
|
|
123
|
+
const c = JSON.parse(JSON.stringify(m));
|
|
124
|
+
if (kind === "table") c.id = tkey("tbl");
|
|
125
|
+
if (kind === "component") c.id = rid("ci");
|
|
126
|
+
return c;
|
|
127
|
+
};
|
|
128
|
+
/** "a\nb\n\nc" → `<p>a<br>b</p><p>c</p>`. Split on exactly one blank line, so any text reads back as written. */
|
|
129
|
+
var textToParas = (s) => s.split("\n\n").map((p) => `<p>${esc(p).replace(/\n/g, "<br>")}</p>`).join("");
|
|
130
|
+
/** The inverse of textToParas: each paragraph's text, its line breaks kept. */
|
|
131
|
+
function parasToText(el) {
|
|
132
|
+
const ps = Array.from(el.children).filter((c) => c.tagName === "P");
|
|
133
|
+
const text = (n) => {
|
|
134
|
+
const c = n.cloneNode(true);
|
|
135
|
+
c.querySelectorAll("br").forEach((br) => br.replaceWith("\n"));
|
|
136
|
+
return (c.textContent ?? "").replace(/\u200b/g, "");
|
|
137
|
+
};
|
|
138
|
+
return ps.length ? ps.map(text).join("\n\n") : text(el);
|
|
139
|
+
}
|
|
140
|
+
/** An image is `<figure><img src alt></figure>`: production's renderer writes exactly this, and its ingest reads it. */
|
|
141
|
+
var xAttr = (extra) => extra ? ` data-extra="${escAttr(extra)}"` : "";
|
|
142
|
+
var attr = (name, v) => v === void 0 ? "" : ` ${name}="${escAttr(String(v))}"`;
|
|
143
|
+
function renderStatic(kind, model) {
|
|
144
|
+
switch (kind) {
|
|
145
|
+
case "image": {
|
|
146
|
+
const m = model;
|
|
147
|
+
const img = m.src ? `<img src="${escAttr(m.src)}"${attr("alt", m.alt)}>` : "";
|
|
148
|
+
const linked = img && m.href !== void 0 ? `<a href="${escAttr(m.href)}">${img}</a>` : img;
|
|
149
|
+
const cap = m.caption !== void 0 ? `<figcaption>${esc(m.caption)}</figcaption>` : "";
|
|
150
|
+
return `<figure data-rt="image"${attr("data-align", m.align)}${attr("data-size", m.size)}${xAttr(m.extra)}>${linked}${cap}</figure>`;
|
|
151
|
+
}
|
|
152
|
+
case "table": return renderStoredTable(model);
|
|
153
|
+
case "pullquote": {
|
|
154
|
+
const m = model;
|
|
155
|
+
const name = m.name ? m.link ? `<a href="${escAttr(m.link)}" data-name>${esc(m.name)}</a>` : `<span data-name>${esc(m.name)}</span>` : "";
|
|
156
|
+
const role = m.role ? `<span data-role>${esc(m.role)}</span>` : "";
|
|
157
|
+
const cap = name || role ? `<figcaption>${name}${name && role ? ", " : ""}${role}</figcaption>` : "";
|
|
158
|
+
return `<figure data-rt="pullquote"><blockquote${m.link ? ` cite="${escAttr(m.link)}"` : ""}><p>${esc(m.quote)}</p></blockquote>${cap}</figure>`;
|
|
159
|
+
}
|
|
160
|
+
case "takeaways": {
|
|
161
|
+
const m = model;
|
|
162
|
+
const pts = m.points.map((p) => p.trim()).filter(Boolean);
|
|
163
|
+
return `<aside data-rt="takeaways">${m.title ? `<p data-title>${esc(m.title)}</p>` : ""}<ul>${pts.map((p) => `<li>${esc(p)}</li>`).join("")}</ul></aside>`;
|
|
164
|
+
}
|
|
165
|
+
case "callout": {
|
|
166
|
+
const m = model;
|
|
167
|
+
const title = m.title !== void 0 ? `<p data-title="true">${esc(m.title)}</p>` : "";
|
|
168
|
+
const body = m.body !== void 0 ? `<div data-body="true">${textToParas(m.body)}</div>` : "";
|
|
169
|
+
return `<div data-rt="callout"${attr("data-callout", m.tone)}${xAttr(m.extra)}>${title}${body}</div>`;
|
|
170
|
+
}
|
|
171
|
+
case "toggle": {
|
|
172
|
+
const m = model;
|
|
173
|
+
const title = m.title !== void 0 ? `<summary>${esc(m.title)}</summary>` : "";
|
|
174
|
+
const body = m.body !== void 0 ? `<div data-body="true">${textToParas(m.body)}</div>` : "";
|
|
175
|
+
return `<details data-rt="toggle"${xAttr(m.extra)}>${title}${body}</details>`;
|
|
176
|
+
}
|
|
177
|
+
case "video": {
|
|
178
|
+
const m = model;
|
|
179
|
+
return `<div data-rt="video"${attr("data-url", m.url)}${attr("data-title", m.title)}${xAttr(m.extra)}>${m.url ? `<a href="${escAttr(m.url)}">${esc(m.title || m.url)}</a>` : ""}</div>`;
|
|
180
|
+
}
|
|
181
|
+
case "file": {
|
|
182
|
+
const m = model;
|
|
183
|
+
const link = m.url && m.name ? `<a href="${escAttr(m.url)}" download>${esc(m.name)}</a>` : "";
|
|
184
|
+
return `<div data-rt="file"${attr("data-url", m.url)}${attr("data-name", m.name)}${attr("data-size", m.size)}${xAttr(m.extra)}>${link}</div>`;
|
|
185
|
+
}
|
|
186
|
+
case "component": {
|
|
187
|
+
const m = model;
|
|
188
|
+
const label = m.name || "Component";
|
|
189
|
+
const copy = m.detached ? ` data-detached="true"${attr("data-props", m.props)}${attr("data-blocks", m.blocks)}${attr("data-source-published-at", m.sourcePublishedAt)}` : "";
|
|
190
|
+
return `<div data-rt="component"${attr("data-ref", m.ref)} data-id="${escAttr(m.id)}"${attr("data-name", m.name)}${attr("data-overrides", m.overrides)}${attr("data-variant", m.variant)}${copy}${xAttr(m.extra)}>⧉ ${esc(label)} · ${m.detached ? "detached copy" : "component"}</div>`;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
var words = (el) => (el?.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
195
|
+
var scopeIs = (c, scope) => c.tagName === "TH" && (c.getAttribute("scope") ?? "").toLowerCase() === scope;
|
|
196
|
+
/** In `<thead>`: a `th[scope=colgroup]`, every other cell an empty `<td>`. A site's own two-row header stays rows. */
|
|
197
|
+
var isColumnGroupRow = (tr) => tr.parentElement?.tagName === "THEAD" && Array.from(tr.cells).some((c) => scopeIs(c, "colgroup")) && Array.from(tr.cells).every((c) => scopeIs(c, "colgroup") || c.tagName === "TD" && !words(c));
|
|
198
|
+
/**
|
|
199
|
+
* One `th[scope=rowgroup]` and nothing else, OPENING its own `<tbody>` with a body row after it (what production and
|
|
200
|
+
* V2 write). A site's own `scope=rowgroup` row anywhere else stays a row, as production's ingest keeps it.
|
|
201
|
+
*/
|
|
202
|
+
var isRowGroupRow = (tr) => {
|
|
203
|
+
const body = tr.parentElement;
|
|
204
|
+
if (tr.cells.length !== 1 || !scopeIs(tr.cells[0], "rowgroup") || body?.tagName !== "TBODY") return false;
|
|
205
|
+
const rows = Array.from(body.children).filter((r) => r.tagName === "TR");
|
|
206
|
+
return rows[0] === tr && rows.length > 1;
|
|
207
|
+
};
|
|
208
|
+
var KEY = /^[A-Za-z0-9-]{1,32}$/;
|
|
209
|
+
/**
|
|
210
|
+
* Production's table markup → the table value, cell for cell (renderStoredTable's inverse): the plain `<table>`, or
|
|
211
|
+
* the `<figure data-rt="table">` around one with its note. The V2 reader (parseTableElement) is not used here: it reads
|
|
212
|
+
* a one-column row as a row-group heading and a caption-less grid by guesses that a stored table never meant.
|
|
213
|
+
*/
|
|
214
|
+
function parseStoredTable(src) {
|
|
215
|
+
const fig = src.tagName === "FIGURE" ? src : null;
|
|
216
|
+
const table = fig ? fig.querySelector(":scope > table") : src;
|
|
217
|
+
const t = emptyTable(0, 0);
|
|
218
|
+
const trs = Array.from(table.querySelectorAll(":scope > thead > tr, :scope > tbody > tr, :scope > tfoot > tr, :scope > tr"));
|
|
219
|
+
const groupRow = trs.find(isColumnGroupRow);
|
|
220
|
+
const grid = trs.filter((tr) => tr !== groupRow && !isRowGroupRow(tr));
|
|
221
|
+
const head = grid.filter((tr) => tr.parentElement?.tagName === "THEAD");
|
|
222
|
+
const body = grid.filter((tr) => tr.parentElement?.tagName !== "THEAD");
|
|
223
|
+
const width = Math.max(1, ...grid.map((tr) => tr.cells.length));
|
|
224
|
+
const headCells = head.length ? Array.from(head[head.length - 1].cells) : [];
|
|
225
|
+
t.headerRow = head.length > 0;
|
|
226
|
+
t.headerColumn = body.length > 0 && body.every((tr) => tr.cells[0]?.tagName === "TH");
|
|
227
|
+
t.caption = words(table.querySelector(":scope > caption"));
|
|
228
|
+
t.columns = Array.from({ length: width }, (_, i) => ({
|
|
229
|
+
_key: tkey("c"),
|
|
230
|
+
label: words(headCells[i]),
|
|
231
|
+
type: "text"
|
|
232
|
+
}));
|
|
233
|
+
const cellOf = (cell) => {
|
|
234
|
+
if (!cell) return "";
|
|
235
|
+
const { rest: c, marks } = splitMarks(cell);
|
|
236
|
+
const text = words(c);
|
|
237
|
+
const a = c.children.length === 1 && c.firstElementChild?.tagName === "A" && c.firstElementChild.textContent?.trim() === text ? c.firstElementChild : null;
|
|
238
|
+
const value = a ? {
|
|
239
|
+
label: text,
|
|
240
|
+
href: a.getAttribute("href") ?? ""
|
|
241
|
+
} : text;
|
|
242
|
+
return marks ? {
|
|
243
|
+
value,
|
|
244
|
+
marks
|
|
245
|
+
} : value;
|
|
246
|
+
};
|
|
247
|
+
const groupOf = (list, own, prefix, label) => {
|
|
248
|
+
const k = (own ?? "").trim();
|
|
249
|
+
const found = k ? list.find((g) => g._key === k) : void 0;
|
|
250
|
+
if (found) return found;
|
|
251
|
+
const g = {
|
|
252
|
+
_key: k && k.length <= 64 && !list.some((x) => x._key === k) ? k : tkey(prefix),
|
|
253
|
+
label
|
|
254
|
+
};
|
|
255
|
+
list.push(g);
|
|
256
|
+
return g;
|
|
257
|
+
};
|
|
258
|
+
if (groupRow) {
|
|
259
|
+
const groups = [];
|
|
260
|
+
let at = 0;
|
|
261
|
+
for (const c of Array.from(groupRow.cells)) {
|
|
262
|
+
const span = Math.max(1, c.colSpan || 1);
|
|
263
|
+
if (c.tagName === "TH") {
|
|
264
|
+
const g = groupOf(groups, c.getAttribute("data-group"), "g", words(c));
|
|
265
|
+
for (let i = at; i < at + span && i < width; i++) t.columns[i].group = g._key;
|
|
266
|
+
}
|
|
267
|
+
at += span;
|
|
268
|
+
}
|
|
269
|
+
t.columnGroups = groups;
|
|
270
|
+
}
|
|
271
|
+
const rowGroups = [];
|
|
272
|
+
let current;
|
|
273
|
+
t.rows = [];
|
|
274
|
+
for (const tr of trs) {
|
|
275
|
+
if (tr === groupRow || tr.parentElement?.tagName === "THEAD") continue;
|
|
276
|
+
if (isRowGroupRow(tr)) {
|
|
277
|
+
current = {
|
|
278
|
+
key: groupOf(rowGroups, tr.parentElement?.getAttribute("data-key") ?? null, "rg", words(tr.cells[0]))._key,
|
|
279
|
+
body: tr.parentElement
|
|
280
|
+
};
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (current && current.body !== tr.parentElement) current = void 0;
|
|
284
|
+
t.rows.push({
|
|
285
|
+
_key: tkey("r"),
|
|
286
|
+
cells: Object.fromEntries(t.columns.map((col, i) => [col._key, cellOf(tr.cells[i])])),
|
|
287
|
+
...current ? { group: current.key } : {}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
if (rowGroups.length) t.rowGroups = rowGroups;
|
|
291
|
+
const note = fig?.querySelector(":scope > [data-notes]");
|
|
292
|
+
const notes = words(note);
|
|
293
|
+
if (notes) t.notes = notes;
|
|
294
|
+
const own = (note?.getAttribute("id") ?? table.getAttribute("aria-describedby") ?? "").replace(/-notes$/, "");
|
|
295
|
+
if (KEY.test(own)) t.id = own;
|
|
296
|
+
t.columns.forEach((col) => {
|
|
297
|
+
const vals = t.rows.map((r) => r.cells[col._key]).filter((v) => v !== "");
|
|
298
|
+
if (vals.length && vals.every((v) => isObjLike(v))) col.type = "link";
|
|
299
|
+
});
|
|
300
|
+
return t;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The table as production's renderer writes a Portable Text table (@bettercms-ai/richtext html.ts tableHtml): a header
|
|
304
|
+
* row in <thead>, header cells of the first column as <th>, every cell its text (a link cell its link). A caption, a
|
|
305
|
+
* note or a group adds what that renderer writes for it, in the order the rows are held (an unedited stored table
|
|
306
|
+
* comes back as it was; the editor's row list writes V2's order, loose rows first). An empty group has no row to label
|
|
307
|
+
* and is not written, as production's renderer writes none.
|
|
308
|
+
*/
|
|
309
|
+
function renderStoredTable(input) {
|
|
310
|
+
const t = normalizeTable(input);
|
|
311
|
+
const cols = t.columns;
|
|
312
|
+
const cell = (row, c) => {
|
|
313
|
+
const raw = row.cells[c._key];
|
|
314
|
+
const v = cellValue(raw);
|
|
315
|
+
const text = esc(cellText(c, row, raw));
|
|
316
|
+
const marks = isCellObject(raw) && typeof raw.marks === "string" ? raw.marks : "";
|
|
317
|
+
return (isObjLike(v) && typeof v.href === "string" && v.href ? `<a href="${escAttr(v.href)}">${text}</a>` : text) + marks;
|
|
318
|
+
};
|
|
319
|
+
const rowHtml = (row) => `<tr>${cols.map((c, i) => i === 0 && t.headerColumn ? `<th>${cell(row, c)}</th>` : `<td>${cell(row, c)}</td>`).join("")}</tr>`;
|
|
320
|
+
const span = (name, n) => n > 1 ? ` ${name}="${n}"` : "";
|
|
321
|
+
const colLabels = new Map((t.columnGroups ?? []).map((g) => [g._key, String(g.label ?? "")]));
|
|
322
|
+
const rowLabels = new Map((t.rowGroups ?? []).map((g) => [g._key, String(g.label ?? "")]));
|
|
323
|
+
const runs = (items, keyOf) => {
|
|
324
|
+
const out = [];
|
|
325
|
+
for (const x of items) {
|
|
326
|
+
const key = keyOf(x);
|
|
327
|
+
const last = out[out.length - 1];
|
|
328
|
+
if (last && last.key === key) last.items.push(x);
|
|
329
|
+
else out.push({
|
|
330
|
+
key,
|
|
331
|
+
items: [x]
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return out.some((r) => r.key !== void 0) ? out : [];
|
|
335
|
+
};
|
|
336
|
+
const colRuns = runs(cols, (c) => c.group && colLabels.has(c.group) ? c.group : void 0);
|
|
337
|
+
const rowRuns = runs(t.rows, (r) => r.group && rowLabels.has(r.group) ? r.group : void 0);
|
|
338
|
+
const caption = t.caption.trim();
|
|
339
|
+
const notes = [(t.notes ?? "").trim(), ...(t.footnotes ?? []).map((f, i) => f.text.trim() ? `[${i + 1}] ${f.text.trim()}` : "")].filter(Boolean).join(" ");
|
|
340
|
+
if (!caption && !notes && !colRuns.length && !rowRuns.length) {
|
|
341
|
+
const out = ["<table>"];
|
|
342
|
+
if (t.headerRow) out.push(`<thead><tr>${cols.map((c) => `<th>${esc(c.label)}</th>`).join("")}</tr></thead>`);
|
|
343
|
+
out.push(`<tbody>${t.rows.map(rowHtml).join("")}</tbody></table>`);
|
|
344
|
+
return out.join("");
|
|
345
|
+
}
|
|
346
|
+
const notesId = notes ? `${t.id}-notes` : "";
|
|
347
|
+
const out = [`<table${notesId ? ` aria-describedby="${escAttr(notesId)}"` : ""}>`];
|
|
348
|
+
if (caption) out.push(`<caption>${esc(caption)}</caption>`);
|
|
349
|
+
out.push(colRuns.map((r) => `<colgroup${span("span", r.items.length)}></colgroup>`).join(""));
|
|
350
|
+
const groupRow = colRuns.length ? `<tr>${colRuns.map((r) => r.key === void 0 ? "<td></td>".repeat(r.items.length) : `<th scope="colgroup"${span("colspan", r.items.length)} data-group="${escAttr(r.key)}">${esc(colLabels.get(r.key))}</th>`).join("")}</tr>` : "";
|
|
351
|
+
if (groupRow || t.headerRow) out.push(`<thead>${groupRow}${t.headerRow ? `<tr>${cols.map((c) => `<th>${esc(c.label)}</th>`).join("")}</tr>` : ""}</thead>`);
|
|
352
|
+
if (rowRuns.length) for (const r of rowRuns) out.push(`<tbody${r.key === void 0 ? "" : ` data-key="${escAttr(r.key)}"`}>${r.key === void 0 ? "" : `<tr><th scope="rowgroup"${span("colspan", cols.length)}>${esc(rowLabels.get(r.key))}</th></tr>`}${r.items.map(rowHtml).join("")}</tbody>`);
|
|
353
|
+
else if (t.rows.length) out.push(`<tbody>${t.rows.map(rowHtml).join("")}</tbody>`);
|
|
354
|
+
out.push("</table>");
|
|
355
|
+
const html = out.join("");
|
|
356
|
+
return notes ? `<figure data-rt="table">${html}<p data-notes id="${escAttr(notesId)}">${esc(notes)}</p></figure>` : html;
|
|
357
|
+
}
|
|
358
|
+
/** The footnote markers closing a cell (`<sup data-footnote>` holding only text), and the cell without them. */
|
|
359
|
+
function splitMarks(c) {
|
|
360
|
+
const rest = c.cloneNode(true);
|
|
361
|
+
const marks = [];
|
|
362
|
+
for (let n = rest.lastChild; n; n = rest.lastChild) if (n.nodeType === 3 && !(n.textContent ?? "").trim() && marks.length) n.remove();
|
|
363
|
+
else if (n.nodeType === 1 && n.tagName === "SUP" && n.hasAttribute("data-footnote") && !n.children.length) {
|
|
364
|
+
marks.unshift(n.outerHTML);
|
|
365
|
+
n.remove();
|
|
366
|
+
} else break;
|
|
367
|
+
return {
|
|
368
|
+
rest,
|
|
369
|
+
marks: marks.join("")
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/** A cell the table value can hold: text, line breaks, or one link around its text, then any footnote markers. */
|
|
373
|
+
var plainCell = (cell) => {
|
|
374
|
+
const c = splitMarks(cell).rest;
|
|
375
|
+
return Array.from(c.childNodes).every((n) => n.nodeType === 3 || n.nodeType === 1 && n.tagName === "BR") || c.children.length === 1 && c.firstElementChild.tagName === "A" && c.firstElementChild.children.length === 0 && (c.textContent ?? "").trim() === (c.firstElementChild.textContent ?? "").trim();
|
|
376
|
+
};
|
|
377
|
+
function detectKind(el) {
|
|
378
|
+
const rt = el.getAttribute("data-rt");
|
|
379
|
+
if (rt === "table") return el.tagName === "TABLE" && !Array.from(el.querySelectorAll("td,th")).every(plainCell) ? null : "table";
|
|
380
|
+
if (rt && ISLAND_KINDS.includes(rt)) return rt;
|
|
381
|
+
if (el.tagName === "BLOCKQUOTE" && el.querySelector(":scope > cite")) return "pullquote";
|
|
382
|
+
if (el.tagName === "TABLE") return Array.from(el.querySelectorAll("td,th")).every(plainCell) ? "table" : null;
|
|
383
|
+
if (el.tagName === "FIGURE" && el.querySelector(":scope > table, :scope > .bt-scroll > table")) return "table";
|
|
384
|
+
if (el.tagName === "FIGURE") {
|
|
385
|
+
const kids = Array.from(el.children);
|
|
386
|
+
const media = kids.filter((k) => k.tagName !== "FIGCAPTION");
|
|
387
|
+
const m = media[0];
|
|
388
|
+
if (media.length === 1 && kids.length - media.length <= 1 && (m.tagName === "IMG" || m.tagName === "A" && m.children.length === 1 && m.firstElementChild.tagName === "IMG")) return "image";
|
|
389
|
+
}
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
var attrOf = (el, name) => el.hasAttribute(name) ? el.getAttribute(name) : void 0;
|
|
393
|
+
var oneOf = (list, v) => v !== void 0 && list.includes(v) ? v : void 0;
|
|
394
|
+
function parseIsland(kind, el) {
|
|
395
|
+
switch (kind) {
|
|
396
|
+
case "image": {
|
|
397
|
+
const img = el.querySelector("img");
|
|
398
|
+
const a = img?.parentElement?.tagName === "A" ? img.parentElement : null;
|
|
399
|
+
const cap = el.querySelector(":scope > figcaption");
|
|
400
|
+
const m = { src: img?.getAttribute("src") ?? "" };
|
|
401
|
+
if (img?.hasAttribute("alt")) m.alt = img.getAttribute("alt");
|
|
402
|
+
if (cap) m.caption = (cap.textContent ?? "").replace(/\u200b/g, "");
|
|
403
|
+
const align = oneOf(IMAGE_ALIGNS, attrOf(el, "data-align"));
|
|
404
|
+
const size = oneOf(IMAGE_SIZES, attrOf(el, "data-size"));
|
|
405
|
+
if (align) m.align = align;
|
|
406
|
+
if (size) m.size = size;
|
|
407
|
+
if (a) m.href = a.getAttribute("href") ?? "";
|
|
408
|
+
const extra = attrOf(el, "data-extra");
|
|
409
|
+
if (extra) m.extra = extra;
|
|
410
|
+
return m;
|
|
411
|
+
}
|
|
412
|
+
case "table":
|
|
413
|
+
if (el.matches("figure[data-rt=table]")) return el.querySelector(":scope > table") ? parseStoredTable(el) : parseTableElement(el);
|
|
414
|
+
return parseStoredTable(el.matches("table") ? el : el.querySelector("table"));
|
|
415
|
+
case "pullquote": {
|
|
416
|
+
const text = (n) => (n?.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
417
|
+
const bq = el.matches("blockquote") ? el : el.querySelector("blockquote");
|
|
418
|
+
const cap = el.querySelector("figcaption");
|
|
419
|
+
const nameEl = cap?.querySelector("[data-name]") ?? el.querySelector("blockquote > cite, cite");
|
|
420
|
+
let role = text(cap?.querySelector("[data-role]") ?? null);
|
|
421
|
+
let name = text(nameEl);
|
|
422
|
+
if (!cap && name.includes(",")) [name, role] = [name.slice(0, name.indexOf(",")).trim(), name.slice(name.indexOf(",") + 1).trim()];
|
|
423
|
+
const quoteEl = bq?.cloneNode(true);
|
|
424
|
+
quoteEl?.querySelectorAll("cite").forEach((c) => c.remove());
|
|
425
|
+
return {
|
|
426
|
+
quote: text(quoteEl ?? null),
|
|
427
|
+
name,
|
|
428
|
+
role,
|
|
429
|
+
link: bq?.getAttribute("cite") ?? nameEl?.getAttribute("href") ?? ""
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
case "takeaways": {
|
|
433
|
+
const text = (n) => (n?.textContent ?? "").replace(/\s+/g, " ").trim();
|
|
434
|
+
const pts = Array.from(el.querySelectorAll("li")).map((li) => text(li));
|
|
435
|
+
return {
|
|
436
|
+
title: text(el.querySelector("[data-title]")),
|
|
437
|
+
points: pts.length ? pts : [""]
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
case "callout": {
|
|
441
|
+
const title = el.querySelector(":scope > [data-title]");
|
|
442
|
+
const body = el.querySelector(":scope > [data-body]");
|
|
443
|
+
const m = {};
|
|
444
|
+
const tone = attrOf(el, "data-callout");
|
|
445
|
+
if (tone !== void 0) m.tone = tone;
|
|
446
|
+
if (title) m.title = (title.textContent ?? "").replace(/\u200b/g, "");
|
|
447
|
+
if (body) m.body = parasToText(body);
|
|
448
|
+
const extra = attrOf(el, "data-extra");
|
|
449
|
+
if (extra) m.extra = extra;
|
|
450
|
+
return m;
|
|
451
|
+
}
|
|
452
|
+
case "toggle": {
|
|
453
|
+
const title = el.querySelector(":scope > summary");
|
|
454
|
+
const body = el.querySelector(":scope > [data-body]");
|
|
455
|
+
const m = {};
|
|
456
|
+
if (title) m.title = (title.textContent ?? "").replace(/\u200b/g, "");
|
|
457
|
+
if (body) m.body = parasToText(body);
|
|
458
|
+
const extra = attrOf(el, "data-extra");
|
|
459
|
+
if (extra) m.extra = extra;
|
|
460
|
+
return m;
|
|
461
|
+
}
|
|
462
|
+
case "video": {
|
|
463
|
+
const m = {};
|
|
464
|
+
const url = attrOf(el, "data-url");
|
|
465
|
+
const title = attrOf(el, "data-title");
|
|
466
|
+
if (url !== void 0) m.url = url;
|
|
467
|
+
if (title !== void 0) m.title = title;
|
|
468
|
+
const extra = attrOf(el, "data-extra");
|
|
469
|
+
if (extra) m.extra = extra;
|
|
470
|
+
return m;
|
|
471
|
+
}
|
|
472
|
+
case "file": {
|
|
473
|
+
const m = {};
|
|
474
|
+
const url = attrOf(el, "data-url");
|
|
475
|
+
const name = attrOf(el, "data-name");
|
|
476
|
+
const size = attrOf(el, "data-size");
|
|
477
|
+
if (url !== void 0) m.url = url;
|
|
478
|
+
if (name !== void 0) m.name = name;
|
|
479
|
+
if (size !== void 0 && Number.isFinite(Number(size))) m.size = Number(size);
|
|
480
|
+
const extra = attrOf(el, "data-extra");
|
|
481
|
+
if (extra) m.extra = extra;
|
|
482
|
+
return m;
|
|
483
|
+
}
|
|
484
|
+
case "component": {
|
|
485
|
+
const m = { id: attrOf(el, "data-id") || rid("ci") };
|
|
486
|
+
const ref = attrOf(el, "data-ref") ?? attrOf(el, "data-block");
|
|
487
|
+
const name = attrOf(el, "data-name");
|
|
488
|
+
const overrides = attrOf(el, "data-overrides");
|
|
489
|
+
if (ref !== void 0) m.ref = ref;
|
|
490
|
+
if (name !== void 0) m.name = name;
|
|
491
|
+
if (overrides !== void 0) m.overrides = overrides;
|
|
492
|
+
const variant = attrOf(el, "data-variant");
|
|
493
|
+
if (variant !== void 0) m.variant = variant;
|
|
494
|
+
if (el.getAttribute("data-detached") === "true") {
|
|
495
|
+
m.detached = true;
|
|
496
|
+
const props = attrOf(el, "data-props");
|
|
497
|
+
const blocks = attrOf(el, "data-blocks");
|
|
498
|
+
const at = attrOf(el, "data-source-published-at");
|
|
499
|
+
if (props !== void 0) m.props = props;
|
|
500
|
+
if (blocks !== void 0) m.blocks = blocks;
|
|
501
|
+
if (at !== void 0) m.sourcePublishedAt = at;
|
|
502
|
+
}
|
|
503
|
+
const extra = attrOf(el, "data-extra");
|
|
504
|
+
if (extra) m.extra = extra;
|
|
505
|
+
return m;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function createIsland(kind, model) {
|
|
510
|
+
const el = document.createElement("div");
|
|
511
|
+
el.setAttribute("data-rt-island", kind);
|
|
512
|
+
el.setAttribute("contenteditable", "false");
|
|
513
|
+
el.__rt = model;
|
|
514
|
+
return el;
|
|
515
|
+
}
|
|
516
|
+
/** Static block HTML → islands (top level only). Keeps a writable line after a trailing island or rule. */
|
|
517
|
+
function hydrate(root) {
|
|
518
|
+
for (const ch of Array.from(root.children)) {
|
|
519
|
+
if (ch.hasAttribute("data-rt-island")) continue;
|
|
520
|
+
const k = detectKind(ch);
|
|
521
|
+
if (!k) continue;
|
|
522
|
+
ch.replaceWith(createIsland(k, parseIsland(k, ch)));
|
|
523
|
+
}
|
|
524
|
+
let run = [];
|
|
525
|
+
const flush = (before) => {
|
|
526
|
+
if (run.some((n) => (n.textContent ?? "").trim() || n.nodeType === 1 && n.tagName !== "BR")) {
|
|
527
|
+
const p = document.createElement("p");
|
|
528
|
+
root.insertBefore(p, before);
|
|
529
|
+
run.forEach((n) => p.append(n));
|
|
530
|
+
} else run.forEach((n) => n.parentNode === root && n.nodeType === 3 && root.removeChild(n));
|
|
531
|
+
run = [];
|
|
532
|
+
};
|
|
533
|
+
for (const n of Array.from(root.childNodes)) if (n.nodeType === 1 && (BLOCK_TAGS.has(n.tagName) || n.hasAttribute("data-rt-island"))) flush(n);
|
|
534
|
+
else if (n.nodeType === 1 || n.nodeType === 3) run.push(n);
|
|
535
|
+
flush(null);
|
|
536
|
+
if (!root.firstElementChild) root.innerHTML = "<p><br></p>";
|
|
537
|
+
const last = root.lastElementChild;
|
|
538
|
+
if (last && (last.hasAttribute("data-rt-island") || last.tagName === "HR")) {
|
|
539
|
+
const p = document.createElement("p");
|
|
540
|
+
p.innerHTML = "<br>";
|
|
541
|
+
root.append(p);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
var BLOCK_TAGS = new Set([
|
|
545
|
+
"P",
|
|
546
|
+
"H1",
|
|
547
|
+
"H2",
|
|
548
|
+
"H3",
|
|
549
|
+
"H4",
|
|
550
|
+
"H5",
|
|
551
|
+
"H6",
|
|
552
|
+
"BLOCKQUOTE",
|
|
553
|
+
"PRE",
|
|
554
|
+
"UL",
|
|
555
|
+
"OL",
|
|
556
|
+
"HR",
|
|
557
|
+
"FIGURE",
|
|
558
|
+
"TABLE",
|
|
559
|
+
"DIV",
|
|
560
|
+
"DETAILS",
|
|
561
|
+
"SECTION",
|
|
562
|
+
"ASIDE",
|
|
563
|
+
"NAV"
|
|
564
|
+
]);
|
|
565
|
+
var isEmptyP = (el) => el.tagName === "P" && (el.innerHTML === "" || el.innerHTML === "<br>");
|
|
566
|
+
/** Live DOM → stored HTML. */
|
|
567
|
+
function serialize(root) {
|
|
568
|
+
const clone = root.cloneNode(true);
|
|
569
|
+
const live = Array.from(root.children);
|
|
570
|
+
Array.from(clone.children).forEach((c, i) => {
|
|
571
|
+
if (!c.hasAttribute("data-rt-island")) return;
|
|
572
|
+
const l = live[i];
|
|
573
|
+
const kind = c.getAttribute("data-rt-island");
|
|
574
|
+
const model = l.__rt;
|
|
575
|
+
if (!model) return c.remove();
|
|
576
|
+
const tpl = document.createElement("template");
|
|
577
|
+
tpl.innerHTML = renderStatic(kind, model);
|
|
578
|
+
c.replaceWith(tpl.content);
|
|
579
|
+
});
|
|
580
|
+
clone.querySelectorAll("[data-hint]").forEach((n) => n.removeAttribute("data-hint"));
|
|
581
|
+
while (clone.children.length > 1 && clone.lastElementChild && isEmptyP(clone.lastElementChild)) clone.lastElementChild.remove();
|
|
582
|
+
const html = clone.innerHTML.replace(//g, "");
|
|
583
|
+
return html === "<p><br></p>" || html === "<p></p>" ? "" : html;
|
|
584
|
+
}
|
|
585
|
+
/** The HTML exactly as the editor would store it after opening `html` (load → hydrate → serialize), with no edit. */
|
|
586
|
+
function editorRoundTrip(html) {
|
|
587
|
+
const el = document.createElement("div");
|
|
588
|
+
el.innerHTML = sanitize(html || "") || "<p><br></p>";
|
|
589
|
+
hydrate(el);
|
|
590
|
+
return serialize(el);
|
|
591
|
+
}
|
|
592
|
+
/** Strip scripts, event handlers and script URLs from HTML we did not author (paste, Markdown, loaded values). */
|
|
593
|
+
function sanitize(html) {
|
|
594
|
+
if (!/[<&]/.test(html)) return html;
|
|
595
|
+
const doc = new DOMParser().parseFromString(`<body>${html}</body>`, "text/html");
|
|
596
|
+
doc.body.querySelectorAll("script,style,iframe,object,embed,link,meta,form,input,button,textarea,select,noscript").forEach((n) => n.remove());
|
|
597
|
+
doc.body.querySelectorAll("*").forEach((el) => {
|
|
598
|
+
for (const a of Array.from(el.attributes)) {
|
|
599
|
+
const n = a.name.toLowerCase();
|
|
600
|
+
if (n.startsWith("on")) el.removeAttribute(a.name);
|
|
601
|
+
else if ((n === "href" || n === "src" || n === "xlink:href") && /^\s*(javascript|vbscript|data:text)/i.test(a.value)) el.removeAttribute(a.name);
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
return doc.body.innerHTML;
|
|
605
|
+
}
|
|
606
|
+
var TEXT_BLOCKS = new Set([
|
|
607
|
+
"P",
|
|
608
|
+
"H1",
|
|
609
|
+
"H2",
|
|
610
|
+
"H3",
|
|
611
|
+
"H4",
|
|
612
|
+
"H5",
|
|
613
|
+
"H6",
|
|
614
|
+
"BLOCKQUOTE",
|
|
615
|
+
"PRE",
|
|
616
|
+
"LI",
|
|
617
|
+
"DIV"
|
|
618
|
+
]);
|
|
619
|
+
function topBlock(root, node) {
|
|
620
|
+
if (!root) return null;
|
|
621
|
+
let n = node;
|
|
622
|
+
while (n && n.parentNode !== root) n = n.parentNode;
|
|
623
|
+
return n && n.nodeType === 1 ? n : null;
|
|
624
|
+
}
|
|
625
|
+
/** Nearest text-ish block element around a node, inside root. */
|
|
626
|
+
function closestBlock(root, node) {
|
|
627
|
+
let n = node;
|
|
628
|
+
while (n && n !== root) {
|
|
629
|
+
if (n.nodeType === 1 && TEXT_BLOCKS.has(n.tagName) && n.closest("[data-rt-island]") === null) return n;
|
|
630
|
+
n = n.parentNode;
|
|
631
|
+
}
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
function placeCaret(el, atEnd = true) {
|
|
635
|
+
const s = window.getSelection();
|
|
636
|
+
if (!s) return;
|
|
637
|
+
const r = document.createRange();
|
|
638
|
+
r.selectNodeContents(el);
|
|
639
|
+
r.collapse(!atEnd);
|
|
640
|
+
s.removeAllRanges();
|
|
641
|
+
s.addRange(r);
|
|
642
|
+
}
|
|
643
|
+
function textBeforeCaret(block) {
|
|
644
|
+
const s = window.getSelection();
|
|
645
|
+
if (!s || !s.rangeCount) return null;
|
|
646
|
+
const r = s.getRangeAt(0);
|
|
647
|
+
if (!block.contains(r.startContainer)) return null;
|
|
648
|
+
const pre = document.createRange();
|
|
649
|
+
pre.selectNodeContents(block);
|
|
650
|
+
pre.setEnd(r.startContainer, r.startOffset);
|
|
651
|
+
return pre.toString();
|
|
652
|
+
}
|
|
653
|
+
function editingHost(n) {
|
|
654
|
+
return (n ? n.nodeType === 1 ? n : n.parentElement : null)?.closest("[contenteditable=\"true\"],[contenteditable=\"plaintext-only\"]") ?? null;
|
|
655
|
+
}
|
|
656
|
+
/** A range's box. Browsers measure a collapsed caret as an empty rect, and some engines cannot measure ranges at all: then
|
|
657
|
+
* the box of the element the range sits in. */
|
|
658
|
+
function rangeRect(r, fallback) {
|
|
659
|
+
let rect = null;
|
|
660
|
+
try {
|
|
661
|
+
rect = r.getBoundingClientRect();
|
|
662
|
+
} catch {
|
|
663
|
+
rect = null;
|
|
664
|
+
}
|
|
665
|
+
if (rect && (rect.width || rect.height)) return rect;
|
|
666
|
+
return ((r.startContainer.nodeType === 1 ? r.startContainer : r.startContainer.parentElement) ?? fallback ?? document.body).getBoundingClientRect();
|
|
667
|
+
}
|
|
668
|
+
var NOT_COUNTED = "[data-rt=component],[data-rt=pullquote],[data-rt=takeaways],[data-rt=video],[data-rt=file]";
|
|
669
|
+
var WORDS = (s) => s.replace(/\u200b/g, "").trim().split(/\s+/).filter(Boolean).length;
|
|
670
|
+
function countWords(html) {
|
|
671
|
+
if (!html) return 0;
|
|
672
|
+
if (!/data-rt="(?:component|pullquote|takeaways|video|file)"/.test(html) || typeof DOMParser === "undefined") return WORDS(html.replace(/<\/(p|li|h[1-6]|blockquote|pre|figcaption|td|th|summary)>/g, " ").replace(/<[^>]+>/g, " ").replace(/ |&[a-z]+;/g, " "));
|
|
673
|
+
const doc = new DOMParser().parseFromString(`<body>${html}</body>`, "text/html");
|
|
674
|
+
doc.body.querySelectorAll(NOT_COUNTED).forEach((n) => n.remove());
|
|
675
|
+
doc.body.querySelectorAll("p,li,h1,h2,h3,h4,h5,h6,td,th,figcaption,summary,pre,blockquote,div").forEach((n) => n.append(" "));
|
|
676
|
+
return WORDS(doc.body.textContent ?? "");
|
|
677
|
+
}
|
|
678
|
+
/** Linked component instances in the body. */
|
|
679
|
+
var countComponents = (html) => (html.match(/data-rt="component"/g) ?? []).length;
|
|
680
|
+
/** "1,840 words · 3 components" */
|
|
681
|
+
var bodyCountLabel = (html) => {
|
|
682
|
+
const w = countWords(html);
|
|
683
|
+
const c = countComponents(html);
|
|
684
|
+
return `${w.toLocaleString("en-US")} ${w === 1 ? "word" : "words"}${c ? ` · ${c} ${c === 1 ? "component" : "components"}` : ""}`;
|
|
685
|
+
};
|
|
686
|
+
var isEmptyHtml = (html) => !html.replace(/<(?!img|hr|figure|table|details|div data-rt)[^>]*>/g, "").replace(/ /g, "").trim();
|
|
687
|
+
//#endregion
|
|
688
|
+
export { CALLOUT_TONES, bodyCountLabel, cloneModel, closestBlock, countComponents, countWords, createIsland, defaultModel, editingHost, editorRoundTrip, esc, escAttr, hydrate, isEmptyHtml, placeCaret, rangeRect, rid, sanitize, serialize, textBeforeCaret, topBlock };
|
|
689
|
+
|
|
690
|
+
//# sourceMappingURL=dom.js.map
|