@bettercms-ai/kit 0.1.1 → 2.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/README.md +22 -16
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/adapters/dock-values.d.ts +28 -0
- package/dist/adapters/dock-values.js +41 -0
- package/dist/adapters/dock-values.js.map +1 -0
- package/dist/adapters/icons.d.ts +15 -0
- package/dist/adapters/icons.js +27 -0
- package/dist/adapters/icons.js.map +1 -0
- package/dist/adapters/lossy.d.ts +326 -0
- package/dist/adapters/lossy.js +414 -0
- package/dist/adapters/lossy.js.map +1 -0
- package/dist/adapters/prod-types.d.ts +546 -0
- package/dist/adapters/prod-types.js +714 -0
- package/dist/adapters/prod-types.js.map +1 -0
- package/dist/adapters/schema.d.ts +154 -0
- package/dist/adapters/schema.js +3020 -0
- package/dist/adapters/schema.js.map +1 -0
- package/dist/adapters/values.d.ts +221 -0
- package/dist/adapters/values.js +623 -0
- package/dist/adapters/values.js.map +1 -0
- package/dist/brand/logo.d.ts +17 -0
- package/dist/brand/logo.js +96 -0
- package/dist/brand/logo.js.map +1 -0
- package/dist/context.d.ts +359 -0
- package/dist/context.js +217 -0
- package/dist/context.js.map +1 -0
- package/dist/controls/button.d.ts +72 -0
- package/dist/controls/button.js +578 -0
- package/dist/controls/button.js.map +1 -0
- package/dist/controls/c1.d.ts +11 -0
- package/dist/controls/c1.js +24 -0
- package/dist/controls/c1.js.map +1 -0
- package/dist/controls/c2.d.ts +10 -0
- package/dist/controls/c2.js +19 -0
- package/dist/controls/c2.js.map +1 -0
- package/dist/controls/choice.d.ts +44 -0
- package/dist/controls/choice.js +463 -0
- package/dist/controls/choice.js.map +1 -0
- package/dist/controls/code-register.d.ts +1 -0
- package/dist/controls/code-register.js +8 -0
- package/dist/controls/code-register.js.map +1 -0
- package/dist/controls/code.d.ts +42 -0
- package/dist/controls/code.js +397 -0
- package/dist/controls/code.js.map +1 -0
- package/dist/controls/color.d.ts +5 -0
- package/dist/controls/color.js +130 -0
- package/dist/controls/color.js.map +1 -0
- package/dist/controls/component-services.d.ts +156 -0
- package/dist/controls/component-services.js +7 -0
- package/dist/controls/component-services.js.map +1 -0
- package/dist/controls/date-register.d.ts +1 -0
- package/dist/controls/date-register.js +9 -0
- package/dist/controls/date-register.js.map +1 -0
- package/dist/controls/date-zone.d.ts +104 -0
- package/dist/controls/date-zone.js +278 -0
- package/dist/controls/date-zone.js.map +1 -0
- package/dist/controls/date.d.ts +7 -0
- package/dist/controls/date.js +466 -0
- package/dist/controls/date.js.map +1 -0
- package/dist/controls/form-picker-register.d.ts +1 -0
- package/dist/controls/form-picker-register.js +19 -0
- package/dist/controls/form-picker-register.js.map +1 -0
- package/dist/controls/form-picker.d.ts +43 -0
- package/dist/controls/form-picker.js +85 -0
- package/dist/controls/form-picker.js.map +1 -0
- package/dist/controls/icon-register.d.ts +1 -0
- package/dist/controls/icon-register.js +8 -0
- package/dist/controls/icon-register.js.map +1 -0
- package/dist/controls/icon.d.ts +40 -0
- package/dist/controls/icon.js +360 -0
- package/dist/controls/icon.js.map +1 -0
- package/dist/controls/index.d.ts +5 -0
- package/dist/controls/index.js +38 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/controls/json-register.d.ts +1 -0
- package/dist/controls/json-register.js +8 -0
- package/dist/controls/json-register.js.map +1 -0
- package/dist/controls/json.d.ts +2 -0
- package/dist/controls/json.js +82 -0
- package/dist/controls/json.js.map +1 -0
- package/dist/controls/link.d.ts +260 -0
- package/dist/controls/link.js +1186 -0
- package/dist/controls/link.js.map +1 -0
- package/dist/controls/location-register.d.ts +1 -0
- package/dist/controls/location-register.js +8 -0
- package/dist/controls/location-register.js.map +1 -0
- package/dist/controls/location.d.ts +16 -0
- package/dist/controls/location.js +221 -0
- package/dist/controls/location.js.map +1 -0
- package/dist/controls/media-register.d.ts +1 -0
- package/dist/controls/media-register.js +12 -0
- package/dist/controls/media-register.js.map +1 -0
- package/dist/controls/media-services.d.ts +46 -0
- package/dist/controls/media-services.js +0 -0
- package/dist/controls/media.d.ts +104 -0
- package/dist/controls/media.js +1396 -0
- package/dist/controls/media.js.map +1 -0
- package/dist/controls/number.d.ts +22 -0
- package/dist/controls/number.js +196 -0
- package/dist/controls/number.js.map +1 -0
- package/dist/controls/reference-register.d.ts +1 -0
- package/dist/controls/reference-register.js +10 -0
- package/dist/controls/reference-register.js.map +1 -0
- package/dist/controls/reference-services.d.ts +58 -0
- package/dist/controls/reference-services.js +0 -0
- package/dist/controls/reference.d.ts +23 -0
- package/dist/controls/reference.js +777 -0
- package/dist/controls/reference.js.map +1 -0
- package/dist/controls/rich-text/blocks.d.ts +49 -0
- package/dist/controls/rich-text/blocks.js +1859 -0
- package/dist/controls/rich-text/blocks.js.map +1 -0
- package/dist/controls/rich-text/catalog.d.ts +101 -0
- package/dist/controls/rich-text/catalog.js +623 -0
- package/dist/controls/rich-text/catalog.js.map +1 -0
- package/dist/controls/rich-text/codec.d.ts +64 -0
- package/dist/controls/rich-text/codec.js +34 -0
- package/dist/controls/rich-text/codec.js.map +1 -0
- package/dist/controls/rich-text/component-card.d.ts +14 -0
- package/dist/controls/rich-text/component-card.js +1024 -0
- package/dist/controls/rich-text/component-card.js.map +1 -0
- package/dist/controls/rich-text/component-panel.d.ts +47 -0
- package/dist/controls/rich-text/component-panel.js +141 -0
- package/dist/controls/rich-text/component-panel.js.map +1 -0
- package/dist/controls/rich-text/control.d.ts +20 -0
- package/dist/controls/rich-text/control.js +296 -0
- package/dist/controls/rich-text/control.js.map +1 -0
- package/dist/controls/rich-text/dom.d.ts +233 -0
- package/dist/controls/rich-text/dom.js +1019 -0
- package/dist/controls/rich-text/dom.js.map +1 -0
- package/dist/controls/rich-text/editor.d.ts +57 -0
- package/dist/controls/rich-text/editor.js +1630 -0
- package/dist/controls/rich-text/editor.js.map +1 -0
- package/dist/controls/rich-text/floating.d.ts +28 -0
- package/dist/controls/rich-text/floating.js +154 -0
- package/dist/controls/rich-text/floating.js.map +1 -0
- package/dist/controls/rich-text/index.d.ts +1 -0
- package/dist/controls/rich-text/index.js +12 -0
- package/dist/controls/rich-text/index.js.map +1 -0
- package/dist/controls/rich-text/link-form.d.ts +13 -0
- package/dist/controls/rich-text/link-form.js +147 -0
- package/dist/controls/rich-text/link-form.js.map +1 -0
- package/dist/controls/rich-text/markdown.d.ts +6 -0
- package/dist/controls/rich-text/markdown.js +181 -0
- package/dist/controls/rich-text/markdown.js.map +1 -0
- package/dist/controls/rich-text/ops.d.ts +35 -0
- package/dist/controls/rich-text/ops.js +316 -0
- package/dist/controls/rich-text/ops.js.map +1 -0
- package/dist/controls/rich-text/plain.d.ts +17 -0
- package/dist/controls/rich-text/plain.js +44 -0
- package/dist/controls/rich-text/plain.js.map +1 -0
- package/dist/controls/rich-text/toolbar.d.ts +89 -0
- package/dist/controls/rich-text/toolbar.js +343 -0
- package/dist/controls/rich-text/toolbar.js.map +1 -0
- package/dist/controls/scale.d.ts +56 -0
- package/dist/controls/scale.js +563 -0
- package/dist/controls/scale.js.map +1 -0
- package/dist/controls/slot-register.d.ts +1 -0
- package/dist/controls/slot-register.js +16 -0
- package/dist/controls/slot-register.js.map +1 -0
- package/dist/controls/slot-services.d.ts +122 -0
- package/dist/controls/slot-services.js +155 -0
- package/dist/controls/slot-services.js.map +1 -0
- package/dist/controls/slot.d.ts +33 -0
- package/dist/controls/slot.js +366 -0
- package/dist/controls/slot.js.map +1 -0
- package/dist/controls/table/index.d.ts +1 -0
- package/dist/controls/table/index.js +12 -0
- package/dist/controls/table/index.js.map +1 -0
- package/dist/controls/table/prod.d.ts +21 -0
- package/dist/controls/table/prod.js +79 -0
- package/dist/controls/table/prod.js.map +1 -0
- package/dist/controls/table/refs.d.ts +50 -0
- package/dist/controls/table/refs.js +79 -0
- package/dist/controls/table/refs.js.map +1 -0
- package/dist/controls/table/stored.d.ts +15 -0
- package/dist/controls/table/stored.js +44 -0
- package/dist/controls/table/stored.js.map +1 -0
- package/dist/controls/table/table-editor.d.ts +103 -0
- package/dist/controls/table/table-editor.js +2725 -0
- package/dist/controls/table/table-editor.js.map +1 -0
- package/dist/controls/table/table-link.d.ts +24 -0
- package/dist/controls/table/table-link.js +180 -0
- package/dist/controls/table/table-link.js.map +1 -0
- package/dist/controls/table/table.d.ts +9 -0
- package/dist/controls/table/table.js +103 -0
- package/dist/controls/table/table.js.map +1 -0
- package/dist/controls/text.d.ts +17 -0
- package/dist/controls/text.js +322 -0
- package/dist/controls/text.js.map +1 -0
- package/dist/controls/unknown-value.d.ts +17 -0
- package/dist/controls/unknown-value.js +66 -0
- package/dist/controls/unknown-value.js.map +1 -0
- package/dist/core/core.d.ts +63 -0
- package/dist/core/core.js +171 -0
- package/dist/core/core.js.map +1 -0
- package/dist/core/facets.d.ts +347 -0
- package/dist/core/facets.js +334 -0
- package/dist/core/facets.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +3 -0
- package/dist/engine/array.d.ts +101 -0
- package/dist/engine/array.js +906 -0
- package/dist/engine/array.js.map +1 -0
- package/dist/engine/bits.d.ts +24 -0
- package/dist/engine/bits.js +60 -0
- package/dist/engine/bits.js.map +1 -0
- package/dist/engine/breadcrumb.d.ts +45 -0
- package/dist/engine/breadcrumb.js +63 -0
- package/dist/engine/breadcrumb.js.map +1 -0
- package/dist/engine/expand.d.ts +66 -0
- package/dist/engine/expand.js +153 -0
- package/dist/engine/expand.js.map +1 -0
- package/dist/engine/field-list.d.ts +20 -0
- package/dist/engine/field-list.js +19 -0
- package/dist/engine/field-list.js.map +1 -0
- package/dist/engine/field-shell.d.ts +49 -0
- package/dist/engine/field-shell.js +988 -0
- package/dist/engine/field-shell.js.map +1 -0
- package/dist/engine/frame.d.ts +122 -0
- package/dist/engine/frame.js +601 -0
- package/dist/engine/frame.js.map +1 -0
- package/dist/engine/group-summary.d.ts +5 -0
- package/dist/engine/group-summary.js +70 -0
- package/dist/engine/group-summary.js.map +1 -0
- package/dist/engine/grouping.d.ts +238 -0
- package/dist/engine/grouping.js +996 -0
- package/dist/engine/grouping.js.map +1 -0
- package/dist/engine/item-list.d.ts +99 -0
- package/dist/engine/item-list.js +725 -0
- package/dist/engine/item-list.js.map +1 -0
- package/dist/engine/kit-field.d.ts +72 -0
- package/dist/engine/kit-field.js +558 -0
- package/dist/engine/kit-field.js.map +1 -0
- package/dist/engine/schema-form.d.ts +116 -0
- package/dist/engine/schema-form.js +462 -0
- package/dist/engine/schema-form.js.map +1 -0
- package/dist/engine/slot.d.ts +13 -0
- package/dist/engine/slot.js +216 -0
- package/dist/engine/slot.js.map +1 -0
- package/dist/index.d.ts +45 -3139
- package/dist/index.js +47 -2036
- package/dist/index.js.map +1 -0
- package/dist/kit.css +75 -0
- package/dist/lib/cn.d.ts +4 -0
- package/dist/lib/cn.js +56 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/columns.d.ts +14 -0
- package/dist/lib/columns.js +30 -0
- package/dist/lib/columns.js.map +1 -0
- package/dist/lib/frames.d.ts +36 -0
- package/dist/lib/frames.js +214 -0
- package/dist/lib/frames.js.map +1 -0
- package/dist/lib/icon-image.d.ts +10 -0
- package/dist/lib/icon-image.js +8 -0
- package/dist/lib/icon-image.js.map +1 -0
- package/dist/lib/icons.d.ts +16 -0
- package/dist/lib/icons.js +173 -0
- package/dist/lib/icons.js.map +1 -0
- package/dist/lib/input-modality.d.ts +11 -0
- package/dist/lib/input-modality.js +47 -0
- package/dist/lib/input-modality.js.map +1 -0
- package/dist/lib/key-event.d.ts +11 -0
- package/dist/lib/key-event.js +16 -0
- package/dist/lib/key-event.js.map +1 -0
- package/dist/lib/path.d.ts +29 -0
- package/dist/lib/path.js +66 -0
- package/dist/lib/path.js.map +1 -0
- package/dist/lib/schema.d.ts +80 -0
- package/dist/lib/schema.js +384 -0
- package/dist/lib/schema.js.map +1 -0
- package/dist/lib/utils.d.ts +7 -0
- package/dist/lib/utils.js +37 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validate.d.ts +30 -0
- package/dist/lib/validate.js +224 -0
- package/dist/lib/validate.js.map +1 -0
- package/dist/library/analysis.d.ts +23 -0
- package/dist/library/analysis.js +160 -0
- package/dist/library/analysis.js.map +1 -0
- package/dist/library/catalog.d.ts +57 -0
- package/dist/library/catalog.js +307 -0
- package/dist/library/catalog.js.map +1 -0
- package/dist/library/coreNotes.d.ts +8 -0
- package/dist/library/coreNotes.js +111 -0
- package/dist/library/coreNotes.js.map +1 -0
- package/dist/library/coverage.d.ts +40 -0
- package/dist/library/coverage.js +59 -0
- package/dist/library/coverage.js.map +1 -0
- package/dist/library/entries/advanced.entries.d.ts +2 -0
- package/dist/library/entries/advanced.entries.js +6579 -0
- package/dist/library/entries/advanced.entries.js.map +1 -0
- package/dist/library/entries/commerce.entries.d.ts +2 -0
- package/dist/library/entries/commerce.entries.js +4140 -0
- package/dist/library/entries/commerce.entries.js.map +1 -0
- package/dist/library/entries/company.entries.d.ts +2 -0
- package/dist/library/entries/company.entries.js +2731 -0
- package/dist/library/entries/company.entries.js.map +1 -0
- package/dist/library/entries/conversion.entries.d.ts +2 -0
- package/dist/library/entries/conversion.entries.js +3707 -0
- package/dist/library/entries/conversion.entries.js.map +1 -0
- package/dist/library/entries/data.entries.d.ts +7 -0
- package/dist/library/entries/data.entries.js +4613 -0
- package/dist/library/entries/data.entries.js.map +1 -0
- package/dist/library/entries/events.entries.d.ts +2 -0
- package/dist/library/entries/events.entries.js +3428 -0
- package/dist/library/entries/events.entries.js.map +1 -0
- package/dist/library/entries/features.entries.d.ts +2 -0
- package/dist/library/entries/features.entries.js +3157 -0
- package/dist/library/entries/features.entries.js.map +1 -0
- package/dist/library/entries/heroes.entries.d.ts +2 -0
- package/dist/library/entries/heroes.entries.js +3401 -0
- package/dist/library/entries/heroes.entries.js.map +1 -0
- package/dist/library/entries/index.d.ts +3 -0
- package/dist/library/entries/index.js +35 -0
- package/dist/library/entries/index.js.map +1 -0
- package/dist/library/entries/listings.entries.d.ts +2 -0
- package/dist/library/entries/listings.entries.js +2976 -0
- package/dist/library/entries/listings.entries.js.map +1 -0
- package/dist/library/entries/longform.entries.d.ts +2 -0
- package/dist/library/entries/longform.entries.js +4227 -0
- package/dist/library/entries/longform.entries.js.map +1 -0
- package/dist/library/entries/media.entries.d.ts +2 -0
- package/dist/library/entries/media.entries.js +2781 -0
- package/dist/library/entries/media.entries.js.map +1 -0
- package/dist/library/entries/navigation.entries.d.ts +2 -0
- package/dist/library/entries/navigation.entries.js +4011 -0
- package/dist/library/entries/navigation.entries.js.map +1 -0
- package/dist/library/entries/pricing.entries.d.ts +2 -0
- package/dist/library/entries/pricing.entries.js +2383 -0
- package/dist/library/entries/pricing.entries.js.map +1 -0
- package/dist/library/entries/social-proof.entries.d.ts +2 -0
- package/dist/library/entries/social-proof.entries.js +2297 -0
- package/dist/library/entries/social-proof.entries.js.map +1 -0
- package/dist/library/examples/bento.d.ts +92 -0
- package/dist/library/examples/bento.js +201 -0
- package/dist/library/examples/bento.js.map +1 -0
- package/dist/library/examples/blocks.d.ts +14 -0
- package/dist/library/examples/blocks.js +313 -0
- package/dist/library/examples/blocks.js.map +1 -0
- package/dist/library/examples/faq.d.ts +28 -0
- package/dist/library/examples/faq.js +230 -0
- package/dist/library/examples/faq.js.map +1 -0
- package/dist/library/examples/hero.d.ts +43 -0
- package/dist/library/examples/hero.js +222 -0
- package/dist/library/examples/hero.js.map +1 -0
- package/dist/library/examples/index.d.ts +36 -0
- package/dist/library/examples/index.js +109 -0
- package/dist/library/examples/index.js.map +1 -0
- package/dist/library/examples/journalStory.d.ts +93 -0
- package/dist/library/examples/journalStory.js +338 -0
- package/dist/library/examples/journalStory.js.map +1 -0
- package/dist/library/examples/megaMenu.d.ts +134 -0
- package/dist/library/examples/megaMenu.js +442 -0
- package/dist/library/examples/megaMenu.js.map +1 -0
- package/dist/library/examples/pricing.d.ts +103 -0
- package/dist/library/examples/pricing.js +479 -0
- package/dist/library/examples/pricing.js.map +1 -0
- package/dist/library/examples/tabs.d.ts +87 -0
- package/dist/library/examples/tabs.js +180 -0
- package/dist/library/examples/tabs.js.map +1 -0
- package/dist/library/export.d.ts +42 -0
- package/dist/library/export.js +80 -0
- package/dist/library/export.js.map +1 -0
- package/dist/library/index.d.ts +13 -0
- package/dist/library/index.js +6 -0
- package/dist/library/kit-catalog.json +1510 -0
- package/dist/library/types.d.ts +42 -0
- package/dist/library/types.js +0 -0
- package/dist/schema/adapters.d.ts +28 -0
- package/dist/schema/adapters.js +492 -0
- package/dist/schema/adapters.js.map +1 -0
- package/dist/schema/help.d.ts +27 -0
- package/dist/schema/help.js +56 -0
- package/dist/schema/help.js.map +1 -0
- package/dist/schema/scale.d.ts +69 -0
- package/dist/schema/scale.js +250 -0
- package/dist/schema/scale.js.map +1 -0
- package/dist/schema/sources.d.ts +103 -0
- package/dist/schema/sources.js +65 -0
- package/dist/schema/sources.js.map +1 -0
- package/dist/schema/table.d.ts +319 -0
- package/dist/schema/table.js +1199 -0
- package/dist/schema/table.js.map +1 -0
- package/dist/schema/types.d.ts +297 -0
- package/dist/schema/types.js +14 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/table/table-view.d.ts +14 -0
- package/dist/table/table-view.js +140 -0
- package/dist/table/table-view.js.map +1 -0
- package/dist/table/table.css +73 -0
- package/dist/testing/corpus.d.ts +63 -0
- package/dist/testing/corpus.js +129 -0
- package/dist/testing/corpus.js.map +1 -0
- package/dist/testing/test-form.d.ts +11 -0
- package/dist/testing/test-form.js +38 -0
- package/dist/testing/test-form.js.map +1 -0
- package/dist/theme.css +345 -0
- package/dist/theme.d.ts +20 -1504
- package/dist/theme.js +43 -4126
- package/dist/theme.js.map +1 -0
- package/dist/tokens.css +542 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +0 -0
- package/dist/ui/action-tray.d.ts +54 -0
- package/dist/ui/action-tray.js +154 -0
- package/dist/ui/action-tray.js.map +1 -0
- package/dist/ui/autocomplete.d.ts +30 -0
- package/dist/ui/autocomplete.js +139 -0
- package/dist/ui/autocomplete.js.map +1 -0
- package/dist/ui/button.d.ts +57 -0
- package/dist/ui/button.js +201 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/choice-switch.d.ts +36 -0
- package/dist/ui/choice-switch.js +57 -0
- package/dist/ui/choice-switch.js.map +1 -0
- package/dist/ui/controls.d.ts +83 -0
- package/dist/ui/controls.js +331 -0
- package/dist/ui/controls.js.map +1 -0
- package/dist/ui/display.d.ts +163 -0
- package/dist/ui/display.js +455 -0
- package/dist/ui/display.js.map +1 -0
- package/dist/ui/expanded-editor-modal.d.ts +26 -0
- package/dist/ui/expanded-editor-modal.js +140 -0
- package/dist/ui/expanded-editor-modal.js.map +1 -0
- package/dist/ui/field-context.d.ts +12 -0
- package/dist/ui/field-context.js +23 -0
- package/dist/ui/field-context.js.map +1 -0
- package/dist/ui/floating-panel.d.ts +152 -0
- package/dist/ui/floating-panel.js +928 -0
- package/dist/ui/floating-panel.js.map +1 -0
- package/dist/ui/index.d.ts +16 -0
- package/dist/ui/index.js +18 -0
- package/dist/ui/input.d.ts +78 -0
- package/dist/ui/input.js +250 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/mode-bar.d.ts +31 -0
- package/dist/ui/mode-bar.js +65 -0
- package/dist/ui/mode-bar.js.map +1 -0
- package/dist/ui/overlay.d.ts +195 -0
- package/dist/ui/overlay.js +697 -0
- package/dist/ui/overlay.js.map +1 -0
- package/dist/ui/path-crumbs.d.ts +90 -0
- package/dist/ui/path-crumbs.js +566 -0
- package/dist/ui/path-crumbs.js.map +1 -0
- package/dist/ui/presence.d.ts +16 -0
- package/dist/ui/presence.js +65 -0
- package/dist/ui/presence.js.map +1 -0
- package/dist/ui/select.d.ts +66 -0
- package/dist/ui/select.js +407 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui/shortcut-hint.d.ts +14 -0
- package/dist/ui/shortcut-hint.js +35 -0
- package/dist/ui/shortcut-hint.js.map +1 -0
- package/dist/ui/spinner.d.ts +24 -0
- package/dist/ui/spinner.js +42 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/ui/split-button.d.ts +32 -0
- package/dist/ui/split-button.js +60 -0
- package/dist/ui/split-button.js.map +1 -0
- package/dist/ui/surfaces.d.ts +23 -0
- package/dist/ui/surfaces.js +26 -0
- package/dist/ui/surfaces.js.map +1 -0
- package/dist/ui/tab.d.ts +38 -0
- package/dist/ui/tab.js +87 -0
- package/dist/ui/tab.js.map +1 -0
- package/dist/ui/toast.d.ts +20 -0
- package/dist/ui/toast.js +115 -0
- package/dist/ui/toast.js.map +1 -0
- package/dist/ui/tooltip-root.d.ts +13 -0
- package/dist/ui/tooltip-root.js +77 -0
- package/dist/ui/tooltip-root.js.map +1 -0
- package/dist/ui/variants.d.ts +15 -0
- package/dist/ui/variants.js +14 -0
- package/dist/ui/variants.js.map +1 -0
- package/package.json +76 -50
- package/LICENSE +0 -21
- 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.mjs +0 -2044
- package/dist/theme.d.mts +0 -1506
- 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,2725 @@
|
|
|
1
|
+
import { GENERAL_TABLE, boolLabels, cellNote, cellText, cellType, cellValue, coerce, isCellObject, isEmptyCell, isObjLike, normalizeTable, orderedRows, parseDelimited, parseTableElement, pasteRange, tableFromRows, tableToRows, tkey, toBool, toNumber, withValue } from "../../schema/table.js";
|
|
2
|
+
import { cn } from "../../lib/cn.js";
|
|
3
|
+
import { useKitServices } from "../../context.js";
|
|
4
|
+
import { Button, IconButton } from "../../ui/button.js";
|
|
5
|
+
import { Segmented, Switch } from "../../ui/controls.js";
|
|
6
|
+
import { Menu, MenuCheckItem, MenuContent, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Popover, PopoverAnchor, PopoverContent } from "../../ui/overlay.js";
|
|
7
|
+
import { FieldSection, FieldUnit, FieldUnitRow } from "../../engine/grouping.js";
|
|
8
|
+
import { Input, Textarea } from "../../ui/input.js";
|
|
9
|
+
import { Select } from "../../ui/select.js";
|
|
10
|
+
import { LinkField, hrefOf, linkText, normLink } from "../link.js";
|
|
11
|
+
import { SharedSortProvider, useSharedSort } from "../../engine/item-list.js";
|
|
12
|
+
import { RowList } from "../../engine/array.js";
|
|
13
|
+
import { ExpandedEditorModal } from "../../ui/expanded-editor-modal.js";
|
|
14
|
+
import { PathCrumbs } from "../../ui/path-crumbs.js";
|
|
15
|
+
import { ChoiceSwitch } from "../../ui/choice-switch.js";
|
|
16
|
+
import { LinkAddressButton, isScriptHref, tableLink } from "./table-link.js";
|
|
17
|
+
import { refLabel, useRefSearch } from "./refs.js";
|
|
18
|
+
import * as React from "react";
|
|
19
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
import { IconAlignLeft, IconArrowDown, IconArrowUp, IconArrowsMaximize, IconCheck, IconChevronDown, IconCurrencyDollar, IconDots, IconFileDatabase, IconFolder, IconGripVertical, IconHash, IconLayoutColumns, IconLetterT, IconLink, IconList, IconPlus, IconStar, IconTable, IconToggleRight } from "@tabler/icons-react";
|
|
21
|
+
import { ContextMenu } from "@base-ui/react/context-menu";
|
|
22
|
+
//#region src/controls/table/table-editor.tsx
|
|
23
|
+
/**
|
|
24
|
+
* TABLE EDITOR (CPO D42, D49, D50, D52; port of V2 src/components/table/table-editor.tsx) — calm by default.
|
|
25
|
+
*
|
|
26
|
+
* Default nested array UX (D50): Title, Columns (an array list), Rows (nested under their groups, each the kit's own
|
|
27
|
+
* array row: first cell, summary, ⋯, ›), Note under the table, then a collapsed Table settings. A row or column
|
|
28
|
+
* drills through the kit form's navigation (standard breadcrumb + frame header, TableFrame); outside a form,
|
|
29
|
+
* through a local drill with the same trail. A row is one field per column; the column's type picks the
|
|
30
|
+
* control; per-cell exceptions (words instead, footnote, clear) sit behind a quiet ⋯ by the cell's label.
|
|
31
|
+
* Expanded the spreadsheet lives ONLY in the expanded-editor modal (D49), opened by ⤢ in the field's label row: click a
|
|
32
|
+
* cell and type, Tab / arrows / Enter move, "+" adds a column, grips reorder, ⋯ / Shift+F10 / right-click for
|
|
33
|
+
* column, row and cell options.
|
|
34
|
+
* Settings (D52) only presentation and structure, only what `field.table.settings` offers this kind.
|
|
35
|
+
*
|
|
36
|
+
* Kit deviations from V2 (no @dnd-kit / Radix in the kit): rows reorder inside their run with the kit's useDragReorder
|
|
37
|
+
* (pointer + ↑/↓ on the grip); moving a row to another group is the row's ⋯ › Move to group (V2 also allowed dragging it
|
|
38
|
+
* across). The cell context menu is Base UI's ContextMenu. Toasts come from KitServices (absent → silent). Link cells use
|
|
39
|
+
* the table's own address editor (table-link.tsx) in the spreadsheet and the global LinkField in a drilled row (as V2); reference cells search through the host (refs.ts).
|
|
40
|
+
*/
|
|
41
|
+
var TYPE_UI = {
|
|
42
|
+
text: {
|
|
43
|
+
label: "Text",
|
|
44
|
+
icon: IconLetterT
|
|
45
|
+
},
|
|
46
|
+
number: {
|
|
47
|
+
label: "Number",
|
|
48
|
+
icon: IconHash
|
|
49
|
+
},
|
|
50
|
+
money: {
|
|
51
|
+
label: "Price",
|
|
52
|
+
icon: IconCurrencyDollar
|
|
53
|
+
},
|
|
54
|
+
boolean: {
|
|
55
|
+
label: "Yes / No",
|
|
56
|
+
icon: IconToggleRight
|
|
57
|
+
},
|
|
58
|
+
link: {
|
|
59
|
+
label: "Link",
|
|
60
|
+
icon: IconLink
|
|
61
|
+
},
|
|
62
|
+
rating: {
|
|
63
|
+
label: "Rating",
|
|
64
|
+
icon: IconStar
|
|
65
|
+
},
|
|
66
|
+
"richtext-inline": {
|
|
67
|
+
label: "Rich text",
|
|
68
|
+
icon: IconAlignLeft,
|
|
69
|
+
dev: true
|
|
70
|
+
},
|
|
71
|
+
reference: {
|
|
72
|
+
label: "Page or CMS item",
|
|
73
|
+
icon: IconFileDatabase,
|
|
74
|
+
dev: true
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var NUMERIC = [
|
|
78
|
+
"number",
|
|
79
|
+
"money",
|
|
80
|
+
"rating"
|
|
81
|
+
];
|
|
82
|
+
var CURRENCIES = [
|
|
83
|
+
"USD",
|
|
84
|
+
"EUR",
|
|
85
|
+
"GBP",
|
|
86
|
+
"INR"
|
|
87
|
+
];
|
|
88
|
+
var TypeIcon = ({ type, className }) => {
|
|
89
|
+
const I = TYPE_UI[type].icon;
|
|
90
|
+
return /* @__PURE__ */ jsx(I, {
|
|
91
|
+
className: cn("size-3.5 shrink-0 text-kit-fg-4", className),
|
|
92
|
+
stroke: 1.75,
|
|
93
|
+
"aria-hidden": true
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
var mapRow = (key, f) => (t) => ({
|
|
97
|
+
...t,
|
|
98
|
+
rows: t.rows.map((r) => r._key === key ? f(r) : r)
|
|
99
|
+
});
|
|
100
|
+
var clean = (r) => {
|
|
101
|
+
const x = { ...r };
|
|
102
|
+
[
|
|
103
|
+
"group",
|
|
104
|
+
"footer",
|
|
105
|
+
"type",
|
|
106
|
+
"highlight"
|
|
107
|
+
].forEach((k) => !x[k] && delete x[k]);
|
|
108
|
+
return x;
|
|
109
|
+
};
|
|
110
|
+
/** What a person typed → the cell. A value that doesn't fit its column (e.g. "Partly" in Yes / No) becomes a text cell. */
|
|
111
|
+
function typedCell(prev, col, row, raw) {
|
|
112
|
+
const colType = row.type ?? col.type;
|
|
113
|
+
const own = isCellObject(prev) ? prev.type : void 0;
|
|
114
|
+
const plain = raw.trim();
|
|
115
|
+
const note = cellNote(prev);
|
|
116
|
+
const fits = (ty) => !plain || (ty !== "number" && ty !== "money" && ty !== "rating" || toNumber(plain.replace(/(USD|EUR|GBP|JPY|INR|AUD|CAD|CHF)$/i, "")) != null) && (ty !== "boolean" || toBool(plain) != null);
|
|
117
|
+
let type = own;
|
|
118
|
+
if (own === "text" && fits(colType)) type = void 0;
|
|
119
|
+
else if (!own && !fits(colType)) type = "text";
|
|
120
|
+
const ty = type ?? colType;
|
|
121
|
+
let v;
|
|
122
|
+
if (ty === "link") {
|
|
123
|
+
const p = cellValue(prev);
|
|
124
|
+
const l = isObjLike(p) && !("ref" in p) ? p : null;
|
|
125
|
+
v = plain ? {
|
|
126
|
+
...l ?? {},
|
|
127
|
+
label: plain,
|
|
128
|
+
href: l?.href ?? ""
|
|
129
|
+
} : null;
|
|
130
|
+
} else v = coerce(raw, {
|
|
131
|
+
type: ty,
|
|
132
|
+
max: col.max
|
|
133
|
+
});
|
|
134
|
+
return type || note ? {
|
|
135
|
+
value: v,
|
|
136
|
+
...type ? { type } : {},
|
|
137
|
+
...note ? { note } : {}
|
|
138
|
+
} : v;
|
|
139
|
+
}
|
|
140
|
+
/** Change a column's type; filled cells are re-read as the new type (words that don't fit become a text cell). */
|
|
141
|
+
function retype(t, key, type, resolveRef) {
|
|
142
|
+
const col = t.columns.find((c) => c._key === key);
|
|
143
|
+
if (!col || col.type === type) return t;
|
|
144
|
+
const next = {
|
|
145
|
+
...col,
|
|
146
|
+
type,
|
|
147
|
+
...type === "money" && !col.currency ? { currency: "USD" } : {}
|
|
148
|
+
};
|
|
149
|
+
if (type !== "number") delete next.unit;
|
|
150
|
+
if (type !== "money") delete next.currency;
|
|
151
|
+
if (type !== "rating") delete next.max;
|
|
152
|
+
if (type !== "boolean") {
|
|
153
|
+
delete next.trueLabel;
|
|
154
|
+
delete next.falseLabel;
|
|
155
|
+
}
|
|
156
|
+
if (type !== "reference") delete next.refTo;
|
|
157
|
+
if (type !== "number" && type !== "money") delete next.decimals;
|
|
158
|
+
return {
|
|
159
|
+
...t,
|
|
160
|
+
columns: t.columns.map((c) => c._key === key ? next : c),
|
|
161
|
+
rows: t.rows.map((r) => {
|
|
162
|
+
const cell = r.cells[key];
|
|
163
|
+
if (isCellObject(cell) && cell.type || r.type) return r;
|
|
164
|
+
const v = cellValue(cell);
|
|
165
|
+
if (isEmptyCell(v)) return r;
|
|
166
|
+
const raw = col.type === "link" && isObjLike(v) ? v.label : col.type === "reference" && isObjLike(v) ? refLabel(v) : cellText(col, r, cell, resolveRef);
|
|
167
|
+
const written = type === "reference" ? raw ? {
|
|
168
|
+
value: raw,
|
|
169
|
+
type: "text"
|
|
170
|
+
} : null : typedCell(cell, next, r, raw);
|
|
171
|
+
return {
|
|
172
|
+
...r,
|
|
173
|
+
cells: {
|
|
174
|
+
...r.cells,
|
|
175
|
+
[key]: written
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
})
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
var displayRows = (t) => {
|
|
182
|
+
const { bodies, foot } = orderedRows(t);
|
|
183
|
+
const out = [];
|
|
184
|
+
bodies.forEach((b) => b.rows.forEach((row, i) => out.push({
|
|
185
|
+
row,
|
|
186
|
+
groupStart: i === 0 ? b.group : void 0
|
|
187
|
+
})));
|
|
188
|
+
foot.forEach((row, i) => out.push({
|
|
189
|
+
row,
|
|
190
|
+
footStart: i === 0
|
|
191
|
+
}));
|
|
192
|
+
return out;
|
|
193
|
+
};
|
|
194
|
+
/** Move a row to a displayed position; crossing into another group (or the totals) takes on that place. */
|
|
195
|
+
function moveRowTo(t, from, to) {
|
|
196
|
+
const order = displayRows(t).map((d) => d.row);
|
|
197
|
+
if (to < 0 || to >= order.length || from === to) return t;
|
|
198
|
+
const [r] = order.splice(from, 1);
|
|
199
|
+
const target = order[Math.min(to, order.length - 1)] ?? r;
|
|
200
|
+
order.splice(to, 0, clean({
|
|
201
|
+
...r,
|
|
202
|
+
group: target.group,
|
|
203
|
+
footer: target.footer
|
|
204
|
+
}));
|
|
205
|
+
return {
|
|
206
|
+
...t,
|
|
207
|
+
rows: order
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
var rowTitle = (t, r, i, resolveRef) => {
|
|
211
|
+
const c = t.columns[0];
|
|
212
|
+
return c && cellText(c, r, r.cells[c._key], resolveRef) || `Row ${i + 1}`;
|
|
213
|
+
};
|
|
214
|
+
var moveItem = (list, from, to) => {
|
|
215
|
+
const next = list.slice();
|
|
216
|
+
const [x] = next.splice(from, 1);
|
|
217
|
+
next.splice(to, 0, x);
|
|
218
|
+
return next;
|
|
219
|
+
};
|
|
220
|
+
var dropColumn = (t, key) => ({
|
|
221
|
+
...t,
|
|
222
|
+
columns: t.columns.filter((c) => c._key !== key),
|
|
223
|
+
rows: t.rows.map((r) => ({
|
|
224
|
+
...r,
|
|
225
|
+
cells: Object.fromEntries(Object.entries(r.cells).filter(([k]) => k !== key))
|
|
226
|
+
}))
|
|
227
|
+
});
|
|
228
|
+
var copyColumn = (t, i) => {
|
|
229
|
+
const c = t.columns[i];
|
|
230
|
+
const k = tkey("c");
|
|
231
|
+
const columns = [
|
|
232
|
+
...t.columns.slice(0, i + 1),
|
|
233
|
+
{
|
|
234
|
+
...c,
|
|
235
|
+
_key: k,
|
|
236
|
+
label: c.label ? `${c.label} copy` : "",
|
|
237
|
+
...c.highlight ? { highlight: void 0 } : {}
|
|
238
|
+
},
|
|
239
|
+
...t.columns.slice(i + 1)
|
|
240
|
+
];
|
|
241
|
+
return {
|
|
242
|
+
...t,
|
|
243
|
+
columns,
|
|
244
|
+
rows: t.rows.map((r) => r.cells[c._key] === void 0 ? r : {
|
|
245
|
+
...r,
|
|
246
|
+
cells: {
|
|
247
|
+
...r.cells,
|
|
248
|
+
[k]: r.cells[c._key]
|
|
249
|
+
}
|
|
250
|
+
})
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
/** CPO D49: the ONE way into the spreadsheet — opens it in the shared ExpandedEditorModal. Place it next to the title. */
|
|
254
|
+
function TableFullScreenButton({ onOpen, className }) {
|
|
255
|
+
return /* @__PURE__ */ jsx(IconButton, {
|
|
256
|
+
size: "sm",
|
|
257
|
+
label: "Edit in full screen",
|
|
258
|
+
className,
|
|
259
|
+
onClick: onOpen,
|
|
260
|
+
children: /* @__PURE__ */ jsx(IconArrowsMaximize, { stroke: 1.5 })
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function TableEditor(props) {
|
|
264
|
+
const { value, onChange, readOnly, actions, label, options = GENERAL_TABLE, developer, resolveRef, nav, fullScreen } = props;
|
|
265
|
+
const t = React.useMemo(() => normalizeTable(value), [value]);
|
|
266
|
+
const [fullInner, setFullInner] = React.useState(false);
|
|
267
|
+
const full = fullScreen?.open ?? fullInner;
|
|
268
|
+
const setFull = fullScreen?.onOpenChange ?? setFullInner;
|
|
269
|
+
const root = React.useRef(null);
|
|
270
|
+
const { toast } = useKitServices();
|
|
271
|
+
const ctx = makeCtx({
|
|
272
|
+
t,
|
|
273
|
+
onChange,
|
|
274
|
+
options,
|
|
275
|
+
developer,
|
|
276
|
+
resolveRef,
|
|
277
|
+
readOnly,
|
|
278
|
+
toast
|
|
279
|
+
});
|
|
280
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
281
|
+
ref: root,
|
|
282
|
+
className: "flex min-w-0 flex-col",
|
|
283
|
+
"data-table-editor": "",
|
|
284
|
+
onKeyDown: (e) => e.key !== "Escape" && !e.target.closest?.("[aria-roledescription=\"sortable\"]") && e.stopPropagation(),
|
|
285
|
+
onPaste: (e) => e.stopPropagation(),
|
|
286
|
+
onCut: (e) => e.stopPropagation(),
|
|
287
|
+
onCopy: (e) => e.stopPropagation(),
|
|
288
|
+
children: [/* @__PURE__ */ jsx(TableBody, {
|
|
289
|
+
ctx,
|
|
290
|
+
label,
|
|
291
|
+
nav,
|
|
292
|
+
head: /* @__PURE__ */ jsxs(Fragment, { children: [readOnly || fullScreen ? null : /* @__PURE__ */ jsx(TableFullScreenButton, {
|
|
293
|
+
className: "-my-1",
|
|
294
|
+
onOpen: () => setFull(true)
|
|
295
|
+
}), actions] })
|
|
296
|
+
}), /* @__PURE__ */ jsx(ExpandedEditorModal, {
|
|
297
|
+
open: full,
|
|
298
|
+
onOpenChange: setFull,
|
|
299
|
+
layout: "wide",
|
|
300
|
+
crumbs: [
|
|
301
|
+
props.parentTitle,
|
|
302
|
+
label || "Table",
|
|
303
|
+
t.caption || void 0
|
|
304
|
+
].filter(Boolean),
|
|
305
|
+
meta: `${t.rows.length} ${t.rows.length === 1 ? "row" : "rows"} · ${t.columns.length} ${t.columns.length === 1 ? "column" : "columns"}`,
|
|
306
|
+
returnFocus: () => fullScreen?.returnFocus?.() ?? root.current?.querySelector("button[aria-label=\"Edit in full screen\"]") ?? null,
|
|
307
|
+
initialFocus: () => document.querySelector("[role=dialog] [data-cell=\"0:0\"], [role=dialog] [data-cell=\"-1:0\"]"),
|
|
308
|
+
children: full ? /* @__PURE__ */ jsx("div", {
|
|
309
|
+
"data-table-editor": "",
|
|
310
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
311
|
+
onPaste: (e) => e.stopPropagation(),
|
|
312
|
+
children: /* @__PURE__ */ jsx(Grid, {
|
|
313
|
+
ctx,
|
|
314
|
+
label,
|
|
315
|
+
full: true
|
|
316
|
+
})
|
|
317
|
+
}) : null
|
|
318
|
+
})]
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
function makeCtx({ t, onChange, options = {}, developer, resolveRef, readOnly, toast }) {
|
|
322
|
+
const types = Object.keys(TYPE_UI).filter((ty) => options.columnTypes ? options.columnTypes.includes(ty) : !TYPE_UI[ty].dev || developer);
|
|
323
|
+
return {
|
|
324
|
+
t,
|
|
325
|
+
set: onChange,
|
|
326
|
+
edit: (f) => onChange(f(t)),
|
|
327
|
+
options,
|
|
328
|
+
developer: !!developer,
|
|
329
|
+
types,
|
|
330
|
+
resolveRef,
|
|
331
|
+
lock: !!options.lockColumns || !!readOnly,
|
|
332
|
+
readOnly: !!readOnly,
|
|
333
|
+
undoable: (message, prev, description) => toast?.(message, {
|
|
334
|
+
description,
|
|
335
|
+
action: {
|
|
336
|
+
label: "Undo",
|
|
337
|
+
onClick: () => onChange(prev)
|
|
338
|
+
},
|
|
339
|
+
duration: 1e4
|
|
340
|
+
})
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* One row or one column of a table, as the body of a drilled frame (D50). The kit form shows it under the standard
|
|
345
|
+
* breadcrumb and frame header, exactly like an FAQ item; hosts without a form get the same body from TableEditor.
|
|
346
|
+
*/
|
|
347
|
+
function TableItemEditor({ kind, index, value, onChange, options, developer, resolveRef, readOnly }) {
|
|
348
|
+
const t = React.useMemo(() => normalizeTable(value), [value]);
|
|
349
|
+
const { toast } = useKitServices();
|
|
350
|
+
const ctx = makeCtx({
|
|
351
|
+
t,
|
|
352
|
+
onChange,
|
|
353
|
+
options,
|
|
354
|
+
developer,
|
|
355
|
+
resolveRef,
|
|
356
|
+
readOnly,
|
|
357
|
+
toast
|
|
358
|
+
});
|
|
359
|
+
if (kind === "row") {
|
|
360
|
+
const row = t.rows[index];
|
|
361
|
+
return row ? /* @__PURE__ */ jsx(RowFields, {
|
|
362
|
+
ctx,
|
|
363
|
+
row
|
|
364
|
+
}) : /* @__PURE__ */ jsx(Gone, { kind: "row" });
|
|
365
|
+
}
|
|
366
|
+
const col = t.columns[index];
|
|
367
|
+
return col ? /* @__PURE__ */ jsx(ColumnFields, {
|
|
368
|
+
ctx,
|
|
369
|
+
col
|
|
370
|
+
}) : /* @__PURE__ */ jsx(Gone, { kind: "column" });
|
|
371
|
+
}
|
|
372
|
+
/** A frame restored onto a row or column that was deleted elsewhere says so, never an empty body. */
|
|
373
|
+
var Gone = ({ kind }) => /* @__PURE__ */ jsxs("p", {
|
|
374
|
+
role: "note",
|
|
375
|
+
className: "text-kit-sm text-kit-fg-3",
|
|
376
|
+
children: [
|
|
377
|
+
"This ",
|
|
378
|
+
kind,
|
|
379
|
+
" is no longer in the table."
|
|
380
|
+
]
|
|
381
|
+
});
|
|
382
|
+
/** A column's minimum width: its longest header word + the type icon and ⋯ never break mid-word (≥ 96px, ≤ 240px). */
|
|
383
|
+
var colMinWidth = (c, full) => {
|
|
384
|
+
const longest = Math.max(0, ...c.label.split(/\s+/).map((w) => w.length));
|
|
385
|
+
return Math.min(240, Math.max(full ? 150 : 96, Math.ceil(longest * 7.6) + 58));
|
|
386
|
+
};
|
|
387
|
+
function Grid({ ctx, label, full }) {
|
|
388
|
+
const { t, set, lock, readOnly } = ctx;
|
|
389
|
+
const { toast } = useKitServices();
|
|
390
|
+
const rows = displayRows(t);
|
|
391
|
+
const cols = t.columns;
|
|
392
|
+
const host = React.useRef(null);
|
|
393
|
+
const pending = React.useRef(null);
|
|
394
|
+
const [, bump] = React.useReducer((n) => n + 1, 0);
|
|
395
|
+
const focus = (r, c) => {
|
|
396
|
+
pending.current = `${r}:${c}`;
|
|
397
|
+
bump();
|
|
398
|
+
};
|
|
399
|
+
React.useLayoutEffect(() => {
|
|
400
|
+
const p = pending.current;
|
|
401
|
+
if (!p) return;
|
|
402
|
+
const el = host.current?.querySelector(`[data-cell="${p}"]`);
|
|
403
|
+
if (!el) return;
|
|
404
|
+
pending.current = null;
|
|
405
|
+
el.focus({ preventScroll: true });
|
|
406
|
+
el.scrollIntoView?.({
|
|
407
|
+
block: "nearest",
|
|
408
|
+
inline: "nearest"
|
|
409
|
+
});
|
|
410
|
+
if (el instanceof HTMLTextAreaElement) el.setSelectionRange(el.value.length, el.value.length);
|
|
411
|
+
});
|
|
412
|
+
const bodyCount = t.rows.filter((r) => !r.footer).length;
|
|
413
|
+
const atMaxRows = !!ctx.options.maxRows && bodyCount >= ctx.options.maxRows;
|
|
414
|
+
const atMaxCols = !!ctx.options.maxColumns && cols.length >= ctx.options.maxColumns;
|
|
415
|
+
const addRow = (at = rows.length) => {
|
|
416
|
+
if (readOnly) return;
|
|
417
|
+
const anchor = rows[Math.min(at, rows.length) - 1]?.row;
|
|
418
|
+
const intoTotals = !!anchor?.footer && at < rows.length;
|
|
419
|
+
if (atMaxRows && !intoTotals) return toast?.("Limit reached", { description: `This table allows ${ctx.options.maxRows} rows at most.` });
|
|
420
|
+
const order = rows.map((d) => d.row);
|
|
421
|
+
order.splice(at, 0, {
|
|
422
|
+
_key: tkey("r"),
|
|
423
|
+
cells: {},
|
|
424
|
+
...anchor?.group ? { group: anchor.group } : {},
|
|
425
|
+
...intoTotals ? { footer: true } : {}
|
|
426
|
+
});
|
|
427
|
+
set({
|
|
428
|
+
...t,
|
|
429
|
+
rows: order
|
|
430
|
+
});
|
|
431
|
+
focus(at, 0);
|
|
432
|
+
};
|
|
433
|
+
const addCol = (at = cols.length) => {
|
|
434
|
+
if (lock) return;
|
|
435
|
+
if (atMaxCols) return toast?.("Limit reached", { description: `This table allows ${ctx.options.maxColumns} columns at most.` });
|
|
436
|
+
const next = [...cols];
|
|
437
|
+
next.splice(at, 0, {
|
|
438
|
+
_key: tkey("c"),
|
|
439
|
+
label: "",
|
|
440
|
+
type: "text"
|
|
441
|
+
});
|
|
442
|
+
set({
|
|
443
|
+
...t,
|
|
444
|
+
columns: next
|
|
445
|
+
});
|
|
446
|
+
focus(-1, at);
|
|
447
|
+
};
|
|
448
|
+
const move = (from, dir) => {
|
|
449
|
+
const r = from.r + (dir === "down" ? 1 : dir === "up" ? -1 : 0);
|
|
450
|
+
const c = from.c + (dir === "right" ? 1 : dir === "left" ? -1 : 0);
|
|
451
|
+
if (c < 0 || c >= cols.length || r < -1) return;
|
|
452
|
+
if (r >= rows.length) return addRow();
|
|
453
|
+
focus(r, c);
|
|
454
|
+
};
|
|
455
|
+
const onPaste = (e, r, c) => {
|
|
456
|
+
if (readOnly) return false;
|
|
457
|
+
const html = e.clipboardData.getData("text/html");
|
|
458
|
+
const text = e.clipboardData.getData("text/plain");
|
|
459
|
+
let range = [];
|
|
460
|
+
if (html && /<table[\s>]/i.test(html) && typeof DOMParser !== "undefined") {
|
|
461
|
+
const tbl = new DOMParser().parseFromString(html, "text/html").querySelector("table");
|
|
462
|
+
if (tbl) range = tableToRows(parseTableElement(tbl)).slice(r < 0 ? 0 : 1);
|
|
463
|
+
}
|
|
464
|
+
if (!range.length && /[\t\n]/.test(text.trim())) range = parseDelimited(text);
|
|
465
|
+
if (!range.length) return false;
|
|
466
|
+
e.preventDefault();
|
|
467
|
+
const blank = t.rows.every((x) => Object.values(x.cells).every((v) => isEmptyCell(cellValue(v)))) && cols.every((x) => !x.label.trim());
|
|
468
|
+
let next;
|
|
469
|
+
if (blank && !lock && range.length > 1) {
|
|
470
|
+
const n = tableFromRows(range, { header: true });
|
|
471
|
+
next = {
|
|
472
|
+
...t,
|
|
473
|
+
columns: n.columns,
|
|
474
|
+
rows: n.rows,
|
|
475
|
+
headerColumn: n.headerColumn || t.headerColumn
|
|
476
|
+
};
|
|
477
|
+
} else next = pasteRange({
|
|
478
|
+
...t,
|
|
479
|
+
rows: rows.map((d) => d.row)
|
|
480
|
+
}, {
|
|
481
|
+
row: r,
|
|
482
|
+
col: c
|
|
483
|
+
}, range, { lockColumns: lock });
|
|
484
|
+
const body = next.rows.filter((x) => !x.footer).length;
|
|
485
|
+
if (ctx.options.maxRows && body > ctx.options.maxRows) {
|
|
486
|
+
toast?.("Paste not applied", { description: `It would make ${body} rows; this table allows ${ctx.options.maxRows}.` });
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
if (ctx.options.maxColumns && next.columns.length > ctx.options.maxColumns) {
|
|
490
|
+
toast?.("Paste not applied", { description: `It would make ${next.columns.length} columns; this table allows ${ctx.options.maxColumns}.` });
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
set(next);
|
|
494
|
+
toast?.(`Pasted ${range.length} ${range.length === 1 ? "row" : "rows"}`);
|
|
495
|
+
return true;
|
|
496
|
+
};
|
|
497
|
+
const drag = React.useRef(null);
|
|
498
|
+
const helpId = `${React.useId()}-grid-help`;
|
|
499
|
+
const [over, setOver] = React.useState(null);
|
|
500
|
+
const drop = (kind, i) => {
|
|
501
|
+
const d = drag.current;
|
|
502
|
+
drag.current = null;
|
|
503
|
+
setOver(null);
|
|
504
|
+
if (!d || d.kind !== kind || d.i === i) return;
|
|
505
|
+
if (kind === "row") set(moveRowTo(t, d.i, i));
|
|
506
|
+
else if (!lock) set({
|
|
507
|
+
...t,
|
|
508
|
+
columns: moveItem(cols, d.i, i)
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
512
|
+
ref: host,
|
|
513
|
+
className: cn("min-w-0 overflow-x-auto rounded-kit-lg border border-kit-field-border bg-kit-surface", full && "max-h-full min-h-0 flex-1 overflow-auto"),
|
|
514
|
+
"data-full": full ? "" : void 0,
|
|
515
|
+
children: [
|
|
516
|
+
/* @__PURE__ */ jsxs("table", {
|
|
517
|
+
role: "grid",
|
|
518
|
+
"aria-label": label || t.caption || "Table",
|
|
519
|
+
"aria-describedby": helpId,
|
|
520
|
+
className: "w-full border-separate border-spacing-0 text-kit-sm",
|
|
521
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
522
|
+
/* @__PURE__ */ jsx("th", {
|
|
523
|
+
className: cn("w-8 border-b border-kit-line bg-kit-subtle", full && "sticky left-0 top-0 z-[3]"),
|
|
524
|
+
"aria-hidden": true
|
|
525
|
+
}),
|
|
526
|
+
cols.map((c, ci) => /* @__PURE__ */ jsx("th", {
|
|
527
|
+
scope: "col",
|
|
528
|
+
style: { minWidth: colMinWidth(c, full) },
|
|
529
|
+
className: cn("group/col relative border-b border-l border-kit-line bg-kit-subtle p-0 text-left align-bottom font-medium", full && "sticky top-0 z-[2]", full && ci === 0 && "left-8 z-[3]", over?.kind === "col" && over.i === ci && "shadow-[inset_2px_0_0_var(--kit-fg-2)]"),
|
|
530
|
+
onDragOver: (e) => drag.current?.kind === "col" && (e.preventDefault(), setOver({
|
|
531
|
+
kind: "col",
|
|
532
|
+
i: ci
|
|
533
|
+
})),
|
|
534
|
+
onDrop: () => drop("col", ci),
|
|
535
|
+
children: /* @__PURE__ */ jsx(ColumnMenu, {
|
|
536
|
+
ctx,
|
|
537
|
+
col: c,
|
|
538
|
+
index: ci,
|
|
539
|
+
onInsert: (right) => addCol(right ? ci + 1 : ci),
|
|
540
|
+
children: (openMenu) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
541
|
+
lock ? null : /* @__PURE__ */ jsx("span", {
|
|
542
|
+
draggable: true,
|
|
543
|
+
onDragStart: (e) => (drag.current = {
|
|
544
|
+
kind: "col",
|
|
545
|
+
i: ci
|
|
546
|
+
}, e.dataTransfer.setData("text/plain", c.label)),
|
|
547
|
+
className: "-ml-1 hidden cursor-grab text-kit-fg-4 group-hover/col:block",
|
|
548
|
+
"aria-hidden": true,
|
|
549
|
+
children: /* @__PURE__ */ jsx(IconGripVertical, {
|
|
550
|
+
className: "size-3.5",
|
|
551
|
+
stroke: 1.5
|
|
552
|
+
})
|
|
553
|
+
}),
|
|
554
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: c.type }),
|
|
555
|
+
/* @__PURE__ */ jsx(CellInput, {
|
|
556
|
+
cell: `-1:${ci}`,
|
|
557
|
+
value: c.label,
|
|
558
|
+
display: c.label,
|
|
559
|
+
placeholder: ci === 0 && t.headerColumn ? "Row names" : "Column name",
|
|
560
|
+
readOnly: lock,
|
|
561
|
+
className: cn("font-medium text-kit-fg", !t.headerRow && "text-kit-fg-3"),
|
|
562
|
+
ariaLabel: `Column ${ci + 1} name${t.headerRow ? "" : " (not shown on the page)"}`,
|
|
563
|
+
onCommit: (v) => set({
|
|
564
|
+
...t,
|
|
565
|
+
columns: t.columns.map((x) => x._key === c._key ? {
|
|
566
|
+
...x,
|
|
567
|
+
label: v.replace(/\s+/g, " ").trim()
|
|
568
|
+
} : x)
|
|
569
|
+
}),
|
|
570
|
+
onMove: (dir) => move({
|
|
571
|
+
r: -1,
|
|
572
|
+
c: ci
|
|
573
|
+
}, dir),
|
|
574
|
+
onMenu: openMenu,
|
|
575
|
+
onPaste: (e) => onPaste(e, -1, ci)
|
|
576
|
+
})
|
|
577
|
+
] })
|
|
578
|
+
})
|
|
579
|
+
}, c._key)),
|
|
580
|
+
/* @__PURE__ */ jsx("th", {
|
|
581
|
+
className: "w-9 border-b border-l border-kit-line bg-kit-subtle p-0",
|
|
582
|
+
children: lock ? null : /* @__PURE__ */ jsx(IconButton, {
|
|
583
|
+
size: "xs",
|
|
584
|
+
label: "Add column",
|
|
585
|
+
className: "mx-auto",
|
|
586
|
+
disabled: atMaxCols,
|
|
587
|
+
onClick: () => addCol(),
|
|
588
|
+
children: /* @__PURE__ */ jsx(IconPlus, { stroke: 1.75 })
|
|
589
|
+
})
|
|
590
|
+
})
|
|
591
|
+
] }) }), /* @__PURE__ */ jsx("tbody", { children: rows.map(({ row, groupStart, footStart }, ri) => /* @__PURE__ */ jsxs(React.Fragment, { children: [groupStart || footStart ? /* @__PURE__ */ jsx("tr", {
|
|
592
|
+
"aria-hidden": true,
|
|
593
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
594
|
+
colSpan: cols.length + 2,
|
|
595
|
+
className: "border-t border-kit-line bg-[var(--kit-subtle-2)] px-2 py-1 text-kit-2xs font-medium text-kit-fg-3",
|
|
596
|
+
children: groupStart ? groupStart.label || "Untitled group" : "Totals"
|
|
597
|
+
})
|
|
598
|
+
}) : null, /* @__PURE__ */ jsxs("tr", {
|
|
599
|
+
className: cn("group/row", over?.kind === "row" && over.i === ri && "shadow-[inset_0_2px_0_var(--kit-fg-2)]"),
|
|
600
|
+
onDragOver: (e) => drag.current?.kind === "row" && (e.preventDefault(), setOver({
|
|
601
|
+
kind: "row",
|
|
602
|
+
i: ri
|
|
603
|
+
})),
|
|
604
|
+
onDrop: () => drop("row", ri),
|
|
605
|
+
children: [
|
|
606
|
+
/* @__PURE__ */ jsx("td", {
|
|
607
|
+
className: cn("w-8 border-t border-kit-line bg-[var(--kit-subtle-2)] p-0 align-middle", full && "sticky left-0 z-[1] bg-kit-subtle"),
|
|
608
|
+
children: readOnly ? /* @__PURE__ */ jsx("div", {
|
|
609
|
+
className: "flex h-8 items-center justify-center text-kit-2xs text-kit-fg-4",
|
|
610
|
+
children: ri + 1
|
|
611
|
+
}) : /* @__PURE__ */ jsx(RowMenu, {
|
|
612
|
+
ctx,
|
|
613
|
+
row,
|
|
614
|
+
index: ri,
|
|
615
|
+
count: rows.length,
|
|
616
|
+
onInsert: (below) => addRow(below ? ri + 1 : ri),
|
|
617
|
+
children: (trigger) => /* @__PURE__ */ jsxs("div", {
|
|
618
|
+
draggable: true,
|
|
619
|
+
onDragStart: (e) => (drag.current = {
|
|
620
|
+
kind: "row",
|
|
621
|
+
i: ri
|
|
622
|
+
}, e.dataTransfer.setData("text/plain", String(ri))),
|
|
623
|
+
className: "flex h-8 cursor-grab items-center justify-center text-kit-2xs text-kit-fg-4",
|
|
624
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
625
|
+
className: "group-hover/row:hidden group-focus-within/row:hidden",
|
|
626
|
+
children: ri + 1
|
|
627
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
628
|
+
className: "hidden group-hover/row:flex group-focus-within/row:flex",
|
|
629
|
+
children: trigger
|
|
630
|
+
})]
|
|
631
|
+
})
|
|
632
|
+
})
|
|
633
|
+
}),
|
|
634
|
+
cols.map((c, ci) => /* @__PURE__ */ jsx(GridCell, {
|
|
635
|
+
full,
|
|
636
|
+
ctx,
|
|
637
|
+
row,
|
|
638
|
+
col: c,
|
|
639
|
+
r: ri,
|
|
640
|
+
c: ci,
|
|
641
|
+
onMove: (dir) => move({
|
|
642
|
+
r: ri,
|
|
643
|
+
c: ci
|
|
644
|
+
}, dir),
|
|
645
|
+
onPaste: (e) => onPaste(e, ri, ci)
|
|
646
|
+
}, c._key)),
|
|
647
|
+
/* @__PURE__ */ jsx("td", { className: "border-l border-t border-kit-line" })
|
|
648
|
+
]
|
|
649
|
+
})] }, row._key)) })]
|
|
650
|
+
}),
|
|
651
|
+
/* @__PURE__ */ jsx("p", {
|
|
652
|
+
id: helpId,
|
|
653
|
+
className: "sr-only",
|
|
654
|
+
children: "Tab and the arrow keys move between cells. Shift+F10 on a column, row or cell opens its options."
|
|
655
|
+
}),
|
|
656
|
+
readOnly ? null : /* @__PURE__ */ jsxs("button", {
|
|
657
|
+
type: "button",
|
|
658
|
+
onClick: () => addRow(),
|
|
659
|
+
disabled: atMaxRows,
|
|
660
|
+
className: "flex h-8 w-full items-center gap-1.5 border-t border-kit-line px-2.5 text-left text-kit-xs text-kit-fg-3 hover:bg-kit-subtle hover:text-kit-fg disabled:opacity-45",
|
|
661
|
+
children: [
|
|
662
|
+
/* @__PURE__ */ jsx(IconPlus, {
|
|
663
|
+
className: "size-3.5",
|
|
664
|
+
stroke: 1.75,
|
|
665
|
+
"aria-hidden": true
|
|
666
|
+
}),
|
|
667
|
+
" ",
|
|
668
|
+
atMaxRows ? `Add row · ${ctx.options.maxRows} at most` : "Add row"
|
|
669
|
+
]
|
|
670
|
+
})
|
|
671
|
+
]
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
/** A grid cell: always editable (no select-then-edit mode). Yes / No is a check toggle; links and references open a small editor. */
|
|
675
|
+
function GridCell({ ctx, row, col, r, c, onMove, onPaste, full }) {
|
|
676
|
+
const { t, edit, resolveRef, readOnly } = ctx;
|
|
677
|
+
const cell = row.cells[col._key];
|
|
678
|
+
const v = cellValue(cell);
|
|
679
|
+
const declared = cellType(col, row, cell);
|
|
680
|
+
const ty = declared === "boolean" && !isEmptyCell(v) && toBool(v) == null ? "text" : declared;
|
|
681
|
+
const write = (next) => edit(mapRow(row._key, (x) => ({
|
|
682
|
+
...x,
|
|
683
|
+
cells: {
|
|
684
|
+
...x.cells,
|
|
685
|
+
[col._key]: next ?? null
|
|
686
|
+
}
|
|
687
|
+
})));
|
|
688
|
+
const head = t.headerColumn && c === 0;
|
|
689
|
+
const note = cellNote(cell);
|
|
690
|
+
const n = note ? (t.footnotes ?? []).findIndex((f) => f._key === note) + 1 : 0;
|
|
691
|
+
const fn = note ? (t.footnotes ?? []).find((f) => f._key === note) : void 0;
|
|
692
|
+
const [noteOpen, setNoteOpen] = React.useState(false);
|
|
693
|
+
const name = `${col.label || `Column ${c + 1}`}, ${rowTitle(t, row, r, resolveRef)}`;
|
|
694
|
+
let body;
|
|
695
|
+
if (ty === "boolean") {
|
|
696
|
+
const b = toBool(v);
|
|
697
|
+
const { yes, no } = boolLabels(col);
|
|
698
|
+
body = /* @__PURE__ */ jsx("button", {
|
|
699
|
+
type: "button",
|
|
700
|
+
role: "checkbox",
|
|
701
|
+
"aria-checked": b === true,
|
|
702
|
+
"aria-label": `${name}: ${b == null ? "not set" : b ? yes : no}`,
|
|
703
|
+
"aria-readonly": readOnly || void 0,
|
|
704
|
+
"data-cell": `${r}:${c}`,
|
|
705
|
+
onClick: () => !readOnly && write(withValue(cell, b !== true)),
|
|
706
|
+
onKeyDown: (e) => {
|
|
707
|
+
const k = e.key;
|
|
708
|
+
if (k === "ArrowUp" || k === "ArrowDown" || k === "ArrowLeft" || k === "ArrowRight") {
|
|
709
|
+
e.preventDefault();
|
|
710
|
+
onMove(k.slice(5).toLowerCase());
|
|
711
|
+
} else if (k === "Enter") {
|
|
712
|
+
e.preventDefault();
|
|
713
|
+
onMove("down");
|
|
714
|
+
} else if (readOnly) return;
|
|
715
|
+
else if (k === "Delete" || k === "Backspace") {
|
|
716
|
+
e.preventDefault();
|
|
717
|
+
write(withValue(cell, null));
|
|
718
|
+
} else if (/^[yn]$/i.test(k)) {
|
|
719
|
+
e.preventDefault();
|
|
720
|
+
write(withValue(cell, /y/i.test(k)));
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
onPaste: (e) => onPaste(e),
|
|
724
|
+
className: "flex h-8 w-full items-center px-2 outline-none focus-visible:shadow-[inset_0_0_0_2px_var(--kit-fg-3)]",
|
|
725
|
+
children: b == null ? /* @__PURE__ */ jsx("span", {
|
|
726
|
+
className: "text-kit-fg-4",
|
|
727
|
+
children: "—"
|
|
728
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
729
|
+
className: cn("flex size-4 items-center justify-center rounded-kit-sm border", b ? "border-kit-inverse bg-kit-inverse text-kit-fg-inverse" : "border-kit-line-strong"),
|
|
730
|
+
children: b ? /* @__PURE__ */ jsx(IconCheck, {
|
|
731
|
+
className: "size-3",
|
|
732
|
+
stroke: 3,
|
|
733
|
+
"aria-hidden": true
|
|
734
|
+
}) : null
|
|
735
|
+
})
|
|
736
|
+
});
|
|
737
|
+
} else if (ty === "reference") body = /* @__PURE__ */ jsx(RefCell, {
|
|
738
|
+
ctx,
|
|
739
|
+
cell,
|
|
740
|
+
col,
|
|
741
|
+
cellId: `${r}:${c}`,
|
|
742
|
+
name,
|
|
743
|
+
onWrite: write,
|
|
744
|
+
onMove
|
|
745
|
+
});
|
|
746
|
+
else {
|
|
747
|
+
const draft = isEmptyCell(v) ? "" : NUMERIC.includes(ty) ? String(toNumber(v) ?? cellText(col, row, cell)) : ty === "link" && isObjLike(v) ? v.label : ty === "richtext-inline" ? String(v) : cellText(col, row, cell, resolveRef);
|
|
748
|
+
const link = ty === "link" ? isObjLike(v) && !("ref" in v) ? v : {
|
|
749
|
+
label: typeof v === "string" ? v : "",
|
|
750
|
+
href: ""
|
|
751
|
+
} : null;
|
|
752
|
+
body = /* @__PURE__ */ jsxs("div", {
|
|
753
|
+
className: "relative flex items-start",
|
|
754
|
+
children: [
|
|
755
|
+
ty === "rating" && !isEmptyCell(v) ? /* @__PURE__ */ jsx(IconStar, {
|
|
756
|
+
className: "ml-2 mt-2 size-3 shrink-0 text-kit-warning",
|
|
757
|
+
stroke: 2,
|
|
758
|
+
"aria-hidden": true
|
|
759
|
+
}) : null,
|
|
760
|
+
/* @__PURE__ */ jsx(CellInput, {
|
|
761
|
+
cell: `${r}:${c}`,
|
|
762
|
+
value: draft,
|
|
763
|
+
display: isEmptyCell(v) ? "" : ty === "rating" ? draft : cellText(col, row, cell, resolveRef),
|
|
764
|
+
placeholder: "—",
|
|
765
|
+
numeric: NUMERIC.includes(ty),
|
|
766
|
+
readOnly,
|
|
767
|
+
className: cn(head && "font-medium", NUMERIC.includes(ty) && "text-right tabular-nums"),
|
|
768
|
+
ariaLabel: name,
|
|
769
|
+
onCommit: (raw) => raw !== draft && write(typedCell(cell, col, row, raw)),
|
|
770
|
+
onMove,
|
|
771
|
+
onPaste
|
|
772
|
+
}),
|
|
773
|
+
link ? /* @__PURE__ */ jsx(LinkAddressButton, {
|
|
774
|
+
className: "mr-1 mt-1.5",
|
|
775
|
+
link,
|
|
776
|
+
readOnly,
|
|
777
|
+
onSave: (l) => write(withValue(cell, l))
|
|
778
|
+
}) : null
|
|
779
|
+
]
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
const cls = cn("relative border-l border-t border-kit-line p-0 align-top", head && "bg-[var(--kit-subtle-2)]", full && c === 0 && "sticky left-8 z-[1] bg-kit-surface", row.highlight && "bg-kit-accent-softer", col.highlight && "bg-kit-subtle");
|
|
783
|
+
return /* @__PURE__ */ jsxs("td", {
|
|
784
|
+
className: cls,
|
|
785
|
+
children: [readOnly ? body : /* @__PURE__ */ jsx(CellMenu, {
|
|
786
|
+
ctx,
|
|
787
|
+
row,
|
|
788
|
+
col,
|
|
789
|
+
cell,
|
|
790
|
+
onWrite: write,
|
|
791
|
+
onNote: () => window.setTimeout(() => setNoteOpen(true)),
|
|
792
|
+
children: body
|
|
793
|
+
}), /* @__PURE__ */ jsxs(Popover, {
|
|
794
|
+
open: noteOpen && !!fn,
|
|
795
|
+
onOpenChange: setNoteOpen,
|
|
796
|
+
children: [/* @__PURE__ */ jsx(PopoverAnchor, {
|
|
797
|
+
render: n > 0 ? /* @__PURE__ */ jsx("button", {
|
|
798
|
+
type: "button",
|
|
799
|
+
tabIndex: -1,
|
|
800
|
+
"aria-label": `Footnote ${n}`,
|
|
801
|
+
onClick: () => setNoteOpen(true),
|
|
802
|
+
className: "absolute right-0.5 top-0.5 rounded-kit-xs px-0.5 text-kit-2xs leading-3 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg"
|
|
803
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
804
|
+
className: "pointer-events-none absolute right-1 top-1 size-0",
|
|
805
|
+
"aria-hidden": true
|
|
806
|
+
}),
|
|
807
|
+
children: n > 0 ? n : null
|
|
808
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
809
|
+
align: "end",
|
|
810
|
+
className: "w-72 p-2",
|
|
811
|
+
children: fn ? /* @__PURE__ */ jsx(Input, {
|
|
812
|
+
size: "sm",
|
|
813
|
+
autoFocus: true,
|
|
814
|
+
value: fn.text,
|
|
815
|
+
readOnly,
|
|
816
|
+
placeholder: "What the footnote says",
|
|
817
|
+
"aria-label": `Footnote ${n}`,
|
|
818
|
+
onChange: (e) => ctx.set({
|
|
819
|
+
...t,
|
|
820
|
+
footnotes: (t.footnotes ?? []).map((x) => x._key === fn._key ? {
|
|
821
|
+
...x,
|
|
822
|
+
text: e.target.value
|
|
823
|
+
} : x)
|
|
824
|
+
}),
|
|
825
|
+
onKeyDown: (e) => e.key === "Enter" && (e.preventDefault(), setNoteOpen(false))
|
|
826
|
+
}) : null
|
|
827
|
+
})]
|
|
828
|
+
})]
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
/** One cell's text. Shows the written value at rest ("$39", "2.4 kg") and the raw value while typing; commits on leave. */
|
|
832
|
+
function CellInput({ cell, value, display, onCommit, onMove, onMenu, onPaste, placeholder, numeric, className, ariaLabel, readOnly }) {
|
|
833
|
+
const [focused, setFocused] = React.useState(false);
|
|
834
|
+
const [draft, setDraft] = React.useState(value);
|
|
835
|
+
const ref = React.useRef(null);
|
|
836
|
+
const shown = focused ? draft : display;
|
|
837
|
+
React.useLayoutEffect(() => {
|
|
838
|
+
const el = ref.current;
|
|
839
|
+
if (!el) return;
|
|
840
|
+
el.style.height = "0px";
|
|
841
|
+
el.style.height = `${Math.max(32, el.scrollHeight)}px`;
|
|
842
|
+
}, [shown]);
|
|
843
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
844
|
+
ref,
|
|
845
|
+
rows: 1,
|
|
846
|
+
"data-cell": cell,
|
|
847
|
+
"data-cell-editing": focused && draft !== value ? "" : void 0,
|
|
848
|
+
value: shown,
|
|
849
|
+
readOnly,
|
|
850
|
+
placeholder,
|
|
851
|
+
"aria-label": ariaLabel,
|
|
852
|
+
inputMode: numeric ? "decimal" : void 0,
|
|
853
|
+
spellCheck: !numeric,
|
|
854
|
+
onFocus: () => {
|
|
855
|
+
setDraft(value);
|
|
856
|
+
setFocused(true);
|
|
857
|
+
},
|
|
858
|
+
onBlur: () => {
|
|
859
|
+
setFocused(false);
|
|
860
|
+
if (!readOnly && draft !== value) onCommit(draft);
|
|
861
|
+
},
|
|
862
|
+
onChange: (e) => setDraft(e.target.value),
|
|
863
|
+
onPaste: (e) => onPaste?.(e),
|
|
864
|
+
onKeyDown: (e) => {
|
|
865
|
+
const el = e.currentTarget;
|
|
866
|
+
const k = e.key;
|
|
867
|
+
const atStart = el.selectionStart === 0 && el.selectionEnd === 0;
|
|
868
|
+
const atEnd = el.selectionStart === el.value.length && el.selectionEnd === el.value.length;
|
|
869
|
+
const oneLine = !el.value.includes("\n");
|
|
870
|
+
if (k === "F10" && e.shiftKey || k === "ContextMenu") {
|
|
871
|
+
if (onMenu) {
|
|
872
|
+
e.preventDefault();
|
|
873
|
+
onMenu();
|
|
874
|
+
}
|
|
875
|
+
} else if (k === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
|
|
876
|
+
e.preventDefault();
|
|
877
|
+
onMove("down");
|
|
878
|
+
} else if (k === "Escape" && draft !== value) {
|
|
879
|
+
e.preventDefault();
|
|
880
|
+
e.stopPropagation();
|
|
881
|
+
setDraft(value);
|
|
882
|
+
} else if (k === "ArrowUp" && (oneLine || atStart)) {
|
|
883
|
+
e.preventDefault();
|
|
884
|
+
onMove("up");
|
|
885
|
+
} else if (k === "ArrowDown" && (oneLine || atEnd)) {
|
|
886
|
+
e.preventDefault();
|
|
887
|
+
onMove("down");
|
|
888
|
+
} else if (k === "ArrowLeft" && atStart) {
|
|
889
|
+
e.preventDefault();
|
|
890
|
+
onMove("left");
|
|
891
|
+
} else if (k === "ArrowRight" && atEnd) {
|
|
892
|
+
e.preventDefault();
|
|
893
|
+
onMove("right");
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
className: cn("block min-h-8 w-full resize-none overflow-hidden bg-transparent px-2 py-1.5 text-kit-sm leading-5 text-kit-fg outline-none [overflow-wrap:normal] [word-break:normal] placeholder:text-kit-fg-4 focus:bg-kit-surface focus:shadow-[inset_0_0_0_2px_var(--kit-fg-3)]", className)
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* A reference cell: a page or entry chosen from the host's search (refs.ts). Stores `{ ref, label, href? }`: the label and
|
|
901
|
+
* public path travel with the id so the published table reads without a lookup.
|
|
902
|
+
*/
|
|
903
|
+
function RefCell({ ctx, cell, col, cellId, name, onWrite, onMove }) {
|
|
904
|
+
const [open, setOpen] = React.useState(false);
|
|
905
|
+
const [q, setQ] = React.useState("");
|
|
906
|
+
const v = cellValue(cell);
|
|
907
|
+
const r = isObjLike(v) && "ref" in v ? v : null;
|
|
908
|
+
const label = r ? ctx.resolveRef?.(r.ref)?.label ?? refLabel(r) : typeof v === "string" ? v : "";
|
|
909
|
+
const search = useRefSearch(open, col.refTo?.length ? col.refTo : null, q);
|
|
910
|
+
const pick = (o) => {
|
|
911
|
+
onWrite(withValue(cell, {
|
|
912
|
+
ref: o.id,
|
|
913
|
+
label: o.title,
|
|
914
|
+
...o.href ? { href: o.href } : {}
|
|
915
|
+
}));
|
|
916
|
+
setOpen(false);
|
|
917
|
+
};
|
|
918
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
919
|
+
open,
|
|
920
|
+
onOpenChange: (o) => (setOpen(o), o || setQ("")),
|
|
921
|
+
children: [/* @__PURE__ */ jsx(PopoverAnchor, {
|
|
922
|
+
render: /* @__PURE__ */ jsx("button", {
|
|
923
|
+
type: "button",
|
|
924
|
+
"data-cell": cellId,
|
|
925
|
+
"aria-label": `${name}: ${label || "not chosen"}`,
|
|
926
|
+
"aria-haspopup": "dialog",
|
|
927
|
+
disabled: ctx.readOnly,
|
|
928
|
+
onClick: () => setOpen(true),
|
|
929
|
+
onKeyDown: (e) => {
|
|
930
|
+
const k = e.key;
|
|
931
|
+
if (k.startsWith("Arrow")) {
|
|
932
|
+
e.preventDefault();
|
|
933
|
+
onMove(k.slice(5).toLowerCase());
|
|
934
|
+
} else if (!ctx.readOnly && (k === "Delete" || k === "Backspace") && !isEmptyCell(v)) {
|
|
935
|
+
e.preventDefault();
|
|
936
|
+
onWrite(withValue(cell, null));
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
className: "flex min-h-8 w-full items-center px-2 text-left text-kit-sm text-kit-fg outline-none focus-visible:shadow-[inset_0_0_0_2px_var(--kit-fg-3)]"
|
|
940
|
+
}),
|
|
941
|
+
children: label ? /* @__PURE__ */ jsx("span", {
|
|
942
|
+
className: "truncate underline decoration-kit-fg-4 underline-offset-2",
|
|
943
|
+
children: label
|
|
944
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
945
|
+
className: "text-kit-fg-4",
|
|
946
|
+
children: "Choose…"
|
|
947
|
+
})
|
|
948
|
+
}), /* @__PURE__ */ jsxs(PopoverContent, {
|
|
949
|
+
align: "start",
|
|
950
|
+
className: "w-72 p-1.5",
|
|
951
|
+
children: [
|
|
952
|
+
/* @__PURE__ */ jsx(Input, {
|
|
953
|
+
size: "sm",
|
|
954
|
+
autoFocus: true,
|
|
955
|
+
value: q,
|
|
956
|
+
placeholder: "Search…",
|
|
957
|
+
"aria-label": "Find a page or entry",
|
|
958
|
+
onChange: (e) => setQ(e.target.value)
|
|
959
|
+
}),
|
|
960
|
+
/* @__PURE__ */ jsx("div", {
|
|
961
|
+
role: "status",
|
|
962
|
+
className: "sr-only",
|
|
963
|
+
children: search.status === "ready" ? `${search.options.length} results` : search.status === "loading" ? "Searching" : ""
|
|
964
|
+
}),
|
|
965
|
+
/* @__PURE__ */ jsxs("ul", {
|
|
966
|
+
className: "mt-1 max-h-56 overflow-auto",
|
|
967
|
+
"aria-label": "Pages and entries",
|
|
968
|
+
children: [
|
|
969
|
+
search.status === "ready" ? search.options.map((o) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
|
|
970
|
+
type: "button",
|
|
971
|
+
className: "flex w-full flex-col rounded-kit-md px-2 py-1.5 text-left hover:bg-kit-hover",
|
|
972
|
+
onClick: () => pick(o),
|
|
973
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
974
|
+
className: "truncate text-kit-sm text-kit-fg",
|
|
975
|
+
children: o.title
|
|
976
|
+
}), o.subtitle ? /* @__PURE__ */ jsx("span", {
|
|
977
|
+
className: "truncate text-kit-xs text-kit-fg-3",
|
|
978
|
+
children: o.subtitle
|
|
979
|
+
}) : null]
|
|
980
|
+
}) }, o.id)) : null,
|
|
981
|
+
search.status === "ready" && !search.options.length ? /* @__PURE__ */ jsxs("li", {
|
|
982
|
+
className: "px-2 py-1.5 text-kit-xs text-kit-fg-3",
|
|
983
|
+
children: [
|
|
984
|
+
"Nothing found",
|
|
985
|
+
q.trim() ? ` for “${q.trim()}”` : "",
|
|
986
|
+
"."
|
|
987
|
+
]
|
|
988
|
+
}) : null,
|
|
989
|
+
search.status === "loading" ? /* @__PURE__ */ jsx("li", {
|
|
990
|
+
className: "px-2 py-1.5 text-kit-xs text-kit-fg-3",
|
|
991
|
+
children: "Searching…"
|
|
992
|
+
}) : null,
|
|
993
|
+
search.status === "error" ? /* @__PURE__ */ jsxs("li", {
|
|
994
|
+
role: "alert",
|
|
995
|
+
className: "px-2 py-1.5 text-kit-xs text-kit-danger-fg",
|
|
996
|
+
children: ["Couldn't search: ", search.message]
|
|
997
|
+
}) : null,
|
|
998
|
+
search.status === "unavailable" ? /* @__PURE__ */ jsx("li", {
|
|
999
|
+
role: "note",
|
|
1000
|
+
className: "px-2 py-1.5 text-kit-xs text-kit-fg-3",
|
|
1001
|
+
children: "This view can't search pages or entries, so the cell can't change here."
|
|
1002
|
+
}) : null
|
|
1003
|
+
]
|
|
1004
|
+
}),
|
|
1005
|
+
r && !ctx.readOnly ? /* @__PURE__ */ jsx(Button, {
|
|
1006
|
+
size: "sm",
|
|
1007
|
+
variant: "ghost",
|
|
1008
|
+
className: "mt-1 w-full justify-start text-kit-fg-2",
|
|
1009
|
+
onClick: () => (onWrite(withValue(cell, null)), setOpen(false)),
|
|
1010
|
+
children: "Clear"
|
|
1011
|
+
}) : null
|
|
1012
|
+
]
|
|
1013
|
+
})]
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
function ColumnMenu({ ctx, col, index, onInsert, children }) {
|
|
1017
|
+
const { t, set, edit, lock, types, readOnly } = ctx;
|
|
1018
|
+
const [open, setOpen] = React.useState(false);
|
|
1019
|
+
const [details, setDetails] = React.useState(false);
|
|
1020
|
+
const n = t.columns.length;
|
|
1021
|
+
const atMax = !!ctx.options.maxColumns && n >= ctx.options.maxColumns;
|
|
1022
|
+
const remove = () => {
|
|
1023
|
+
if (n <= 1) return;
|
|
1024
|
+
const prev = t;
|
|
1025
|
+
set(dropColumn(t, col._key));
|
|
1026
|
+
ctx.undoable("Column deleted", prev);
|
|
1027
|
+
};
|
|
1028
|
+
const shownTypes = types.includes(col.type) ? types : [...types, col.type];
|
|
1029
|
+
const hasDetails = !lock && (col.type === "number" || col.type === "money" || col.type === "boolean" || col.type === "rating");
|
|
1030
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
1031
|
+
open: details,
|
|
1032
|
+
onOpenChange: setDetails,
|
|
1033
|
+
children: [/* @__PURE__ */ jsxs(PopoverAnchor, {
|
|
1034
|
+
render: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1 pl-1.5 pr-0.5" }),
|
|
1035
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1036
|
+
className: "flex min-w-0 flex-1 items-center gap-1",
|
|
1037
|
+
children: children(() => setOpen(true))
|
|
1038
|
+
}), readOnly ? null : /* @__PURE__ */ jsxs(Menu, {
|
|
1039
|
+
open,
|
|
1040
|
+
onOpenChange: setOpen,
|
|
1041
|
+
children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
1042
|
+
render: /* @__PURE__ */ jsx(IconButton, {
|
|
1043
|
+
size: "xs",
|
|
1044
|
+
tabIndex: -1,
|
|
1045
|
+
label: `Options for column ${col.label || index + 1}`,
|
|
1046
|
+
className: "shrink-0 opacity-0 focus-visible:opacity-100 group-hover/col:opacity-100 group-focus-within/col:opacity-100 data-[popup-open]:opacity-100 [@media(pointer:coarse)]:opacity-100"
|
|
1047
|
+
}),
|
|
1048
|
+
children: /* @__PURE__ */ jsx(IconDots, { stroke: 1.5 })
|
|
1049
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
1050
|
+
align: "end",
|
|
1051
|
+
className: "min-w-52",
|
|
1052
|
+
children: [
|
|
1053
|
+
lock ? null : /* @__PURE__ */ jsxs(MenuSub, { children: [/* @__PURE__ */ jsxs(MenuSubTrigger, {
|
|
1054
|
+
icon: /* @__PURE__ */ jsx(TypeIcon, {
|
|
1055
|
+
type: col.type,
|
|
1056
|
+
className: "text-kit-fg-2"
|
|
1057
|
+
}),
|
|
1058
|
+
children: ["Type: ", TYPE_UI[col.type].label]
|
|
1059
|
+
}), /* @__PURE__ */ jsx(MenuSubContent, { children: /* @__PURE__ */ jsx(MenuRadioGroup, {
|
|
1060
|
+
value: col.type,
|
|
1061
|
+
onValueChange: (v) => edit((x) => retype(x, col._key, v, ctx.resolveRef)),
|
|
1062
|
+
children: shownTypes.map((ty) => /* @__PURE__ */ jsx(MenuRadioItem, {
|
|
1063
|
+
value: ty,
|
|
1064
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
1065
|
+
className: "flex items-center gap-2",
|
|
1066
|
+
children: [/* @__PURE__ */ jsx(TypeIcon, {
|
|
1067
|
+
type: ty,
|
|
1068
|
+
className: "text-kit-fg-2"
|
|
1069
|
+
}), TYPE_UI[ty].label]
|
|
1070
|
+
})
|
|
1071
|
+
}, ty))
|
|
1072
|
+
}) })] }),
|
|
1073
|
+
hasDetails ? /* @__PURE__ */ jsx(MenuItem, {
|
|
1074
|
+
onClick: () => window.setTimeout(() => setDetails(true)),
|
|
1075
|
+
children: col.type === "number" ? "Unit…" : col.type === "money" ? "Currency…" : col.type === "rating" ? "Scale…" : "Words for yes and no…"
|
|
1076
|
+
}) : null,
|
|
1077
|
+
lock ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1078
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
1079
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1080
|
+
disabled: atMax,
|
|
1081
|
+
onClick: () => onInsert(false),
|
|
1082
|
+
children: "Insert column left"
|
|
1083
|
+
}),
|
|
1084
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1085
|
+
disabled: atMax,
|
|
1086
|
+
onClick: () => onInsert(true),
|
|
1087
|
+
children: "Insert column right"
|
|
1088
|
+
}),
|
|
1089
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1090
|
+
disabled: atMax,
|
|
1091
|
+
onClick: () => set(copyColumn(t, index)),
|
|
1092
|
+
children: "Duplicate column"
|
|
1093
|
+
}),
|
|
1094
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1095
|
+
disabled: index === 0,
|
|
1096
|
+
onClick: () => set({
|
|
1097
|
+
...t,
|
|
1098
|
+
columns: moveItem(t.columns, index, index - 1)
|
|
1099
|
+
}),
|
|
1100
|
+
children: "Move left"
|
|
1101
|
+
}),
|
|
1102
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1103
|
+
disabled: index === n - 1,
|
|
1104
|
+
onClick: () => set({
|
|
1105
|
+
...t,
|
|
1106
|
+
columns: moveItem(t.columns, index, index + 1)
|
|
1107
|
+
}),
|
|
1108
|
+
children: "Move right"
|
|
1109
|
+
})
|
|
1110
|
+
] }),
|
|
1111
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
1112
|
+
/* @__PURE__ */ jsx(MenuCheckItem, {
|
|
1113
|
+
checked: t.headerRow,
|
|
1114
|
+
onCheckedChange: (v) => set({
|
|
1115
|
+
...t,
|
|
1116
|
+
headerRow: v
|
|
1117
|
+
}),
|
|
1118
|
+
children: "Show column names"
|
|
1119
|
+
}),
|
|
1120
|
+
/* @__PURE__ */ jsx(MenuCheckItem, {
|
|
1121
|
+
checked: t.headerColumn,
|
|
1122
|
+
onCheckedChange: (v) => set({
|
|
1123
|
+
...t,
|
|
1124
|
+
headerColumn: v
|
|
1125
|
+
}),
|
|
1126
|
+
children: "First column names each row"
|
|
1127
|
+
}),
|
|
1128
|
+
/* @__PURE__ */ jsx(MenuCheckItem, {
|
|
1129
|
+
checked: !!col.highlight,
|
|
1130
|
+
onCheckedChange: (v) => set({
|
|
1131
|
+
...t,
|
|
1132
|
+
columns: t.columns.map((c) => ({
|
|
1133
|
+
...c,
|
|
1134
|
+
highlight: c._key === col._key && v ? true : void 0
|
|
1135
|
+
}))
|
|
1136
|
+
}),
|
|
1137
|
+
children: "Highlight this column"
|
|
1138
|
+
}),
|
|
1139
|
+
lock ? null : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuSeparator, {}), /* @__PURE__ */ jsx(MenuItem, {
|
|
1140
|
+
danger: true,
|
|
1141
|
+
disabled: n <= 1,
|
|
1142
|
+
onClick: remove,
|
|
1143
|
+
children: n <= 1 ? "Delete column · a table keeps one" : "Delete column"
|
|
1144
|
+
})] })
|
|
1145
|
+
]
|
|
1146
|
+
})]
|
|
1147
|
+
})]
|
|
1148
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
1149
|
+
align: "end",
|
|
1150
|
+
className: "w-64 p-3",
|
|
1151
|
+
children: /* @__PURE__ */ jsx(ColumnDetails, {
|
|
1152
|
+
col,
|
|
1153
|
+
onPatch: (p) => set({
|
|
1154
|
+
...t,
|
|
1155
|
+
columns: t.columns.map((c) => c._key === col._key ? withPatch(c, p) : c)
|
|
1156
|
+
})
|
|
1157
|
+
})
|
|
1158
|
+
})]
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
/** A stored TableLink as the global link field's value (V2 tableLinkValue). */
|
|
1162
|
+
var tableLinkValue = (l) => ({
|
|
1163
|
+
...normLink(l.href),
|
|
1164
|
+
newTab: !!l.newTab,
|
|
1165
|
+
target: l.newTab ? "_blank" : "_self",
|
|
1166
|
+
rel: l.rel ?? "follow"
|
|
1167
|
+
});
|
|
1168
|
+
/** Patch a column; a key set to undefined is removed (the stored value never carries an empty key). */
|
|
1169
|
+
function withPatch(c, p) {
|
|
1170
|
+
const next = {
|
|
1171
|
+
...c,
|
|
1172
|
+
...p
|
|
1173
|
+
};
|
|
1174
|
+
for (const k of Object.keys(p)) if (next[k] === void 0) delete next[k];
|
|
1175
|
+
return next;
|
|
1176
|
+
}
|
|
1177
|
+
function ColumnDetails({ col, onPatch, compact = true, readOnly }) {
|
|
1178
|
+
const id = React.useId();
|
|
1179
|
+
const row = (key, label, node, help) => /* @__PURE__ */ jsxs("label", {
|
|
1180
|
+
htmlFor: `${id}-${key}`,
|
|
1181
|
+
className: cn("flex flex-col", compact ? "gap-1" : "gap-1.5"),
|
|
1182
|
+
children: [
|
|
1183
|
+
/* @__PURE__ */ jsx("span", {
|
|
1184
|
+
className: cn("font-medium text-kit-fg-2", compact ? "text-kit-xs" : "text-kit-sm"),
|
|
1185
|
+
children: label
|
|
1186
|
+
}),
|
|
1187
|
+
node,
|
|
1188
|
+
help ? /* @__PURE__ */ jsx("span", {
|
|
1189
|
+
className: "text-kit-2xs leading-4 text-kit-fg-3",
|
|
1190
|
+
children: help
|
|
1191
|
+
}) : null
|
|
1192
|
+
]
|
|
1193
|
+
});
|
|
1194
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1195
|
+
className: cn("flex flex-col", compact ? "gap-2.5" : "gap-4"),
|
|
1196
|
+
children: [
|
|
1197
|
+
col.type === "number" ? row("unit", "Unit", /* @__PURE__ */ jsx(Input, {
|
|
1198
|
+
id: `${id}-unit`,
|
|
1199
|
+
size: "sm",
|
|
1200
|
+
autoFocus: compact,
|
|
1201
|
+
readOnly,
|
|
1202
|
+
maxLength: 16,
|
|
1203
|
+
value: col.unit ?? "",
|
|
1204
|
+
placeholder: "kg, %, min",
|
|
1205
|
+
onChange: (e) => onPatch({ unit: e.target.value || void 0 })
|
|
1206
|
+
}), "Written after every value.") : null,
|
|
1207
|
+
col.type === "money" ? row("currency", "Currency", /* @__PURE__ */ jsx(Segmented, {
|
|
1208
|
+
size: "sm",
|
|
1209
|
+
"aria-label": "Currency",
|
|
1210
|
+
value: col.currency ?? "USD",
|
|
1211
|
+
onChange: (currency) => !readOnly && onPatch({ currency }),
|
|
1212
|
+
items: (CURRENCIES.includes(col.currency ?? "USD") ? CURRENCIES : [...CURRENCIES, col.currency]).map((c) => ({
|
|
1213
|
+
value: c,
|
|
1214
|
+
label: c
|
|
1215
|
+
}))
|
|
1216
|
+
})) : null,
|
|
1217
|
+
col.type === "rating" ? row("max", "Out of", /* @__PURE__ */ jsx(Input, {
|
|
1218
|
+
id: `${id}-max`,
|
|
1219
|
+
size: "sm",
|
|
1220
|
+
autoFocus: compact,
|
|
1221
|
+
readOnly,
|
|
1222
|
+
type: "number",
|
|
1223
|
+
min: 1,
|
|
1224
|
+
max: 10,
|
|
1225
|
+
value: col.max ?? 5,
|
|
1226
|
+
onChange: (e) => {
|
|
1227
|
+
const n = Math.round(Number(e.target.value));
|
|
1228
|
+
onPatch({ max: Number.isFinite(n) && n >= 1 ? Math.min(10, n) : void 0 });
|
|
1229
|
+
}
|
|
1230
|
+
})) : null,
|
|
1231
|
+
col.type === "boolean" ? /* @__PURE__ */ jsxs(Fragment, { children: [row("yes", "Yes says", /* @__PURE__ */ jsx(Input, {
|
|
1232
|
+
id: `${id}-yes`,
|
|
1233
|
+
size: "sm",
|
|
1234
|
+
autoFocus: compact,
|
|
1235
|
+
readOnly,
|
|
1236
|
+
maxLength: 300,
|
|
1237
|
+
value: col.trueLabel ?? "",
|
|
1238
|
+
placeholder: "Included",
|
|
1239
|
+
onChange: (e) => onPatch({ trueLabel: e.target.value || void 0 })
|
|
1240
|
+
}), "People who can't see the check mark hear these words."), row("no", "No says", /* @__PURE__ */ jsx(Input, {
|
|
1241
|
+
id: `${id}-no`,
|
|
1242
|
+
size: "sm",
|
|
1243
|
+
readOnly,
|
|
1244
|
+
maxLength: 300,
|
|
1245
|
+
value: col.falseLabel ?? "",
|
|
1246
|
+
placeholder: "Not included",
|
|
1247
|
+
onChange: (e) => onPatch({ falseLabel: e.target.value || void 0 })
|
|
1248
|
+
}))] }) : null
|
|
1249
|
+
]
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
function RowMenu({ ctx, row, index, count, onInsert, children }) {
|
|
1253
|
+
const { t, set, edit } = ctx;
|
|
1254
|
+
const atMax = !!ctx.options.maxRows && !row.footer && t.rows.filter((r) => !r.footer).length >= ctx.options.maxRows;
|
|
1255
|
+
const duplicate = () => {
|
|
1256
|
+
const order = displayRows(t).map((d) => d.row);
|
|
1257
|
+
order.splice(index + 1, 0, {
|
|
1258
|
+
...row,
|
|
1259
|
+
_key: tkey("r"),
|
|
1260
|
+
cells: { ...row.cells }
|
|
1261
|
+
});
|
|
1262
|
+
set({
|
|
1263
|
+
...t,
|
|
1264
|
+
rows: order
|
|
1265
|
+
});
|
|
1266
|
+
};
|
|
1267
|
+
const remove = () => {
|
|
1268
|
+
const prev = t;
|
|
1269
|
+
set({
|
|
1270
|
+
...t,
|
|
1271
|
+
rows: t.rows.filter((r) => r._key !== row._key)
|
|
1272
|
+
});
|
|
1273
|
+
ctx.undoable("Row deleted", prev);
|
|
1274
|
+
};
|
|
1275
|
+
const groups = offered(ctx.options).groups ? t.rowGroups ?? [] : [];
|
|
1276
|
+
const trigger = /* @__PURE__ */ jsx(MenuTrigger, {
|
|
1277
|
+
render: /* @__PURE__ */ jsx(IconButton, {
|
|
1278
|
+
size: "xs",
|
|
1279
|
+
tabIndex: -1,
|
|
1280
|
+
label: `Options for row ${index + 1}`
|
|
1281
|
+
}),
|
|
1282
|
+
children: /* @__PURE__ */ jsx(IconDots, { stroke: 1.5 })
|
|
1283
|
+
});
|
|
1284
|
+
return /* @__PURE__ */ jsxs(Menu, { children: [children(trigger), /* @__PURE__ */ jsxs(MenuContent, {
|
|
1285
|
+
className: "min-w-52",
|
|
1286
|
+
children: [
|
|
1287
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1288
|
+
disabled: atMax,
|
|
1289
|
+
onClick: () => onInsert(false),
|
|
1290
|
+
children: "Insert row above"
|
|
1291
|
+
}),
|
|
1292
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1293
|
+
disabled: atMax,
|
|
1294
|
+
onClick: () => onInsert(true),
|
|
1295
|
+
children: "Insert row below"
|
|
1296
|
+
}),
|
|
1297
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1298
|
+
disabled: atMax,
|
|
1299
|
+
onClick: duplicate,
|
|
1300
|
+
children: "Duplicate row"
|
|
1301
|
+
}),
|
|
1302
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1303
|
+
disabled: index === 0,
|
|
1304
|
+
onClick: () => set(moveRowTo(t, index, index - 1)),
|
|
1305
|
+
children: "Move up"
|
|
1306
|
+
}),
|
|
1307
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1308
|
+
disabled: index === count - 1,
|
|
1309
|
+
onClick: () => set(moveRowTo(t, index, index + 1)),
|
|
1310
|
+
children: "Move down"
|
|
1311
|
+
}),
|
|
1312
|
+
groups.length ? /* @__PURE__ */ jsxs(MenuSub, { children: [/* @__PURE__ */ jsx(MenuSubTrigger, { children: "Move to group" }), /* @__PURE__ */ jsx(MenuSubContent, { children: /* @__PURE__ */ jsxs(MenuRadioGroup, {
|
|
1313
|
+
value: row.group ?? "",
|
|
1314
|
+
onValueChange: (g) => edit(mapRow(row._key, (x) => clean({
|
|
1315
|
+
...x,
|
|
1316
|
+
group: g || void 0,
|
|
1317
|
+
footer: void 0
|
|
1318
|
+
}))),
|
|
1319
|
+
children: [/* @__PURE__ */ jsx(MenuRadioItem, {
|
|
1320
|
+
value: "",
|
|
1321
|
+
children: "No group"
|
|
1322
|
+
}), groups.map((g) => /* @__PURE__ */ jsx(MenuRadioItem, {
|
|
1323
|
+
value: g._key,
|
|
1324
|
+
children: g.label || "Untitled group"
|
|
1325
|
+
}, g._key))]
|
|
1326
|
+
}) })] }) : null,
|
|
1327
|
+
offered(ctx.options).highlight ? /* @__PURE__ */ jsx(MenuCheckItem, {
|
|
1328
|
+
checked: !!row.highlight,
|
|
1329
|
+
onCheckedChange: (v) => edit(mapRow(row._key, (x) => clean({
|
|
1330
|
+
...x,
|
|
1331
|
+
highlight: v
|
|
1332
|
+
}))),
|
|
1333
|
+
children: "Highlight this row"
|
|
1334
|
+
}) : null,
|
|
1335
|
+
offered(ctx.options).totals ? /* @__PURE__ */ jsx(MenuCheckItem, {
|
|
1336
|
+
checked: !!row.footer,
|
|
1337
|
+
onCheckedChange: (v) => edit(mapRow(row._key, (x) => clean({
|
|
1338
|
+
...x,
|
|
1339
|
+
footer: v,
|
|
1340
|
+
group: void 0
|
|
1341
|
+
}))),
|
|
1342
|
+
children: "Totals row"
|
|
1343
|
+
}) : null,
|
|
1344
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
1345
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1346
|
+
danger: true,
|
|
1347
|
+
onClick: remove,
|
|
1348
|
+
children: "Delete row"
|
|
1349
|
+
})
|
|
1350
|
+
]
|
|
1351
|
+
})] });
|
|
1352
|
+
}
|
|
1353
|
+
/** Right-click (or Shift+F10 / the menu key) on a cell: words instead of the column's type, a footnote, clear. */
|
|
1354
|
+
function CellMenu({ ctx, row, col, cell, onWrite, onNote, children }) {
|
|
1355
|
+
const { t, set } = ctx;
|
|
1356
|
+
const own = isCellObject(cell) ? cell.type : void 0;
|
|
1357
|
+
const note = cellNote(cell);
|
|
1358
|
+
const colType = row.type ?? col.type;
|
|
1359
|
+
const asText = own === "text";
|
|
1360
|
+
const atMax = !!ctx.options.maxRows && !row.footer && t.rows.filter((r) => !r.footer).length >= ctx.options.maxRows;
|
|
1361
|
+
const setOwn = (type) => {
|
|
1362
|
+
const raw = cellText(col, row, cell, ctx.resolveRef);
|
|
1363
|
+
const value = coerce(raw, {
|
|
1364
|
+
type: type ?? colType,
|
|
1365
|
+
max: col.max
|
|
1366
|
+
});
|
|
1367
|
+
onWrite(type || note ? {
|
|
1368
|
+
value,
|
|
1369
|
+
...type ? { type } : {},
|
|
1370
|
+
...note ? { note } : {}
|
|
1371
|
+
} : value);
|
|
1372
|
+
};
|
|
1373
|
+
const insertRow = (below) => {
|
|
1374
|
+
const order = displayRows(t).map((d) => d.row);
|
|
1375
|
+
const at = order.findIndex((r) => r._key === row._key) + (below ? 1 : 0);
|
|
1376
|
+
order.splice(at, 0, clean({
|
|
1377
|
+
_key: tkey("r"),
|
|
1378
|
+
cells: {},
|
|
1379
|
+
group: row.group,
|
|
1380
|
+
footer: row.footer
|
|
1381
|
+
}));
|
|
1382
|
+
set({
|
|
1383
|
+
...t,
|
|
1384
|
+
rows: order
|
|
1385
|
+
});
|
|
1386
|
+
};
|
|
1387
|
+
return /* @__PURE__ */ jsxs(ContextMenu.Root, { children: [/* @__PURE__ */ jsx(ContextMenu.Trigger, {
|
|
1388
|
+
render: /* @__PURE__ */ jsx("div", {}),
|
|
1389
|
+
children
|
|
1390
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
1391
|
+
className: "min-w-52",
|
|
1392
|
+
children: [
|
|
1393
|
+
colType !== "text" && colType !== "reference" && colType !== "richtext-inline" ? /* @__PURE__ */ jsx(MenuItem, {
|
|
1394
|
+
onClick: () => setOwn(asText ? void 0 : "text"),
|
|
1395
|
+
children: asText ? `Use ${TYPE_UI[colType].label} like the column` : "Write words in this cell instead"
|
|
1396
|
+
}) : null,
|
|
1397
|
+
offered(ctx.options).footnotes ? note ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuItem, {
|
|
1398
|
+
onClick: onNote,
|
|
1399
|
+
children: "Edit footnote"
|
|
1400
|
+
}), /* @__PURE__ */ jsx(MenuItem, {
|
|
1401
|
+
onClick: () => set(unlinkNote(t, row._key, col._key)),
|
|
1402
|
+
children: "Remove footnote"
|
|
1403
|
+
})] }) : /* @__PURE__ */ jsx(MenuItem, {
|
|
1404
|
+
onClick: () => (set(linkNote(t, row._key, col._key)[0]), onNote()),
|
|
1405
|
+
children: "Add a footnote"
|
|
1406
|
+
}) : null,
|
|
1407
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
1408
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1409
|
+
disabled: atMax,
|
|
1410
|
+
onClick: () => insertRow(true),
|
|
1411
|
+
children: "Insert row below"
|
|
1412
|
+
}),
|
|
1413
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1414
|
+
disabled: atMax,
|
|
1415
|
+
onClick: () => insertRow(false),
|
|
1416
|
+
children: "Insert row above"
|
|
1417
|
+
}),
|
|
1418
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1419
|
+
onClick: () => onWrite(withValue(cell, null)),
|
|
1420
|
+
children: "Clear cell"
|
|
1421
|
+
}),
|
|
1422
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1423
|
+
danger: true,
|
|
1424
|
+
onClick: () => {
|
|
1425
|
+
const prev = t;
|
|
1426
|
+
set({
|
|
1427
|
+
...t,
|
|
1428
|
+
rows: t.rows.filter((r) => r._key !== row._key)
|
|
1429
|
+
});
|
|
1430
|
+
ctx.undoable("Row deleted", prev);
|
|
1431
|
+
},
|
|
1432
|
+
children: "Delete row"
|
|
1433
|
+
})
|
|
1434
|
+
]
|
|
1435
|
+
})] });
|
|
1436
|
+
}
|
|
1437
|
+
var hasName = (t, r) => !!t.columns[0] && !isEmptyCell(cellValue(r.cells[t.columns[0]._key]));
|
|
1438
|
+
/** The row that was open when its drill closed, per table: focus lands back on it (form frames and the local drill). */
|
|
1439
|
+
var returnTo = /* @__PURE__ */ new Map();
|
|
1440
|
+
var ROWS_FIELD = {
|
|
1441
|
+
name: "rows",
|
|
1442
|
+
title: "Rows",
|
|
1443
|
+
type: "table",
|
|
1444
|
+
icon: "list"
|
|
1445
|
+
};
|
|
1446
|
+
var COLUMNS_FIELD = {
|
|
1447
|
+
name: "columns",
|
|
1448
|
+
title: "Columns",
|
|
1449
|
+
type: "table",
|
|
1450
|
+
icon: "layout-columns"
|
|
1451
|
+
};
|
|
1452
|
+
var noop = () => void 0;
|
|
1453
|
+
var colSummary = (c) => [TYPE_UI[c.type].label, c.type === "number" ? c.unit : c.type === "money" ? c.currency ?? "USD" : c.type === "rating" ? `out of ${c.max ?? 5}` : void 0].filter(Boolean).join(" · ");
|
|
1454
|
+
/** D52: the whole table is ONE group, shown the way every nested group is shown: a single 1px inset line on the left. */
|
|
1455
|
+
var TABLE_GROUP = "ml-1.5 border-l border-kit-line pl-3";
|
|
1456
|
+
/** A sub-part of the table field: the same label style as every field label (13/500, fg-2; fg while focus is inside). */
|
|
1457
|
+
var PART_LABEL = "text-kit-sm font-medium text-kit-fg-2 transition-colors group-focus-within/part:text-kit-fg";
|
|
1458
|
+
/** CPO D52: the settings a table kind offers, with their defaults (schema/table.ts › TableSettingsOptions). */
|
|
1459
|
+
var PHONES = [
|
|
1460
|
+
{
|
|
1461
|
+
value: "scroll",
|
|
1462
|
+
label: "Scroll"
|
|
1463
|
+
},
|
|
1464
|
+
{
|
|
1465
|
+
value: "stack",
|
|
1466
|
+
label: "Stack"
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
value: "cards",
|
|
1470
|
+
label: "Cards"
|
|
1471
|
+
}
|
|
1472
|
+
];
|
|
1473
|
+
function offered(options) {
|
|
1474
|
+
const s = options.settings ?? {};
|
|
1475
|
+
const phones = PHONES.filter((p) => !s.phones || s.phones.includes(p.value));
|
|
1476
|
+
return {
|
|
1477
|
+
headers: s.headers !== false,
|
|
1478
|
+
totals: s.totals !== false,
|
|
1479
|
+
phones: phones.length > 1 ? phones : [],
|
|
1480
|
+
highlight: s.highlight !== false,
|
|
1481
|
+
sticky: s.sticky !== false,
|
|
1482
|
+
sort: !!s.sort,
|
|
1483
|
+
search: !!s.search,
|
|
1484
|
+
jsonLd: (options.jsonLd ?? []).filter((x) => x !== "none"),
|
|
1485
|
+
groups: options.allowGroups !== false,
|
|
1486
|
+
footnotes: options.allowFootnotes !== false,
|
|
1487
|
+
note: options.allowNote !== false
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
/** Unlink a footnote from one cell; the footnote itself goes when no other cell points at it. */
|
|
1491
|
+
function unlinkNote(t, rowKey, colKey) {
|
|
1492
|
+
let note;
|
|
1493
|
+
const rows = t.rows.map((r) => {
|
|
1494
|
+
if (r._key !== rowKey) return r;
|
|
1495
|
+
const c = r.cells[colKey];
|
|
1496
|
+
if (!isCellObject(c) || !c.note) return r;
|
|
1497
|
+
note = c.note;
|
|
1498
|
+
return {
|
|
1499
|
+
...r,
|
|
1500
|
+
cells: {
|
|
1501
|
+
...r.cells,
|
|
1502
|
+
[colKey]: c.type ? {
|
|
1503
|
+
value: c.value,
|
|
1504
|
+
type: c.type
|
|
1505
|
+
} : c.value
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
});
|
|
1509
|
+
if (!note) return t;
|
|
1510
|
+
const used = rows.some((r) => Object.values(r.cells).some((c) => isCellObject(c) && c.note === note));
|
|
1511
|
+
return {
|
|
1512
|
+
...t,
|
|
1513
|
+
rows,
|
|
1514
|
+
footnotes: used ? t.footnotes : (t.footnotes ?? []).filter((f) => f._key !== note)
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
/** Link a new, empty footnote to one cell. Returns the table and the footnote's key (its input takes focus). */
|
|
1518
|
+
function linkNote(t, rowKey, colKey) {
|
|
1519
|
+
const f = {
|
|
1520
|
+
_key: tkey("f"),
|
|
1521
|
+
text: ""
|
|
1522
|
+
};
|
|
1523
|
+
return [{
|
|
1524
|
+
...t,
|
|
1525
|
+
footnotes: [...t.footnotes ?? [], f],
|
|
1526
|
+
rows: t.rows.map((r) => {
|
|
1527
|
+
if (r._key !== rowKey) return r;
|
|
1528
|
+
const c = r.cells[colKey];
|
|
1529
|
+
const own = isCellObject(c) ? c.type : void 0;
|
|
1530
|
+
return {
|
|
1531
|
+
...r,
|
|
1532
|
+
cells: {
|
|
1533
|
+
...r.cells,
|
|
1534
|
+
[colKey]: {
|
|
1535
|
+
value: cellValue(c),
|
|
1536
|
+
...own ? { type: own } : {},
|
|
1537
|
+
note: f._key
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
})
|
|
1542
|
+
}, f._key];
|
|
1543
|
+
}
|
|
1544
|
+
var focusSoon = (selector) => requestAnimationFrame(() => document.querySelector(selector)?.focus());
|
|
1545
|
+
function TableBody({ ctx, label, nav, head }) {
|
|
1546
|
+
const { t, set, readOnly, options } = ctx;
|
|
1547
|
+
const [open, setOpen] = React.useState(null);
|
|
1548
|
+
const host = React.useRef(null);
|
|
1549
|
+
const localId = React.useId();
|
|
1550
|
+
const id = nav?.id ?? localId;
|
|
1551
|
+
const focusRow = (key) => host.current?.querySelector(`[data-row-open="${CSS.escape(key)}"]`)?.focus({ preventScroll: false });
|
|
1552
|
+
React.useEffect(() => {
|
|
1553
|
+
if (open || !returnTo.has(id)) return;
|
|
1554
|
+
const raf = requestAnimationFrame(() => {
|
|
1555
|
+
const key = returnTo.get(id);
|
|
1556
|
+
returnTo.delete(id);
|
|
1557
|
+
const a = document.activeElement;
|
|
1558
|
+
if (key && (!a || a === document.body || a.matches("[data-frame-body]") || host.current?.contains(a) || !a.isConnected)) focusRow(key);
|
|
1559
|
+
});
|
|
1560
|
+
return () => cancelAnimationFrame(raf);
|
|
1561
|
+
}, [open, id]);
|
|
1562
|
+
const go = (kind, index, key) => {
|
|
1563
|
+
returnTo.set(id, key);
|
|
1564
|
+
if (nav) window.setTimeout(() => nav.open(kind, index), 0);
|
|
1565
|
+
else setOpen({
|
|
1566
|
+
kind,
|
|
1567
|
+
key
|
|
1568
|
+
});
|
|
1569
|
+
};
|
|
1570
|
+
const list = open ? open.kind === "rows" ? t.rows : t.columns : [];
|
|
1571
|
+
const at = open ? list.findIndex((x) => x._key === open.key) : -1;
|
|
1572
|
+
if (open && at >= 0) return /* @__PURE__ */ jsx("div", {
|
|
1573
|
+
className: TABLE_GROUP,
|
|
1574
|
+
children: /* @__PURE__ */ jsx(LocalDrill, {
|
|
1575
|
+
ctx,
|
|
1576
|
+
label,
|
|
1577
|
+
open,
|
|
1578
|
+
index: at,
|
|
1579
|
+
onBack: () => setOpen(null),
|
|
1580
|
+
onGo: (key) => setOpen({
|
|
1581
|
+
kind: open.kind,
|
|
1582
|
+
key
|
|
1583
|
+
})
|
|
1584
|
+
})
|
|
1585
|
+
});
|
|
1586
|
+
const base = nav?.basePath ?? [];
|
|
1587
|
+
const titleId = `${id}-title`;
|
|
1588
|
+
const noteId = `${id}-note`;
|
|
1589
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1590
|
+
ref: host,
|
|
1591
|
+
role: "group",
|
|
1592
|
+
"aria-label": label || "Table",
|
|
1593
|
+
className: cn(TABLE_GROUP, "flex flex-col gap-4 @max-[360px]:gap-3", !readOnly && "mb-2"),
|
|
1594
|
+
children: [
|
|
1595
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1596
|
+
className: "group/part flex flex-col gap-1.5",
|
|
1597
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1598
|
+
className: "flex min-h-5 items-center gap-1.5",
|
|
1599
|
+
children: [
|
|
1600
|
+
/* @__PURE__ */ jsx("label", {
|
|
1601
|
+
htmlFor: titleId,
|
|
1602
|
+
className: PART_LABEL,
|
|
1603
|
+
children: "Title"
|
|
1604
|
+
}),
|
|
1605
|
+
options.requireCaption !== false && !t.caption.trim() ? /* @__PURE__ */ jsx("span", {
|
|
1606
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
1607
|
+
children: "Required"
|
|
1608
|
+
}) : null,
|
|
1609
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
1610
|
+
head
|
|
1611
|
+
]
|
|
1612
|
+
}), /* @__PURE__ */ jsx(Textarea, {
|
|
1613
|
+
id: titleId,
|
|
1614
|
+
rows: 1,
|
|
1615
|
+
maxLength: 300,
|
|
1616
|
+
value: t.caption,
|
|
1617
|
+
readOnly,
|
|
1618
|
+
placeholder: "What the table shows",
|
|
1619
|
+
onChange: (e) => set({
|
|
1620
|
+
...t,
|
|
1621
|
+
caption: e.target.value.replace(/\n/g, " ")
|
|
1622
|
+
}),
|
|
1623
|
+
className: "min-h-8 resize-none py-1.5"
|
|
1624
|
+
})]
|
|
1625
|
+
}),
|
|
1626
|
+
/* @__PURE__ */ jsx(ColumnsPart, {
|
|
1627
|
+
ctx,
|
|
1628
|
+
basePath: base,
|
|
1629
|
+
onOpen: (i, key) => go("columns", i, key)
|
|
1630
|
+
}),
|
|
1631
|
+
/* @__PURE__ */ jsx(RowsPart, {
|
|
1632
|
+
ctx,
|
|
1633
|
+
basePath: base,
|
|
1634
|
+
onOpen: (i, key) => go("rows", i, key)
|
|
1635
|
+
}),
|
|
1636
|
+
offered(options).note ? /* @__PURE__ */ jsxs("div", {
|
|
1637
|
+
className: "group/part flex flex-col gap-1.5",
|
|
1638
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
1639
|
+
htmlFor: noteId,
|
|
1640
|
+
className: PART_LABEL,
|
|
1641
|
+
children: "Note under the table"
|
|
1642
|
+
}), /* @__PURE__ */ jsx(Textarea, {
|
|
1643
|
+
id: noteId,
|
|
1644
|
+
rows: 2,
|
|
1645
|
+
maxLength: 2e3,
|
|
1646
|
+
value: t.notes ?? "",
|
|
1647
|
+
readOnly,
|
|
1648
|
+
placeholder: "Source: our own tests, September 2026.",
|
|
1649
|
+
onChange: (e) => set({
|
|
1650
|
+
...t,
|
|
1651
|
+
notes: e.target.value || void 0
|
|
1652
|
+
})
|
|
1653
|
+
})]
|
|
1654
|
+
}) : null,
|
|
1655
|
+
readOnly ? null : /* @__PURE__ */ jsx(TableSettings, { ctx })
|
|
1656
|
+
]
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
/** Columns: an array list like any other (type icon, name, "Yes / No" summary, ⋯, ›). */
|
|
1660
|
+
function ColumnsPart({ ctx, basePath, onOpen }) {
|
|
1661
|
+
const { t, set, lock, options } = ctx;
|
|
1662
|
+
const n = t.columns.length;
|
|
1663
|
+
const atMax = !!options.maxColumns && n >= options.maxColumns;
|
|
1664
|
+
const write = (columns) => set({
|
|
1665
|
+
...t,
|
|
1666
|
+
columns
|
|
1667
|
+
});
|
|
1668
|
+
const add = () => {
|
|
1669
|
+
if (atMax) return;
|
|
1670
|
+
const col = {
|
|
1671
|
+
_key: tkey("c"),
|
|
1672
|
+
label: "",
|
|
1673
|
+
type: "text"
|
|
1674
|
+
};
|
|
1675
|
+
write([...t.columns, col]);
|
|
1676
|
+
onOpen(n, col._key);
|
|
1677
|
+
};
|
|
1678
|
+
const ops = {
|
|
1679
|
+
atMax,
|
|
1680
|
+
atMin: n <= 1,
|
|
1681
|
+
add,
|
|
1682
|
+
duplicate: (i) => !atMax && set(copyColumn(t, i)),
|
|
1683
|
+
move: (i, d) => i + d >= 0 && i + d < n && write(moveItem(t.columns, i, i + d)),
|
|
1684
|
+
reorder: (from, to) => write(moveItem(t.columns, from, to)),
|
|
1685
|
+
remove: (i, title) => {
|
|
1686
|
+
if (n <= 1) return;
|
|
1687
|
+
const prev = t;
|
|
1688
|
+
set(dropColumn(t, t.columns[i]._key));
|
|
1689
|
+
ctx.undoable(`“${title}” removed`, prev);
|
|
1690
|
+
},
|
|
1691
|
+
insertBlank: noop
|
|
1692
|
+
};
|
|
1693
|
+
const rows = t.columns.map((c, i) => ({
|
|
1694
|
+
id: c._key,
|
|
1695
|
+
index: i,
|
|
1696
|
+
item: c,
|
|
1697
|
+
path: [
|
|
1698
|
+
...basePath,
|
|
1699
|
+
"columns",
|
|
1700
|
+
i
|
|
1701
|
+
],
|
|
1702
|
+
preview: {
|
|
1703
|
+
title: c.label || "Untitled column",
|
|
1704
|
+
subtitle: colSummary(c),
|
|
1705
|
+
empty: !c.label
|
|
1706
|
+
}
|
|
1707
|
+
}));
|
|
1708
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1709
|
+
role: "group",
|
|
1710
|
+
"aria-label": "Columns",
|
|
1711
|
+
className: "group/part flex flex-col gap-1.5",
|
|
1712
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1713
|
+
className: PART_LABEL,
|
|
1714
|
+
children: "Columns"
|
|
1715
|
+
}), /* @__PURE__ */ jsx(RowList, {
|
|
1716
|
+
field: {
|
|
1717
|
+
...COLUMNS_FIELD,
|
|
1718
|
+
validation: { min: 1 }
|
|
1719
|
+
},
|
|
1720
|
+
rows,
|
|
1721
|
+
readOnly: lock,
|
|
1722
|
+
layout: "list",
|
|
1723
|
+
mode: "drill",
|
|
1724
|
+
openId: null,
|
|
1725
|
+
onOpen: (r) => onOpen(r.index, r.id),
|
|
1726
|
+
onCloseInline: noop,
|
|
1727
|
+
ops,
|
|
1728
|
+
renderInline: () => null,
|
|
1729
|
+
emptyLabel: "No columns yet.",
|
|
1730
|
+
leading: (r) => /* @__PURE__ */ jsx("span", {
|
|
1731
|
+
className: "flex size-7 shrink-0 items-center justify-center rounded-kit-md bg-kit-muted text-kit-fg-2",
|
|
1732
|
+
children: /* @__PURE__ */ jsx(TypeIcon, {
|
|
1733
|
+
type: r.item.type,
|
|
1734
|
+
className: "size-4 text-kit-fg-2"
|
|
1735
|
+
})
|
|
1736
|
+
}),
|
|
1737
|
+
addButton: /* @__PURE__ */ jsx(Button, {
|
|
1738
|
+
size: "sm",
|
|
1739
|
+
variant: "ghost",
|
|
1740
|
+
className: "text-kit-fg-2",
|
|
1741
|
+
leftIcon: /* @__PURE__ */ jsx(IconPlus, { stroke: 1.5 }),
|
|
1742
|
+
disabled: atMax,
|
|
1743
|
+
onClick: add,
|
|
1744
|
+
children: atMax ? `Add column · ${options.maxColumns} at most` : "Add column"
|
|
1745
|
+
})
|
|
1746
|
+
})]
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* Rows (D52): groups live in the row list itself. Loose rows first, then each group under a heading you rename in place
|
|
1751
|
+
* (its ⋯ moves or removes it), then Totals. "Add group" sits next to the last "Add row"; a row changes group by its ⋯ ›
|
|
1752
|
+
* Move to group. Every list is the kit's array row list; drag (and ↑/↓ on the grip) reorders inside a group.
|
|
1753
|
+
*/
|
|
1754
|
+
function RowsPart({ ctx, basePath, onOpen }) {
|
|
1755
|
+
const { t, set, resolveRef, readOnly, options } = ctx;
|
|
1756
|
+
const can = offered(options);
|
|
1757
|
+
const groups = can.groups ? t.rowGroups ?? [] : [];
|
|
1758
|
+
const known = new Set(groups.map((g) => g._key));
|
|
1759
|
+
const body = t.rows.filter((r) => !r.footer);
|
|
1760
|
+
const runs = [];
|
|
1761
|
+
const loose = body.filter((r) => !r.group || !known.has(r.group));
|
|
1762
|
+
if (loose.length || !groups.length) runs.push({
|
|
1763
|
+
key: "loose",
|
|
1764
|
+
items: loose
|
|
1765
|
+
});
|
|
1766
|
+
groups.forEach((g) => runs.push({
|
|
1767
|
+
key: g._key,
|
|
1768
|
+
group: g,
|
|
1769
|
+
items: body.filter((r) => r.group === g._key)
|
|
1770
|
+
}));
|
|
1771
|
+
const foot = t.rows.filter((r) => r.footer);
|
|
1772
|
+
if (foot.length) runs.push({
|
|
1773
|
+
key: "totals",
|
|
1774
|
+
totals: true,
|
|
1775
|
+
items: foot
|
|
1776
|
+
});
|
|
1777
|
+
const lastBody = runs.filter((r) => !r.totals).length - 1;
|
|
1778
|
+
const atMax = !!options.maxRows && body.length >= options.maxRows;
|
|
1779
|
+
const place = (r, x) => clean({
|
|
1780
|
+
...x,
|
|
1781
|
+
group: r.group?._key ?? (r.key === "loose" && x.group && !known.has(x.group) ? x.group : void 0),
|
|
1782
|
+
footer: r.totals || void 0
|
|
1783
|
+
});
|
|
1784
|
+
const writeRuns = (next) => set({
|
|
1785
|
+
...t,
|
|
1786
|
+
rows: next.flatMap((r) => r.items.map((x) => place(r, x)))
|
|
1787
|
+
});
|
|
1788
|
+
const writeRun = (ri, items) => writeRuns(runs.map((r, j) => j === ri ? {
|
|
1789
|
+
...r,
|
|
1790
|
+
items
|
|
1791
|
+
} : r));
|
|
1792
|
+
const add = (ri) => {
|
|
1793
|
+
if (atMax && !runs[ri].totals) return;
|
|
1794
|
+
const run = runs[ri];
|
|
1795
|
+
const row = place(run, {
|
|
1796
|
+
_key: tkey("r"),
|
|
1797
|
+
cells: {}
|
|
1798
|
+
});
|
|
1799
|
+
const rows = runs.flatMap((r, j) => j === ri ? [...r.items.map((x) => place(r, x)), row] : r.items.map((x) => place(r, x)));
|
|
1800
|
+
set({
|
|
1801
|
+
...t,
|
|
1802
|
+
rows
|
|
1803
|
+
});
|
|
1804
|
+
onOpen(rows.indexOf(row), row._key);
|
|
1805
|
+
};
|
|
1806
|
+
const addGroup = () => {
|
|
1807
|
+
const g = {
|
|
1808
|
+
_key: tkey("rg"),
|
|
1809
|
+
label: ""
|
|
1810
|
+
};
|
|
1811
|
+
set({
|
|
1812
|
+
...t,
|
|
1813
|
+
rowGroups: [...t.rowGroups ?? [], g]
|
|
1814
|
+
});
|
|
1815
|
+
focusSoon(`[data-group-name="${g._key}"]`);
|
|
1816
|
+
};
|
|
1817
|
+
const placeName = (k) => k === "totals" ? "Totals" : k === "loose" ? "No group" : groups.find((g) => g._key === k)?.label || "Untitled group";
|
|
1818
|
+
/** Move a row to the end of another run (a group, no group, or Totals). */
|
|
1819
|
+
const moveTo = (row, target) => {
|
|
1820
|
+
const prev = t;
|
|
1821
|
+
const rest = t.rows.filter((r) => r._key !== row._key);
|
|
1822
|
+
set({
|
|
1823
|
+
...t,
|
|
1824
|
+
rows: [...rest, clean({
|
|
1825
|
+
...row,
|
|
1826
|
+
group: target.totals ? void 0 : target.group,
|
|
1827
|
+
footer: target.totals || void 0
|
|
1828
|
+
})]
|
|
1829
|
+
});
|
|
1830
|
+
ctx.undoable(`Moved to ${placeName(target.totals ? "totals" : target.group ?? "loose")}`, prev);
|
|
1831
|
+
};
|
|
1832
|
+
const opsFor = (ri) => {
|
|
1833
|
+
const items = runs[ri].items;
|
|
1834
|
+
const runMax = atMax && !runs[ri].totals;
|
|
1835
|
+
return {
|
|
1836
|
+
atMax: runMax,
|
|
1837
|
+
atMin: false,
|
|
1838
|
+
add: () => add(ri),
|
|
1839
|
+
duplicate: (i) => !runMax && writeRun(ri, [
|
|
1840
|
+
...items.slice(0, i + 1),
|
|
1841
|
+
{
|
|
1842
|
+
...items[i],
|
|
1843
|
+
_key: tkey("r"),
|
|
1844
|
+
cells: { ...items[i].cells }
|
|
1845
|
+
},
|
|
1846
|
+
...items.slice(i + 1)
|
|
1847
|
+
]),
|
|
1848
|
+
move: (i, d) => i + d >= 0 && i + d < items.length && writeRun(ri, moveItem(items, i, i + d)),
|
|
1849
|
+
reorder: (from, to) => writeRun(ri, moveItem(items, from, to)),
|
|
1850
|
+
remove: (i, title) => {
|
|
1851
|
+
const prev = t;
|
|
1852
|
+
writeRun(ri, items.filter((_, j) => j !== i));
|
|
1853
|
+
ctx.undoable(`“${title}” removed`, prev);
|
|
1854
|
+
},
|
|
1855
|
+
insertBlank: noop
|
|
1856
|
+
};
|
|
1857
|
+
};
|
|
1858
|
+
const sub = (r) => t.columns.slice(1, 3).map((c) => {
|
|
1859
|
+
const s = cellText(c, r, r.cells[c._key], resolveRef);
|
|
1860
|
+
return s ? `${c.label || "Untitled"}: ${s}` : "";
|
|
1861
|
+
}).filter(Boolean).join(" · ");
|
|
1862
|
+
const model = (row, i) => {
|
|
1863
|
+
const named = hasName(t, row);
|
|
1864
|
+
return {
|
|
1865
|
+
id: row._key,
|
|
1866
|
+
index: i,
|
|
1867
|
+
item: row,
|
|
1868
|
+
path: [
|
|
1869
|
+
...basePath,
|
|
1870
|
+
"rows",
|
|
1871
|
+
t.rows.indexOf(row)
|
|
1872
|
+
],
|
|
1873
|
+
preview: {
|
|
1874
|
+
title: named ? rowTitle(t, row, i, resolveRef) : "Untitled row",
|
|
1875
|
+
subtitle: sub(row) || void 0,
|
|
1876
|
+
empty: !named
|
|
1877
|
+
}
|
|
1878
|
+
};
|
|
1879
|
+
};
|
|
1880
|
+
const moveMenu = (r) => {
|
|
1881
|
+
const row = r.item;
|
|
1882
|
+
const here = row.footer ? "totals" : row.group && known.has(row.group) ? row.group : "";
|
|
1883
|
+
const places = [
|
|
1884
|
+
...groups.length ? [{
|
|
1885
|
+
value: "",
|
|
1886
|
+
label: "No group"
|
|
1887
|
+
}] : [],
|
|
1888
|
+
...groups.map((g) => ({
|
|
1889
|
+
value: g._key,
|
|
1890
|
+
label: g.label || "Untitled group"
|
|
1891
|
+
})),
|
|
1892
|
+
...can.totals && (foot.length || groups.length) ? [{
|
|
1893
|
+
value: "totals",
|
|
1894
|
+
label: "Totals"
|
|
1895
|
+
}] : []
|
|
1896
|
+
];
|
|
1897
|
+
if (!places.some((p) => p.value !== here)) return null;
|
|
1898
|
+
return /* @__PURE__ */ jsxs(MenuSub, { children: [/* @__PURE__ */ jsx(MenuSubTrigger, {
|
|
1899
|
+
icon: /* @__PURE__ */ jsx(IconFolder, { stroke: 1.5 }),
|
|
1900
|
+
children: "Move to group"
|
|
1901
|
+
}), /* @__PURE__ */ jsx(MenuSubContent, {
|
|
1902
|
+
className: "min-w-44",
|
|
1903
|
+
children: /* @__PURE__ */ jsx(MenuRadioGroup, {
|
|
1904
|
+
value: here,
|
|
1905
|
+
onValueChange: (v) => v !== here && moveTo(row, v === "totals" ? { totals: true } : { group: v || void 0 }),
|
|
1906
|
+
children: places.map((p) => /* @__PURE__ */ jsx(MenuRadioItem, {
|
|
1907
|
+
value: p.value,
|
|
1908
|
+
children: p.label
|
|
1909
|
+
}, p.value || "none"))
|
|
1910
|
+
})
|
|
1911
|
+
})] });
|
|
1912
|
+
};
|
|
1913
|
+
const sharedSort = useSharedSort();
|
|
1914
|
+
const unnamed = t.rows.find((r) => !hasName(t, r) && t.columns.slice(1).some((c) => !isEmptyCell(cellValue(r.cells[c._key]))));
|
|
1915
|
+
const addRowButton = (ri) => /* @__PURE__ */ jsx(Button, {
|
|
1916
|
+
size: "sm",
|
|
1917
|
+
variant: "ghost",
|
|
1918
|
+
className: "text-kit-fg-2",
|
|
1919
|
+
leftIcon: /* @__PURE__ */ jsx(IconPlus, { stroke: 1.5 }),
|
|
1920
|
+
disabled: atMax && !runs[ri].totals,
|
|
1921
|
+
onClick: () => add(ri),
|
|
1922
|
+
children: atMax && !runs[ri].totals ? `Add row · ${options.maxRows} at most` : "Add row"
|
|
1923
|
+
});
|
|
1924
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1925
|
+
role: "group",
|
|
1926
|
+
"aria-label": "Rows",
|
|
1927
|
+
className: "group/part flex flex-col gap-1.5",
|
|
1928
|
+
children: [
|
|
1929
|
+
/* @__PURE__ */ jsx("span", {
|
|
1930
|
+
className: PART_LABEL,
|
|
1931
|
+
children: "Rows"
|
|
1932
|
+
}),
|
|
1933
|
+
unnamed && !readOnly ? /* @__PURE__ */ jsx("button", {
|
|
1934
|
+
type: "button",
|
|
1935
|
+
onClick: () => onOpen(t.rows.indexOf(unnamed), unnamed._key),
|
|
1936
|
+
className: "self-start text-left text-kit-xs text-kit-warning-fg underline-offset-2 hover:underline",
|
|
1937
|
+
children: "A row has values but no name. Open it"
|
|
1938
|
+
}) : null,
|
|
1939
|
+
/* @__PURE__ */ jsx(SharedSortProvider, {
|
|
1940
|
+
value: sharedSort.value,
|
|
1941
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1942
|
+
className: "flex flex-col gap-3",
|
|
1943
|
+
children: runs.map((run, ri) => {
|
|
1944
|
+
const list = /* @__PURE__ */ jsx(RowList, {
|
|
1945
|
+
field: ROWS_FIELD,
|
|
1946
|
+
rows: run.items.map(model),
|
|
1947
|
+
readOnly,
|
|
1948
|
+
layout: "list",
|
|
1949
|
+
mode: "drill",
|
|
1950
|
+
openId: null,
|
|
1951
|
+
onOpen: (r) => onOpen(t.rows.indexOf(r.item), r.id),
|
|
1952
|
+
onCloseInline: noop,
|
|
1953
|
+
ops: opsFor(ri),
|
|
1954
|
+
renderInline: () => null,
|
|
1955
|
+
menuExtra: moveMenu,
|
|
1956
|
+
emptyLabel: run.totals ? "No totals yet." : run.group ? "No rows in this group yet." : "No rows yet.",
|
|
1957
|
+
addButton: ri === lastBody && can.groups ? /* @__PURE__ */ jsxs("span", {
|
|
1958
|
+
className: "flex flex-wrap items-center gap-1",
|
|
1959
|
+
children: [addRowButton(ri), /* @__PURE__ */ jsx(Button, {
|
|
1960
|
+
size: "sm",
|
|
1961
|
+
variant: "ghost",
|
|
1962
|
+
className: "text-kit-fg-2",
|
|
1963
|
+
leftIcon: /* @__PURE__ */ jsx(IconPlus, { stroke: 1.5 }),
|
|
1964
|
+
onClick: addGroup,
|
|
1965
|
+
children: "Add group"
|
|
1966
|
+
})]
|
|
1967
|
+
}) : addRowButton(ri)
|
|
1968
|
+
});
|
|
1969
|
+
if (!run.group && !run.totals) return /* @__PURE__ */ jsx("div", { children: list }, run.key);
|
|
1970
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1971
|
+
role: "group",
|
|
1972
|
+
"aria-label": run.totals ? "Totals" : run.group.label || "Untitled group",
|
|
1973
|
+
className: "flex flex-col gap-1.5",
|
|
1974
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1975
|
+
className: "rounded-kit-md transition-colors",
|
|
1976
|
+
children: run.totals ? /* @__PURE__ */ jsx("span", {
|
|
1977
|
+
className: "flex h-7 items-center px-0.5 text-kit-sm font-medium text-kit-fg-2",
|
|
1978
|
+
children: "Totals"
|
|
1979
|
+
}) : /* @__PURE__ */ jsx(GroupHeading, {
|
|
1980
|
+
ctx,
|
|
1981
|
+
group: run.group,
|
|
1982
|
+
index: groups.indexOf(run.group),
|
|
1983
|
+
count: groups.length,
|
|
1984
|
+
rows: run.items.length
|
|
1985
|
+
})
|
|
1986
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1987
|
+
className: "ml-1.5 border-l border-kit-line pl-3",
|
|
1988
|
+
children: list
|
|
1989
|
+
})]
|
|
1990
|
+
}, run.key);
|
|
1991
|
+
})
|
|
1992
|
+
})
|
|
1993
|
+
}),
|
|
1994
|
+
sharedSort.a11y
|
|
1995
|
+
]
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1998
|
+
/** A row group's heading, renamed in place. It reads as a label at rest; its ⋯ moves or removes the group. */
|
|
1999
|
+
function GroupHeading({ ctx, group, index, count, rows }) {
|
|
2000
|
+
const { t, set, readOnly } = ctx;
|
|
2001
|
+
const [draft, setDraft] = React.useState(group.label);
|
|
2002
|
+
const [seen, setSeen] = React.useState(group.label);
|
|
2003
|
+
if (seen !== group.label) {
|
|
2004
|
+
setSeen(group.label);
|
|
2005
|
+
setDraft(group.label);
|
|
2006
|
+
}
|
|
2007
|
+
const rename = (label) => label !== group.label && set({
|
|
2008
|
+
...t,
|
|
2009
|
+
rowGroups: (t.rowGroups ?? []).map((g) => g._key === group._key ? {
|
|
2010
|
+
...g,
|
|
2011
|
+
label
|
|
2012
|
+
} : g)
|
|
2013
|
+
});
|
|
2014
|
+
const moveGroup = (d) => set({
|
|
2015
|
+
...t,
|
|
2016
|
+
rowGroups: moveItem(t.rowGroups ?? [], index, index + d)
|
|
2017
|
+
});
|
|
2018
|
+
const remove = () => {
|
|
2019
|
+
const prev = t;
|
|
2020
|
+
set({
|
|
2021
|
+
...t,
|
|
2022
|
+
rowGroups: (t.rowGroups ?? []).filter((g) => g._key !== group._key),
|
|
2023
|
+
rows: t.rows.map((r) => r.group === group._key ? clean({
|
|
2024
|
+
...r,
|
|
2025
|
+
group: void 0
|
|
2026
|
+
}) : r)
|
|
2027
|
+
});
|
|
2028
|
+
ctx.undoable(`“${group.label || "Untitled group"}” removed`, prev, rows ? `Its ${rows === 1 ? "row stays" : `${rows} rows stay`} in the table.` : void 0);
|
|
2029
|
+
};
|
|
2030
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2031
|
+
className: "group/gh flex min-w-0 items-center gap-1",
|
|
2032
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
2033
|
+
"data-group-name": group._key,
|
|
2034
|
+
value: draft,
|
|
2035
|
+
readOnly,
|
|
2036
|
+
maxLength: 300,
|
|
2037
|
+
placeholder: "Group name",
|
|
2038
|
+
"aria-label": "Group name",
|
|
2039
|
+
onChange: (e) => setDraft(e.target.value),
|
|
2040
|
+
onBlur: () => rename(draft.replace(/\s+/g, " ").trim()),
|
|
2041
|
+
onKeyDown: (e) => {
|
|
2042
|
+
if (e.key === "Enter") {
|
|
2043
|
+
e.preventDefault();
|
|
2044
|
+
e.currentTarget.blur();
|
|
2045
|
+
} else if (e.key === "Escape" && draft !== group.label) {
|
|
2046
|
+
e.preventDefault();
|
|
2047
|
+
e.stopPropagation();
|
|
2048
|
+
setDraft(group.label);
|
|
2049
|
+
}
|
|
2050
|
+
},
|
|
2051
|
+
className: "-mx-0.5 h-7 min-w-0 flex-1 truncate rounded-kit-md bg-transparent px-0.5 text-[13px] font-medium text-kit-fg-2 outline-none transition-colors placeholder:font-normal placeholder:text-kit-fg-4 hover:bg-kit-hover focus:bg-kit-surface focus:px-2 focus:text-kit-fg focus:shadow-[inset_0_0_0_1px_var(--kit-line-strong)]"
|
|
2052
|
+
}), readOnly ? null : /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
2053
|
+
render: /* @__PURE__ */ jsx(IconButton, {
|
|
2054
|
+
size: "xs",
|
|
2055
|
+
label: `Options for ${group.label || "this group"}`,
|
|
2056
|
+
className: "opacity-0 focus-visible:opacity-100 group-hover/gh:opacity-100 group-focus-within/gh:opacity-100 data-[popup-open]:opacity-100 [@media(pointer:coarse)]:opacity-100"
|
|
2057
|
+
}),
|
|
2058
|
+
children: /* @__PURE__ */ jsx(IconDots, { stroke: 1.5 })
|
|
2059
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
2060
|
+
align: "end",
|
|
2061
|
+
className: "min-w-44",
|
|
2062
|
+
children: [
|
|
2063
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
2064
|
+
icon: /* @__PURE__ */ jsx(IconArrowUp, { stroke: 1.5 }),
|
|
2065
|
+
disabled: index === 0,
|
|
2066
|
+
onClick: () => moveGroup(-1),
|
|
2067
|
+
children: "Move up"
|
|
2068
|
+
}),
|
|
2069
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
2070
|
+
icon: /* @__PURE__ */ jsx(IconArrowDown, { stroke: 1.5 }),
|
|
2071
|
+
disabled: index >= count - 1,
|
|
2072
|
+
onClick: () => moveGroup(1),
|
|
2073
|
+
children: "Move down"
|
|
2074
|
+
}),
|
|
2075
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
2076
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
2077
|
+
danger: true,
|
|
2078
|
+
onClick: remove,
|
|
2079
|
+
children: "Remove group"
|
|
2080
|
+
})
|
|
2081
|
+
]
|
|
2082
|
+
})] })]
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
/**
|
|
2086
|
+
* Height of the sticky bars pinned above a table in its scroll area: the rich-text editor publishes
|
|
2087
|
+
* --rt-sticky-top (field tabs + its toolbar), a kit form --kit-sticky-top (field tabs).
|
|
2088
|
+
*/
|
|
2089
|
+
var STICKY_TOP = "var(--rt-sticky-top, var(--kit-sticky-top, 0px))";
|
|
2090
|
+
/** Scroll only the nearest scroll area (never the shell) so `el`'s top clears the sticky bars (its scroll-margin-top). */
|
|
2091
|
+
function revealBelowStickies(el) {
|
|
2092
|
+
if (!el) return;
|
|
2093
|
+
let area = el.parentElement;
|
|
2094
|
+
while (area && !/(auto|scroll)/.test(getComputedStyle(area).overflowY)) area = area.parentElement;
|
|
2095
|
+
const hidden = (area ? area.getBoundingClientRect().top : 0) + (parseFloat(getComputedStyle(el).scrollMarginTop) || 0) - el.getBoundingClientRect().top;
|
|
2096
|
+
if (hidden > 1) (area ?? document.scrollingElement)?.scrollBy?.({ top: -hidden });
|
|
2097
|
+
}
|
|
2098
|
+
/** Tables outside a kit form (the /style-guide/kit sandbox, demos): the same drill, with the same breadcrumb and header. */
|
|
2099
|
+
function LocalDrill({ ctx, label, open, index, onBack, onGo }) {
|
|
2100
|
+
const { t, resolveRef } = ctx;
|
|
2101
|
+
const rows = open.kind === "rows";
|
|
2102
|
+
const list = rows ? t.rows : t.columns;
|
|
2103
|
+
const titleAt = (i) => rows ? hasName(t, t.rows[i]) ? rowTitle(t, t.rows[i], i, resolveRef) : "Untitled row" : t.columns[i].label || "Untitled column";
|
|
2104
|
+
const row = rows ? t.rows[index] : void 0;
|
|
2105
|
+
const group = row?.group && !row.footer ? t.rowGroups?.find((g) => g._key === row.group) : void 0;
|
|
2106
|
+
const title = titleAt(index);
|
|
2107
|
+
const noun = rows ? "row" : "column";
|
|
2108
|
+
const rootRef = React.useRef(null);
|
|
2109
|
+
const headRef = React.useRef(null);
|
|
2110
|
+
React.useLayoutEffect(() => {
|
|
2111
|
+
headRef.current?.focus({ preventScroll: true });
|
|
2112
|
+
const raf = requestAnimationFrame(() => revealBelowStickies(rootRef.current));
|
|
2113
|
+
return () => cancelAnimationFrame(raf);
|
|
2114
|
+
}, [index]);
|
|
2115
|
+
const step = (d) => list[index + d] && onGo(list[index + d]._key);
|
|
2116
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2117
|
+
ref: rootRef,
|
|
2118
|
+
className: "flex flex-col gap-4",
|
|
2119
|
+
style: { scrollMarginTop: `calc(${STICKY_TOP} + 8px)` },
|
|
2120
|
+
onKeyDown: (e) => e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), onBack()),
|
|
2121
|
+
children: [
|
|
2122
|
+
/* @__PURE__ */ jsx("div", {
|
|
2123
|
+
className: "sticky z-[2] -my-1 bg-kit-surface py-1",
|
|
2124
|
+
style: { top: STICKY_TOP },
|
|
2125
|
+
children: /* @__PURE__ */ jsx(PathCrumbs, {
|
|
2126
|
+
size: "sm",
|
|
2127
|
+
label: "Table path",
|
|
2128
|
+
items: [
|
|
2129
|
+
{
|
|
2130
|
+
id: "table",
|
|
2131
|
+
label: label || "Table",
|
|
2132
|
+
icon: /* @__PURE__ */ jsx(IconTable, {}),
|
|
2133
|
+
onSelect: onBack
|
|
2134
|
+
},
|
|
2135
|
+
...group ? [{
|
|
2136
|
+
id: "group",
|
|
2137
|
+
label: group.label || "Untitled group",
|
|
2138
|
+
icon: /* @__PURE__ */ jsx(IconFolder, {}),
|
|
2139
|
+
onSelect: onBack
|
|
2140
|
+
}] : [],
|
|
2141
|
+
{
|
|
2142
|
+
id: "current",
|
|
2143
|
+
label: title,
|
|
2144
|
+
icon: rows ? /* @__PURE__ */ jsx(IconList, {}) : /* @__PURE__ */ jsx(IconLayoutColumns, {})
|
|
2145
|
+
}
|
|
2146
|
+
]
|
|
2147
|
+
})
|
|
2148
|
+
}),
|
|
2149
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2150
|
+
ref: headRef,
|
|
2151
|
+
tabIndex: -1,
|
|
2152
|
+
className: "flex items-start gap-2.5 outline-none",
|
|
2153
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2154
|
+
className: "min-w-0 flex-1",
|
|
2155
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
2156
|
+
className: "truncate text-kit-base font-semibold leading-6 text-kit-fg",
|
|
2157
|
+
children: title
|
|
2158
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
2159
|
+
className: "truncate text-kit-xs leading-4 text-kit-fg-3",
|
|
2160
|
+
children: `${rows ? "Row" : "Column"} ${index + 1} of ${list.length} in ${label || "the table"}`
|
|
2161
|
+
})]
|
|
2162
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
2163
|
+
className: "-mr-1 flex shrink-0 items-center gap-0.5 pt-0.5",
|
|
2164
|
+
children: [/* @__PURE__ */ jsx(IconButton, {
|
|
2165
|
+
size: "sm",
|
|
2166
|
+
label: index > 0 ? `Previous ${noun}: ${titleAt(index - 1)}` : `First ${noun}`,
|
|
2167
|
+
disabled: index === 0,
|
|
2168
|
+
onClick: () => step(-1),
|
|
2169
|
+
children: /* @__PURE__ */ jsx(IconArrowUp, { stroke: 1.5 })
|
|
2170
|
+
}), /* @__PURE__ */ jsx(IconButton, {
|
|
2171
|
+
size: "sm",
|
|
2172
|
+
label: index < list.length - 1 ? `Next ${noun}: ${titleAt(index + 1)}` : `Last ${noun}`,
|
|
2173
|
+
disabled: index >= list.length - 1,
|
|
2174
|
+
onClick: () => step(1),
|
|
2175
|
+
children: /* @__PURE__ */ jsx(IconArrowDown, { stroke: 1.5 })
|
|
2176
|
+
})]
|
|
2177
|
+
})]
|
|
2178
|
+
}),
|
|
2179
|
+
rows ? /* @__PURE__ */ jsx(RowFields, {
|
|
2180
|
+
ctx,
|
|
2181
|
+
row: t.rows[index]
|
|
2182
|
+
}) : /* @__PURE__ */ jsx(ColumnFields, {
|
|
2183
|
+
ctx,
|
|
2184
|
+
col: t.columns[index]
|
|
2185
|
+
})
|
|
2186
|
+
]
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
function RowFields({ ctx, row }) {
|
|
2190
|
+
const { t, edit, readOnly, options } = ctx;
|
|
2191
|
+
const write = (col, next) => edit(mapRow(row._key, (x) => ({
|
|
2192
|
+
...x,
|
|
2193
|
+
cells: {
|
|
2194
|
+
...x.cells,
|
|
2195
|
+
[col._key]: next ?? null
|
|
2196
|
+
}
|
|
2197
|
+
})));
|
|
2198
|
+
const named = hasName(t, row);
|
|
2199
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2200
|
+
className: "flex flex-col gap-4",
|
|
2201
|
+
children: [t.columns.map((col, ci) => /* @__PURE__ */ jsx(CellField, {
|
|
2202
|
+
ctx,
|
|
2203
|
+
row,
|
|
2204
|
+
col,
|
|
2205
|
+
ci,
|
|
2206
|
+
needsName: ci === 0 && !named,
|
|
2207
|
+
onWrite: (c) => write(col, c)
|
|
2208
|
+
}, col._key)), readOnly || !offered(options).highlight ? null : /* @__PURE__ */ jsx(SwitchRow, {
|
|
2209
|
+
label: "Highlight this row",
|
|
2210
|
+
checked: !!row.highlight,
|
|
2211
|
+
onChange: (v) => edit(mapRow(row._key, (x) => clean({
|
|
2212
|
+
...x,
|
|
2213
|
+
highlight: v
|
|
2214
|
+
})))
|
|
2215
|
+
})]
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
/**
|
|
2219
|
+
* One cell as a field. Per-cell exceptions are quiet: a ⋯ by the label (shown on hover or focus) offers "Write words
|
|
2220
|
+
* instead" for a typed column, a footnote and Clear. A footnote is written right here, under the cell (D52).
|
|
2221
|
+
*/
|
|
2222
|
+
function CellField({ ctx, row, col, ci, needsName, onWrite }) {
|
|
2223
|
+
const { t, set, resolveRef, readOnly, options } = ctx;
|
|
2224
|
+
const cell = row.cells[col._key];
|
|
2225
|
+
const declared = cellType(col, row, cell);
|
|
2226
|
+
const v = cellValue(cell);
|
|
2227
|
+
const ty = declared === "boolean" && !isEmptyCell(v) && toBool(v) == null ? "text" : declared;
|
|
2228
|
+
const colType = row.type ?? col.type;
|
|
2229
|
+
const asWords = ty === "text" && colType !== "text";
|
|
2230
|
+
const note = cellNote(cell);
|
|
2231
|
+
const fn = note ? (t.footnotes ?? []).find((f) => f._key === note) : void 0;
|
|
2232
|
+
const fi = fn ? (t.footnotes ?? []).indexOf(fn) : -1;
|
|
2233
|
+
const id = `${row._key}-${col._key}`;
|
|
2234
|
+
const name = col.label || `Column ${ci + 1}`;
|
|
2235
|
+
const canWords = !readOnly && colType !== "text" && colType !== "reference" && colType !== "richtext-inline";
|
|
2236
|
+
const canNote = !readOnly && offered(options).footnotes;
|
|
2237
|
+
const setWords = (on) => {
|
|
2238
|
+
const raw = cellText(col, row, cell, resolveRef);
|
|
2239
|
+
const type = on ? "text" : void 0;
|
|
2240
|
+
const value = coerce(raw, {
|
|
2241
|
+
type: type ?? colType,
|
|
2242
|
+
max: col.max
|
|
2243
|
+
});
|
|
2244
|
+
onWrite(type || note ? {
|
|
2245
|
+
value,
|
|
2246
|
+
...type ? { type } : {},
|
|
2247
|
+
...note ? { note } : {}
|
|
2248
|
+
} : value);
|
|
2249
|
+
};
|
|
2250
|
+
const addNote = () => {
|
|
2251
|
+
const [next, key] = linkNote(t, row._key, col._key);
|
|
2252
|
+
set(next);
|
|
2253
|
+
focusSoon(`[data-footnote="${key}"]`);
|
|
2254
|
+
};
|
|
2255
|
+
const b = toBool(v);
|
|
2256
|
+
let control;
|
|
2257
|
+
if (ty === "boolean") control = /* @__PURE__ */ jsxs("label", {
|
|
2258
|
+
className: "flex h-8 items-center gap-2.5",
|
|
2259
|
+
children: [/* @__PURE__ */ jsx(Switch, {
|
|
2260
|
+
id,
|
|
2261
|
+
size: "sm",
|
|
2262
|
+
"aria-labelledby": `${id}-name`,
|
|
2263
|
+
"aria-describedby": `${id}-says`,
|
|
2264
|
+
disabled: readOnly,
|
|
2265
|
+
checked: b === true,
|
|
2266
|
+
onCheckedChange: (x) => onWrite(withValue(cell, x))
|
|
2267
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2268
|
+
id: `${id}-says`,
|
|
2269
|
+
className: cn("text-kit-sm", b == null ? "text-kit-fg-4" : "text-kit-fg-2"),
|
|
2270
|
+
children: b == null ? "Not set" : b ? boolLabels(col).yes : boolLabels(col).no
|
|
2271
|
+
})]
|
|
2272
|
+
});
|
|
2273
|
+
else if (ty === "reference") control = /* @__PURE__ */ jsx("div", {
|
|
2274
|
+
className: "rounded-kit-md border border-kit-field-border bg-kit-field-bg",
|
|
2275
|
+
children: /* @__PURE__ */ jsx(RefCell, {
|
|
2276
|
+
ctx,
|
|
2277
|
+
cell,
|
|
2278
|
+
col,
|
|
2279
|
+
cellId: id,
|
|
2280
|
+
name,
|
|
2281
|
+
onWrite,
|
|
2282
|
+
onMove: noop
|
|
2283
|
+
})
|
|
2284
|
+
});
|
|
2285
|
+
else if (ty === "link") {
|
|
2286
|
+
const l = isObjLike(v) && !("ref" in v) ? v : {
|
|
2287
|
+
label: typeof v === "string" ? v : "",
|
|
2288
|
+
href: ""
|
|
2289
|
+
};
|
|
2290
|
+
control = /* @__PURE__ */ jsxs(FieldUnit, { children: [/* @__PURE__ */ jsx(FieldUnitRow, { children: /* @__PURE__ */ jsx("input", {
|
|
2291
|
+
id,
|
|
2292
|
+
className: "h-9 w-full min-w-0 bg-transparent px-2 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-4",
|
|
2293
|
+
readOnly,
|
|
2294
|
+
defaultValue: l.label,
|
|
2295
|
+
placeholder: "Link text",
|
|
2296
|
+
"aria-label": `${name} link text`,
|
|
2297
|
+
onBlur: (e) => e.target.value !== l.label && onWrite(withValue(cell, {
|
|
2298
|
+
...l,
|
|
2299
|
+
label: e.target.value
|
|
2300
|
+
}))
|
|
2301
|
+
}, `l${l.label}`) }), /* @__PURE__ */ jsx(FieldUnitRow, { children: /* @__PURE__ */ jsx(LinkField, {
|
|
2302
|
+
"aria-label": `${name} link`,
|
|
2303
|
+
value: tableLinkValue(l),
|
|
2304
|
+
readOnly,
|
|
2305
|
+
className: "border-0 bg-transparent shadow-none",
|
|
2306
|
+
onChange: (n) => {
|
|
2307
|
+
const o = n && typeof n === "object" ? n : null;
|
|
2308
|
+
if (o && isScriptHref(hrefOf(o))) return;
|
|
2309
|
+
onWrite(withValue(cell, o ? tableLink(l.label || linkText(o), hrefOf(o), o.newTab, o.rel) : {
|
|
2310
|
+
label: l.label,
|
|
2311
|
+
href: ""
|
|
2312
|
+
}));
|
|
2313
|
+
}
|
|
2314
|
+
}) })] });
|
|
2315
|
+
} else control = /* @__PURE__ */ jsx(FormText, {
|
|
2316
|
+
id,
|
|
2317
|
+
readOnly,
|
|
2318
|
+
autoFocus: needsName,
|
|
2319
|
+
value: isEmptyCell(v) ? "" : NUMERIC.includes(ty) ? String(toNumber(v) ?? cellText(col, row, cell)) : ty === "richtext-inline" ? String(v) : cellText(col, row, cell, resolveRef),
|
|
2320
|
+
suffix: ty === "number" ? col.unit : ty === "money" ? col.currency ?? "USD" : ty === "rating" ? `/ ${col.max ?? 5}` : void 0,
|
|
2321
|
+
numeric: NUMERIC.includes(ty),
|
|
2322
|
+
onCommit: (raw) => onWrite(typedCell(cell, col, row, raw))
|
|
2323
|
+
});
|
|
2324
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2325
|
+
className: "group/cell flex min-w-0 flex-col gap-1.5",
|
|
2326
|
+
children: [
|
|
2327
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2328
|
+
className: "flex min-h-5 min-w-0 items-center gap-1.5",
|
|
2329
|
+
children: [
|
|
2330
|
+
/* @__PURE__ */ jsx("label", {
|
|
2331
|
+
id: `${id}-name`,
|
|
2332
|
+
htmlFor: id,
|
|
2333
|
+
className: "truncate text-kit-sm font-medium text-kit-fg-2 transition-colors group-focus-within/cell:text-kit-fg",
|
|
2334
|
+
children: name
|
|
2335
|
+
}),
|
|
2336
|
+
needsName ? /* @__PURE__ */ jsx("span", {
|
|
2337
|
+
className: "shrink-0 text-kit-xs text-kit-warning-fg",
|
|
2338
|
+
children: "Needs a name"
|
|
2339
|
+
}) : null,
|
|
2340
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
2341
|
+
canWords || canNote || !readOnly && !isEmptyCell(v) ? /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
2342
|
+
render: /* @__PURE__ */ jsx(IconButton, {
|
|
2343
|
+
size: "xs",
|
|
2344
|
+
label: `Options for ${name}`,
|
|
2345
|
+
className: "-my-1 opacity-0 focus-visible:opacity-100 group-hover/cell:opacity-100 group-focus-within/cell:opacity-100 data-[popup-open]:opacity-100 [@media(pointer:coarse)]:opacity-100"
|
|
2346
|
+
}),
|
|
2347
|
+
children: /* @__PURE__ */ jsx(IconDots, { stroke: 1.5 })
|
|
2348
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
2349
|
+
align: "end",
|
|
2350
|
+
className: "min-w-52",
|
|
2351
|
+
children: [
|
|
2352
|
+
canWords ? /* @__PURE__ */ jsx(MenuItem, {
|
|
2353
|
+
onClick: () => setWords(!asWords),
|
|
2354
|
+
children: asWords ? `Use ${TYPE_UI[colType].label} like the column` : "Write words instead"
|
|
2355
|
+
}) : null,
|
|
2356
|
+
canNote ? note ? /* @__PURE__ */ jsx(MenuItem, {
|
|
2357
|
+
onClick: () => set(unlinkNote(t, row._key, col._key)),
|
|
2358
|
+
children: "Remove footnote"
|
|
2359
|
+
}) : /* @__PURE__ */ jsx(MenuItem, {
|
|
2360
|
+
onClick: addNote,
|
|
2361
|
+
children: "Add a footnote"
|
|
2362
|
+
}) : null,
|
|
2363
|
+
!isEmptyCell(v) ? /* @__PURE__ */ jsxs(Fragment, { children: [canWords || canNote ? /* @__PURE__ */ jsx(MenuSeparator, {}) : null, /* @__PURE__ */ jsx(MenuItem, {
|
|
2364
|
+
onClick: () => onWrite(withValue(cell, null)),
|
|
2365
|
+
children: "Clear"
|
|
2366
|
+
})] }) : null
|
|
2367
|
+
]
|
|
2368
|
+
})] }) : null
|
|
2369
|
+
]
|
|
2370
|
+
}),
|
|
2371
|
+
control,
|
|
2372
|
+
fn ? /* @__PURE__ */ jsxs("div", {
|
|
2373
|
+
className: "flex items-center gap-2",
|
|
2374
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
2375
|
+
className: "shrink-0 text-kit-xs text-kit-fg-3",
|
|
2376
|
+
children: ["Footnote ", fi + 1]
|
|
2377
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
2378
|
+
size: "sm",
|
|
2379
|
+
"data-footnote": fn._key,
|
|
2380
|
+
value: fn.text,
|
|
2381
|
+
readOnly,
|
|
2382
|
+
maxLength: 2e3,
|
|
2383
|
+
placeholder: "What the footnote says",
|
|
2384
|
+
"aria-label": `${name}: footnote ${fi + 1}`,
|
|
2385
|
+
onChange: (e) => set({
|
|
2386
|
+
...t,
|
|
2387
|
+
footnotes: (t.footnotes ?? []).map((x) => x._key === fn._key ? {
|
|
2388
|
+
...x,
|
|
2389
|
+
text: e.target.value
|
|
2390
|
+
} : x)
|
|
2391
|
+
})
|
|
2392
|
+
})]
|
|
2393
|
+
}) : null
|
|
2394
|
+
]
|
|
2395
|
+
});
|
|
2396
|
+
}
|
|
2397
|
+
function SwitchRow({ label, checked, onChange, disabled }) {
|
|
2398
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
2399
|
+
className: "flex min-h-8 items-center justify-between gap-2 text-kit-sm text-kit-fg-2",
|
|
2400
|
+
children: [label, /* @__PURE__ */ jsx(Switch, {
|
|
2401
|
+
size: "sm",
|
|
2402
|
+
checked,
|
|
2403
|
+
disabled,
|
|
2404
|
+
onCheckedChange: onChange,
|
|
2405
|
+
"aria-label": label
|
|
2406
|
+
})]
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
function ColumnFields({ ctx, col }) {
|
|
2410
|
+
const { t, set, lock, types, readOnly } = ctx;
|
|
2411
|
+
const id = React.useId();
|
|
2412
|
+
const patch = (p) => set({
|
|
2413
|
+
...t,
|
|
2414
|
+
columns: t.columns.map((c) => c._key === col._key ? withPatch(c, p) : c)
|
|
2415
|
+
});
|
|
2416
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2417
|
+
className: "flex flex-col gap-4",
|
|
2418
|
+
children: [
|
|
2419
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2420
|
+
className: "flex flex-col gap-1.5",
|
|
2421
|
+
children: [
|
|
2422
|
+
/* @__PURE__ */ jsx("label", {
|
|
2423
|
+
htmlFor: id,
|
|
2424
|
+
className: "text-kit-sm font-medium text-kit-fg-2",
|
|
2425
|
+
children: "Name"
|
|
2426
|
+
}),
|
|
2427
|
+
/* @__PURE__ */ jsx(Input, {
|
|
2428
|
+
id,
|
|
2429
|
+
size: "sm",
|
|
2430
|
+
autoFocus: !col.label && !lock,
|
|
2431
|
+
readOnly: lock,
|
|
2432
|
+
maxLength: 300,
|
|
2433
|
+
value: col.label,
|
|
2434
|
+
placeholder: "Column name",
|
|
2435
|
+
onChange: (e) => patch({ label: e.target.value })
|
|
2436
|
+
}),
|
|
2437
|
+
lock && !readOnly ? /* @__PURE__ */ jsx("span", {
|
|
2438
|
+
className: "text-kit-2xs leading-4 text-kit-fg-3",
|
|
2439
|
+
children: "This table's columns are set by its developer."
|
|
2440
|
+
}) : null
|
|
2441
|
+
]
|
|
2442
|
+
}),
|
|
2443
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2444
|
+
className: "flex flex-col gap-1.5",
|
|
2445
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2446
|
+
className: "text-kit-sm font-medium text-kit-fg-2",
|
|
2447
|
+
children: "Type"
|
|
2448
|
+
}), lock ? /* @__PURE__ */ jsxs("span", {
|
|
2449
|
+
className: "flex h-8 items-center gap-2 text-kit-sm text-kit-fg-2",
|
|
2450
|
+
children: [/* @__PURE__ */ jsx(TypeIcon, {
|
|
2451
|
+
type: col.type,
|
|
2452
|
+
className: "text-kit-fg-2"
|
|
2453
|
+
}), TYPE_UI[col.type].label]
|
|
2454
|
+
}) : /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
2455
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
2456
|
+
size: "sm",
|
|
2457
|
+
variant: "secondary",
|
|
2458
|
+
className: "justify-between",
|
|
2459
|
+
leftIcon: /* @__PURE__ */ jsx(TypeIcon, {
|
|
2460
|
+
type: col.type,
|
|
2461
|
+
className: "text-kit-fg-2"
|
|
2462
|
+
}),
|
|
2463
|
+
rightIcon: /* @__PURE__ */ jsx(IconChevronDown, { stroke: 1.5 })
|
|
2464
|
+
}),
|
|
2465
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
2466
|
+
className: "flex-1 text-left",
|
|
2467
|
+
children: TYPE_UI[col.type].label
|
|
2468
|
+
})
|
|
2469
|
+
}), /* @__PURE__ */ jsx(MenuContent, {
|
|
2470
|
+
align: "start",
|
|
2471
|
+
className: "min-w-52",
|
|
2472
|
+
children: /* @__PURE__ */ jsx(MenuRadioGroup, {
|
|
2473
|
+
value: col.type,
|
|
2474
|
+
onValueChange: (v) => ctx.edit((x) => retype(x, col._key, v, ctx.resolveRef)),
|
|
2475
|
+
children: (types.includes(col.type) ? types : [...types, col.type]).map((ty) => /* @__PURE__ */ jsx(MenuRadioItem, {
|
|
2476
|
+
value: ty,
|
|
2477
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
2478
|
+
className: "flex items-center gap-2",
|
|
2479
|
+
children: [/* @__PURE__ */ jsx(TypeIcon, {
|
|
2480
|
+
type: ty,
|
|
2481
|
+
className: "text-kit-fg-2"
|
|
2482
|
+
}), TYPE_UI[ty].label]
|
|
2483
|
+
})
|
|
2484
|
+
}, ty))
|
|
2485
|
+
})
|
|
2486
|
+
})] })]
|
|
2487
|
+
}),
|
|
2488
|
+
/* @__PURE__ */ jsx(ColumnDetails, {
|
|
2489
|
+
col,
|
|
2490
|
+
onPatch: patch,
|
|
2491
|
+
compact: false,
|
|
2492
|
+
readOnly: lock
|
|
2493
|
+
})
|
|
2494
|
+
]
|
|
2495
|
+
});
|
|
2496
|
+
}
|
|
2497
|
+
function FormText({ id, value, onCommit, suffix, numeric, readOnly, autoFocus }) {
|
|
2498
|
+
const [draft, setDraft] = React.useState(value);
|
|
2499
|
+
const [seen, setSeen] = React.useState(value);
|
|
2500
|
+
if (seen !== value) {
|
|
2501
|
+
setSeen(value);
|
|
2502
|
+
setDraft(value);
|
|
2503
|
+
}
|
|
2504
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2505
|
+
className: "relative",
|
|
2506
|
+
children: [/* @__PURE__ */ jsx(Textarea, {
|
|
2507
|
+
id,
|
|
2508
|
+
rows: 1,
|
|
2509
|
+
value: draft,
|
|
2510
|
+
readOnly,
|
|
2511
|
+
autoFocus,
|
|
2512
|
+
maxLength: 5e3,
|
|
2513
|
+
inputMode: numeric ? "decimal" : void 0,
|
|
2514
|
+
onChange: (e) => setDraft(e.target.value),
|
|
2515
|
+
onBlur: () => draft !== value && onCommit(draft),
|
|
2516
|
+
className: cn("min-h-8 resize-none py-1.5", suffix && "pr-12")
|
|
2517
|
+
}), suffix ? /* @__PURE__ */ jsx("span", {
|
|
2518
|
+
className: "pointer-events-none absolute right-2.5 top-1.5 text-kit-xs text-kit-fg-3",
|
|
2519
|
+
children: suffix
|
|
2520
|
+
}) : null]
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
var SEARCH = [
|
|
2524
|
+
{
|
|
2525
|
+
value: "none",
|
|
2526
|
+
label: "Nothing special"
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
value: "ItemList",
|
|
2530
|
+
label: "A comparison"
|
|
2531
|
+
},
|
|
2532
|
+
{
|
|
2533
|
+
value: "Dataset",
|
|
2534
|
+
label: "A data report"
|
|
2535
|
+
},
|
|
2536
|
+
{
|
|
2537
|
+
value: "Offers",
|
|
2538
|
+
label: "A price list"
|
|
2539
|
+
}
|
|
2540
|
+
];
|
|
2541
|
+
var NO_COLUMN = "__none";
|
|
2542
|
+
/** Totals on: an empty totals row appears at the end of the list. Off: empty totals rows go, filled ones rejoin the body. */
|
|
2543
|
+
function setTotals(t, on) {
|
|
2544
|
+
if (on) return t.rows.some((r) => r.footer) ? t : {
|
|
2545
|
+
...t,
|
|
2546
|
+
rows: [...t.rows, {
|
|
2547
|
+
_key: tkey("r"),
|
|
2548
|
+
cells: {},
|
|
2549
|
+
footer: true
|
|
2550
|
+
}]
|
|
2551
|
+
};
|
|
2552
|
+
return {
|
|
2553
|
+
...t,
|
|
2554
|
+
rows: t.rows.filter((r) => !r.footer || Object.values(r.cells).some((c) => !isEmptyCell(cellValue(c)))).map((r) => r.footer ? clean({
|
|
2555
|
+
...r,
|
|
2556
|
+
footer: void 0
|
|
2557
|
+
}) : r)
|
|
2558
|
+
};
|
|
2559
|
+
}
|
|
2560
|
+
function TableSettings({ ctx }) {
|
|
2561
|
+
const { t, set, developer, options } = ctx;
|
|
2562
|
+
const can = offered(options);
|
|
2563
|
+
const d = t.design ?? {};
|
|
2564
|
+
const sortable = t.columns.some((c) => c.sortable);
|
|
2565
|
+
const totals = t.rows.some((r) => r.footer);
|
|
2566
|
+
const phones = d.responsive ?? "scroll";
|
|
2567
|
+
const highlighted = t.columns.find((c) => c.highlight);
|
|
2568
|
+
const pickable = t.columns.filter((_, i) => !(t.headerColumn && i === 0));
|
|
2569
|
+
const jsonOffered = SEARCH.filter((x) => x.value === "none" || can.jsonLd.includes(x.value));
|
|
2570
|
+
const showJson = can.jsonLd.length > 0 || !!t.jsonLd && t.jsonLd.type !== "none";
|
|
2571
|
+
if (!(can.headers || can.totals || can.phones.length || can.highlight || can.sort || can.search || showJson || developer)) return null;
|
|
2572
|
+
const design = (p) => set({
|
|
2573
|
+
...t,
|
|
2574
|
+
design: withPatch(d, p)
|
|
2575
|
+
});
|
|
2576
|
+
const summary = [
|
|
2577
|
+
can.phones.length ? `${PHONES.find((p) => p.value === phones)?.label ?? "Scroll"} on phones` : "",
|
|
2578
|
+
can.highlight && highlighted ? `${highlighted.label || "A column"} highlighted` : "",
|
|
2579
|
+
can.totals && totals ? "Totals row" : ""
|
|
2580
|
+
].filter(Boolean).join(" · ");
|
|
2581
|
+
const pick = (label, node) => /* @__PURE__ */ jsxs("div", {
|
|
2582
|
+
className: "flex flex-col gap-1.5",
|
|
2583
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2584
|
+
className: "text-kit-sm font-medium text-kit-fg-2",
|
|
2585
|
+
children: label
|
|
2586
|
+
}), node]
|
|
2587
|
+
});
|
|
2588
|
+
return /* @__PURE__ */ jsxs(FieldSection, {
|
|
2589
|
+
title: "Table settings",
|
|
2590
|
+
defaultOpen: false,
|
|
2591
|
+
summary,
|
|
2592
|
+
className: "before:hidden",
|
|
2593
|
+
children: [
|
|
2594
|
+
can.headers ? /* @__PURE__ */ jsxs("div", {
|
|
2595
|
+
className: "flex flex-col",
|
|
2596
|
+
children: [
|
|
2597
|
+
/* @__PURE__ */ jsx(SwitchRow, {
|
|
2598
|
+
label: "Show column names",
|
|
2599
|
+
checked: t.headerRow,
|
|
2600
|
+
onChange: (v) => set({
|
|
2601
|
+
...t,
|
|
2602
|
+
headerRow: v
|
|
2603
|
+
})
|
|
2604
|
+
}),
|
|
2605
|
+
/* @__PURE__ */ jsx(SwitchRow, {
|
|
2606
|
+
label: "First column names each row",
|
|
2607
|
+
checked: t.headerColumn,
|
|
2608
|
+
onChange: (v) => set({
|
|
2609
|
+
...t,
|
|
2610
|
+
headerColumn: v
|
|
2611
|
+
})
|
|
2612
|
+
}),
|
|
2613
|
+
can.totals ? /* @__PURE__ */ jsx(SwitchRow, {
|
|
2614
|
+
label: "Totals row",
|
|
2615
|
+
checked: totals,
|
|
2616
|
+
onChange: (v) => set(setTotals(t, v))
|
|
2617
|
+
}) : null
|
|
2618
|
+
]
|
|
2619
|
+
}) : can.totals ? /* @__PURE__ */ jsx(SwitchRow, {
|
|
2620
|
+
label: "Totals row",
|
|
2621
|
+
checked: totals,
|
|
2622
|
+
onChange: (v) => set(setTotals(t, v))
|
|
2623
|
+
}) : null,
|
|
2624
|
+
can.highlight ? pick("Highlight column", /* @__PURE__ */ jsx(Select, {
|
|
2625
|
+
"aria-label": "Highlight column",
|
|
2626
|
+
value: highlighted?._key ?? NO_COLUMN,
|
|
2627
|
+
onValueChange: (k) => set({
|
|
2628
|
+
...t,
|
|
2629
|
+
columns: t.columns.map((c) => withPatch(c, { highlight: c._key === k ? true : void 0 }))
|
|
2630
|
+
}),
|
|
2631
|
+
options: [{
|
|
2632
|
+
value: NO_COLUMN,
|
|
2633
|
+
label: "None"
|
|
2634
|
+
}, ...pickable.map((c) => ({
|
|
2635
|
+
value: c._key,
|
|
2636
|
+
label: c.label || "Untitled column"
|
|
2637
|
+
}))]
|
|
2638
|
+
})) : null,
|
|
2639
|
+
can.phones.length ? pick("On phones", /* @__PURE__ */ jsx(ChoiceSwitch, {
|
|
2640
|
+
"aria-label": "On phones",
|
|
2641
|
+
value: phones,
|
|
2642
|
+
onChange: (responsive) => design({ responsive }),
|
|
2643
|
+
items: can.phones
|
|
2644
|
+
})) : null,
|
|
2645
|
+
can.sort || can.search ? /* @__PURE__ */ jsxs("div", {
|
|
2646
|
+
className: "flex flex-col",
|
|
2647
|
+
children: [can.sort ? /* @__PURE__ */ jsx(SwitchRow, {
|
|
2648
|
+
label: "Visitors can sort columns",
|
|
2649
|
+
checked: sortable,
|
|
2650
|
+
onChange: (v) => set({
|
|
2651
|
+
...t,
|
|
2652
|
+
columns: t.columns.map((c, i) => withPatch(c, { sortable: v && !(t.headerColumn && i === 0) ? true : void 0 }))
|
|
2653
|
+
})
|
|
2654
|
+
}) : null, can.search ? /* @__PURE__ */ jsx(SwitchRow, {
|
|
2655
|
+
label: "Visitors can search rows",
|
|
2656
|
+
checked: !!t.filterable,
|
|
2657
|
+
onChange: (v) => set(dropUndefined({
|
|
2658
|
+
...t,
|
|
2659
|
+
filterable: v || void 0
|
|
2660
|
+
}))
|
|
2661
|
+
}) : null]
|
|
2662
|
+
}) : null,
|
|
2663
|
+
showJson ? /* @__PURE__ */ jsxs(Fragment, { children: [pick("Help search engines read this as", /* @__PURE__ */ jsx(ChoiceSwitch, {
|
|
2664
|
+
"aria-label": "Help search engines read this as",
|
|
2665
|
+
value: t.jsonLd?.type ?? "none",
|
|
2666
|
+
onChange: (type) => set(dropUndefined({
|
|
2667
|
+
...t,
|
|
2668
|
+
jsonLd: type === "none" ? void 0 : {
|
|
2669
|
+
...t.jsonLd,
|
|
2670
|
+
type,
|
|
2671
|
+
...type === "ItemList" ? { axis: t.jsonLd?.axis ?? "rows" } : {}
|
|
2672
|
+
}
|
|
2673
|
+
})),
|
|
2674
|
+
items: jsonOffered
|
|
2675
|
+
})), t.jsonLd?.type === "ItemList" && developer ? pick("The things compared are the", /* @__PURE__ */ jsx(ChoiceSwitch, {
|
|
2676
|
+
"aria-label": "The things compared are the",
|
|
2677
|
+
value: t.jsonLd.axis ?? "rows",
|
|
2678
|
+
onChange: (axis) => set({
|
|
2679
|
+
...t,
|
|
2680
|
+
jsonLd: {
|
|
2681
|
+
...t.jsonLd,
|
|
2682
|
+
axis
|
|
2683
|
+
}
|
|
2684
|
+
}),
|
|
2685
|
+
items: [{
|
|
2686
|
+
value: "rows",
|
|
2687
|
+
label: "Rows"
|
|
2688
|
+
}, {
|
|
2689
|
+
value: "columns",
|
|
2690
|
+
label: "Columns"
|
|
2691
|
+
}]
|
|
2692
|
+
})) : null] }) : null,
|
|
2693
|
+
developer ? /* @__PURE__ */ jsxs("div", {
|
|
2694
|
+
className: "flex flex-col",
|
|
2695
|
+
children: [
|
|
2696
|
+
/* @__PURE__ */ jsx(SwitchRow, {
|
|
2697
|
+
label: "Hide the title on the page",
|
|
2698
|
+
checked: !!d.hideCaption,
|
|
2699
|
+
onChange: (v) => design({ hideCaption: v || void 0 })
|
|
2700
|
+
}),
|
|
2701
|
+
can.sticky ? /* @__PURE__ */ jsx(SwitchRow, {
|
|
2702
|
+
label: "Keep column names in view",
|
|
2703
|
+
checked: !!d.sticky,
|
|
2704
|
+
onChange: (v) => design({ sticky: v || void 0 })
|
|
2705
|
+
}) : null,
|
|
2706
|
+
/* @__PURE__ */ jsx(SwitchRow, {
|
|
2707
|
+
label: "Striped rows",
|
|
2708
|
+
checked: !!d.striped,
|
|
2709
|
+
onChange: (v) => design({ striped: v || void 0 })
|
|
2710
|
+
}),
|
|
2711
|
+
/* @__PURE__ */ jsx(SwitchRow, {
|
|
2712
|
+
label: "Compact",
|
|
2713
|
+
checked: d.density === "compact",
|
|
2714
|
+
onChange: (v) => design({ density: v ? "compact" : void 0 })
|
|
2715
|
+
})
|
|
2716
|
+
]
|
|
2717
|
+
}) : null
|
|
2718
|
+
]
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
var dropUndefined = (o) => Object.fromEntries(Object.entries(o).filter(([, v]) => v !== void 0));
|
|
2722
|
+
//#endregion
|
|
2723
|
+
export { TYPE_UI, TableEditor, TableFullScreenButton, TableItemEditor, linkNote, moveRowTo, offered, retype, setTotals, typedCell, unlinkNote };
|
|
2724
|
+
|
|
2725
|
+
//# sourceMappingURL=table-editor.js.map
|