@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,1186 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { useKitEnv, useKitServices } from "../context.js";
|
|
3
|
+
import { isObj } from "../lib/path.js";
|
|
4
|
+
import { Button, IconButton } from "../ui/button.js";
|
|
5
|
+
import { Switch } from "../ui/controls.js";
|
|
6
|
+
import { Menu, MenuContent, MenuItem, MenuTrigger, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Tooltip } from "../ui/overlay.js";
|
|
7
|
+
import { Input } from "../ui/input.js";
|
|
8
|
+
import { Select } from "../ui/select.js";
|
|
9
|
+
import * as React from "react";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { IconAdjustmentsHorizontal, IconArrowUpRight, IconAt, IconCheck, IconChevronDown, IconExternalLink, IconFile, IconFileDatabase, IconFolderOpen, IconHash, IconLink, IconMail, IconPaperclip, IconPhone, IconWorld, IconX } from "@tabler/icons-react";
|
|
12
|
+
//#region src/controls/link.tsx
|
|
13
|
+
/**
|
|
14
|
+
* LINK — the ONE link element of the product (V2 HEAD kit/controls/link.tsx, DESIGN §8.7, CPO D43 · D48 · D57).
|
|
15
|
+
*
|
|
16
|
+
* - <LinkForm> Type (Page · CMS item · URL · Email · Phone · Section · File) → the target for that type (search over
|
|
17
|
+
* the host's pages and CMS items, paste detection, URL / email / phone / #anchor validation; File =
|
|
18
|
+
* the host's media library) → Section on the picked page → options (new tab · rel · email subject).
|
|
19
|
+
* - <LinkPopoverBody> the link panel: what it links to now + LinkForm + Remove link · Cancel · Apply.
|
|
20
|
+
* - <LinkField> a link at rest (one bordered row): click edits in place (quick edit), the sliders icon opens the panel.
|
|
21
|
+
* - <LinkPicker> the target input inside all of the above.
|
|
22
|
+
* - <LinkLine> how a link READS at rest: page icon + title + path · external icon + domain · mail / phone.
|
|
23
|
+
*
|
|
24
|
+
* Where the targets come from. The kit never fetches: the host hands its own link-target query in as a React hook,
|
|
25
|
+
* `KitServices.useLinkTargets` (KitLinkServices below), and the media library as `KitServices.MediaPicker`. With no hook a
|
|
26
|
+
* page link is typed as a path and the list says so in words; with no media picker the File type is not offered.
|
|
27
|
+
* Section anchors come from the host that knows the page (SectionAnchorsProvider); without one a section is typed (#faq).
|
|
28
|
+
*
|
|
29
|
+
* Stored shape (prod `link`, adapters/values.ts linkToProd / linkFromProd). The kit value is what the field already
|
|
30
|
+
* stores: a STRING href stays a string (legacy fields and the sites that read `href={link}`), an object stays an object.
|
|
31
|
+
* An empty field takes `field.valueShape` and, with none, the string (prod LinkField's default). In the string shape the
|
|
32
|
+
* options (new tab, rel) need the object, so they hide — V2's `valueShape="string"`. An object never carries `target`
|
|
33
|
+
* (derived from newTab), `rel: "follow"` (follow = no rel) or `newTab: false`, so it reads back exactly as written.
|
|
34
|
+
*
|
|
35
|
+
* Deviations from V2, each because prod has no source for it: no "From this entry" {{token}} targets (no binding store
|
|
36
|
+
* behind them), no seeded page anchors, no fabricated CDN address for a file (a file without a public url is refused).
|
|
37
|
+
*/
|
|
38
|
+
var NO_TARGETS = [];
|
|
39
|
+
var useNoTargets = () => ({
|
|
40
|
+
targets: NO_TARGETS,
|
|
41
|
+
loading: false,
|
|
42
|
+
error: void 0
|
|
43
|
+
});
|
|
44
|
+
/** The host's pages, CMS items (and files, when it lists them). */
|
|
45
|
+
function useLinkTargets() {
|
|
46
|
+
const svc = useKitServices();
|
|
47
|
+
const r = (svc.useLinkTargets ?? useNoTargets)();
|
|
48
|
+
return {
|
|
49
|
+
targets: r.targets ?? NO_TARGETS,
|
|
50
|
+
loading: !!r.loading,
|
|
51
|
+
error: r.error,
|
|
52
|
+
unavailable: !svc.useLinkTargets
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
var SectionAnchorsCtx = React.createContext(null);
|
|
56
|
+
/** The host that knows the page being edited lists its section anchors, so the Section type is a pick. */
|
|
57
|
+
function SectionAnchorsProvider({ anchors, children }) {
|
|
58
|
+
return /* @__PURE__ */ jsx(SectionAnchorsCtx.Provider, {
|
|
59
|
+
value: anchors,
|
|
60
|
+
children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function useSectionTargets() {
|
|
64
|
+
const anchors = React.useContext(SectionAnchorsCtx);
|
|
65
|
+
return React.useMemo(() => (anchors ?? []).map((a) => ({
|
|
66
|
+
id: `section:${a.anchor}`,
|
|
67
|
+
title: a.label,
|
|
68
|
+
href: a.anchor.startsWith("#") ? a.anchor : `#${a.anchor}`,
|
|
69
|
+
kind: "section",
|
|
70
|
+
group: "On this page",
|
|
71
|
+
onChoose: a.ensure
|
|
72
|
+
})), [anchors]);
|
|
73
|
+
}
|
|
74
|
+
/** A file from the media library as a link target, or the reason it can't be one. */
|
|
75
|
+
function fileTarget(a) {
|
|
76
|
+
if (!a.url || a.url.startsWith("blob:")) return { problem: "This file has no public address yet. Wait for the upload to finish, then pick it again." };
|
|
77
|
+
const name = a.name || fileName(a.url);
|
|
78
|
+
return {
|
|
79
|
+
id: a.id,
|
|
80
|
+
title: name,
|
|
81
|
+
href: a.url,
|
|
82
|
+
kind: "file",
|
|
83
|
+
meta: name.split(".").pop()?.toUpperCase(),
|
|
84
|
+
group: "Files"
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
var normLink = (v) => {
|
|
88
|
+
const o = typeof v === "string" ? { href: v } : isObj(v) ? {
|
|
89
|
+
...v,
|
|
90
|
+
href: typeof v.href === "string" ? v.href : ""
|
|
91
|
+
} : { href: "" };
|
|
92
|
+
if (o.newTab === void 0 && o.target === "_blank") o.newTab = true;
|
|
93
|
+
if (!o.type) o.type = detectType(o.href);
|
|
94
|
+
return o;
|
|
95
|
+
};
|
|
96
|
+
function detectType(raw) {
|
|
97
|
+
const s = raw.trim();
|
|
98
|
+
if (!s) return "page";
|
|
99
|
+
if (s.startsWith("#")) return "section";
|
|
100
|
+
if (/^mailto:/i.test(s) || /^[^\s@/]+@[^\s@]+\.[^\s@]+$/.test(s)) return "email";
|
|
101
|
+
if (/^tel:/i.test(s) || /^\+?[\d\s().-]{7,}$/.test(s)) return "phone";
|
|
102
|
+
if (/\.(pdf|zip|docx?|csv)$/i.test(s)) return "file";
|
|
103
|
+
if (/^https?:\/\//i.test(s) || /^www\./i.test(s) || /^[a-z0-9-]+(\.[a-z0-9-]+)+(\/|$)/i.test(s)) return "url";
|
|
104
|
+
return "page";
|
|
105
|
+
}
|
|
106
|
+
var LINK_TYPES = [
|
|
107
|
+
{
|
|
108
|
+
type: "page",
|
|
109
|
+
label: "Page",
|
|
110
|
+
icon: /* @__PURE__ */ jsx(IconFile, { stroke: 1.5 }),
|
|
111
|
+
placeholder: "Search pages and CMS items, or paste a link",
|
|
112
|
+
target: "Page"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: "entry",
|
|
116
|
+
label: "CMS item",
|
|
117
|
+
icon: /* @__PURE__ */ jsx(IconFileDatabase, { stroke: 1.5 }),
|
|
118
|
+
placeholder: "Search CMS items",
|
|
119
|
+
target: "CMS item"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "url",
|
|
123
|
+
label: "URL",
|
|
124
|
+
icon: /* @__PURE__ */ jsx(IconWorld, { stroke: 1.5 }),
|
|
125
|
+
placeholder: "https://example.com",
|
|
126
|
+
target: "Address"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: "email",
|
|
130
|
+
label: "Email",
|
|
131
|
+
icon: /* @__PURE__ */ jsx(IconAt, { stroke: 1.5 }),
|
|
132
|
+
placeholder: "name@company.com",
|
|
133
|
+
target: "Email address"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: "phone",
|
|
137
|
+
label: "Phone",
|
|
138
|
+
icon: /* @__PURE__ */ jsx(IconPhone, { stroke: 1.5 }),
|
|
139
|
+
placeholder: "+1 541 555 0182",
|
|
140
|
+
target: "Phone number"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: "section",
|
|
144
|
+
label: "Section",
|
|
145
|
+
icon: /* @__PURE__ */ jsx(IconHash, { stroke: 1.5 }),
|
|
146
|
+
placeholder: "#section-on-this-page",
|
|
147
|
+
target: "Section on this page"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
type: "file",
|
|
151
|
+
label: "File",
|
|
152
|
+
icon: /* @__PURE__ */ jsx(IconPaperclip, { stroke: 1.5 }),
|
|
153
|
+
placeholder: "Search files",
|
|
154
|
+
target: "File"
|
|
155
|
+
}
|
|
156
|
+
];
|
|
157
|
+
var typeMeta = (t) => LINK_TYPES.find((x) => x.type === t) ?? LINK_TYPES[0];
|
|
158
|
+
/** The target a value points at: by id first, then by an exact path ("/about" typed by hand still reads as About). */
|
|
159
|
+
function findTarget(targets, v) {
|
|
160
|
+
const byId = targets.find((t) => v.pageId && t.id === v.pageId || v.entryId && t.id === v.entryId || v.assetId && t.id === v.assetId);
|
|
161
|
+
if (byId) return byId;
|
|
162
|
+
if (v.type === "section") return v.href ? targets.find((t) => t.kind === "section" && t.href === (v.href.startsWith("#") ? v.href : `#${v.href}`)) : void 0;
|
|
163
|
+
if (!v.href || v.type !== "page" && v.type !== "entry" && v.type !== "file") return void 0;
|
|
164
|
+
if (v.type === "file") return targets.find((t) => t.kind === "file" && t.href === v.href) ?? (v.title ? {
|
|
165
|
+
id: v.assetId ?? v.href,
|
|
166
|
+
title: v.title,
|
|
167
|
+
href: v.href,
|
|
168
|
+
kind: "file",
|
|
169
|
+
group: "Files"
|
|
170
|
+
} : void 0);
|
|
171
|
+
const path = v.href.replace(/[?#].*$/, "").replace(/\/$/, "") || "/";
|
|
172
|
+
return targets.find((t) => t.kind !== "file" && t.kind !== "section" && t.href === path);
|
|
173
|
+
}
|
|
174
|
+
/** The final href for a link value. */
|
|
175
|
+
function hrefOf(v) {
|
|
176
|
+
switch (v.type) {
|
|
177
|
+
case "email": {
|
|
178
|
+
const addr = (v.email ?? v.href).replace(/^mailto:/i, "").replace(/\?.*$/, "");
|
|
179
|
+
return addr ? `mailto:${addr}${v.subject ? `?subject=${encodeURIComponent(v.subject)}` : ""}` : "";
|
|
180
|
+
}
|
|
181
|
+
case "phone": {
|
|
182
|
+
const n = (v.phone ?? v.href).replace(/^tel:/i, "").replace(/[^\d+]/g, "");
|
|
183
|
+
return n ? `tel:${n}` : "";
|
|
184
|
+
}
|
|
185
|
+
case "section": return v.href.startsWith("#") ? v.href : v.href ? `#${v.href}` : "";
|
|
186
|
+
default: return `${v.anchor !== void 0 ? v.href.replace(/#.*$/, "") : v.href}${v.anchor && v.anchor !== "none" ? v.anchor : ""}`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
var BAD_URL = "Enter a full address, like https://example.com.";
|
|
190
|
+
/** Why a link can't be saved yet, in plain words. Undefined when it is fine (or empty). */
|
|
191
|
+
function linkProblem(v) {
|
|
192
|
+
if (!hasLink(v)) return void 0;
|
|
193
|
+
const raw = (v.type === "email" ? v.email ?? v.href : v.type === "phone" ? v.phone ?? v.href : v.href).trim();
|
|
194
|
+
if (/^(javascript|data|vbscript):/i.test(raw.replace(/[\u0000- ]/g, ""))) return "Script links aren't allowed.";
|
|
195
|
+
switch (v.type) {
|
|
196
|
+
case "url":
|
|
197
|
+
if (raw.startsWith("/") || raw.startsWith("#")) return void 0;
|
|
198
|
+
try {
|
|
199
|
+
const u = new URL(/^[a-z][a-z0-9+.-]*:/i.test(raw) ? raw : `https://${raw}`);
|
|
200
|
+
if (!/^https?:$/.test(u.protocol)) return BAD_URL;
|
|
201
|
+
return /\.[a-z]{2,}$/i.test(u.hostname) || u.hostname === "localhost" ? void 0 : BAD_URL;
|
|
202
|
+
} catch {
|
|
203
|
+
return BAD_URL;
|
|
204
|
+
}
|
|
205
|
+
case "email": return /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(raw.replace(/^mailto:/i, "").replace(/\?.*$/, "")) ? void 0 : "Enter an email address, like name@company.com.";
|
|
206
|
+
case "phone": return raw.replace(/^tel:/i, "").replace(/\D/g, "").length >= 7 ? void 0 : "Enter a phone number with at least 7 digits.";
|
|
207
|
+
case "section": return /^#?[A-Za-z][\w-]*$/.test(raw) ? void 0 : "Use letters, numbers and dashes, like #faq.";
|
|
208
|
+
case "page":
|
|
209
|
+
case "entry": return raw.startsWith("/") || raw.startsWith("#") || v.pageId || v.entryId ? void 0 : "Pick a page, or start a path with /, like /about.";
|
|
210
|
+
default: return;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** One list for every link editor (dropdown, never a segmented row — D40). */
|
|
214
|
+
var REL_ITEMS = [
|
|
215
|
+
{
|
|
216
|
+
value: "follow",
|
|
217
|
+
label: "Do-follow",
|
|
218
|
+
description: "Normal link. Search engines follow it."
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
value: "nofollow",
|
|
222
|
+
label: "No-follow",
|
|
223
|
+
description: "Search engines don't follow or credit it."
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
value: "sponsored",
|
|
227
|
+
label: "Sponsored",
|
|
228
|
+
description: "Paid, affiliate or ad link."
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
value: "ugc",
|
|
232
|
+
label: "UGC",
|
|
233
|
+
description: "Link added by users, e.g. comments."
|
|
234
|
+
}
|
|
235
|
+
];
|
|
236
|
+
var hasLink = (v) => !!(v.href || v.email || v.phone);
|
|
237
|
+
var TARGET_KEYS = {
|
|
238
|
+
title: void 0,
|
|
239
|
+
pageId: void 0,
|
|
240
|
+
entryId: void 0,
|
|
241
|
+
assetId: void 0,
|
|
242
|
+
anchor: void 0
|
|
243
|
+
};
|
|
244
|
+
/** The value a picked target produces (keeps label, style and options). */
|
|
245
|
+
function withTarget(v, t) {
|
|
246
|
+
return {
|
|
247
|
+
...v,
|
|
248
|
+
...TARGET_KEYS,
|
|
249
|
+
email: void 0,
|
|
250
|
+
phone: void 0,
|
|
251
|
+
subject: void 0,
|
|
252
|
+
type: t.kind === "file" ? "file" : t.kind === "entry" ? "entry" : t.kind === "section" ? "section" : "page",
|
|
253
|
+
href: t.href,
|
|
254
|
+
title: t.title,
|
|
255
|
+
pageId: t.kind === "page" ? t.id : void 0,
|
|
256
|
+
entryId: t.kind === "entry" ? t.id : void 0,
|
|
257
|
+
assetId: t.kind === "file" ? t.id : void 0
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/** The value typed text produces (auto-detects URL / email / phone / #section unless the type was chosen). */
|
|
261
|
+
function withText(v, s, type) {
|
|
262
|
+
const t = type ?? detectType(s);
|
|
263
|
+
const n = {
|
|
264
|
+
...v,
|
|
265
|
+
...TARGET_KEYS,
|
|
266
|
+
type: t,
|
|
267
|
+
email: void 0,
|
|
268
|
+
phone: void 0
|
|
269
|
+
};
|
|
270
|
+
if (t === "email") Object.assign(n, {
|
|
271
|
+
email: s.replace(/^mailto:/i, ""),
|
|
272
|
+
href: s
|
|
273
|
+
});
|
|
274
|
+
else if (t === "phone") Object.assign(n, {
|
|
275
|
+
phone: s.replace(/^tel:/i, ""),
|
|
276
|
+
href: s
|
|
277
|
+
});
|
|
278
|
+
else n.href = s;
|
|
279
|
+
return n;
|
|
280
|
+
}
|
|
281
|
+
/** Clean a value before it is stored: add https:// to bare domains, refuse script URLs, store the href the site renders. */
|
|
282
|
+
function finalizeLink(v) {
|
|
283
|
+
const out = { ...v };
|
|
284
|
+
if (/^(javascript|data|vbscript):/i.test(out.href.replace(/[\u0000- ]/g, ""))) return null;
|
|
285
|
+
if (out.type === "url" && out.href && !/^(https?:|\/|#)/.test(out.href)) out.href = `https://${out.href.replace(/^\/+/, "")}`;
|
|
286
|
+
if (hasLink(out)) out.href = hrefOf(out);
|
|
287
|
+
return out;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The object as prod stores it, keyed like the value it replaces (`original`), so an edit changes only what was edited:
|
|
291
|
+
* no undefined keys; no `rel: "follow"` (follow is no rel: the backend normalises it away and a button refuses it); no
|
|
292
|
+
* `newTab: false` and no `target` unless the stored value had that key (a stored `target` is kept in sync with newTab,
|
|
293
|
+
* and is then the one that carries it).
|
|
294
|
+
*/
|
|
295
|
+
function storedLink(v, original) {
|
|
296
|
+
const had = (k) => isObj(original) && k in original;
|
|
297
|
+
const out = {};
|
|
298
|
+
for (const [k, x] of Object.entries(v)) {
|
|
299
|
+
if (x === void 0 || k === "target") continue;
|
|
300
|
+
if (k === "rel" && x === "follow") continue;
|
|
301
|
+
if (k === "newTab" && !had("newTab") && (x === false || had("target"))) continue;
|
|
302
|
+
out[k] = x;
|
|
303
|
+
}
|
|
304
|
+
if (had("target")) out.target = v.newTab ? "_blank" : "_self";
|
|
305
|
+
return out;
|
|
306
|
+
}
|
|
307
|
+
/** Text the picker's input shows for a value that has no picked target. */
|
|
308
|
+
var inputText = (v) => v.type === "email" ? v.email ?? v.href.replace(/^mailto:/i, "") : v.type === "phone" ? v.phone ?? v.href.replace(/^tel:/i, "") : v.href;
|
|
309
|
+
var STATUS_LABEL = {
|
|
310
|
+
draft: "Draft",
|
|
311
|
+
changed: "Edited",
|
|
312
|
+
scheduled: "Scheduled",
|
|
313
|
+
review: "In review",
|
|
314
|
+
archived: "Archived"
|
|
315
|
+
};
|
|
316
|
+
function linkIcon(v, target) {
|
|
317
|
+
if (!hasLink(v)) return /* @__PURE__ */ jsx(IconLink, { stroke: 1.5 });
|
|
318
|
+
if (target) return target.kind === "entry" ? /* @__PURE__ */ jsx(IconFileDatabase, { stroke: 1.5 }) : target.kind === "file" ? /* @__PURE__ */ jsx(IconPaperclip, { stroke: 1.5 }) : target.kind === "section" ? /* @__PURE__ */ jsx(IconHash, { stroke: 1.5 }) : /* @__PURE__ */ jsx(IconFile, { stroke: 1.5 });
|
|
319
|
+
switch (v.type) {
|
|
320
|
+
case "url": return /* @__PURE__ */ jsx(IconExternalLink, { stroke: 1.5 });
|
|
321
|
+
case "email": return /* @__PURE__ */ jsx(IconMail, { stroke: 1.5 });
|
|
322
|
+
case "phone": return /* @__PURE__ */ jsx(IconPhone, { stroke: 1.5 });
|
|
323
|
+
case "section": return /* @__PURE__ */ jsx(IconHash, { stroke: 1.5 });
|
|
324
|
+
case "file": return /* @__PURE__ */ jsx(IconPaperclip, { stroke: 1.5 });
|
|
325
|
+
case "entry": return /* @__PURE__ */ jsx(IconFileDatabase, { stroke: 1.5 });
|
|
326
|
+
default: return /* @__PURE__ */ jsx(IconFile, { stroke: 1.5 });
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** Primary + secondary text: page title + path · domain + rest of the URL · address · number. */
|
|
330
|
+
function describeLink(v, target) {
|
|
331
|
+
if (!hasLink(v)) return { primary: "" };
|
|
332
|
+
const anchor = v.anchor && v.anchor !== "none" ? v.anchor : "";
|
|
333
|
+
if (target) return {
|
|
334
|
+
primary: target.title,
|
|
335
|
+
secondary: target.kind === "section" ? `${target.href} on this page` : target.kind === "file" ? fileKind(target) : `${target.href}${anchor}`
|
|
336
|
+
};
|
|
337
|
+
switch (v.type) {
|
|
338
|
+
case "url": try {
|
|
339
|
+
const u = new URL(/^https?:/i.test(v.href) ? v.href : `https://${v.href}`);
|
|
340
|
+
const rest = `${u.pathname === "/" ? "" : u.pathname}${u.search}${u.hash}`;
|
|
341
|
+
return {
|
|
342
|
+
primary: u.hostname.replace(/^www\./, ""),
|
|
343
|
+
secondary: rest || void 0
|
|
344
|
+
};
|
|
345
|
+
} catch {
|
|
346
|
+
return { primary: v.href };
|
|
347
|
+
}
|
|
348
|
+
case "email": return {
|
|
349
|
+
primary: v.email ?? v.href.replace(/^mailto:/i, "").replace(/\?.*$/, ""),
|
|
350
|
+
secondary: v.subject ? `Subject: ${v.subject}` : void 0
|
|
351
|
+
};
|
|
352
|
+
case "phone": return { primary: v.phone ?? v.href.replace(/^tel:/i, "") };
|
|
353
|
+
case "section": return {
|
|
354
|
+
primary: v.href,
|
|
355
|
+
secondary: "On this page"
|
|
356
|
+
};
|
|
357
|
+
default: return {
|
|
358
|
+
primary: v.title || v.href,
|
|
359
|
+
secondary: v.title ? v.href : void 0
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/** "PDF file": the name is already the title */
|
|
364
|
+
var fileKind = (t) => `${t.meta ?? (fileName(t.href).split(".").pop() ?? "").toUpperCase()} file`.trim();
|
|
365
|
+
function fileName(href) {
|
|
366
|
+
const last = href.replace(/[?#].*$/, "").split("/").pop() ?? href;
|
|
367
|
+
try {
|
|
368
|
+
return decodeURIComponent(last);
|
|
369
|
+
} catch {
|
|
370
|
+
return last;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/** What a person reads for a link (one string — menus, aria labels, history). */
|
|
374
|
+
var linkText = (v) => hasLink(v) ? v.title || describeLink(v).primary : "";
|
|
375
|
+
/** A link at rest: icon · title (fg) · path (fg-3) · new-tab mark. Empty → "Add link". */
|
|
376
|
+
function LinkLine({ v, target, placeholder = "Add link", className }) {
|
|
377
|
+
const d = describeLink(v, target);
|
|
378
|
+
const empty = !hasLink(v);
|
|
379
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
380
|
+
className: cn("flex min-w-0 flex-1 items-center gap-2", className),
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ jsx("span", {
|
|
383
|
+
className: cn("flex shrink-0 [&_svg]:size-4", empty ? "text-kit-fg-3" : "text-kit-fg-2"),
|
|
384
|
+
"aria-hidden": true,
|
|
385
|
+
children: linkIcon(v, target)
|
|
386
|
+
}),
|
|
387
|
+
/* @__PURE__ */ jsx("span", {
|
|
388
|
+
className: cn("min-w-0 shrink truncate text-kit-sm", empty ? "text-kit-fg-3" : "text-kit-fg"),
|
|
389
|
+
children: empty ? placeholder : d.primary
|
|
390
|
+
}),
|
|
391
|
+
d.secondary ? /* @__PURE__ */ jsx("span", {
|
|
392
|
+
className: "min-w-0 flex-1 truncate text-kit-xs text-kit-fg-3",
|
|
393
|
+
children: d.secondary
|
|
394
|
+
}) : /* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
395
|
+
!empty && v.newTab ? /* @__PURE__ */ jsxs("span", {
|
|
396
|
+
className: "inline-flex shrink-0 items-center gap-0.5 text-kit-2xs text-kit-fg-3",
|
|
397
|
+
children: [/* @__PURE__ */ jsx(IconArrowUpRight, {
|
|
398
|
+
className: "size-3",
|
|
399
|
+
stroke: 1.5,
|
|
400
|
+
"aria-hidden": true
|
|
401
|
+
}), "New tab"]
|
|
402
|
+
}) : null
|
|
403
|
+
]
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
/** While the media library is open from a picker, focus sits in its dialog: a quick edit must not close under it. */
|
|
407
|
+
var libraryOpen = false;
|
|
408
|
+
/** Marks the floating results list, so a quick edit losing focus to it is not "focus left the editor". */
|
|
409
|
+
var LIST_ATTR = "data-kit-link-list";
|
|
410
|
+
function LinkPicker({ value, onChange, onPick, onEnter, onEscape, autoFocus, startSearching, id, "aria-label": ariaLabel = "Link to", size = "md", bare, lockedType, inlineList, types, invalid, "aria-describedby": describedBy, className }) {
|
|
411
|
+
const v = normLink(value);
|
|
412
|
+
const host = useLinkTargets();
|
|
413
|
+
const sections = useSectionTargets();
|
|
414
|
+
const { MediaPicker } = useKitServices();
|
|
415
|
+
const targets = React.useMemo(() => [...host.targets, ...sections], [host.targets, sections]);
|
|
416
|
+
const picked = findTarget(targets, v);
|
|
417
|
+
const [library, setLibraryState] = React.useState(false);
|
|
418
|
+
const setLibrary = (o) => {
|
|
419
|
+
libraryOpen = o;
|
|
420
|
+
setLibraryState(o);
|
|
421
|
+
};
|
|
422
|
+
React.useEffect(() => () => void (libraryOpen = false), []);
|
|
423
|
+
const [fileProblem, setFileProblem] = React.useState();
|
|
424
|
+
const [searching, setSearching] = React.useState(!!startSearching || !picked);
|
|
425
|
+
const [text, setText] = React.useState(() => picked ? "" : inputText(v));
|
|
426
|
+
const [manualTypeState, setManualType] = React.useState(null);
|
|
427
|
+
const manualType = lockedType ?? manualTypeState;
|
|
428
|
+
const [open, setOpen] = React.useState(false);
|
|
429
|
+
const [active, setActive] = React.useState(-1);
|
|
430
|
+
const inputRef = React.useRef(null);
|
|
431
|
+
const wrapRef = React.useRef(null);
|
|
432
|
+
const listId = React.useId();
|
|
433
|
+
const type = manualType ?? v.type ?? "page";
|
|
434
|
+
const meta = typeMeta(manualType ?? (searching && !text ? "page" : v.type));
|
|
435
|
+
const showChip = !!picked && !searching;
|
|
436
|
+
React.useEffect(() => {
|
|
437
|
+
if (autoFocus) requestAnimationFrame(() => {
|
|
438
|
+
inputRef.current?.focus({ preventScroll: true });
|
|
439
|
+
inputRef.current?.select();
|
|
440
|
+
});
|
|
441
|
+
}, [autoFocus]);
|
|
442
|
+
const q = text.trim().toLowerCase().replace(/^[/#]/, "");
|
|
443
|
+
const searchable = type === "page" || type === "entry" || type === "file" || type === "section" && sections.length > 0;
|
|
444
|
+
const urlish = type !== "section" && (/^(https?:|www\.|mailto:|tel:|#)/i.test(text.trim()) || text.trim() !== "" && detectType(text) !== "page" && !manualType);
|
|
445
|
+
const rows = React.useMemo(() => {
|
|
446
|
+
if (!searchable || urlish) return [];
|
|
447
|
+
const pool = targets.filter((t) => type === "file" ? t.kind === "file" : type === "entry" ? t.kind === "entry" : type === "section" ? t.kind === "section" : t.kind === "page" || t.kind === "entry");
|
|
448
|
+
const hit = (t) => !q || t.title.toLowerCase().includes(q) || t.href.toLowerCase().includes(q) || (t.meta ?? "").toLowerCase().includes(q);
|
|
449
|
+
const out = [];
|
|
450
|
+
const perGroup = /* @__PURE__ */ new Map();
|
|
451
|
+
const cap = q ? 6 : type === "page" ? 4 : 6;
|
|
452
|
+
for (const t of pool) {
|
|
453
|
+
if (!hit(t)) continue;
|
|
454
|
+
const n = perGroup.get(t.group) ?? 0;
|
|
455
|
+
if (n >= cap) continue;
|
|
456
|
+
perGroup.set(t.group, n + 1);
|
|
457
|
+
out.push({
|
|
458
|
+
key: `${t.kind}:${t.id}`,
|
|
459
|
+
group: t.group,
|
|
460
|
+
target: t
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
const order = [...new Set(out.map((r) => r.group))];
|
|
464
|
+
return out.sort((a, b) => order.indexOf(a.group) - order.indexOf(b.group)).slice(0, 24);
|
|
465
|
+
}, [
|
|
466
|
+
targets,
|
|
467
|
+
type,
|
|
468
|
+
q,
|
|
469
|
+
searchable,
|
|
470
|
+
urlish
|
|
471
|
+
]);
|
|
472
|
+
const note = (() => {
|
|
473
|
+
if (!searchable || urlish || rows.length) return void 0;
|
|
474
|
+
if (type === "section") return void 0;
|
|
475
|
+
if (type === "file") return MediaPicker ? "Choose a file from the library with the folder button." : void 0;
|
|
476
|
+
if (host.unavailable) return "Page search isn't available here. Type a path, like /about.";
|
|
477
|
+
if (host.error) return `${host.error.replace(/\.?$/, ".")} Type a path, like /about.`;
|
|
478
|
+
if (host.loading) return "Loading pages…";
|
|
479
|
+
return q ? `Nothing matches “${text.trim()}”. Type a path, like /about.` : type === "entry" ? "No CMS items yet." : "No pages yet. Type a path, like /about.";
|
|
480
|
+
})();
|
|
481
|
+
const listOpen = open && searching && (rows.length > 0 || !!note);
|
|
482
|
+
React.useEffect(() => {
|
|
483
|
+
if (!listOpen) return;
|
|
484
|
+
const onKey = (e) => {
|
|
485
|
+
if (e.key !== "Escape" || !wrapRef.current?.contains(document.activeElement)) return;
|
|
486
|
+
e.preventDefault();
|
|
487
|
+
e.stopPropagation();
|
|
488
|
+
setOpen(false);
|
|
489
|
+
};
|
|
490
|
+
window.addEventListener("keydown", onKey, true);
|
|
491
|
+
return () => window.removeEventListener("keydown", onKey, true);
|
|
492
|
+
}, [listOpen]);
|
|
493
|
+
const choose = (t) => {
|
|
494
|
+
t.onChoose?.();
|
|
495
|
+
const n = withTarget(v, t);
|
|
496
|
+
setText("");
|
|
497
|
+
setManualType(null);
|
|
498
|
+
setSearching(false);
|
|
499
|
+
setOpen(false);
|
|
500
|
+
setFileProblem(void 0);
|
|
501
|
+
onChange(n);
|
|
502
|
+
onPick?.(n);
|
|
503
|
+
};
|
|
504
|
+
const type_ = (s) => {
|
|
505
|
+
setText(s);
|
|
506
|
+
setOpen(true);
|
|
507
|
+
setActive(s.trim() ? 0 : -1);
|
|
508
|
+
onChange(withText(v, s, manualType ?? void 0));
|
|
509
|
+
};
|
|
510
|
+
const clear = () => {
|
|
511
|
+
setText("");
|
|
512
|
+
setManualType(null);
|
|
513
|
+
setSearching(true);
|
|
514
|
+
onChange({
|
|
515
|
+
...withText(v, ""),
|
|
516
|
+
href: ""
|
|
517
|
+
});
|
|
518
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
519
|
+
};
|
|
520
|
+
const setType = (t) => {
|
|
521
|
+
setManualType(t);
|
|
522
|
+
setText("");
|
|
523
|
+
setSearching(true);
|
|
524
|
+
onChange({
|
|
525
|
+
...withText(v, "", t),
|
|
526
|
+
href: ""
|
|
527
|
+
});
|
|
528
|
+
setOpen(true);
|
|
529
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
530
|
+
};
|
|
531
|
+
const h = size === "sm" ? "h-8" : "h-9";
|
|
532
|
+
const list = /* @__PURE__ */ jsxs("div", {
|
|
533
|
+
id: listId,
|
|
534
|
+
role: "listbox",
|
|
535
|
+
"aria-label": type === "file" ? "Files" : type === "section" ? "Sections on this page" : "Pages and CMS items",
|
|
536
|
+
className: "max-h-72 overflow-y-auto overscroll-contain",
|
|
537
|
+
children: [rows.map((r, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [i === 0 || rows[i - 1].group !== r.group ? /* @__PURE__ */ jsx("div", {
|
|
538
|
+
role: "presentation",
|
|
539
|
+
className: "px-2 pb-1 pt-2 text-kit-xs font-medium text-kit-fg-3 first:pt-1",
|
|
540
|
+
children: r.group
|
|
541
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
542
|
+
id: `${listId}-${i}`,
|
|
543
|
+
role: "option",
|
|
544
|
+
"aria-selected": i === active,
|
|
545
|
+
onMouseEnter: () => setActive(i),
|
|
546
|
+
onClick: () => choose(r.target),
|
|
547
|
+
className: cn("flex h-8 cursor-pointer items-center gap-2 rounded-kit-md px-2 text-kit-sm", i === active && "bg-kit-hover"),
|
|
548
|
+
children: [
|
|
549
|
+
/* @__PURE__ */ jsx("span", {
|
|
550
|
+
className: "flex shrink-0 text-kit-fg-3 [&_svg]:size-4",
|
|
551
|
+
"aria-hidden": true,
|
|
552
|
+
children: linkIcon({
|
|
553
|
+
href: r.target.href,
|
|
554
|
+
type: r.target.kind
|
|
555
|
+
}, r.target)
|
|
556
|
+
}),
|
|
557
|
+
/* @__PURE__ */ jsx("span", {
|
|
558
|
+
className: "min-w-0 shrink truncate text-kit-fg",
|
|
559
|
+
children: r.target.title
|
|
560
|
+
}),
|
|
561
|
+
/* @__PURE__ */ jsx("span", {
|
|
562
|
+
className: "min-w-0 flex-1 truncate text-kit-xs text-kit-fg-3",
|
|
563
|
+
children: r.target.kind === "file" ? fileName(r.target.href) : r.target.href
|
|
564
|
+
}),
|
|
565
|
+
r.target.status && STATUS_LABEL[r.target.status] ? /* @__PURE__ */ jsx("span", {
|
|
566
|
+
className: "shrink-0 text-kit-2xs text-kit-fg-3",
|
|
567
|
+
children: STATUS_LABEL[r.target.status]
|
|
568
|
+
}) : null
|
|
569
|
+
]
|
|
570
|
+
})] }, r.key)), !rows.length && note ? /* @__PURE__ */ jsx("p", {
|
|
571
|
+
role: "status",
|
|
572
|
+
className: "px-2 py-1.5 text-kit-xs text-kit-fg-3",
|
|
573
|
+
children: note
|
|
574
|
+
}) : rows.length && host.error && type !== "file" && type !== "section" ? /* @__PURE__ */ jsx("p", {
|
|
575
|
+
role: "status",
|
|
576
|
+
className: "px-2 py-1.5 text-kit-xs text-kit-fg-3",
|
|
577
|
+
children: host.error.replace(/\.?$/, ".")
|
|
578
|
+
}) : null]
|
|
579
|
+
});
|
|
580
|
+
const allowed = LINK_TYPES.filter((t) => (!types || types.includes(t.type)) && (t.type !== "file" || MediaPicker || v.type === "file"));
|
|
581
|
+
const typeMenu = /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsxs(MenuTrigger, {
|
|
582
|
+
render: /* @__PURE__ */ jsx("button", {
|
|
583
|
+
type: "button",
|
|
584
|
+
"aria-label": `Link type: ${meta.label}`,
|
|
585
|
+
className: "ml-0.5 flex h-7 shrink-0 items-center gap-0.5 rounded-kit-md px-1.5 text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[popup-open]:bg-kit-hover [&_svg]:size-3.5"
|
|
586
|
+
}),
|
|
587
|
+
children: [meta.icon, /* @__PURE__ */ jsx(IconChevronDown, {
|
|
588
|
+
className: "!size-3",
|
|
589
|
+
stroke: 1.5
|
|
590
|
+
})]
|
|
591
|
+
}), /* @__PURE__ */ jsx(MenuContent, {
|
|
592
|
+
className: "min-w-48",
|
|
593
|
+
children: allowed.map((t) => /* @__PURE__ */ jsx(MenuItem, {
|
|
594
|
+
icon: t.icon,
|
|
595
|
+
onClick: () => setType(t.type),
|
|
596
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
597
|
+
className: "flex w-full items-center justify-between gap-3",
|
|
598
|
+
children: [t.label, t.type === type ? /* @__PURE__ */ jsx(IconCheck, {
|
|
599
|
+
className: "size-3.5 text-kit-fg-2",
|
|
600
|
+
stroke: 2
|
|
601
|
+
}) : null]
|
|
602
|
+
})
|
|
603
|
+
}, t.type))
|
|
604
|
+
})] });
|
|
605
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
606
|
+
className: cn("flex min-w-0 flex-col gap-1", className),
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ jsxs(Popover, {
|
|
609
|
+
open: listOpen && !inlineList,
|
|
610
|
+
onOpenChange: (o) => !o && setOpen(false),
|
|
611
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
612
|
+
ref: wrapRef,
|
|
613
|
+
className: "min-w-0",
|
|
614
|
+
children: /* @__PURE__ */ jsx(PopoverAnchor, {
|
|
615
|
+
className: cn("flex min-w-0 items-center", bare ? "bg-transparent" : "rounded-kit-md border border-kit-field-border bg-kit-field-bg shadow-kit-field transition-colors hover:border-kit-field-border-hover focus-within:border-kit-field-border-focus", !bare && invalid && "border-[var(--kit-field-invalid)] hover:border-[var(--kit-field-invalid)]", h),
|
|
616
|
+
children: showChip ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
617
|
+
/* @__PURE__ */ jsx("span", {
|
|
618
|
+
className: "ml-2 flex shrink-0 text-kit-fg-2 [&_svg]:size-4",
|
|
619
|
+
"aria-hidden": true,
|
|
620
|
+
children: linkIcon(v, picked)
|
|
621
|
+
}),
|
|
622
|
+
/* @__PURE__ */ jsxs("button", {
|
|
623
|
+
id,
|
|
624
|
+
type: "button",
|
|
625
|
+
onClick: () => {
|
|
626
|
+
setSearching(true);
|
|
627
|
+
setOpen(true);
|
|
628
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
629
|
+
},
|
|
630
|
+
"aria-label": `${ariaLabel}: ${picked.title}, ${picked.href}. Change`,
|
|
631
|
+
className: "flex h-full min-w-0 flex-1 items-center gap-2 px-2 text-left outline-none",
|
|
632
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
633
|
+
className: "min-w-0 shrink truncate text-kit-sm text-kit-fg",
|
|
634
|
+
children: picked.title
|
|
635
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
636
|
+
className: "min-w-0 flex-1 truncate text-kit-xs text-kit-fg-3",
|
|
637
|
+
children: describeLink(v, picked).secondary
|
|
638
|
+
})]
|
|
639
|
+
}),
|
|
640
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
641
|
+
label: "Clear link",
|
|
642
|
+
size: "xs",
|
|
643
|
+
className: "mr-1",
|
|
644
|
+
onClick: clear,
|
|
645
|
+
children: /* @__PURE__ */ jsx(IconX, { stroke: 1.5 })
|
|
646
|
+
})
|
|
647
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
648
|
+
lockedType !== void 0 || inlineList ? /* @__PURE__ */ jsx("span", {
|
|
649
|
+
className: "ml-2.5 flex shrink-0 text-kit-fg-3 [&_svg]:size-4",
|
|
650
|
+
"aria-hidden": true,
|
|
651
|
+
children: meta.icon
|
|
652
|
+
}) : typeMenu,
|
|
653
|
+
/* @__PURE__ */ jsx("input", {
|
|
654
|
+
ref: inputRef,
|
|
655
|
+
id,
|
|
656
|
+
role: "combobox",
|
|
657
|
+
"aria-label": ariaLabel,
|
|
658
|
+
"aria-invalid": invalid || void 0,
|
|
659
|
+
"aria-describedby": describedBy,
|
|
660
|
+
"aria-expanded": listOpen,
|
|
661
|
+
"aria-controls": listOpen ? listId : void 0,
|
|
662
|
+
"aria-autocomplete": "list",
|
|
663
|
+
"aria-activedescendant": listOpen && active >= 0 && rows[active] ? `${listId}-${active}` : void 0,
|
|
664
|
+
value: text,
|
|
665
|
+
onChange: (e) => type_(e.target.value),
|
|
666
|
+
onFocus: () => setOpen(true),
|
|
667
|
+
onBlur: (e) => {
|
|
668
|
+
if (wrapRef.current?.contains(e.relatedTarget)) return;
|
|
669
|
+
if (inlineList) setOpen(false);
|
|
670
|
+
if (picked && !text) setSearching(false);
|
|
671
|
+
},
|
|
672
|
+
onKeyDown: (e) => {
|
|
673
|
+
if (e.key === "ArrowDown" && rows.length) {
|
|
674
|
+
e.preventDefault();
|
|
675
|
+
setOpen(true);
|
|
676
|
+
setActive((a) => (a + 1) % rows.length);
|
|
677
|
+
} else if (e.key === "ArrowUp" && rows.length) {
|
|
678
|
+
e.preventDefault();
|
|
679
|
+
setActive((a) => a <= 0 ? rows.length - 1 : a - 1);
|
|
680
|
+
} else if (e.key === "Enter") {
|
|
681
|
+
e.preventDefault();
|
|
682
|
+
if (listOpen && active >= 0 && rows[active]) choose(rows[active].target);
|
|
683
|
+
else onEnter?.(withText(v, text, manualType ?? void 0));
|
|
684
|
+
} else if (e.key === "Escape") {
|
|
685
|
+
if (listOpen) {
|
|
686
|
+
e.preventDefault();
|
|
687
|
+
e.stopPropagation();
|
|
688
|
+
setOpen(false);
|
|
689
|
+
} else if (picked && !text && !startSearching) {
|
|
690
|
+
e.preventDefault();
|
|
691
|
+
e.stopPropagation();
|
|
692
|
+
setSearching(false);
|
|
693
|
+
} else if (onEscape) {
|
|
694
|
+
e.preventDefault();
|
|
695
|
+
e.stopPropagation();
|
|
696
|
+
onEscape();
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
placeholder: picked && !text ? picked.title : meta.placeholder,
|
|
701
|
+
autoComplete: "off",
|
|
702
|
+
spellCheck: false,
|
|
703
|
+
className: "h-full min-w-0 flex-1 bg-transparent px-2 text-kit-sm text-kit-fg outline-none placeholder:text-kit-fg-3"
|
|
704
|
+
}),
|
|
705
|
+
text ? /* @__PURE__ */ jsx(IconButton, {
|
|
706
|
+
label: "Clear",
|
|
707
|
+
size: "xs",
|
|
708
|
+
className: "mr-1",
|
|
709
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
710
|
+
onClick: clear,
|
|
711
|
+
children: /* @__PURE__ */ jsx(IconX, { stroke: 1.5 })
|
|
712
|
+
}) : null,
|
|
713
|
+
type === "file" && MediaPicker ? /* @__PURE__ */ jsx(IconButton, {
|
|
714
|
+
label: "Choose or upload a file",
|
|
715
|
+
size: "xs",
|
|
716
|
+
className: "mr-1 text-kit-fg-3",
|
|
717
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
718
|
+
onClick: () => {
|
|
719
|
+
setOpen(false);
|
|
720
|
+
setLibrary(true);
|
|
721
|
+
},
|
|
722
|
+
children: /* @__PURE__ */ jsx(IconFolderOpen, { stroke: 1.5 })
|
|
723
|
+
}) : null
|
|
724
|
+
] })
|
|
725
|
+
})
|
|
726
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
727
|
+
keepFocus: true,
|
|
728
|
+
align: "start",
|
|
729
|
+
side: "bottom",
|
|
730
|
+
sideOffset: 4,
|
|
731
|
+
"data-kit-link-list": "",
|
|
732
|
+
className: "w-[max(var(--anchor-width),280px)] max-w-[min(420px,calc(100vw-24px))] !bg-kit-surface p-1 shadow-kit-lg",
|
|
733
|
+
children: list
|
|
734
|
+
})]
|
|
735
|
+
}),
|
|
736
|
+
inlineList && listOpen ? /* @__PURE__ */ jsx("div", {
|
|
737
|
+
className: "rounded-kit-md border border-kit-line bg-kit-surface p-1 [&_[role=listbox]]:max-h-56",
|
|
738
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
739
|
+
children: list
|
|
740
|
+
}) : null,
|
|
741
|
+
fileProblem ? /* @__PURE__ */ jsx("p", {
|
|
742
|
+
role: "alert",
|
|
743
|
+
className: "text-kit-xs text-kit-danger-fg",
|
|
744
|
+
children: fileProblem
|
|
745
|
+
}) : null,
|
|
746
|
+
library && MediaPicker ? /* @__PURE__ */ jsx(MediaPicker, {
|
|
747
|
+
open: true,
|
|
748
|
+
accept: ["file"],
|
|
749
|
+
onOpenChange: (o) => !o && setLibrary(false),
|
|
750
|
+
onPick: (a) => {
|
|
751
|
+
if (!a[0]) return;
|
|
752
|
+
const t = fileTarget(a[0]);
|
|
753
|
+
if ("problem" in t) setFileProblem(t.problem);
|
|
754
|
+
else choose(t);
|
|
755
|
+
}
|
|
756
|
+
}) : null
|
|
757
|
+
]
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
function LinkOptions({ v, onChange, compact, disabled }) {
|
|
761
|
+
const tabId = React.useId();
|
|
762
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
763
|
+
className: cn("flex flex-col", compact ? "gap-2" : "gap-2.5"),
|
|
764
|
+
children: [
|
|
765
|
+
v.type === "email" ? /* @__PURE__ */ jsxs("label", {
|
|
766
|
+
className: "flex items-center justify-between gap-3",
|
|
767
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
768
|
+
className: "text-kit-xs text-kit-fg-2",
|
|
769
|
+
children: "Subject"
|
|
770
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
771
|
+
size: "sm",
|
|
772
|
+
value: v.subject ?? "",
|
|
773
|
+
onChange: (e) => onChange({
|
|
774
|
+
...v,
|
|
775
|
+
subject: e.target.value
|
|
776
|
+
}),
|
|
777
|
+
placeholder: "Wholesale inquiry",
|
|
778
|
+
className: "max-w-52"
|
|
779
|
+
})]
|
|
780
|
+
}) : null,
|
|
781
|
+
/* @__PURE__ */ jsxs("label", {
|
|
782
|
+
htmlFor: tabId,
|
|
783
|
+
className: "flex min-h-7 items-center justify-between gap-3",
|
|
784
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
785
|
+
className: "text-kit-xs text-kit-fg-2",
|
|
786
|
+
children: "Open in new tab"
|
|
787
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
788
|
+
disabled,
|
|
789
|
+
id: tabId,
|
|
790
|
+
size: "sm",
|
|
791
|
+
checked: !!v.newTab,
|
|
792
|
+
onCheckedChange: (c) => onChange({
|
|
793
|
+
...v,
|
|
794
|
+
newTab: c,
|
|
795
|
+
target: void 0
|
|
796
|
+
})
|
|
797
|
+
})]
|
|
798
|
+
}),
|
|
799
|
+
/* @__PURE__ */ jsxs("div", {
|
|
800
|
+
className: "flex items-center justify-between gap-3",
|
|
801
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
802
|
+
className: "text-kit-xs text-kit-fg-2",
|
|
803
|
+
children: "Rel"
|
|
804
|
+
}), /* @__PURE__ */ jsx(Select, {
|
|
805
|
+
disabled,
|
|
806
|
+
"aria-label": "Rel",
|
|
807
|
+
size: "sm",
|
|
808
|
+
className: "w-[168px]",
|
|
809
|
+
value: v.rel ?? "follow",
|
|
810
|
+
onValueChange: (r) => onChange({
|
|
811
|
+
...v,
|
|
812
|
+
rel: r
|
|
813
|
+
}),
|
|
814
|
+
options: REL_ITEMS
|
|
815
|
+
})]
|
|
816
|
+
})
|
|
817
|
+
]
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
function LinkForm({ value, onChange, onEnter, hideOptions, types, autoFocus, readOnly, className }) {
|
|
821
|
+
const v = normLink(value);
|
|
822
|
+
const { MediaPicker } = useKitServices();
|
|
823
|
+
const allowed = LINK_TYPES.filter((t) => (!types || types.includes(t.type)) && (t.type !== "file" || MediaPicker || v.type === "file"));
|
|
824
|
+
const [kind, setKind] = React.useState(() => {
|
|
825
|
+
const k = v.type === "entry" && hasLink(v) ? "page" : v.type ?? "page";
|
|
826
|
+
return allowed.some((t) => t.type === k) ? k : allowed[0]?.type ?? "page";
|
|
827
|
+
});
|
|
828
|
+
const [resetKey, setResetKey] = React.useState(0);
|
|
829
|
+
const [touched, setTouched] = React.useState(false);
|
|
830
|
+
const { targets } = useLinkTargets();
|
|
831
|
+
const anchors = findTarget(targets, v)?.anchors;
|
|
832
|
+
const typeId = React.useId();
|
|
833
|
+
const targetId = React.useId();
|
|
834
|
+
const errId = React.useId();
|
|
835
|
+
const problem = touched ? linkProblem(v) : void 0;
|
|
836
|
+
const shownType = kind === "page" && hasLink(v) ? v.type ?? "page" : kind;
|
|
837
|
+
React.useEffect(() => {
|
|
838
|
+
if (autoFocus) requestAnimationFrame(() => document.getElementById(typeId)?.focus({ preventScroll: true }));
|
|
839
|
+
}, [autoFocus, typeId]);
|
|
840
|
+
const changeType = (t) => {
|
|
841
|
+
setKind(t);
|
|
842
|
+
setTouched(false);
|
|
843
|
+
onChange({
|
|
844
|
+
...withText(v, "", t === "page" ? void 0 : t),
|
|
845
|
+
href: "",
|
|
846
|
+
type: t,
|
|
847
|
+
anchor: void 0
|
|
848
|
+
});
|
|
849
|
+
setResetKey((k) => k + 1);
|
|
850
|
+
requestAnimationFrame(() => document.getElementById(targetId)?.focus());
|
|
851
|
+
};
|
|
852
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
853
|
+
className: cn("flex min-w-0 flex-col gap-3", className),
|
|
854
|
+
children: [
|
|
855
|
+
/* @__PURE__ */ jsxs("div", {
|
|
856
|
+
className: "flex items-center justify-between gap-3",
|
|
857
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
858
|
+
htmlFor: typeId,
|
|
859
|
+
className: "text-kit-xs text-kit-fg-2",
|
|
860
|
+
children: "Type"
|
|
861
|
+
}), /* @__PURE__ */ jsx(Select, {
|
|
862
|
+
disabled: readOnly,
|
|
863
|
+
id: typeId,
|
|
864
|
+
size: "sm",
|
|
865
|
+
className: "w-[180px]",
|
|
866
|
+
value: shownType,
|
|
867
|
+
onValueChange: (t) => changeType(t),
|
|
868
|
+
options: allowed.map((t) => ({
|
|
869
|
+
value: t.type,
|
|
870
|
+
label: t.label,
|
|
871
|
+
icon: t.icon
|
|
872
|
+
}))
|
|
873
|
+
})]
|
|
874
|
+
}),
|
|
875
|
+
/* @__PURE__ */ jsxs("div", {
|
|
876
|
+
className: "flex flex-col gap-1.5",
|
|
877
|
+
onBlur: (e) => {
|
|
878
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setTouched(true);
|
|
879
|
+
},
|
|
880
|
+
children: [
|
|
881
|
+
/* @__PURE__ */ jsx("label", {
|
|
882
|
+
htmlFor: targetId,
|
|
883
|
+
className: "text-kit-xs text-kit-fg-2",
|
|
884
|
+
children: typeMeta(kind).target
|
|
885
|
+
}),
|
|
886
|
+
/* @__PURE__ */ jsx(LinkPicker, {
|
|
887
|
+
id: targetId,
|
|
888
|
+
size: "sm",
|
|
889
|
+
value: v,
|
|
890
|
+
onChange,
|
|
891
|
+
onPick: () => setTouched(true),
|
|
892
|
+
onEnter: (n) => {
|
|
893
|
+
setTouched(true);
|
|
894
|
+
if (!linkProblem(n)) onEnter?.(n);
|
|
895
|
+
},
|
|
896
|
+
lockedType: kind === "page" ? void 0 : kind,
|
|
897
|
+
inlineList: true,
|
|
898
|
+
types,
|
|
899
|
+
invalid: !!problem,
|
|
900
|
+
"aria-describedby": problem ? errId : void 0,
|
|
901
|
+
"aria-label": typeMeta(kind).target
|
|
902
|
+
}, resetKey),
|
|
903
|
+
problem ? /* @__PURE__ */ jsx("p", {
|
|
904
|
+
id: errId,
|
|
905
|
+
role: "alert",
|
|
906
|
+
className: "text-kit-xs text-kit-danger-fg",
|
|
907
|
+
children: problem
|
|
908
|
+
}) : null
|
|
909
|
+
]
|
|
910
|
+
}),
|
|
911
|
+
anchors?.length ? /* @__PURE__ */ jsxs("div", {
|
|
912
|
+
className: "flex items-center justify-between gap-3",
|
|
913
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
914
|
+
className: "text-kit-xs text-kit-fg-2",
|
|
915
|
+
children: "Section"
|
|
916
|
+
}), /* @__PURE__ */ jsx(Select, {
|
|
917
|
+
disabled: readOnly,
|
|
918
|
+
"aria-label": "Section",
|
|
919
|
+
size: "sm",
|
|
920
|
+
className: "w-[180px]",
|
|
921
|
+
value: v.anchor ?? "none",
|
|
922
|
+
onValueChange: (a) => onChange({
|
|
923
|
+
...v,
|
|
924
|
+
anchor: a
|
|
925
|
+
}),
|
|
926
|
+
options: [{
|
|
927
|
+
value: "none",
|
|
928
|
+
label: "Top of page"
|
|
929
|
+
}, ...anchors.map((a) => ({
|
|
930
|
+
value: a,
|
|
931
|
+
label: a
|
|
932
|
+
}))]
|
|
933
|
+
})]
|
|
934
|
+
}) : null,
|
|
935
|
+
hideOptions ? null : /* @__PURE__ */ jsx(LinkOptions, {
|
|
936
|
+
v,
|
|
937
|
+
onChange,
|
|
938
|
+
compact: true,
|
|
939
|
+
disabled: readOnly
|
|
940
|
+
})
|
|
941
|
+
]
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
function LinkPopoverBody({ initial, onSave, onDetach, onCancel, hideOptions, types }) {
|
|
945
|
+
const start = normLink(initial);
|
|
946
|
+
const [v, setV] = React.useState(start);
|
|
947
|
+
const { targets } = useLinkTargets();
|
|
948
|
+
const startTarget = findTarget(targets, start);
|
|
949
|
+
const fin = (x) => {
|
|
950
|
+
const f = finalizeLink(x);
|
|
951
|
+
return f ? JSON.stringify(storedLink(f)) : "";
|
|
952
|
+
};
|
|
953
|
+
const changed = fin(v) !== fin(start);
|
|
954
|
+
const ok = hasLink(v) && !linkProblem(v);
|
|
955
|
+
const apply = (n = v) => {
|
|
956
|
+
const out = finalizeLink(n);
|
|
957
|
+
if (out && hasLink(out) && !linkProblem(out)) onSave(out);
|
|
958
|
+
};
|
|
959
|
+
return /* @__PURE__ */ jsxs("form", {
|
|
960
|
+
className: "flex flex-col gap-3",
|
|
961
|
+
onSubmit: (e) => {
|
|
962
|
+
e.preventDefault();
|
|
963
|
+
e.stopPropagation();
|
|
964
|
+
apply();
|
|
965
|
+
},
|
|
966
|
+
children: [
|
|
967
|
+
/* @__PURE__ */ jsxs("div", {
|
|
968
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
969
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
970
|
+
className: "text-kit-sm font-medium text-kit-fg",
|
|
971
|
+
children: "Link"
|
|
972
|
+
}), hasLink(start) ? /* @__PURE__ */ jsx("span", {
|
|
973
|
+
className: "flex min-w-0 text-kit-fg-2",
|
|
974
|
+
children: /* @__PURE__ */ jsx(LinkLine, {
|
|
975
|
+
v: start,
|
|
976
|
+
target: startTarget
|
|
977
|
+
})
|
|
978
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
979
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
980
|
+
children: "No link yet"
|
|
981
|
+
})]
|
|
982
|
+
}),
|
|
983
|
+
/* @__PURE__ */ jsx(LinkForm, {
|
|
984
|
+
value: v,
|
|
985
|
+
onChange: setV,
|
|
986
|
+
onEnter: (n) => apply(n),
|
|
987
|
+
hideOptions,
|
|
988
|
+
types,
|
|
989
|
+
autoFocus: true
|
|
990
|
+
}),
|
|
991
|
+
/* @__PURE__ */ jsxs("div", {
|
|
992
|
+
className: "flex items-center gap-2 border-t border-kit-line pt-2.5",
|
|
993
|
+
children: [
|
|
994
|
+
onDetach ? /* @__PURE__ */ jsx(Button, {
|
|
995
|
+
type: "button",
|
|
996
|
+
size: "xs",
|
|
997
|
+
variant: "danger-ghost",
|
|
998
|
+
onClick: onDetach,
|
|
999
|
+
children: "Remove link"
|
|
1000
|
+
}) : null,
|
|
1001
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1" }),
|
|
1002
|
+
onCancel ? /* @__PURE__ */ jsx(Button, {
|
|
1003
|
+
type: "button",
|
|
1004
|
+
size: "xs",
|
|
1005
|
+
variant: "ghost",
|
|
1006
|
+
onClick: onCancel,
|
|
1007
|
+
children: "Cancel"
|
|
1008
|
+
}) : null,
|
|
1009
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1010
|
+
type: "submit",
|
|
1011
|
+
size: "xs",
|
|
1012
|
+
variant: "primary",
|
|
1013
|
+
disabled: !changed || !ok,
|
|
1014
|
+
children: "Apply"
|
|
1015
|
+
})
|
|
1016
|
+
]
|
|
1017
|
+
})
|
|
1018
|
+
]
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
function LinkQuickEdit({ value, onCommit, onDone, ariaLabel, size, bare, types }) {
|
|
1022
|
+
const [draft, setDraft] = React.useState(value);
|
|
1023
|
+
const [problem, setProblem] = React.useState();
|
|
1024
|
+
const done = React.useRef(false);
|
|
1025
|
+
const ref = React.useRef(null);
|
|
1026
|
+
const errId = React.useId();
|
|
1027
|
+
const commit = (n, strict = true) => {
|
|
1028
|
+
if (done.current) return;
|
|
1029
|
+
if (hasLink(n) && strict && linkProblem(n)) return setProblem(linkProblem(n));
|
|
1030
|
+
done.current = true;
|
|
1031
|
+
if (!hasLink(n)) onCommit(null);
|
|
1032
|
+
else {
|
|
1033
|
+
const out = finalizeLink(n);
|
|
1034
|
+
if (out) onCommit(out);
|
|
1035
|
+
}
|
|
1036
|
+
onDone();
|
|
1037
|
+
};
|
|
1038
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1039
|
+
ref,
|
|
1040
|
+
className: "flex min-w-0 flex-col gap-1",
|
|
1041
|
+
onBlur: (e) => {
|
|
1042
|
+
const next = e.relatedTarget;
|
|
1043
|
+
if (libraryOpen || next && (ref.current?.contains(next) || next.closest?.(`[${LIST_ATTR}],[role=menu]`))) return;
|
|
1044
|
+
window.setTimeout(() => {
|
|
1045
|
+
if (libraryOpen || done.current || ref.current?.contains(document.activeElement)) return;
|
|
1046
|
+
if (hrefOf(draft) === hrefOf(value) && draft.pageId === value.pageId && draft.entryId === value.entryId) {
|
|
1047
|
+
done.current = true;
|
|
1048
|
+
onDone();
|
|
1049
|
+
} else commit(draft, false);
|
|
1050
|
+
}, 0);
|
|
1051
|
+
},
|
|
1052
|
+
children: [/* @__PURE__ */ jsx(LinkPicker, {
|
|
1053
|
+
value: draft,
|
|
1054
|
+
onChange: (n) => {
|
|
1055
|
+
setDraft(n);
|
|
1056
|
+
setProblem(void 0);
|
|
1057
|
+
},
|
|
1058
|
+
onPick: (n) => commit(n),
|
|
1059
|
+
onEnter: (n) => commit(n),
|
|
1060
|
+
onEscape: () => {
|
|
1061
|
+
done.current = true;
|
|
1062
|
+
onDone();
|
|
1063
|
+
},
|
|
1064
|
+
autoFocus: true,
|
|
1065
|
+
startSearching: true,
|
|
1066
|
+
"aria-label": ariaLabel,
|
|
1067
|
+
size,
|
|
1068
|
+
bare,
|
|
1069
|
+
types,
|
|
1070
|
+
invalid: !!problem,
|
|
1071
|
+
"aria-describedby": problem ? errId : void 0
|
|
1072
|
+
}), problem ? /* @__PURE__ */ jsx("p", {
|
|
1073
|
+
id: errId,
|
|
1074
|
+
role: "alert",
|
|
1075
|
+
className: cn("text-kit-xs text-kit-danger-fg", bare && "px-2.5 pb-1.5"),
|
|
1076
|
+
children: problem
|
|
1077
|
+
}) : null]
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
function LinkField({ value, onChange: write, valueShape, id: idProp, "aria-label": label, readOnly, size = "sm", types, invalid, placeholder, className }) {
|
|
1081
|
+
const v = normLink(value);
|
|
1082
|
+
const stringOnly = valueShape === "string";
|
|
1083
|
+
const onChange = (n) => write(stringOnly ? n ? hrefOf(n) : "" : n ? storedLink(n, value) : null);
|
|
1084
|
+
const autoId = React.useId();
|
|
1085
|
+
const id = idProp ?? autoId;
|
|
1086
|
+
const [editing, setEditing] = React.useState(false);
|
|
1087
|
+
const [open, setOpen] = React.useState(false);
|
|
1088
|
+
const { targets } = useLinkTargets();
|
|
1089
|
+
const target = findTarget(targets, v);
|
|
1090
|
+
const has = hasLink(v);
|
|
1091
|
+
if (editing && !readOnly) return /* @__PURE__ */ jsx(LinkQuickEdit, {
|
|
1092
|
+
value: v,
|
|
1093
|
+
ariaLabel: label,
|
|
1094
|
+
size,
|
|
1095
|
+
types,
|
|
1096
|
+
onCommit: onChange,
|
|
1097
|
+
onDone: () => {
|
|
1098
|
+
setEditing(false);
|
|
1099
|
+
requestAnimationFrame(() => document.getElementById(id)?.focus({ preventScroll: true }));
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
1103
|
+
open,
|
|
1104
|
+
onOpenChange: setOpen,
|
|
1105
|
+
children: [/* @__PURE__ */ jsxs(PopoverAnchor, {
|
|
1106
|
+
"data-kit-link-field": "",
|
|
1107
|
+
className: cn("group/link relative flex min-w-0 items-center rounded-kit-md border border-kit-field-border bg-kit-field-bg shadow-kit-field transition-colors hover:border-kit-field-border-hover", size === "md" ? "h-9" : "h-8", readOnly && "hover:border-kit-field-border", invalid && "border-[var(--kit-field-invalid)]", className),
|
|
1108
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1109
|
+
id,
|
|
1110
|
+
type: "button",
|
|
1111
|
+
disabled: readOnly,
|
|
1112
|
+
onClick: () => setEditing(true),
|
|
1113
|
+
"aria-label": has ? `${label}: ${linkText(v)}. Edit link` : `Add ${label.toLowerCase()}`,
|
|
1114
|
+
"aria-invalid": invalid || void 0,
|
|
1115
|
+
className: "flex h-full min-w-0 flex-1 items-center px-2.5 text-left outline-none disabled:cursor-default",
|
|
1116
|
+
children: /* @__PURE__ */ jsx(LinkLine, {
|
|
1117
|
+
v,
|
|
1118
|
+
target,
|
|
1119
|
+
placeholder
|
|
1120
|
+
})
|
|
1121
|
+
}), readOnly ? null : /* @__PURE__ */ jsxs("span", {
|
|
1122
|
+
className: "mr-1 flex shrink-0 items-center gap-0.5",
|
|
1123
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
1124
|
+
content: "Link options",
|
|
1125
|
+
children: /* @__PURE__ */ jsx(PopoverTrigger, { render: /* @__PURE__ */ jsx(IconButton, {
|
|
1126
|
+
label: "Link options",
|
|
1127
|
+
tooltip: false,
|
|
1128
|
+
size: "xs",
|
|
1129
|
+
className: "text-kit-fg-3",
|
|
1130
|
+
children: /* @__PURE__ */ jsx(IconAdjustmentsHorizontal, { stroke: 1.5 })
|
|
1131
|
+
}) })
|
|
1132
|
+
}), has ? /* @__PURE__ */ jsx(IconButton, {
|
|
1133
|
+
label: `Clear ${label.toLowerCase()}`,
|
|
1134
|
+
size: "xs",
|
|
1135
|
+
className: "hidden text-kit-fg-3 group-hover/link:inline-flex group-focus-within/link:inline-flex [@media(pointer:coarse)]:inline-flex",
|
|
1136
|
+
onClick: () => onChange(null),
|
|
1137
|
+
children: /* @__PURE__ */ jsx(IconX, { stroke: 1.5 })
|
|
1138
|
+
}) : null]
|
|
1139
|
+
})]
|
|
1140
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
1141
|
+
className: "w-[340px] p-3",
|
|
1142
|
+
align: "start",
|
|
1143
|
+
children: /* @__PURE__ */ jsx(LinkPopoverBody, {
|
|
1144
|
+
initial: v,
|
|
1145
|
+
hideOptions: stringOnly,
|
|
1146
|
+
types,
|
|
1147
|
+
onSave: (n) => {
|
|
1148
|
+
onChange(n);
|
|
1149
|
+
setOpen(false);
|
|
1150
|
+
},
|
|
1151
|
+
onDetach: has ? () => {
|
|
1152
|
+
onChange(null);
|
|
1153
|
+
setOpen(false);
|
|
1154
|
+
} : void 0,
|
|
1155
|
+
onCancel: () => setOpen(false)
|
|
1156
|
+
})
|
|
1157
|
+
})]
|
|
1158
|
+
});
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* The shape a link field writes: the shape its value already has (a string stays a string, an object an object), and
|
|
1162
|
+
* for an empty field `field.valueShape`, else the string prod stores by default.
|
|
1163
|
+
*/
|
|
1164
|
+
function linkShapeOf(value, valueShape) {
|
|
1165
|
+
if (isObj(value)) return "object";
|
|
1166
|
+
if (typeof value === "string" && value !== "") return "string";
|
|
1167
|
+
return valueShape ?? "string";
|
|
1168
|
+
}
|
|
1169
|
+
/** The Block Kit `link` field: the LinkField above, sized for the form it sits in. */
|
|
1170
|
+
function LinkControl({ value, onChange, readOnly, id, field, invalid }) {
|
|
1171
|
+
const { variant } = useKitEnv();
|
|
1172
|
+
return /* @__PURE__ */ jsx(LinkField, {
|
|
1173
|
+
id,
|
|
1174
|
+
value,
|
|
1175
|
+
onChange,
|
|
1176
|
+
valueShape: linkShapeOf(value, field.valueShape),
|
|
1177
|
+
"aria-label": field.title,
|
|
1178
|
+
readOnly,
|
|
1179
|
+
size: variant === "document" ? "md" : "sm",
|
|
1180
|
+
invalid
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
//#endregion
|
|
1184
|
+
export { LINK_TYPES, LinkControl, LinkField, LinkForm, LinkLine, LinkOptions, LinkPicker, LinkPopoverBody, LinkQuickEdit, REL_ITEMS, SectionAnchorsProvider, TARGET_KEYS, describeLink, detectType, fileTarget, finalizeLink, findTarget, hasLink, hrefOf, linkIcon, linkProblem, linkShapeOf, linkText, normLink, storedLink, useLinkTargets, withTarget, withText };
|
|
1185
|
+
|
|
1186
|
+
//# sourceMappingURL=link.js.map
|