@bettercms-ai/kit 0.1.1 → 2.0.0-next.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 +7 -0
- package/dist/controls/form-picker-register.js +15 -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 +6 -0
- package/dist/controls/slot-register.js +13 -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 +58 -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 +80 -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,1396 @@
|
|
|
1
|
+
import { cropPreset, cropRect, isCropRect } from "../adapters/values.js";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { useKitEnv, useKitServices } from "../context.js";
|
|
4
|
+
import { isObj } from "../lib/path.js";
|
|
5
|
+
import { Button, IconButton } from "../ui/button.js";
|
|
6
|
+
import { Progress } from "../ui/controls.js";
|
|
7
|
+
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger, Popover, PopoverAnchor, PopoverContent, Tooltip } from "../ui/overlay.js";
|
|
8
|
+
import { RowChrome } from "../engine/bits.js";
|
|
9
|
+
import { isIconImage } from "../lib/icon-image.js";
|
|
10
|
+
import { Input, Textarea } from "../ui/input.js";
|
|
11
|
+
import { Select } from "../ui/select.js";
|
|
12
|
+
import { useDragReorder } from "../engine/item-list.js";
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { IconAlertTriangle, IconCrop, IconDots, IconDownload, IconExternalLink, IconFileText, IconFocusCentered, IconLink, IconPhoto, IconPlayerPlay, IconPlus, IconRefresh, IconReplace, IconTrash, IconUpload, IconVideo, IconWorld, IconX } from "@tabler/icons-react";
|
|
16
|
+
//#region src/controls/media.tsx
|
|
17
|
+
/**
|
|
18
|
+
* MEDIA — image · gallery · file · video (V2 HEAD 9829bf1 kit/controls/media.tsx, DESIGN.md 8.15).
|
|
19
|
+
*
|
|
20
|
+
* Production parity: dashed drop well ("Add an image / Or drop or paste one here"), filled 16:9 preview with Replace and
|
|
21
|
+
* Remove pills, the caption "{file} · W × H · No alt text" and a ⋯ whose "Alt text and details" opens a popover (alt
|
|
22
|
+
* text, focal point, file name). The media library picker, the upload and the asset metadata are KitServices
|
|
23
|
+
* (media-services.ts): the kit never imports a feature, and a missing service is named in words, never faked.
|
|
24
|
+
*
|
|
25
|
+
* Kit deviations from V2, each because of what the backend stores (adapters/values.ts):
|
|
26
|
+
* - "Crop for this placement" is V2's five-crop dropdown, stored as the rect prod keeps (cut from the picture's own size,
|
|
27
|
+
* centred on the focal point); a stored rect reads back as its preset when the size is known, and is kept as it is
|
|
28
|
+
* otherwise. With no size yet, the dropdown waits, and says why;
|
|
29
|
+
* - a picked asset's width / height / size are read for the caption, never written into the value (prod rebuilds the
|
|
30
|
+
* value from url, id, name, altText and focal; the rest would be refused);
|
|
31
|
+
* - where the host stores the URL string only (`imageStoresUrl`, the dock's top-level image props) the value stays a
|
|
32
|
+
* string, and alt text and focal point are the media library's (said in the details popover);
|
|
33
|
+
* - no built-in demo picker, no simulated upload, no stock poster frames;
|
|
34
|
+
* - the gallery sorts with the engine's `useDragReorder` (@dnd-kit is not on the kit allow-list);
|
|
35
|
+
* - a typed video URL is held as a draft until it is one prod stores (http(s) or a site path), so the dock never
|
|
36
|
+
* refuses a half-typed address.
|
|
37
|
+
*/
|
|
38
|
+
var fileNameFromUrl = (url) => {
|
|
39
|
+
const inline = /^data:image\/([a-z0-9.+-]+)/i.exec(url.trim());
|
|
40
|
+
if (inline) return `Embedded ${inline[1].replace(/\+xml$/i, "").replace(/^jpeg$/i, "jpg").toUpperCase()} image`;
|
|
41
|
+
try {
|
|
42
|
+
const u = new URL(url, typeof window === "undefined" ? "https://x.invalid" : window.location.href);
|
|
43
|
+
if (u.protocol === "data:" || u.protocol === "blob:") return "Image";
|
|
44
|
+
const file = u.pathname.split("/").filter(Boolean).reverse().find((x) => /\.[a-z0-9]{2,5}$/i.test(x));
|
|
45
|
+
return file ? decodeURIComponent(file) : `Image from ${u.hostname.replace(/^www\./, "")}`;
|
|
46
|
+
} catch {
|
|
47
|
+
return "Image";
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var normImage = (v) => {
|
|
51
|
+
if (typeof v === "string") return v ? { url: v } : null;
|
|
52
|
+
return isObj(v) && typeof v.url === "string" && v.url ? v : null;
|
|
53
|
+
};
|
|
54
|
+
/** What an asset becomes in a value: the keys prod keeps (url, id, name, alt), nothing measured. */
|
|
55
|
+
var fromAsset = (a) => {
|
|
56
|
+
const out = a.id ? {
|
|
57
|
+
url: a.url,
|
|
58
|
+
id: a.id
|
|
59
|
+
} : { url: a.url };
|
|
60
|
+
if (a.name) out.name = a.name;
|
|
61
|
+
if (a.alt) out.alt = a.alt;
|
|
62
|
+
return out;
|
|
63
|
+
};
|
|
64
|
+
var formatBytes = (n) => n >= 1e6 ? `${(n / 1e6).toFixed(1)} MB` : `${Math.max(1, Math.round(n / 1e3))} KB`;
|
|
65
|
+
var HTTP = /^https?:\/\/\S+$/i;
|
|
66
|
+
/** An http(s) URL or a site path: what prod's video value takes (video-value.ts isVideoUrl). */
|
|
67
|
+
var isVideoUrl = (s) => s === "" || HTTP.test(s.trim()) || /^\/(?!\/)\S*$/.test(s.trim());
|
|
68
|
+
var NO_ASSET = () => void 0;
|
|
69
|
+
var NO_ICONS = () => [];
|
|
70
|
+
var NO_SRC = (u) => u;
|
|
71
|
+
/** The services the media controls read, each hook stable across renders. */
|
|
72
|
+
function useMedia() {
|
|
73
|
+
const s = useKitServices();
|
|
74
|
+
return {
|
|
75
|
+
s,
|
|
76
|
+
useAsset: s.useMediaAsset ?? NO_ASSET,
|
|
77
|
+
src: s.mediaSrc ?? NO_SRC
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Files the field takes, by `accept` (an `image/*`, `.pdf`, `*` list). */
|
|
81
|
+
function acceptsFile(accept, file) {
|
|
82
|
+
return accept.split(",").some((raw) => {
|
|
83
|
+
const rule = raw.trim().toLowerCase();
|
|
84
|
+
if (!rule || rule === "*" || rule === "*/*") return true;
|
|
85
|
+
if (rule.startsWith(".")) return file.name.toLowerCase().endsWith(rule);
|
|
86
|
+
if (rule.endsWith("/*")) return file.type.toLowerCase().startsWith(rule.slice(0, -1));
|
|
87
|
+
return file.type.toLowerCase() === rule;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function MediaPicker(p) {
|
|
91
|
+
const Picker = useKitServices().MediaPicker;
|
|
92
|
+
return Picker ? /* @__PURE__ */ jsx(Picker, { ...p }) : null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Upload through the host's media library: progress while it runs, the assets handed to `onDone`, and a named reason
|
|
96
|
+
* when it fails or a file is the wrong kind. `run` is undefined when the host has no upload service.
|
|
97
|
+
*/
|
|
98
|
+
function useUpload(accept, kind, onDone) {
|
|
99
|
+
const { uploadMedia, onUploaded, toast } = useKitServices();
|
|
100
|
+
const [progress, setProgress] = React.useState(null);
|
|
101
|
+
const [error, setError] = React.useState(null);
|
|
102
|
+
const alive = React.useRef(true);
|
|
103
|
+
React.useEffect(() => () => {
|
|
104
|
+
alive.current = false;
|
|
105
|
+
}, []);
|
|
106
|
+
return {
|
|
107
|
+
progress,
|
|
108
|
+
error,
|
|
109
|
+
setError,
|
|
110
|
+
run: uploadMedia ? (files) => {
|
|
111
|
+
if (!files.length || progress != null) return;
|
|
112
|
+
const bad = files.find((f) => !acceptsFile(accept, f));
|
|
113
|
+
if (bad) {
|
|
114
|
+
setError(`${bad.name || "That file"} isn't ${kind === "file" ? "a file this field takes" : `an ${kind}`}.`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
setError(null);
|
|
118
|
+
setProgress(0);
|
|
119
|
+
uploadMedia(files, { onProgress: (f) => alive.current && setProgress(Math.round(Math.min(1, Math.max(0, f)) * 100)) }).then((assets) => {
|
|
120
|
+
if (!alive.current) return;
|
|
121
|
+
setProgress(null);
|
|
122
|
+
onUploaded?.(assets);
|
|
123
|
+
onDone(assets);
|
|
124
|
+
toast?.success(files.length > 1 ? `${files.length} files uploaded` : `${assets[0]?.name ?? files[0].name} uploaded`, { description: "Added to the media library" });
|
|
125
|
+
}).catch((e) => {
|
|
126
|
+
if (!alive.current) return;
|
|
127
|
+
setProgress(null);
|
|
128
|
+
setError(`Upload failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
129
|
+
});
|
|
130
|
+
} : void 0
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/** A line under a control that says why something did not happen (role="alert": it is the answer to an action). */
|
|
134
|
+
function Reason({ children, tone = "danger" }) {
|
|
135
|
+
return /* @__PURE__ */ jsx("p", {
|
|
136
|
+
role: tone === "danger" ? "alert" : "note",
|
|
137
|
+
className: cn("text-kit-xs", tone === "danger" ? "text-kit-danger-fg" : "text-kit-fg-3"),
|
|
138
|
+
children
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function DropWell({ id, title, hint, accept, multiple, icon, disabled, onFiles, onLibrary, onUrl, refuse, progress }) {
|
|
142
|
+
const [over, setOver] = React.useState(false);
|
|
143
|
+
const [urlMode, setUrlMode] = React.useState(false);
|
|
144
|
+
const [url, setUrl] = React.useState("");
|
|
145
|
+
const [urlError, setUrlError] = React.useState(null);
|
|
146
|
+
const input = React.useRef(null);
|
|
147
|
+
const takesFiles = (!!onFiles || !!refuse) && !disabled;
|
|
148
|
+
const files = (f) => onFiles ? onFiles(f) : refuse?.(NO_UPLOAD);
|
|
149
|
+
const pickFiles = () => onFiles ? input.current?.click() : refuse?.(NO_UPLOAD);
|
|
150
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
151
|
+
id,
|
|
152
|
+
tabIndex: disabled ? -1 : 0,
|
|
153
|
+
role: "group",
|
|
154
|
+
"aria-label": takesFiles ? `${title}. Paste an image or press Enter to upload` : title,
|
|
155
|
+
onPaste: (e) => {
|
|
156
|
+
const pasted = Array.from(e.clipboardData.files);
|
|
157
|
+
if (pasted.length && takesFiles) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
files(pasted);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
onKeyDown: (e) => {
|
|
163
|
+
if (e.key === "Enter" && e.target === e.currentTarget && takesFiles) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
pickFiles();
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
onDragOver: (e) => {
|
|
169
|
+
if (!takesFiles) return;
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
setOver(true);
|
|
172
|
+
},
|
|
173
|
+
onDragLeave: (e) => {
|
|
174
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setOver(false);
|
|
175
|
+
},
|
|
176
|
+
onDrop: (e) => {
|
|
177
|
+
if (!takesFiles) return;
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
setOver(false);
|
|
180
|
+
files(Array.from(e.dataTransfer.files));
|
|
181
|
+
},
|
|
182
|
+
"data-slot": "kit-drop-well",
|
|
183
|
+
className: cn("relative flex flex-col items-center gap-2.5 rounded-kit-lg border border-dashed px-4 py-5 text-center transition-colors", over ? "border-kit-accent bg-kit-accent-softer" : "border-kit-line-strong bg-kit-subtle hover:border-kit-field-border-hover"),
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ jsx("span", {
|
|
186
|
+
className: cn("flex size-9 items-center justify-center rounded-kit-lg border border-kit-line bg-kit-control-bg text-kit-fg-3 [&_svg]:size-[18px]", over && "text-kit-accent-fg"),
|
|
187
|
+
children: icon
|
|
188
|
+
}),
|
|
189
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
190
|
+
className: "text-kit-sm font-medium text-kit-fg",
|
|
191
|
+
children: over ? "Drop to upload" : title
|
|
192
|
+
}), takesFiles ? /* @__PURE__ */ jsx("div", {
|
|
193
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
194
|
+
children: hint
|
|
195
|
+
}) : null] }),
|
|
196
|
+
urlMode && onUrl ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("form", {
|
|
197
|
+
className: "flex w-full max-w-sm items-center gap-1.5",
|
|
198
|
+
onSubmit: (e) => {
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
e.stopPropagation();
|
|
201
|
+
const v = url.trim();
|
|
202
|
+
if (HTTP.test(v)) {
|
|
203
|
+
onUrl(v);
|
|
204
|
+
setUrlMode(false);
|
|
205
|
+
setUrl("");
|
|
206
|
+
setUrlError(null);
|
|
207
|
+
} else setUrlError("Use a full image URL, like https://…/photo.jpg");
|
|
208
|
+
},
|
|
209
|
+
onKeyDown: (e) => {
|
|
210
|
+
if (e.key === "Escape") {
|
|
211
|
+
e.stopPropagation();
|
|
212
|
+
setUrlMode(false);
|
|
213
|
+
setUrlError(null);
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
217
|
+
autoFocus: true,
|
|
218
|
+
size: "sm",
|
|
219
|
+
value: url,
|
|
220
|
+
"aria-label": "Image URL",
|
|
221
|
+
"aria-invalid": urlError ? true : void 0,
|
|
222
|
+
onChange: (e) => setUrl(e.target.value),
|
|
223
|
+
placeholder: "https://…/photo.jpg",
|
|
224
|
+
leading: /* @__PURE__ */ jsx(IconLink, { stroke: 1.5 })
|
|
225
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
226
|
+
size: "sm",
|
|
227
|
+
type: "submit",
|
|
228
|
+
variant: "primary",
|
|
229
|
+
children: "Add"
|
|
230
|
+
})]
|
|
231
|
+
}), urlError ? /* @__PURE__ */ jsx(Reason, { children: urlError }) : null] }) : /* @__PURE__ */ jsxs("div", {
|
|
232
|
+
className: "flex flex-wrap justify-center gap-1.5",
|
|
233
|
+
children: [
|
|
234
|
+
onLibrary || refuse ? /* @__PURE__ */ jsx(Button, {
|
|
235
|
+
size: "sm",
|
|
236
|
+
variant: "secondary",
|
|
237
|
+
onClick: onLibrary ?? (() => refuse(NO_LIBRARY)),
|
|
238
|
+
disabled,
|
|
239
|
+
children: "Media library"
|
|
240
|
+
}) : null,
|
|
241
|
+
onFiles || refuse ? /* @__PURE__ */ jsx(Button, {
|
|
242
|
+
size: "sm",
|
|
243
|
+
variant: "ghost",
|
|
244
|
+
leftIcon: /* @__PURE__ */ jsx(IconUpload, { stroke: 1.5 }),
|
|
245
|
+
onClick: pickFiles,
|
|
246
|
+
disabled,
|
|
247
|
+
children: "Upload"
|
|
248
|
+
}) : null,
|
|
249
|
+
onUrl ? /* @__PURE__ */ jsx(Button, {
|
|
250
|
+
size: "sm",
|
|
251
|
+
variant: "ghost",
|
|
252
|
+
onClick: () => setUrlMode(true),
|
|
253
|
+
disabled,
|
|
254
|
+
children: "Paste URL"
|
|
255
|
+
}) : null
|
|
256
|
+
]
|
|
257
|
+
}),
|
|
258
|
+
onFiles ? /* @__PURE__ */ jsx("input", {
|
|
259
|
+
ref: input,
|
|
260
|
+
type: "file",
|
|
261
|
+
hidden: true,
|
|
262
|
+
tabIndex: -1,
|
|
263
|
+
"aria-hidden": true,
|
|
264
|
+
accept,
|
|
265
|
+
multiple,
|
|
266
|
+
onChange: (e) => {
|
|
267
|
+
onFiles(Array.from(e.target.files ?? []));
|
|
268
|
+
e.target.value = "";
|
|
269
|
+
}
|
|
270
|
+
}) : null,
|
|
271
|
+
progress != null ? /* @__PURE__ */ jsxs("div", {
|
|
272
|
+
className: "absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-kit-lg bg-kit-surface px-8",
|
|
273
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
274
|
+
className: "text-kit-sm text-kit-fg-2",
|
|
275
|
+
children: [
|
|
276
|
+
/* @__PURE__ */ jsx("span", {
|
|
277
|
+
role: "status",
|
|
278
|
+
children: "Uploading…"
|
|
279
|
+
}),
|
|
280
|
+
" ",
|
|
281
|
+
progress,
|
|
282
|
+
"%"
|
|
283
|
+
]
|
|
284
|
+
}), /* @__PURE__ */ jsx(Progress, {
|
|
285
|
+
value: progress,
|
|
286
|
+
tone: "ink",
|
|
287
|
+
label: "Upload progress",
|
|
288
|
+
className: "max-w-56"
|
|
289
|
+
})]
|
|
290
|
+
}) : null
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/** Why the drop well offers nothing to pick with (no library, no upload): said once, in words. */
|
|
295
|
+
var NO_SOURCE = "No media library or upload is connected to this editor, so nothing can be chosen here.";
|
|
296
|
+
var NO_LIBRARY = "No media library is connected to this editor, so nothing can be picked from it here.";
|
|
297
|
+
var NO_UPLOAD = "No upload is connected to this editor, so files can't be uploaded here.";
|
|
298
|
+
/** Transparency checker on the kit tokens (white in light, dimmed in dark), as the media grid draws it. */
|
|
299
|
+
var CHECKER = "bg-kit-checker-a [background-image:conic-gradient(var(--kit-checker-b)_25%,var(--kit-checker-a)_0_50%,var(--kit-checker-b)_0_75%,var(--kit-checker-a)_0)] [background-size:12px_12px]";
|
|
300
|
+
/** The preview frame's shape bounds: a tall or panoramic picture never makes the dock tall or a sliver. */
|
|
301
|
+
var FRAME_MIN = 1;
|
|
302
|
+
var FRAME_MAX = 2;
|
|
303
|
+
/**
|
|
304
|
+
* How a preview frames a picture of any shape: the frame follows the picture's ratio between square and 2:1, and the
|
|
305
|
+
* picture fits inside it WHOLE, filling the frame's width or height (a portrait is boxed at the sides, a panorama above
|
|
306
|
+
* and below, on the checker). With no known size (still loading, or an SVG with no intrinsic size) the frame is 16:9
|
|
307
|
+
* and the picture is contained. Before 2026-10-16 every picture was cropped to a fixed 16:9 (`object-cover`).
|
|
308
|
+
*/
|
|
309
|
+
function frameFit(size) {
|
|
310
|
+
if (!size || !(size.w > 0) || !(size.h > 0)) return {
|
|
311
|
+
frame: 16 / 9,
|
|
312
|
+
image: null,
|
|
313
|
+
fill: "contain"
|
|
314
|
+
};
|
|
315
|
+
const image = size.w / size.h;
|
|
316
|
+
const frame = Math.min(FRAME_MAX, Math.max(FRAME_MIN, image));
|
|
317
|
+
return {
|
|
318
|
+
frame,
|
|
319
|
+
image,
|
|
320
|
+
fill: image < frame ? "height" : "width"
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
/** The picture's classes for a fit: it keeps its own ratio and the frame's width or height, never cut. */
|
|
324
|
+
var FIT_CLASS = {
|
|
325
|
+
width: "h-auto max-h-full w-full object-contain",
|
|
326
|
+
height: "h-full w-auto max-w-full object-contain",
|
|
327
|
+
contain: "size-full object-contain"
|
|
328
|
+
};
|
|
329
|
+
/** V2's five crops (kit media.tsx CROPS, D46). */
|
|
330
|
+
var CROPS = [
|
|
331
|
+
{
|
|
332
|
+
value: "original",
|
|
333
|
+
label: "Original",
|
|
334
|
+
ratio: "auto",
|
|
335
|
+
description: "Keep the uploaded shape"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
value: "16:9",
|
|
339
|
+
label: "16:9",
|
|
340
|
+
ratio: "16/9",
|
|
341
|
+
description: "Widescreen"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
value: "4:3",
|
|
345
|
+
label: "4:3",
|
|
346
|
+
ratio: "4/3",
|
|
347
|
+
description: "Landscape"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
value: "1:1",
|
|
351
|
+
label: "1:1",
|
|
352
|
+
ratio: "1/1",
|
|
353
|
+
description: "Square"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
value: "4:5",
|
|
357
|
+
label: "4:5",
|
|
358
|
+
ratio: "4/5",
|
|
359
|
+
description: "Portrait"
|
|
360
|
+
}
|
|
361
|
+
];
|
|
362
|
+
var CUSTOM_CROP = "custom";
|
|
363
|
+
/** The crop a value shows: its preset, a stored rect read against the picture's size, or a rect that is none of them. */
|
|
364
|
+
function cropChoice(crop, size) {
|
|
365
|
+
if (!crop) return "original";
|
|
366
|
+
if (typeof crop === "string") return crop;
|
|
367
|
+
if (!isCropRect(crop)) return "original";
|
|
368
|
+
return size && cropPreset(crop, size.w, size.h) || CUSTOM_CROP;
|
|
369
|
+
}
|
|
370
|
+
/** A custom rect's own shape (its fractions of the picture, in pixels), when the picture's size is known. */
|
|
371
|
+
function customRatio(crop, size) {
|
|
372
|
+
if (!size || !crop || typeof crop === "string" || !isCropRect(crop)) return void 0;
|
|
373
|
+
const w = (1 - crop.left - crop.right) * size.w;
|
|
374
|
+
const h = (1 - crop.top - crop.bottom) * size.h;
|
|
375
|
+
return w > 0 && h > 0 ? String(w / h) : void 0;
|
|
376
|
+
}
|
|
377
|
+
/** The value with `choice` cut from the picture (centred on its focal point), or with no crop for Original. */
|
|
378
|
+
function withCrop(v, choice, size) {
|
|
379
|
+
const next = { ...v };
|
|
380
|
+
delete next.crop;
|
|
381
|
+
const rect = choice === "original" ? void 0 : cropRect(choice, size.w, size.h, v.focal);
|
|
382
|
+
if (rect) next.crop = rect;
|
|
383
|
+
return next;
|
|
384
|
+
}
|
|
385
|
+
function ImageDetails({ v, onChange, readOnly, label, urlOnly, altOnly = false, size, asset }) {
|
|
386
|
+
const { src } = useMedia();
|
|
387
|
+
const focal = v.focal ?? {
|
|
388
|
+
x: 50,
|
|
389
|
+
y: 50
|
|
390
|
+
};
|
|
391
|
+
const choice = cropChoice(v.crop, size);
|
|
392
|
+
const crop = CROPS.find((c) => c.value === choice);
|
|
393
|
+
const own = choice === "original" && size ? frameFit(size) : null;
|
|
394
|
+
const pad = own?.image ? own : null;
|
|
395
|
+
const padRatio = crop && crop.ratio !== "auto" ? crop.ratio : pad ? String(pad.image) : customRatio(v.crop, size) ?? "3/2";
|
|
396
|
+
const setFocal = (x, y) => {
|
|
397
|
+
const next = {
|
|
398
|
+
...v,
|
|
399
|
+
focal: {
|
|
400
|
+
x: Math.round(Math.min(100, Math.max(0, x))),
|
|
401
|
+
y: Math.round(Math.min(100, Math.max(0, y)))
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
onChange(crop && crop.value !== "original" && size ? withCrop(next, crop.value, size) : next);
|
|
405
|
+
};
|
|
406
|
+
const fromPointer = (e) => {
|
|
407
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
408
|
+
if (!r.width || !r.height) return;
|
|
409
|
+
setFocal((e.clientX - r.left) / r.width * 100, (e.clientY - r.top) / r.height * 100);
|
|
410
|
+
};
|
|
411
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
412
|
+
className: "flex flex-col gap-3",
|
|
413
|
+
children: [
|
|
414
|
+
/* @__PURE__ */ jsxs("div", {
|
|
415
|
+
className: "flex items-center justify-between",
|
|
416
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
417
|
+
className: "text-kit-sm font-medium text-kit-fg",
|
|
418
|
+
children: "Alt text and details"
|
|
419
|
+
}), size ? /* @__PURE__ */ jsxs("span", {
|
|
420
|
+
className: "tabular-nums text-kit-2xs text-kit-fg-3",
|
|
421
|
+
children: [
|
|
422
|
+
size.w,
|
|
423
|
+
" × ",
|
|
424
|
+
size.h
|
|
425
|
+
]
|
|
426
|
+
}) : null]
|
|
427
|
+
}),
|
|
428
|
+
urlOnly ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Reason, {
|
|
429
|
+
tone: "muted",
|
|
430
|
+
children: "This placement stores the image address only, so its alt text and focal point are the media library's."
|
|
431
|
+
}), asset?.alt ? /* @__PURE__ */ jsxs("div", {
|
|
432
|
+
className: "flex flex-col gap-1",
|
|
433
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
434
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
435
|
+
children: "Alt text in the media library"
|
|
436
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
437
|
+
className: "text-kit-sm text-kit-fg",
|
|
438
|
+
children: asset.alt
|
|
439
|
+
})]
|
|
440
|
+
}) : null] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("label", {
|
|
441
|
+
className: "flex flex-col gap-1.5",
|
|
442
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
443
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
444
|
+
children: "Alt text"
|
|
445
|
+
}), /* @__PURE__ */ jsx(Textarea, {
|
|
446
|
+
rows: 2,
|
|
447
|
+
value: v.alt ?? "",
|
|
448
|
+
readOnly,
|
|
449
|
+
onChange: (e) => {
|
|
450
|
+
const alt = e.target.value;
|
|
451
|
+
const next = { ...v };
|
|
452
|
+
if (alt) next.alt = alt;
|
|
453
|
+
else delete next.alt;
|
|
454
|
+
onChange(next);
|
|
455
|
+
},
|
|
456
|
+
placeholder: "Describe the image for accessibility",
|
|
457
|
+
className: "min-h-14 text-kit-sm",
|
|
458
|
+
"aria-label": `${label} alt text`
|
|
459
|
+
})]
|
|
460
|
+
}), altOnly ? /* @__PURE__ */ jsx(Reason, {
|
|
461
|
+
tone: "muted",
|
|
462
|
+
children: "This image block keeps its address and alt text. A crop or focal point isn't stored with it."
|
|
463
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
464
|
+
className: "flex flex-col gap-1.5",
|
|
465
|
+
children: [
|
|
466
|
+
/* @__PURE__ */ jsxs("div", {
|
|
467
|
+
className: "flex items-center justify-between",
|
|
468
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
469
|
+
className: "flex items-center gap-1 text-kit-xs text-kit-fg-3",
|
|
470
|
+
children: [/* @__PURE__ */ jsx(IconCrop, {
|
|
471
|
+
className: "size-3.5",
|
|
472
|
+
stroke: 1.5,
|
|
473
|
+
"aria-hidden": true
|
|
474
|
+
}), "Crop for this placement"]
|
|
475
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
476
|
+
className: "flex items-center gap-1 text-kit-2xs text-kit-fg-3",
|
|
477
|
+
children: [
|
|
478
|
+
/* @__PURE__ */ jsx(IconFocusCentered, {
|
|
479
|
+
className: "size-3",
|
|
480
|
+
stroke: 1.5,
|
|
481
|
+
"aria-hidden": true
|
|
482
|
+
}),
|
|
483
|
+
"Focal ",
|
|
484
|
+
focal.x,
|
|
485
|
+
"%, ",
|
|
486
|
+
focal.y,
|
|
487
|
+
"%"
|
|
488
|
+
]
|
|
489
|
+
})]
|
|
490
|
+
}),
|
|
491
|
+
/* @__PURE__ */ jsx(Select, {
|
|
492
|
+
size: "sm",
|
|
493
|
+
"aria-label": `${label} crop`,
|
|
494
|
+
disabled: readOnly || !size,
|
|
495
|
+
triggerClassName: "w-full",
|
|
496
|
+
value: choice,
|
|
497
|
+
onValueChange: (c) => size && c !== CUSTOM_CROP && onChange(withCrop(v, c, size)),
|
|
498
|
+
options: [...CROPS.map((c) => ({
|
|
499
|
+
value: c.value,
|
|
500
|
+
label: c.label,
|
|
501
|
+
meta: c.description
|
|
502
|
+
})), ...choice === CUSTOM_CROP ? [{
|
|
503
|
+
value: CUSTOM_CROP,
|
|
504
|
+
label: "Custom",
|
|
505
|
+
meta: "Cut elsewhere",
|
|
506
|
+
disabled: true
|
|
507
|
+
}] : []]
|
|
508
|
+
}),
|
|
509
|
+
!size && !readOnly ? /* @__PURE__ */ jsx("span", {
|
|
510
|
+
className: "text-kit-2xs text-kit-fg-3",
|
|
511
|
+
children: "The crop is cut from the picture's size, which is still loading."
|
|
512
|
+
}) : null,
|
|
513
|
+
/* @__PURE__ */ jsx("div", {
|
|
514
|
+
className: cn(pad ? "mt-1 flex items-center justify-center overflow-hidden rounded-kit-md border border-kit-line" : "contents", pad && CHECKER),
|
|
515
|
+
style: pad ? { aspectRatio: pad.frame } : void 0,
|
|
516
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
517
|
+
role: "slider",
|
|
518
|
+
"aria-label": "Focal point. Click the subject.",
|
|
519
|
+
"aria-valuetext": `${focal.x}% across, ${focal.y}% down`,
|
|
520
|
+
"aria-valuenow": focal.x,
|
|
521
|
+
"aria-valuemin": 0,
|
|
522
|
+
"aria-valuemax": 100,
|
|
523
|
+
"aria-readonly": readOnly || void 0,
|
|
524
|
+
tabIndex: 0,
|
|
525
|
+
onPointerDown: (e) => !readOnly && fromPointer(e),
|
|
526
|
+
onKeyDown: (e) => {
|
|
527
|
+
const d = e.shiftKey ? 10 : 2;
|
|
528
|
+
const step = {
|
|
529
|
+
ArrowLeft: [-d, 0],
|
|
530
|
+
ArrowRight: [d, 0],
|
|
531
|
+
ArrowUp: [0, -d],
|
|
532
|
+
ArrowDown: [0, d]
|
|
533
|
+
}[e.key];
|
|
534
|
+
if (!step || readOnly) return;
|
|
535
|
+
e.preventDefault();
|
|
536
|
+
setFocal(focal.x + step[0], focal.y + step[1]);
|
|
537
|
+
},
|
|
538
|
+
"data-pad-ratio": padRatio,
|
|
539
|
+
className: pad ? cn("relative cursor-crosshair overflow-hidden", pad.fill === "height" ? "h-full" : "w-full") : "relative mt-1 cursor-crosshair overflow-hidden rounded-kit-md border border-kit-line bg-kit-muted",
|
|
540
|
+
style: { aspectRatio: padRatio },
|
|
541
|
+
children: [/* @__PURE__ */ jsx("img", {
|
|
542
|
+
src: src(v.url),
|
|
543
|
+
alt: "",
|
|
544
|
+
draggable: false,
|
|
545
|
+
className: "pointer-events-none size-full select-none object-cover transition-[object-position] duration-200",
|
|
546
|
+
style: { objectPosition: `${focal.x}% ${focal.y}%` }
|
|
547
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
548
|
+
"aria-hidden": true,
|
|
549
|
+
className: "pointer-events-none absolute size-5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-kit-media-handle bg-kit-media-handle-ring shadow-kit-md transition-[left,top] duration-150",
|
|
550
|
+
style: {
|
|
551
|
+
left: `${focal.x}%`,
|
|
552
|
+
top: `${focal.y}%`
|
|
553
|
+
}
|
|
554
|
+
})]
|
|
555
|
+
})
|
|
556
|
+
}),
|
|
557
|
+
/* @__PURE__ */ jsx("span", {
|
|
558
|
+
className: "text-kit-2xs text-kit-fg-3",
|
|
559
|
+
children: "Click the subject. It stays in frame on every screen size."
|
|
560
|
+
})
|
|
561
|
+
]
|
|
562
|
+
})] }),
|
|
563
|
+
urlOnly || altOnly ? /* @__PURE__ */ jsxs("div", {
|
|
564
|
+
className: "flex flex-col gap-1.5",
|
|
565
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
566
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
567
|
+
children: "File name"
|
|
568
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
569
|
+
className: "truncate font-kit-mono text-kit-xs text-kit-fg",
|
|
570
|
+
children: asset?.name ?? v.name ?? fileNameFromUrl(v.url)
|
|
571
|
+
})]
|
|
572
|
+
}) : /* @__PURE__ */ jsxs("label", {
|
|
573
|
+
className: "flex flex-col gap-1.5",
|
|
574
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
575
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
576
|
+
children: "File name"
|
|
577
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
578
|
+
size: "sm",
|
|
579
|
+
value: v.name ?? asset?.name ?? fileNameFromUrl(v.url),
|
|
580
|
+
readOnly,
|
|
581
|
+
spellCheck: false,
|
|
582
|
+
autoComplete: "off",
|
|
583
|
+
onChange: (e) => {
|
|
584
|
+
const next = { ...v };
|
|
585
|
+
if (e.target.value) next.name = e.target.value;
|
|
586
|
+
else delete next.name;
|
|
587
|
+
onChange(next);
|
|
588
|
+
},
|
|
589
|
+
className: "font-kit-mono [&_input]:font-kit-mono",
|
|
590
|
+
"aria-label": `${label} file name`
|
|
591
|
+
})]
|
|
592
|
+
})
|
|
593
|
+
]
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
/** The width × height a stored image value carries (positive numbers only), else undefined. */
|
|
597
|
+
function storedSize(value) {
|
|
598
|
+
if (!value || typeof value !== "object") return void 0;
|
|
599
|
+
const { width, height } = value;
|
|
600
|
+
return typeof width === "number" && typeof height === "number" && width > 0 && height > 0 ? {
|
|
601
|
+
w: width,
|
|
602
|
+
h: height
|
|
603
|
+
} : void 0;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* V2's icon control shape (controls/icon.tsx): ONE button — a 24px glyph tile, the field's name, a quiet replace cue —
|
|
607
|
+
* that opens the library. No Replace pill, no ×, no alt text, crop or details: an icon's alt text is "" (aria-hidden on
|
|
608
|
+
* the page) and Remove sits in the picker's footer. Empty: a dashed tile, "Add icon", and an SVG dropped on it uploads.
|
|
609
|
+
*/
|
|
610
|
+
function IconImageRow({ id, title, url, readOnly, onOpen, onFiles, busy, pickerOpen }) {
|
|
611
|
+
const row = React.useRef(null);
|
|
612
|
+
const [over, setOver] = React.useState(false);
|
|
613
|
+
const wasOpen = React.useRef(false);
|
|
614
|
+
React.useEffect(() => {
|
|
615
|
+
if (wasOpen.current && !pickerOpen) row.current?.focus({ preventScroll: true });
|
|
616
|
+
wasOpen.current = pickerOpen;
|
|
617
|
+
}, [pickerOpen]);
|
|
618
|
+
const empty = !url;
|
|
619
|
+
const inert = readOnly || busy || !onOpen;
|
|
620
|
+
const droppable = empty && !inert && !!onFiles;
|
|
621
|
+
const chrome = React.useContext(RowChrome);
|
|
622
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
623
|
+
className: cn("flex h-8 min-w-0 items-center rounded-kit-md border bg-kit-field-bg pointer-coarse:min-h-11", "transition-colors duration-[120ms] ease-out motion-reduce:transition-none", over ? "border-kit-emphasis-line bg-kit-hover" : "border-kit-line-strong", inert ? "opacity-60" : "[@media(hover:hover)]:hover:bg-kit-hover"),
|
|
624
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
625
|
+
content: title,
|
|
626
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
627
|
+
ref: row,
|
|
628
|
+
id,
|
|
629
|
+
type: "button",
|
|
630
|
+
"data-slot": "kit-icon-row",
|
|
631
|
+
disabled: inert,
|
|
632
|
+
onClick: onOpen,
|
|
633
|
+
"aria-label": empty ? `Add icon, ${title}` : `Replace ${title}`,
|
|
634
|
+
onDragOver: droppable ? (e) => {
|
|
635
|
+
e.preventDefault();
|
|
636
|
+
setOver(true);
|
|
637
|
+
} : void 0,
|
|
638
|
+
onDragLeave: droppable ? () => setOver(false) : void 0,
|
|
639
|
+
onDrop: droppable ? (e) => {
|
|
640
|
+
e.preventDefault();
|
|
641
|
+
setOver(false);
|
|
642
|
+
onFiles(Array.from(e.dataTransfer.files));
|
|
643
|
+
} : void 0,
|
|
644
|
+
className: "flex min-w-0 flex-1 touch-manipulation items-center gap-3 self-stretch rounded-[5px] pl-[3px] pr-2 text-left text-kit-sm focus-visible:-outline-offset-2 disabled:cursor-not-allowed",
|
|
645
|
+
children: [
|
|
646
|
+
/* @__PURE__ */ jsx("span", {
|
|
647
|
+
"aria-hidden": true,
|
|
648
|
+
className: cn("grid size-6 shrink-0 place-items-center overflow-hidden rounded-kit-sm border", empty ? "border-dashed border-kit-emphasis-line" : cn("border-kit-line p-1", CHECKER)),
|
|
649
|
+
children: empty ? /* @__PURE__ */ jsx(IconPlus, {
|
|
650
|
+
className: "size-3.5 text-kit-fg-3",
|
|
651
|
+
stroke: 1.5
|
|
652
|
+
}) : /* @__PURE__ */ jsx("img", {
|
|
653
|
+
src: url,
|
|
654
|
+
alt: "",
|
|
655
|
+
className: "size-full object-contain"
|
|
656
|
+
})
|
|
657
|
+
}),
|
|
658
|
+
/* @__PURE__ */ jsx("span", {
|
|
659
|
+
"aria-hidden": true,
|
|
660
|
+
className: cn("min-w-0 flex-1 truncate", empty ? "text-kit-fg-3" : "text-kit-fg"),
|
|
661
|
+
children: empty ? busy ? "Uploading…" : "Add icon" : title
|
|
662
|
+
}),
|
|
663
|
+
empty ? null : /* @__PURE__ */ jsx(IconRefresh, {
|
|
664
|
+
"aria-hidden": true,
|
|
665
|
+
className: "size-3.5 shrink-0 text-kit-fg-3",
|
|
666
|
+
stroke: 1.5
|
|
667
|
+
})
|
|
668
|
+
]
|
|
669
|
+
})
|
|
670
|
+
}), chrome ? /* @__PURE__ */ jsx("span", {
|
|
671
|
+
"data-slot": "kit-icon-row-chrome",
|
|
672
|
+
className: "flex shrink-0 items-center gap-0.5 pr-1 empty:hidden",
|
|
673
|
+
children: chrome
|
|
674
|
+
}) : null]
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
function ImageControl({ field, value, onChange: write, readOnly, id, path }) {
|
|
678
|
+
const { s, useAsset, src } = useMedia();
|
|
679
|
+
const env = useKitEnv();
|
|
680
|
+
const urlOnly = !!s.imageStoresUrl?.(path);
|
|
681
|
+
const altOnly = !urlOnly && !!s.imageAltOnly?.(path);
|
|
682
|
+
const legacyString = typeof value === "string" || field.valueShape === "string";
|
|
683
|
+
const v = normImage(value);
|
|
684
|
+
const asset = useAsset({
|
|
685
|
+
id: v?.id,
|
|
686
|
+
url: v?.url ?? ""
|
|
687
|
+
});
|
|
688
|
+
const accept = field.svgOnly ? "image/svg+xml" : "image/*";
|
|
689
|
+
const kinds = field.svgOnly ? ["svg"] : ["image", "svg"];
|
|
690
|
+
const [loaded, setLoaded] = React.useState();
|
|
691
|
+
const natural = loaded && v && loaded.url === v.url ? {
|
|
692
|
+
w: loaded.w,
|
|
693
|
+
h: loaded.h
|
|
694
|
+
} : void 0;
|
|
695
|
+
const readNatural = (img) => {
|
|
696
|
+
if (!img || !v || !img.complete || !img.naturalWidth || !img.naturalHeight) return;
|
|
697
|
+
const next = {
|
|
698
|
+
url: v.url,
|
|
699
|
+
w: img.naturalWidth,
|
|
700
|
+
h: img.naturalHeight
|
|
701
|
+
};
|
|
702
|
+
setLoaded((prev) => prev && prev.url === next.url && prev.w === next.w && prev.h === next.h ? prev : next);
|
|
703
|
+
};
|
|
704
|
+
const stored = storedSize(value);
|
|
705
|
+
const size = asset?.width && asset.height ? {
|
|
706
|
+
w: asset.width,
|
|
707
|
+
h: asset.height
|
|
708
|
+
} : stored ?? natural;
|
|
709
|
+
const onChange = (n) => {
|
|
710
|
+
if (!n) return write(urlOnly ? "" : null);
|
|
711
|
+
if (urlOnly) return write(n.url);
|
|
712
|
+
if (legacyString && !n.alt && !n.focal && !n.crop && !n.name && !n.id) return write(n.url);
|
|
713
|
+
write(n);
|
|
714
|
+
};
|
|
715
|
+
const [picker, setPicker] = React.useState(false);
|
|
716
|
+
const [details, setDetails] = React.useState(false);
|
|
717
|
+
const up = useUpload(accept, "image", (a) => a[0] && onChange(fromAsset(a[0])));
|
|
718
|
+
const library = s.MediaPicker && !readOnly ? () => setPicker(true) : void 0;
|
|
719
|
+
const known = (s.useSiteIcons ?? NO_ICONS)();
|
|
720
|
+
if (isIconImage(field, value)) {
|
|
721
|
+
const icons = s.useSiteIcons ? [...v ? [{
|
|
722
|
+
url: v.url,
|
|
723
|
+
value,
|
|
724
|
+
current: true
|
|
725
|
+
}] : [], ...known.filter((i) => i.url !== v?.url && !(v?.id && i.assetId === v.id)).map(({ url, value: stored }) => ({
|
|
726
|
+
url,
|
|
727
|
+
value: stored
|
|
728
|
+
}))] : void 0;
|
|
729
|
+
const pickIcon = (stored) => {
|
|
730
|
+
const n = normImage(stored);
|
|
731
|
+
if (n) onChange(fromAsset({
|
|
732
|
+
id: n.id ?? "",
|
|
733
|
+
url: n.url,
|
|
734
|
+
name: n.name,
|
|
735
|
+
alt: n.alt ?? (typeof n.altText === "string" ? n.altText : void 0),
|
|
736
|
+
kind: "svg"
|
|
737
|
+
}));
|
|
738
|
+
setPicker(false);
|
|
739
|
+
};
|
|
740
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
741
|
+
className: "flex flex-col gap-1.5",
|
|
742
|
+
children: [
|
|
743
|
+
/* @__PURE__ */ jsx(IconImageRow, {
|
|
744
|
+
id,
|
|
745
|
+
title: field.title,
|
|
746
|
+
url: v ? src(v.url) : void 0,
|
|
747
|
+
readOnly,
|
|
748
|
+
onOpen: library,
|
|
749
|
+
onFiles: up.run,
|
|
750
|
+
busy: up.progress != null,
|
|
751
|
+
pickerOpen: picker
|
|
752
|
+
}),
|
|
753
|
+
up.error ? /* @__PURE__ */ jsx(Reason, { children: up.error }) : null,
|
|
754
|
+
!readOnly && !library ? /* @__PURE__ */ jsx(Reason, {
|
|
755
|
+
tone: "muted",
|
|
756
|
+
children: NO_LIBRARY
|
|
757
|
+
}) : null,
|
|
758
|
+
/* @__PURE__ */ jsx(MediaPicker, {
|
|
759
|
+
open: picker,
|
|
760
|
+
onOpenChange: setPicker,
|
|
761
|
+
accept: ["svg"],
|
|
762
|
+
title: v ? "Replace icon" : "Select an icon",
|
|
763
|
+
onPick: (a) => a[0] && onChange(fromAsset(a[0])),
|
|
764
|
+
onRemove: v && !readOnly ? () => {
|
|
765
|
+
onChange(null);
|
|
766
|
+
setPicker(false);
|
|
767
|
+
} : void 0,
|
|
768
|
+
icons,
|
|
769
|
+
onPickIcon: readOnly ? void 0 : pickIcon
|
|
770
|
+
})
|
|
771
|
+
]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
if (!v) return /* @__PURE__ */ jsxs("div", {
|
|
775
|
+
className: "flex flex-col gap-1.5",
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ jsx(DropWell, {
|
|
778
|
+
id,
|
|
779
|
+
title: "Add an image",
|
|
780
|
+
hint: "Or drop or paste one here",
|
|
781
|
+
accept,
|
|
782
|
+
icon: /* @__PURE__ */ jsx(IconPhoto, { stroke: 1.5 }),
|
|
783
|
+
onFiles: up.run,
|
|
784
|
+
onLibrary: library,
|
|
785
|
+
onUrl: readOnly ? void 0 : (url) => onChange({
|
|
786
|
+
url,
|
|
787
|
+
name: fileNameFromUrl(url) || void 0
|
|
788
|
+
}),
|
|
789
|
+
refuse: up.setError,
|
|
790
|
+
disabled: readOnly,
|
|
791
|
+
progress: up.progress
|
|
792
|
+
}),
|
|
793
|
+
up.error ? /* @__PURE__ */ jsx(Reason, { children: up.error }) : null,
|
|
794
|
+
/* @__PURE__ */ jsx(MediaPicker, {
|
|
795
|
+
open: picker,
|
|
796
|
+
onOpenChange: setPicker,
|
|
797
|
+
accept: kinds,
|
|
798
|
+
onPick: (a) => a[0] && onChange(fromAsset(a[0]))
|
|
799
|
+
})
|
|
800
|
+
]
|
|
801
|
+
});
|
|
802
|
+
const fit = frameFit(size);
|
|
803
|
+
const vector = asset?.kind === "svg" || !!field.svgOnly || /\.svg(?:$|[?#])/i.test(v.url);
|
|
804
|
+
const cap = fit.image && size && !vector ? size : void 0;
|
|
805
|
+
const alt = urlOnly ? asset?.alt : v.alt;
|
|
806
|
+
const name = asset?.name ?? v.name ?? fileNameFromUrl(v.url);
|
|
807
|
+
const replace = (a) => {
|
|
808
|
+
const next = fromAsset(a);
|
|
809
|
+
if (!next.alt && v.alt) next.alt = v.alt;
|
|
810
|
+
if (v.focal) next.focal = v.focal;
|
|
811
|
+
onChange(next);
|
|
812
|
+
};
|
|
813
|
+
const openDetails = () => window.setTimeout(() => setDetails(true), 0);
|
|
814
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
815
|
+
open: details,
|
|
816
|
+
onOpenChange: setDetails,
|
|
817
|
+
children: [
|
|
818
|
+
/* @__PURE__ */ jsxs(PopoverAnchor, {
|
|
819
|
+
className: cn("flex flex-col gap-1.5", env.variant === "document" && "max-w-xl"),
|
|
820
|
+
onPaste: (e) => {
|
|
821
|
+
const files = Array.from(e.clipboardData.files);
|
|
822
|
+
if (files.length && up.run && !readOnly) {
|
|
823
|
+
e.preventDefault();
|
|
824
|
+
up.run(files);
|
|
825
|
+
}
|
|
826
|
+
},
|
|
827
|
+
children: [
|
|
828
|
+
/* @__PURE__ */ jsxs("div", {
|
|
829
|
+
"data-slot": "kit-image-frame",
|
|
830
|
+
"data-frame-ratio": String(fit.frame),
|
|
831
|
+
className: cn("group/img relative overflow-hidden rounded-kit-lg border border-kit-line", CHECKER),
|
|
832
|
+
style: { aspectRatio: fit.frame },
|
|
833
|
+
children: [
|
|
834
|
+
/* @__PURE__ */ jsx("button", {
|
|
835
|
+
id,
|
|
836
|
+
type: "button",
|
|
837
|
+
disabled: readOnly,
|
|
838
|
+
onClick: () => library ? library() : openDetails(),
|
|
839
|
+
"aria-label": library ? `Replace ${field.title}` : `${field.title} details`,
|
|
840
|
+
className: "flex size-full items-center justify-center outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-none",
|
|
841
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
842
|
+
src: src(v.url),
|
|
843
|
+
alt: alt ?? "",
|
|
844
|
+
ref: readNatural,
|
|
845
|
+
onLoad: (e) => readNatural(e.currentTarget),
|
|
846
|
+
"data-fill": fit.fill,
|
|
847
|
+
"data-image-ratio": fit.image ?? void 0,
|
|
848
|
+
"data-cap": cap ? `${cap.w}x${cap.h}` : void 0,
|
|
849
|
+
className: FIT_CLASS[fit.fill],
|
|
850
|
+
style: fit.image ? {
|
|
851
|
+
aspectRatio: fit.image,
|
|
852
|
+
...cap ? {
|
|
853
|
+
maxWidth: `min(100%, ${cap.w}px)`,
|
|
854
|
+
maxHeight: `min(100%, ${cap.h}px)`
|
|
855
|
+
} : {}
|
|
856
|
+
} : void 0
|
|
857
|
+
})
|
|
858
|
+
}),
|
|
859
|
+
readOnly ? null : /* @__PURE__ */ jsxs("div", {
|
|
860
|
+
className: "absolute right-2 top-2 flex gap-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover/img:opacity-100 [@media(pointer:coarse)]:opacity-100",
|
|
861
|
+
children: [library ? /* @__PURE__ */ jsxs("button", {
|
|
862
|
+
type: "button",
|
|
863
|
+
onClick: library,
|
|
864
|
+
className: "flex h-7 items-center gap-1 rounded-full border border-kit-swatch-ring bg-kit-media-control px-2.5 text-kit-xs font-medium text-kit-media-control-fg shadow-kit-sm",
|
|
865
|
+
children: [/* @__PURE__ */ jsx(IconReplace, {
|
|
866
|
+
className: "size-3.5",
|
|
867
|
+
stroke: 1.5,
|
|
868
|
+
"aria-hidden": true
|
|
869
|
+
}), "Replace"]
|
|
870
|
+
}) : null, /* @__PURE__ */ jsx(Tooltip, {
|
|
871
|
+
content: "Remove image",
|
|
872
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
873
|
+
type: "button",
|
|
874
|
+
"aria-label": "Remove image",
|
|
875
|
+
onClick: () => onChange(null),
|
|
876
|
+
className: "flex size-7 items-center justify-center rounded-full border border-kit-swatch-ring bg-kit-media-control text-kit-media-control-fg shadow-kit-sm",
|
|
877
|
+
children: /* @__PURE__ */ jsx(IconX, {
|
|
878
|
+
className: "size-3.5",
|
|
879
|
+
stroke: 1.5,
|
|
880
|
+
"aria-hidden": true
|
|
881
|
+
})
|
|
882
|
+
})
|
|
883
|
+
})]
|
|
884
|
+
}),
|
|
885
|
+
up.progress != null ? /* @__PURE__ */ jsx("div", {
|
|
886
|
+
className: "absolute inset-x-3 bottom-3",
|
|
887
|
+
children: /* @__PURE__ */ jsx(Progress, {
|
|
888
|
+
value: up.progress,
|
|
889
|
+
tone: "ink",
|
|
890
|
+
size: "sm",
|
|
891
|
+
label: "Upload progress"
|
|
892
|
+
})
|
|
893
|
+
}) : null
|
|
894
|
+
]
|
|
895
|
+
}),
|
|
896
|
+
/* @__PURE__ */ jsxs("div", {
|
|
897
|
+
className: "flex min-w-0 items-center gap-1.5 pl-0.5",
|
|
898
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
899
|
+
"data-slot": "kit-image-caption",
|
|
900
|
+
className: "min-w-0 flex-1 truncate text-kit-xs text-kit-fg-3",
|
|
901
|
+
children: [
|
|
902
|
+
name,
|
|
903
|
+
size ? /* @__PURE__ */ jsxs(Fragment, { children: [" · ", /* @__PURE__ */ jsxs("span", {
|
|
904
|
+
className: "tabular-nums",
|
|
905
|
+
children: [
|
|
906
|
+
size.w,
|
|
907
|
+
" × ",
|
|
908
|
+
size.h
|
|
909
|
+
]
|
|
910
|
+
})] }) : null,
|
|
911
|
+
" · ",
|
|
912
|
+
alt ? /* @__PURE__ */ jsx("span", {
|
|
913
|
+
className: "text-kit-fg-2",
|
|
914
|
+
children: "Alt text set"
|
|
915
|
+
}) : /* @__PURE__ */ jsxs("span", {
|
|
916
|
+
className: "inline-flex items-center gap-0.5 text-kit-warning-fg",
|
|
917
|
+
children: [/* @__PURE__ */ jsx(IconAlertTriangle, {
|
|
918
|
+
className: "size-3",
|
|
919
|
+
stroke: 1.5,
|
|
920
|
+
"aria-hidden": true
|
|
921
|
+
}), "No alt text"]
|
|
922
|
+
})
|
|
923
|
+
]
|
|
924
|
+
}), /* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
925
|
+
"aria-label": "Image actions",
|
|
926
|
+
className: "flex size-6 shrink-0 items-center justify-center rounded-kit-md text-kit-fg-3 hover:bg-kit-hover hover:text-kit-fg data-[popup-open]:bg-kit-hover",
|
|
927
|
+
children: /* @__PURE__ */ jsx(IconDots, {
|
|
928
|
+
className: "size-4",
|
|
929
|
+
stroke: 1.5,
|
|
930
|
+
"aria-hidden": true
|
|
931
|
+
})
|
|
932
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
933
|
+
align: "end",
|
|
934
|
+
className: "w-52",
|
|
935
|
+
children: [
|
|
936
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
937
|
+
icon: /* @__PURE__ */ jsx(IconFocusCentered, { stroke: 1.5 }),
|
|
938
|
+
onClick: openDetails,
|
|
939
|
+
children: "Alt text and details"
|
|
940
|
+
}),
|
|
941
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
942
|
+
icon: /* @__PURE__ */ jsx(IconReplace, { stroke: 1.5 }),
|
|
943
|
+
disabled: !library,
|
|
944
|
+
onClick: library,
|
|
945
|
+
children: "Replace"
|
|
946
|
+
}),
|
|
947
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
948
|
+
icon: /* @__PURE__ */ jsx(IconExternalLink, { stroke: 1.5 }),
|
|
949
|
+
onClick: () => window.open(src(v.url), "_blank", "noopener"),
|
|
950
|
+
children: "Open original"
|
|
951
|
+
}),
|
|
952
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
953
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
954
|
+
danger: true,
|
|
955
|
+
icon: /* @__PURE__ */ jsx(IconTrash, { stroke: 1.5 }),
|
|
956
|
+
disabled: readOnly,
|
|
957
|
+
onClick: () => !readOnly && onChange(null),
|
|
958
|
+
children: "Remove"
|
|
959
|
+
})
|
|
960
|
+
]
|
|
961
|
+
})] })]
|
|
962
|
+
}),
|
|
963
|
+
up.error ? /* @__PURE__ */ jsx(Reason, { children: up.error }) : null
|
|
964
|
+
]
|
|
965
|
+
}),
|
|
966
|
+
/* @__PURE__ */ jsx(PopoverContent, {
|
|
967
|
+
className: "w-[320px]",
|
|
968
|
+
align: "start",
|
|
969
|
+
side: "bottom",
|
|
970
|
+
children: /* @__PURE__ */ jsx(ImageDetails, {
|
|
971
|
+
v,
|
|
972
|
+
onChange,
|
|
973
|
+
readOnly,
|
|
974
|
+
label: field.title,
|
|
975
|
+
urlOnly,
|
|
976
|
+
altOnly,
|
|
977
|
+
size,
|
|
978
|
+
asset
|
|
979
|
+
})
|
|
980
|
+
}),
|
|
981
|
+
/* @__PURE__ */ jsx(MediaPicker, {
|
|
982
|
+
open: picker,
|
|
983
|
+
onOpenChange: setPicker,
|
|
984
|
+
accept: kinds,
|
|
985
|
+
onPick: (a) => a[0] && replace(a[0])
|
|
986
|
+
})
|
|
987
|
+
]
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
function Thumb({ item, label, readOnly, sort, onRemove, onOpen }) {
|
|
991
|
+
const { src } = useMedia();
|
|
992
|
+
const handle = sort.handle(item.key);
|
|
993
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
994
|
+
ref: sort.register(item.key),
|
|
995
|
+
role: "listitem",
|
|
996
|
+
style: sort.style(item.key),
|
|
997
|
+
className: cn("group/thumb relative aspect-square cursor-grab touch-none overflow-hidden rounded-kit-md border border-kit-line active:cursor-grabbing", CHECKER, sort.active === item.key && "z-10 opacity-90 shadow-kit-lg ring-2 ring-kit-line-strong"),
|
|
998
|
+
children: [
|
|
999
|
+
/* @__PURE__ */ jsx("div", {
|
|
1000
|
+
...readOnly ? {} : handle,
|
|
1001
|
+
role: void 0,
|
|
1002
|
+
tabIndex: 0,
|
|
1003
|
+
"aria-label": readOnly ? label : `${label}, drag to reorder`,
|
|
1004
|
+
onDoubleClick: onOpen,
|
|
1005
|
+
onKeyDown: (e) => {
|
|
1006
|
+
if (!readOnly && (e.key === "Delete" || e.key === "Backspace")) {
|
|
1007
|
+
e.preventDefault();
|
|
1008
|
+
onRemove();
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
if (e.key === "Enter") {
|
|
1012
|
+
e.preventDefault();
|
|
1013
|
+
onOpen();
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
if (!readOnly) handle.onKeyDown(e);
|
|
1017
|
+
},
|
|
1018
|
+
className: "size-full outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-kit-focus-ring focus-visible:[outline-style:solid] [html[data-input-modality=pointer]_&]:focus-visible:outline-none",
|
|
1019
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
1020
|
+
src: src(item.v.url),
|
|
1021
|
+
alt: item.v.alt ?? "",
|
|
1022
|
+
"data-slot": "kit-gallery-thumb",
|
|
1023
|
+
className: "pointer-events-none size-full select-none object-contain",
|
|
1024
|
+
draggable: false
|
|
1025
|
+
})
|
|
1026
|
+
}),
|
|
1027
|
+
!item.v.alt ? /* @__PURE__ */ jsx("span", {
|
|
1028
|
+
role: "img",
|
|
1029
|
+
className: "absolute bottom-1 left-1 size-1.5 rounded-full bg-kit-warning ring-2 ring-kit-surface",
|
|
1030
|
+
"aria-label": "No alt text"
|
|
1031
|
+
}) : null,
|
|
1032
|
+
readOnly ? null : /* @__PURE__ */ jsx("button", {
|
|
1033
|
+
type: "button",
|
|
1034
|
+
"aria-label": (() => {
|
|
1035
|
+
const what = item.v.alt || item.v.name || fileNameFromUrl(item.v.url);
|
|
1036
|
+
return what ? `Remove ${what}` : "Remove image";
|
|
1037
|
+
})(),
|
|
1038
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
1039
|
+
onClick: onRemove,
|
|
1040
|
+
className: "absolute right-1 top-1 flex size-6 items-center justify-center rounded-kit-md bg-kit-inverse/80 text-kit-fg-inverse opacity-0 transition-opacity focus-visible:opacity-100 group-hover/thumb:opacity-100 pointer-coarse:opacity-100",
|
|
1041
|
+
children: /* @__PURE__ */ jsx(IconX, {
|
|
1042
|
+
className: "size-3.5",
|
|
1043
|
+
stroke: 1.5,
|
|
1044
|
+
"aria-hidden": true
|
|
1045
|
+
})
|
|
1046
|
+
})
|
|
1047
|
+
]
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
/** An array of images: a sortable grid of tiles with a dashed "Add images" tile last (hidden at `max`). */
|
|
1051
|
+
function GalleryControl({ value, onChange, readOnly, field, id, path }) {
|
|
1052
|
+
const { s, src } = useMedia();
|
|
1053
|
+
const env = useKitEnv();
|
|
1054
|
+
const raw = Array.isArray(value) ? value : [];
|
|
1055
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1056
|
+
const items = raw.map((x) => {
|
|
1057
|
+
const v = normImage(x) ?? { url: "" };
|
|
1058
|
+
const base = v.id ?? v.url;
|
|
1059
|
+
const n = seen.get(base) ?? 0;
|
|
1060
|
+
seen.set(base, n + 1);
|
|
1061
|
+
return {
|
|
1062
|
+
key: n ? `${base}#${n}` : base,
|
|
1063
|
+
v,
|
|
1064
|
+
raw: x
|
|
1065
|
+
};
|
|
1066
|
+
});
|
|
1067
|
+
const asStrings = raw.length > 0 && raw.every((x) => typeof x === "string");
|
|
1068
|
+
const out = (v) => asStrings && !v.alt && !v.focal ? v.url : v;
|
|
1069
|
+
const write = (list) => onChange(list);
|
|
1070
|
+
const add = (assets) => write([...raw, ...assets.map((a) => out(fromAsset(a)))]);
|
|
1071
|
+
const [picker, setPicker] = React.useState(false);
|
|
1072
|
+
const up = useUpload("image/*", "image", add);
|
|
1073
|
+
const keys = items.map((it) => it.key);
|
|
1074
|
+
const sort = useDragReorder(keys, (from, to) => {
|
|
1075
|
+
const next = [...raw];
|
|
1076
|
+
const [moved] = next.splice(from, 1);
|
|
1077
|
+
next.splice(to, 0, moved);
|
|
1078
|
+
write(next);
|
|
1079
|
+
}, {
|
|
1080
|
+
axis: "grid",
|
|
1081
|
+
disabled: readOnly
|
|
1082
|
+
});
|
|
1083
|
+
const max = field.validation?.max;
|
|
1084
|
+
const canAdd = !readOnly && (max == null || items.length < max) && (s.MediaPicker || up.run);
|
|
1085
|
+
const noun = (i, it) => it.v.name ?? (fileNameFromUrl(it.v.url) || `Image ${i + 1}`);
|
|
1086
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1087
|
+
className: "flex flex-col gap-2",
|
|
1088
|
+
children: [
|
|
1089
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1090
|
+
id,
|
|
1091
|
+
role: "list",
|
|
1092
|
+
"aria-label": field.title,
|
|
1093
|
+
className: "grid grid-cols-3 gap-1.5 @[520px]:grid-cols-5",
|
|
1094
|
+
children: [items.map((it, i) => /* @__PURE__ */ jsx(Thumb, {
|
|
1095
|
+
item: it,
|
|
1096
|
+
label: noun(i, it),
|
|
1097
|
+
readOnly,
|
|
1098
|
+
sort,
|
|
1099
|
+
onOpen: () => s.editImage && !readOnly ? s.editImage({
|
|
1100
|
+
docId: env.docId,
|
|
1101
|
+
path: [...path, i],
|
|
1102
|
+
title: noun(i, it)
|
|
1103
|
+
}) : window.open(src(it.v.url), "_blank", "noopener"),
|
|
1104
|
+
onRemove: () => write(raw.filter((_, j) => j !== i))
|
|
1105
|
+
}, it.key)), canAdd ? /* @__PURE__ */ jsx("div", {
|
|
1106
|
+
role: "listitem",
|
|
1107
|
+
className: "grid",
|
|
1108
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
1109
|
+
type: "button",
|
|
1110
|
+
onClick: () => s.MediaPicker ? setPicker(true) : up.run && document.getElementById(`${id}-files`)?.click(),
|
|
1111
|
+
onPaste: (e) => {
|
|
1112
|
+
const files = Array.from(e.clipboardData.files);
|
|
1113
|
+
if (files.length && up.run) {
|
|
1114
|
+
e.preventDefault();
|
|
1115
|
+
up.run(files);
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
onDragOver: (e) => up.run && e.preventDefault(),
|
|
1119
|
+
onDrop: (e) => {
|
|
1120
|
+
if (!up.run) return;
|
|
1121
|
+
e.preventDefault();
|
|
1122
|
+
up.run(Array.from(e.dataTransfer.files));
|
|
1123
|
+
},
|
|
1124
|
+
className: "flex aspect-square flex-col items-center justify-center gap-1 rounded-kit-md border border-dashed border-kit-line-strong bg-kit-subtle text-kit-xs text-kit-fg-3 transition-colors hover:border-kit-field-border-hover hover:text-kit-fg",
|
|
1125
|
+
children: [/* @__PURE__ */ jsx(IconPlus, {
|
|
1126
|
+
className: "size-4",
|
|
1127
|
+
stroke: 1.5,
|
|
1128
|
+
"aria-hidden": true
|
|
1129
|
+
}), "Add images"]
|
|
1130
|
+
})
|
|
1131
|
+
}) : null]
|
|
1132
|
+
}),
|
|
1133
|
+
sort.a11y,
|
|
1134
|
+
up.run && !s.MediaPicker ? /* @__PURE__ */ jsx("input", {
|
|
1135
|
+
id: `${id}-files`,
|
|
1136
|
+
type: "file",
|
|
1137
|
+
hidden: true,
|
|
1138
|
+
tabIndex: -1,
|
|
1139
|
+
"aria-hidden": true,
|
|
1140
|
+
accept: "image/*",
|
|
1141
|
+
multiple: true,
|
|
1142
|
+
onChange: (e) => {
|
|
1143
|
+
up.run?.(Array.from(e.target.files ?? []));
|
|
1144
|
+
e.target.value = "";
|
|
1145
|
+
}
|
|
1146
|
+
}) : null,
|
|
1147
|
+
up.progress != null ? /* @__PURE__ */ jsx(Progress, {
|
|
1148
|
+
value: up.progress,
|
|
1149
|
+
tone: "ink",
|
|
1150
|
+
size: "sm",
|
|
1151
|
+
label: "Upload progress"
|
|
1152
|
+
}) : null,
|
|
1153
|
+
up.error ? /* @__PURE__ */ jsx(Reason, { children: up.error }) : null,
|
|
1154
|
+
!readOnly && !s.MediaPicker && !up.run ? /* @__PURE__ */ jsx(Reason, {
|
|
1155
|
+
tone: "muted",
|
|
1156
|
+
children: NO_SOURCE
|
|
1157
|
+
}) : null,
|
|
1158
|
+
/* @__PURE__ */ jsx(MediaPicker, {
|
|
1159
|
+
open: picker,
|
|
1160
|
+
onOpenChange: setPicker,
|
|
1161
|
+
multiple: true,
|
|
1162
|
+
accept: ["image", "svg"],
|
|
1163
|
+
onPick: (a) => a.length && add(max != null ? a.slice(0, Math.max(0, max - items.length)) : a)
|
|
1164
|
+
})
|
|
1165
|
+
]
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
var normFile = (v) => {
|
|
1169
|
+
if (typeof v === "string") return v ? { url: v } : null;
|
|
1170
|
+
return isObj(v) && typeof v.url === "string" && v.url ? v : null;
|
|
1171
|
+
};
|
|
1172
|
+
var fileFromAsset = (a) => ({
|
|
1173
|
+
url: a.url,
|
|
1174
|
+
id: a.id,
|
|
1175
|
+
...a.name ? { name: a.name } : {}
|
|
1176
|
+
});
|
|
1177
|
+
function FileControl({ value, onChange, readOnly, id }) {
|
|
1178
|
+
const { s, useAsset, src } = useMedia();
|
|
1179
|
+
const v = normFile(value);
|
|
1180
|
+
const asset = useAsset({
|
|
1181
|
+
id: v?.id,
|
|
1182
|
+
url: v?.url ?? ""
|
|
1183
|
+
});
|
|
1184
|
+
const [picker, setPicker] = React.useState(false);
|
|
1185
|
+
const up = useUpload("*", "file", (a) => a[0] && onChange(fileFromAsset(a[0])));
|
|
1186
|
+
const library = s.MediaPicker && !readOnly ? () => setPicker(true) : void 0;
|
|
1187
|
+
const pickerEl = /* @__PURE__ */ jsx(MediaPicker, {
|
|
1188
|
+
open: picker,
|
|
1189
|
+
onOpenChange: setPicker,
|
|
1190
|
+
accept: ["file"],
|
|
1191
|
+
onPick: (a) => a[0] && onChange(fileFromAsset(a[0]))
|
|
1192
|
+
});
|
|
1193
|
+
if (!v) return /* @__PURE__ */ jsxs("div", {
|
|
1194
|
+
className: "flex flex-col gap-1.5",
|
|
1195
|
+
children: [
|
|
1196
|
+
/* @__PURE__ */ jsx(DropWell, {
|
|
1197
|
+
id,
|
|
1198
|
+
title: "Add a file",
|
|
1199
|
+
hint: "Or drop or paste one here",
|
|
1200
|
+
accept: "*",
|
|
1201
|
+
icon: /* @__PURE__ */ jsx(IconFileText, { stroke: 1.5 }),
|
|
1202
|
+
onFiles: up.run,
|
|
1203
|
+
onLibrary: library,
|
|
1204
|
+
refuse: up.setError,
|
|
1205
|
+
disabled: readOnly,
|
|
1206
|
+
progress: up.progress
|
|
1207
|
+
}),
|
|
1208
|
+
up.error ? /* @__PURE__ */ jsx(Reason, { children: up.error }) : null,
|
|
1209
|
+
pickerEl
|
|
1210
|
+
]
|
|
1211
|
+
});
|
|
1212
|
+
const name = asset?.name ?? v.name ?? fileNameFromUrl(v.url);
|
|
1213
|
+
const ext = (name.includes(".") ? name.split(".").pop() : "")?.toUpperCase() || "FILE";
|
|
1214
|
+
const meta = [ext.toLowerCase(), asset?.size ? formatBytes(asset.size) : null].filter(Boolean).join(" · ");
|
|
1215
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1216
|
+
className: "flex items-center gap-3 rounded-kit-lg border border-kit-line bg-kit-control-bg p-2",
|
|
1217
|
+
children: [
|
|
1218
|
+
/* @__PURE__ */ jsx("span", {
|
|
1219
|
+
"aria-hidden": true,
|
|
1220
|
+
className: "flex size-14 shrink-0 items-center justify-center rounded-kit-md border border-kit-line bg-kit-subtle font-kit-mono text-kit-2xs font-medium text-kit-fg-2",
|
|
1221
|
+
children: ext
|
|
1222
|
+
}),
|
|
1223
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1224
|
+
className: "min-w-0 flex-1",
|
|
1225
|
+
children: [/* @__PURE__ */ jsx("a", {
|
|
1226
|
+
id,
|
|
1227
|
+
href: src(v.url),
|
|
1228
|
+
target: "_blank",
|
|
1229
|
+
rel: "noreferrer",
|
|
1230
|
+
className: "block truncate text-kit-sm font-medium text-kit-accent-fg hover:underline",
|
|
1231
|
+
children: name
|
|
1232
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
1233
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
1234
|
+
children: meta
|
|
1235
|
+
})]
|
|
1236
|
+
}),
|
|
1237
|
+
library ? /* @__PURE__ */ jsx(Button, {
|
|
1238
|
+
size: "sm",
|
|
1239
|
+
variant: "ghost",
|
|
1240
|
+
onClick: library,
|
|
1241
|
+
children: "Replace"
|
|
1242
|
+
}) : null,
|
|
1243
|
+
/* @__PURE__ */ jsxs(Menu, { children: [/* @__PURE__ */ jsx(MenuTrigger, {
|
|
1244
|
+
render: /* @__PURE__ */ jsx(IconButton, {
|
|
1245
|
+
label: "File actions",
|
|
1246
|
+
size: "sm"
|
|
1247
|
+
}),
|
|
1248
|
+
children: /* @__PURE__ */ jsx(IconDots, { stroke: 1.5 })
|
|
1249
|
+
}), /* @__PURE__ */ jsxs(MenuContent, {
|
|
1250
|
+
align: "end",
|
|
1251
|
+
children: [
|
|
1252
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1253
|
+
icon: /* @__PURE__ */ jsx(IconDownload, { stroke: 1.5 }),
|
|
1254
|
+
onClick: () => window.open(src(v.url), "_blank", "noopener"),
|
|
1255
|
+
children: "Open"
|
|
1256
|
+
}),
|
|
1257
|
+
/* @__PURE__ */ jsx(MenuSeparator, {}),
|
|
1258
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1259
|
+
danger: true,
|
|
1260
|
+
icon: /* @__PURE__ */ jsx(IconTrash, { stroke: 1.5 }),
|
|
1261
|
+
disabled: readOnly,
|
|
1262
|
+
onClick: () => !readOnly && onChange(null),
|
|
1263
|
+
children: "Remove"
|
|
1264
|
+
})
|
|
1265
|
+
]
|
|
1266
|
+
})] }),
|
|
1267
|
+
pickerEl
|
|
1268
|
+
]
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
var videoProvider = (url) => /youtu/.test(url) ? "YouTube" : /vimeo/.test(url) ? "Vimeo" : /loom/.test(url) ? "Loom" : /\.(mp4|webm|mov)(\?|$)/i.test(url) ? "MP4" : url ? "Link" : "";
|
|
1272
|
+
var youTubeId = (url) => url.match(/(?:youtu\.be\/|v=|embed\/|shorts\/)([\w-]{11})/)?.[1];
|
|
1273
|
+
var isFileVideo = (url) => /\.(mp4|webm|mov)(\?|$)/i.test(url);
|
|
1274
|
+
function VideoPreview({ url, poster, title }) {
|
|
1275
|
+
const { src } = useMedia();
|
|
1276
|
+
const [playing, setPlaying] = React.useState(false);
|
|
1277
|
+
React.useEffect(() => setPlaying(false), [url]);
|
|
1278
|
+
const yt = youTubeId(url);
|
|
1279
|
+
const thumb = poster ? src(poster) : yt ? `https://i.ytimg.com/vi/${yt}/hqdefault.jpg` : void 0;
|
|
1280
|
+
if (playing && yt) return /* @__PURE__ */ jsx("iframe", {
|
|
1281
|
+
title,
|
|
1282
|
+
src: `https://www.youtube-nocookie.com/embed/${yt}?autoplay=1`,
|
|
1283
|
+
allow: "autoplay; encrypted-media",
|
|
1284
|
+
className: "aspect-video w-full rounded-kit-lg border border-kit-line"
|
|
1285
|
+
});
|
|
1286
|
+
if (playing && isFileVideo(url)) return /* @__PURE__ */ jsx("video", {
|
|
1287
|
+
src: src(url),
|
|
1288
|
+
poster: thumb,
|
|
1289
|
+
controls: true,
|
|
1290
|
+
autoPlay: true,
|
|
1291
|
+
className: "aspect-video w-full rounded-kit-lg border border-kit-line bg-kit-media-backdrop"
|
|
1292
|
+
});
|
|
1293
|
+
const playable = !!yt || isFileVideo(url);
|
|
1294
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1295
|
+
className: "relative aspect-video overflow-hidden rounded-kit-lg border border-kit-line bg-kit-media-backdrop",
|
|
1296
|
+
children: [
|
|
1297
|
+
thumb ? /* @__PURE__ */ jsx("img", {
|
|
1298
|
+
src: thumb,
|
|
1299
|
+
alt: `${title} poster`,
|
|
1300
|
+
className: "size-full object-cover opacity-85"
|
|
1301
|
+
}) : null,
|
|
1302
|
+
/* @__PURE__ */ jsx("button", {
|
|
1303
|
+
type: "button",
|
|
1304
|
+
"aria-label": playable ? "Play preview" : "Open video link",
|
|
1305
|
+
onClick: () => playable ? setPlaying(true) : window.open(src(url), "_blank", "noopener"),
|
|
1306
|
+
className: "absolute inset-0 m-auto flex size-12 items-center justify-center rounded-full bg-kit-media-control text-kit-media-control-fg shadow-kit-lg transition-transform hover:scale-105",
|
|
1307
|
+
children: playable ? /* @__PURE__ */ jsx(IconPlayerPlay, {
|
|
1308
|
+
className: "size-5",
|
|
1309
|
+
stroke: 1.5,
|
|
1310
|
+
"aria-hidden": true
|
|
1311
|
+
}) : /* @__PURE__ */ jsx(IconExternalLink, {
|
|
1312
|
+
className: "size-5",
|
|
1313
|
+
stroke: 1.5,
|
|
1314
|
+
"aria-hidden": true
|
|
1315
|
+
})
|
|
1316
|
+
}),
|
|
1317
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1318
|
+
className: "absolute left-2 top-2 inline-flex items-center gap-1 rounded-kit-md bg-kit-scrim px-1.5 py-0.5 text-kit-xs text-kit-on-scrim",
|
|
1319
|
+
children: [/* @__PURE__ */ jsx(IconVideo, {
|
|
1320
|
+
className: "size-3.5",
|
|
1321
|
+
stroke: 1.5,
|
|
1322
|
+
"aria-hidden": true
|
|
1323
|
+
}), videoProvider(url)]
|
|
1324
|
+
})
|
|
1325
|
+
]
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* A URL input with a live preview. The value keeps its stored shape: a URL string stays a string, a `{ url, poster… }`
|
|
1330
|
+
* object keeps its other keys. What is typed is a draft until it is an address prod stores (http(s) or a site path);
|
|
1331
|
+
* until then the field keeps the saved value and says why under the input.
|
|
1332
|
+
*/
|
|
1333
|
+
function VideoControl({ field, value, onChange, readOnly, id, onBlur }) {
|
|
1334
|
+
const obj = isObj(value) && typeof value.url === "string" ? value : null;
|
|
1335
|
+
const stored = typeof value === "string" ? value : obj?.url ?? "";
|
|
1336
|
+
const [draft, setDraft] = React.useState(stored);
|
|
1337
|
+
const [touched, setTouched] = React.useState(false);
|
|
1338
|
+
React.useEffect(() => setDraft(stored), [stored]);
|
|
1339
|
+
const commit = (raw) => {
|
|
1340
|
+
const url = raw.trim();
|
|
1341
|
+
if (url === stored || !isVideoUrl(url)) return;
|
|
1342
|
+
if (url === "") return onChange(obj ? null : "");
|
|
1343
|
+
onChange(obj ? {
|
|
1344
|
+
...obj,
|
|
1345
|
+
url
|
|
1346
|
+
} : url);
|
|
1347
|
+
};
|
|
1348
|
+
const bad = draft.trim() !== "" && !isVideoUrl(draft);
|
|
1349
|
+
const errorId = `${id}-error`;
|
|
1350
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1351
|
+
className: "flex flex-col gap-2",
|
|
1352
|
+
children: [
|
|
1353
|
+
/* @__PURE__ */ jsx(Input, {
|
|
1354
|
+
id,
|
|
1355
|
+
value: draft,
|
|
1356
|
+
readOnly,
|
|
1357
|
+
"aria-invalid": bad && touched ? true : void 0,
|
|
1358
|
+
"aria-describedby": bad && touched ? errorId : void 0,
|
|
1359
|
+
onBlur: () => {
|
|
1360
|
+
setTouched(true);
|
|
1361
|
+
onBlur?.();
|
|
1362
|
+
},
|
|
1363
|
+
onKeyDown: (e) => {
|
|
1364
|
+
if (e.key === "Escape" && draft !== stored) {
|
|
1365
|
+
e.stopPropagation();
|
|
1366
|
+
setDraft(stored);
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
placeholder: "Paste a YouTube, Vimeo, Loom or MP4 link",
|
|
1370
|
+
leading: /* @__PURE__ */ jsx(IconWorld, { stroke: 1.5 }),
|
|
1371
|
+
onChange: (e) => {
|
|
1372
|
+
setDraft(e.target.value);
|
|
1373
|
+
commit(e.target.value);
|
|
1374
|
+
}
|
|
1375
|
+
}),
|
|
1376
|
+
bad && touched ? /* @__PURE__ */ jsx("p", {
|
|
1377
|
+
id: errorId,
|
|
1378
|
+
role: "alert",
|
|
1379
|
+
className: "text-kit-xs text-kit-danger-fg",
|
|
1380
|
+
children: "Not saved: use a full link starting with https://, or a site path starting with /."
|
|
1381
|
+
}) : null,
|
|
1382
|
+
stored ? /* @__PURE__ */ jsx(VideoPreview, {
|
|
1383
|
+
url: stored,
|
|
1384
|
+
poster: obj?.poster,
|
|
1385
|
+
title: field.title
|
|
1386
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
1387
|
+
className: "text-kit-xs text-kit-fg-3",
|
|
1388
|
+
children: "No video yet. The embed lazy-loads on the page, so it doesn't block the first paint."
|
|
1389
|
+
})
|
|
1390
|
+
]
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
//#endregion
|
|
1394
|
+
export { FileControl, GalleryControl, ImageControl, MediaPicker, VideoControl, VideoPreview, acceptsFile, cropChoice, fileNameFromUrl, formatBytes, frameFit, fromAsset, isVideoUrl, normImage, useUpload, videoProvider, withCrop, youTubeId };
|
|
1395
|
+
|
|
1396
|
+
//# sourceMappingURL=media.js.map
|