@dicehub/kappa 0.6.0 → 0.6.1
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/CHANGELOG.md +11 -0
- package/dist/{DeleteResource-vqXN2M_j.js → DeleteResource-JDnPWd7H.js} +2 -2
- package/dist/{DeleteResource-vqXN2M_j.js.map → DeleteResource-JDnPWd7H.js.map} +1 -1
- package/dist/{ImageCropper-Dfjf3OuM.js → ImageCropper-B-8niGGr.js} +24 -28
- package/dist/{ImageCropper-Dfjf3OuM.js.map → ImageCropper-B-8niGGr.js.map} +1 -1
- package/dist/{ResourcePicker-BbzGyL_F.js → ResourcePicker-Ctmc4QxZ.js} +2 -2
- package/dist/{ResourcePicker-BbzGyL_F.js.map → ResourcePicker-Ctmc4QxZ.js.map} +1 -1
- package/dist/blocks/delete-resource.js +1 -1
- package/dist/blocks/file-browser.js +1 -1
- package/dist/blocks/resource-picker.js +1 -1
- package/dist/{checkbox-DAdzHZnd.js → checkbox-DgwmE-kd.js} +50 -40
- package/dist/checkbox-DgwmE-kd.js.map +1 -0
- package/dist/components/checkbox/CheckboxHiddenInput.vue.d.ts +3 -0
- package/dist/components/checkbox.js +1 -1
- package/dist/components/code-highlighted.js +1 -1
- package/dist/components/code-highlighted.js.map +1 -1
- package/dist/components/data-grid.js +1 -1
- package/dist/components/dialog-layout.js +1 -1
- package/dist/components/image-cropper/image-cropper-source.d.ts +1 -6
- package/dist/components/image-cropper.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/table.js +1 -1
- package/dist/{data-grid-BWXpMwCT.js → data-grid-CobgDr8q.js} +2 -2
- package/dist/{data-grid-BWXpMwCT.js.map → data-grid-CobgDr8q.js.map} +1 -1
- package/dist/{dialog-layout-BG_HOOgK.js → dialog-layout-DLOoWtT1.js} +2 -2
- package/dist/{dialog-layout-BG_HOOgK.js.map → dialog-layout-DLOoWtT1.js.map} +1 -1
- package/dist/{file-browser-tqo1PirD.js → file-browser-CGqaz2eI.js} +4 -4
- package/dist/{file-browser-tqo1PirD.js.map → file-browser-CGqaz2eI.js.map} +1 -1
- package/dist/index.js +43 -43
- package/dist/registry/component-registry.json +1 -1
- package/dist/registry/generated.d.ts +1 -1
- package/dist/{registry-Bt3InMf5.js → registry-CWDzoZaA.js} +3 -3
- package/dist/{registry-Bt3InMf5.js.map → registry-CWDzoZaA.js.map} +1 -1
- package/dist/registry.js +1 -1
- package/dist/styles/kappa.css +1 -1
- package/dist/{table-GDu-HsB6.js → table-B3iRrutc.js} +2 -2
- package/dist/{table-GDu-HsB6.js.map → table-B3iRrutc.js.map} +1 -1
- package/package.json +2 -2
- package/dist/checkbox-DAdzHZnd.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @dicehub/kappa
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Keep Banner action text readable on hover in both themes.
|
|
8
|
+
- 1c3595b: Restore the native checked and mixed states when an application rejects a checkbox update. Keep accessible state and submitted form values aligned with controlled roots, providers, and groups.
|
|
9
|
+
- 1c3595b: Return `null` for unsupported code languages such as `__proto__` and `constructor`.
|
|
10
|
+
- 1c3595b: Keep Dialog and DialogLayout parts independent when both are imported. Preserve Dialog's header and custom close slot.
|
|
11
|
+
- 1c3595b: Restore progressAnatomy, useProgress, and useProgressContext imports from the package root.
|
|
12
|
+
- 1c3595b: Return undefined for unknown registry names, including inherited object keys.
|
|
13
|
+
|
|
3
14
|
## 0.6.0
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./banner-DJkCoAw-.js";
|
|
2
|
-
import { t } from "./dialog-layout-
|
|
2
|
+
import { t } from "./dialog-layout-DLOoWtT1.js";
|
|
3
3
|
import { t as n } from "./input-C2XpksEe.js";
|
|
4
4
|
import { computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, mergeDefaults as d, mergeProps as f, openBlock as p, ref as m, renderSlot as h, toDisplayString as g, unref as _, useId as v, watch as y, withCtx as b, withModifiers as x } from "vue";
|
|
5
5
|
//#region src/blocks/delete-resource/delete-resource.ts
|
|
@@ -159,4 +159,4 @@ var S = {
|
|
|
159
159
|
//#endregion
|
|
160
160
|
export { S as n, T as t };
|
|
161
161
|
|
|
162
|
-
//# sourceMappingURL=DeleteResource-
|
|
162
|
+
//# sourceMappingURL=DeleteResource-JDnPWd7H.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteResource-vqXN2M_j.js","names":["$slots","$attrs"],"sources":["../src/blocks/delete-resource/delete-resource.ts","../src/blocks/delete-resource/DeleteResource.vue","../src/blocks/delete-resource/DeleteResource.vue"],"sourcesContent":["import type { VNodeChild } from \"vue\";\nimport type { DialogOpenChangeDetails, DialogProps } from \"../../components/dialog/dialog\";\n\nexport interface DeleteResourceProps {\n /** Name of the resource being removed. */\n resourceName: string;\n /** Controlled dialog visibility. The consumer closes it after successful deletion. */\n open?: boolean;\n /** Initial visibility when open is not controlled. */\n defaultOpen?: boolean;\n /** Requires an exact, case-sensitive resource-name match before confirmation. */\n requireName?: boolean;\n /** Blocks confirmation, cancellation, and Escape while a request is pending. */\n deleting?: boolean;\n /** Disables confirmation, for example when the resource cannot be removed. */\n disabled?: boolean;\n /** Request failure shown in an announced error banner. Does not block retry. */\n error?: string;\n title?: string;\n description?: string;\n confirmLabel?: string;\n deletingLabel?: string;\n cancelLabel?: string;\n confirmationLabel?: string;\n /** Focus destination on close, useful for programmatically opened dialogs. */\n finalFocusEl?: DialogProps[\"finalFocusEl\"];\n}\n\nexport type DeleteResourceEmits = {\n /** Requests deletion. No network call or automatic close is performed. */\n confirm: [];\n openChange: [details: DialogOpenChangeDetails];\n \"update:open\": [open: boolean];\n};\n\nexport interface DeleteResourceSlots {\n /** One button. Wrapped in Dialog.Trigger with asChild. */\n trigger?: () => VNodeChild;\n /** Optional context or consequences below the resource name. */\n default?: () => VNodeChild;\n}\n\nexport const DELETE_RESOURCE_DEFAULTS = {\n title: \"Delete resource?\",\n description: \"This action cannot be undone.\",\n confirmLabel: \"Delete resource\",\n deletingLabel: \"Deleting…\",\n cancelLabel: \"Cancel\",\n confirmationLabel: \"Type the resource name to confirm\",\n} as const;\n","<script setup lang=\"ts\">\nimport { computed, ref, useId, watch } from \"vue\";\nimport { Banner } from \"../../components/banner\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Input } from \"../../components/input\";\nimport type { DialogOpenChangeDetails } from \"../../components/dialog/dialog\";\nimport {\n DELETE_RESOURCE_DEFAULTS,\n type DeleteResourceEmits,\n type DeleteResourceProps,\n type DeleteResourceSlots,\n} from \"./delete-resource\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(defineProps<DeleteResourceProps>(), {\n ...DELETE_RESOURCE_DEFAULTS,\n open: undefined,\n defaultOpen: false,\n requireName: false,\n deleting: false,\n disabled: false,\n error: undefined,\n finalFocusEl: undefined,\n});\nconst emit = defineEmits<DeleteResourceEmits>();\ndefineSlots<DeleteResourceSlots>();\n\nconst inputId = `kappa-delete-resource-${useId()}`;\nconst resourceId = `${inputId}-name`;\nconst internalOpen = ref(props.defaultOpen);\nconst confirmation = ref(\"\");\nconst formEl = ref<HTMLFormElement | null>(null);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\nconst canConfirm = computed(() => !props.disabled && !props.deleting && (\n !props.requireName || (\n props.resourceName.length > 0 && confirmation.value === props.resourceName\n )\n));\n\n// Each opening and each new resource requires a fresh, explicit confirmation.\nwatch([isOpen, () => props.resourceName, () => props.requireName], () => {\n confirmation.value = \"\";\n});\n\nfunction onOpenChange(details: DialogOpenChangeDetails) {\n if (!details.open && props.deleting) return;\n internalOpen.value = details.open;\n emit(\"update:open\", details.open);\n emit(\"openChange\", details);\n}\n\nfunction initialFocusEl() {\n if (props.requireName) return formEl.value?.ownerDocument.getElementById(inputId) ?? null;\n return formEl.value?.querySelector<HTMLElement>(\n '[data-slot=\"dialog-layout-actions\"] button:not(:disabled)',\n ) ?? null;\n}\n\nfunction confirm() {\n if (canConfirm.value) emit(\"confirm\");\n}\n</script>\n\n<template>\n <DialogLayout.Alert\n :open=\"isOpen\"\n :close-on-escape=\"!props.deleting\"\n :disable-pointer-dismissal=\"true\"\n :initial-focus-el=\"initialFocusEl\"\n :final-focus-el=\"props.finalFocusEl\"\n @open-change=\"onOpenChange\"\n >\n <DialogLayout.Trigger v-if=\"$slots.trigger\" as-child>\n <slot name=\"trigger\" />\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-delete-resource\"\n data-slot=\"delete-resource\"\n :aria-busy=\"props.deleting || undefined\"\n :show-close-button=\"false\"\n size=\"sm\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description>{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <form ref=\"formEl\" class=\"kappa-delete-resource__form\" @submit.prevent=\"confirm\">\n <DialogLayout.Body class=\"kappa-delete-resource__body\">\n <p :id=\"resourceId\" class=\"kappa-delete-resource__name\">{{ props.resourceName }}</p>\n <div v-if=\"$slots.default\" class=\"kappa-delete-resource__details\"><slot /></div>\n <div v-if=\"props.requireName\" class=\"kappa-delete-resource__confirmation\">\n <label :for=\"inputId\">{{ props.confirmationLabel }}</label>\n <Input\n :id=\"inputId\"\n v-model=\"confirmation\"\n :aria-describedby=\"resourceId\"\n :readonly=\"props.deleting\"\n :password-manager-ignore=\"true\"\n autocomplete=\"off\"\n autocapitalize=\"none\"\n :spellcheck=\"false\"\n />\n </div>\n <Banner v-if=\"props.error\" role=\"alert\" variant=\"error\" size=\"sm\">\n {{ props.error }}\n </Banner>\n </DialogLayout.Body>\n <DialogLayout.Actions\n :dismiss-label=\"props.cancelLabel\"\n :dismiss-disabled=\"props.deleting\"\n >\n <DialogLayout.Actions.Primary\n type=\"submit\"\n variant=\"destructive\"\n :disabled=\"!canConfirm\"\n :loading=\"props.deleting\"\n >\n {{ props.deleting ? props.deletingLabel : props.confirmLabel }}\n </DialogLayout.Actions.Primary>\n </DialogLayout.Actions>\n </form>\n </DialogLayout.Content>\n </DialogLayout.Alert>\n</template>\n\n<style src=\"./delete-resource.css\"></style>\n","<script setup lang=\"ts\">\nimport { computed, ref, useId, watch } from \"vue\";\nimport { Banner } from \"../../components/banner\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Input } from \"../../components/input\";\nimport type { DialogOpenChangeDetails } from \"../../components/dialog/dialog\";\nimport {\n DELETE_RESOURCE_DEFAULTS,\n type DeleteResourceEmits,\n type DeleteResourceProps,\n type DeleteResourceSlots,\n} from \"./delete-resource\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(defineProps<DeleteResourceProps>(), {\n ...DELETE_RESOURCE_DEFAULTS,\n open: undefined,\n defaultOpen: false,\n requireName: false,\n deleting: false,\n disabled: false,\n error: undefined,\n finalFocusEl: undefined,\n});\nconst emit = defineEmits<DeleteResourceEmits>();\ndefineSlots<DeleteResourceSlots>();\n\nconst inputId = `kappa-delete-resource-${useId()}`;\nconst resourceId = `${inputId}-name`;\nconst internalOpen = ref(props.defaultOpen);\nconst confirmation = ref(\"\");\nconst formEl = ref<HTMLFormElement | null>(null);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\nconst canConfirm = computed(() => !props.disabled && !props.deleting && (\n !props.requireName || (\n props.resourceName.length > 0 && confirmation.value === props.resourceName\n )\n));\n\n// Each opening and each new resource requires a fresh, explicit confirmation.\nwatch([isOpen, () => props.resourceName, () => props.requireName], () => {\n confirmation.value = \"\";\n});\n\nfunction onOpenChange(details: DialogOpenChangeDetails) {\n if (!details.open && props.deleting) return;\n internalOpen.value = details.open;\n emit(\"update:open\", details.open);\n emit(\"openChange\", details);\n}\n\nfunction initialFocusEl() {\n if (props.requireName) return formEl.value?.ownerDocument.getElementById(inputId) ?? null;\n return formEl.value?.querySelector<HTMLElement>(\n '[data-slot=\"dialog-layout-actions\"] button:not(:disabled)',\n ) ?? null;\n}\n\nfunction confirm() {\n if (canConfirm.value) emit(\"confirm\");\n}\n</script>\n\n<template>\n <DialogLayout.Alert\n :open=\"isOpen\"\n :close-on-escape=\"!props.deleting\"\n :disable-pointer-dismissal=\"true\"\n :initial-focus-el=\"initialFocusEl\"\n :final-focus-el=\"props.finalFocusEl\"\n @open-change=\"onOpenChange\"\n >\n <DialogLayout.Trigger v-if=\"$slots.trigger\" as-child>\n <slot name=\"trigger\" />\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-delete-resource\"\n data-slot=\"delete-resource\"\n :aria-busy=\"props.deleting || undefined\"\n :show-close-button=\"false\"\n size=\"sm\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description>{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <form ref=\"formEl\" class=\"kappa-delete-resource__form\" @submit.prevent=\"confirm\">\n <DialogLayout.Body class=\"kappa-delete-resource__body\">\n <p :id=\"resourceId\" class=\"kappa-delete-resource__name\">{{ props.resourceName }}</p>\n <div v-if=\"$slots.default\" class=\"kappa-delete-resource__details\"><slot /></div>\n <div v-if=\"props.requireName\" class=\"kappa-delete-resource__confirmation\">\n <label :for=\"inputId\">{{ props.confirmationLabel }}</label>\n <Input\n :id=\"inputId\"\n v-model=\"confirmation\"\n :aria-describedby=\"resourceId\"\n :readonly=\"props.deleting\"\n :password-manager-ignore=\"true\"\n autocomplete=\"off\"\n autocapitalize=\"none\"\n :spellcheck=\"false\"\n />\n </div>\n <Banner v-if=\"props.error\" role=\"alert\" variant=\"error\" size=\"sm\">\n {{ props.error }}\n </Banner>\n </DialogLayout.Body>\n <DialogLayout.Actions\n :dismiss-label=\"props.cancelLabel\"\n :dismiss-disabled=\"props.deleting\"\n >\n <DialogLayout.Actions.Primary\n type=\"submit\"\n variant=\"destructive\"\n :disabled=\"!canConfirm\"\n :loading=\"props.deleting\"\n >\n {{ props.deleting ? props.deletingLabel : props.confirmLabel }}\n </DialogLayout.Actions.Primary>\n </DialogLayout.Actions>\n </form>\n </DialogLayout.Content>\n </DialogLayout.Alert>\n</template>\n\n<style src=\"./delete-resource.css\"></style>\n"],"mappings":";;;;;AA0CA,IAAa,IAA2B;CACtC,OAAO;CACP,aAAa;CACb,cAAc;CACd,eAAe;CACf,aAAa;CACb,mBAAmB;AACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EClCA,IAAM,IAAQ,GAUR,IAAO,GAGP,IAAU,yBAAyB,EAAM,KACzC,IAAa,GAAG,EAAQ,QACxB,IAAe,EAAI,EAAM,WAAW,GACpC,IAAe,EAAI,EAAE,GACrB,IAAS,EAA4B,IAAI,GACzC,IAAS,QAAe,EAAM,QAAQ,EAAa,KAAK,GACxD,IAAa,QAAe,CAAC,EAAM,YAAY,CAAC,EAAM,aAC1D,CAAC,EAAM,eACL,EAAM,aAAa,SAAS,KAAK,EAAa,UAAU,EAAM,aAEjE;EAGD,EAAM;GAAC;SAAc,EAAM;SAAoB,EAAM;EAAW,SAAS;GACvE,EAAa,QAAQ;EACvB,CAAC;EAED,SAAS,EAAa,GAAkC;GAClD,CAAC,EAAQ,QAAQ,EAAM,aAC3B,EAAa,QAAQ,EAAQ,MAC7B,EAAK,eAAe,EAAQ,IAAI,GAChC,EAAK,cAAc,CAAO;EAC5B;EAEA,SAAS,IAAiB;GAExB,OADI,EAAM,cAAoB,EAAO,OAAO,cAAc,eAAe,CAAO,KAAK,OAC9E,EAAO,OAAO,cACnB,6DACF,KAAK;EACP;EAEA,SAAS,IAAU;GACjB,AAAI,EAAW,SAAO,EAAK,SAAS;EACtC;oBAIE,EAAA,GAAA,EA2DqB,EAAA,CAAA,CAAA,CAAA,OAAA;GA1DlB,MA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IAAA,EAAA;MAC/D,EAAM,eAAjB,EAAA,GAAA,EAYM,OAZN,GAYM,CAXJ,EAA2D,SAAA,EAAnD,KAAK,EAAO,GAAA,EAAK,EAAM,iBAAiB,GAAA,CAAA,GAChD,EASE,EAAA,CAAA,GAAA;OARC,IAAI;OACI,YAAA,EAAA;OAAA,uBAAA,AAAA,EAAA,QAAA,MAAA,EAAY,QAAA;OACpB,oBAAkB;OAClB,UAAU,EAAM;OAChB,2BAAyB;OAC1B,cAAa;OACb,gBAAe;OACd,YAAY;;MAGH,EAAM,SAApB,EAAA,GAAA,EAES,EAAA,CAAA,GAAA;;OAFkB,MAAK;OAAQ,SAAQ;OAAQ,MAAK;;OAC3D,SAAA,QAAiB,CAAd,EAAA,EAAA,EAAM,KAAK,GAAA,CAAA,CAAA,CAAA;;;;;IAGlB,CAAA,GAAA,EAYuB,EAAA,CAAA,CAAA,CAAA,SAAA;KAXpB,iBAAe,EAAM;KACrB,oBAAkB,EAAM;;KAEzB,SAAA,QAO+B,CAP/B,EAO+B,EAAA,CAAA,CAAA,CAAA,QAAA,SAAA;MAN7B,MAAK;MACL,SAAQ;MACP,UAAQ,CAAG,EAAA;MACX,SAAS,EAAM;;MAEhB,SAAA,QAA+D,CAA5D,EAAA,EAAA,EAAM,WAAW,EAAM,gBAAgB,EAAM,YAAY,GAAA,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"DeleteResource-JDnPWd7H.js","names":["$slots","$attrs"],"sources":["../src/blocks/delete-resource/delete-resource.ts","../src/blocks/delete-resource/DeleteResource.vue","../src/blocks/delete-resource/DeleteResource.vue"],"sourcesContent":["import type { VNodeChild } from \"vue\";\nimport type { DialogOpenChangeDetails, DialogProps } from \"../../components/dialog/dialog\";\n\nexport interface DeleteResourceProps {\n /** Name of the resource being removed. */\n resourceName: string;\n /** Controlled dialog visibility. The consumer closes it after successful deletion. */\n open?: boolean;\n /** Initial visibility when open is not controlled. */\n defaultOpen?: boolean;\n /** Requires an exact, case-sensitive resource-name match before confirmation. */\n requireName?: boolean;\n /** Blocks confirmation, cancellation, and Escape while a request is pending. */\n deleting?: boolean;\n /** Disables confirmation, for example when the resource cannot be removed. */\n disabled?: boolean;\n /** Request failure shown in an announced error banner. Does not block retry. */\n error?: string;\n title?: string;\n description?: string;\n confirmLabel?: string;\n deletingLabel?: string;\n cancelLabel?: string;\n confirmationLabel?: string;\n /** Focus destination on close, useful for programmatically opened dialogs. */\n finalFocusEl?: DialogProps[\"finalFocusEl\"];\n}\n\nexport type DeleteResourceEmits = {\n /** Requests deletion. No network call or automatic close is performed. */\n confirm: [];\n openChange: [details: DialogOpenChangeDetails];\n \"update:open\": [open: boolean];\n};\n\nexport interface DeleteResourceSlots {\n /** One button. Wrapped in Dialog.Trigger with asChild. */\n trigger?: () => VNodeChild;\n /** Optional context or consequences below the resource name. */\n default?: () => VNodeChild;\n}\n\nexport const DELETE_RESOURCE_DEFAULTS = {\n title: \"Delete resource?\",\n description: \"This action cannot be undone.\",\n confirmLabel: \"Delete resource\",\n deletingLabel: \"Deleting…\",\n cancelLabel: \"Cancel\",\n confirmationLabel: \"Type the resource name to confirm\",\n} as const;\n","<script setup lang=\"ts\">\nimport { computed, ref, useId, watch } from \"vue\";\nimport { Banner } from \"../../components/banner\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Input } from \"../../components/input\";\nimport type { DialogOpenChangeDetails } from \"../../components/dialog/dialog\";\nimport {\n DELETE_RESOURCE_DEFAULTS,\n type DeleteResourceEmits,\n type DeleteResourceProps,\n type DeleteResourceSlots,\n} from \"./delete-resource\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(defineProps<DeleteResourceProps>(), {\n ...DELETE_RESOURCE_DEFAULTS,\n open: undefined,\n defaultOpen: false,\n requireName: false,\n deleting: false,\n disabled: false,\n error: undefined,\n finalFocusEl: undefined,\n});\nconst emit = defineEmits<DeleteResourceEmits>();\ndefineSlots<DeleteResourceSlots>();\n\nconst inputId = `kappa-delete-resource-${useId()}`;\nconst resourceId = `${inputId}-name`;\nconst internalOpen = ref(props.defaultOpen);\nconst confirmation = ref(\"\");\nconst formEl = ref<HTMLFormElement | null>(null);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\nconst canConfirm = computed(() => !props.disabled && !props.deleting && (\n !props.requireName || (\n props.resourceName.length > 0 && confirmation.value === props.resourceName\n )\n));\n\n// Each opening and each new resource requires a fresh, explicit confirmation.\nwatch([isOpen, () => props.resourceName, () => props.requireName], () => {\n confirmation.value = \"\";\n});\n\nfunction onOpenChange(details: DialogOpenChangeDetails) {\n if (!details.open && props.deleting) return;\n internalOpen.value = details.open;\n emit(\"update:open\", details.open);\n emit(\"openChange\", details);\n}\n\nfunction initialFocusEl() {\n if (props.requireName) return formEl.value?.ownerDocument.getElementById(inputId) ?? null;\n return formEl.value?.querySelector<HTMLElement>(\n '[data-slot=\"dialog-layout-actions\"] button:not(:disabled)',\n ) ?? null;\n}\n\nfunction confirm() {\n if (canConfirm.value) emit(\"confirm\");\n}\n</script>\n\n<template>\n <DialogLayout.Alert\n :open=\"isOpen\"\n :close-on-escape=\"!props.deleting\"\n :disable-pointer-dismissal=\"true\"\n :initial-focus-el=\"initialFocusEl\"\n :final-focus-el=\"props.finalFocusEl\"\n @open-change=\"onOpenChange\"\n >\n <DialogLayout.Trigger v-if=\"$slots.trigger\" as-child>\n <slot name=\"trigger\" />\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-delete-resource\"\n data-slot=\"delete-resource\"\n :aria-busy=\"props.deleting || undefined\"\n :show-close-button=\"false\"\n size=\"sm\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description>{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <form ref=\"formEl\" class=\"kappa-delete-resource__form\" @submit.prevent=\"confirm\">\n <DialogLayout.Body class=\"kappa-delete-resource__body\">\n <p :id=\"resourceId\" class=\"kappa-delete-resource__name\">{{ props.resourceName }}</p>\n <div v-if=\"$slots.default\" class=\"kappa-delete-resource__details\"><slot /></div>\n <div v-if=\"props.requireName\" class=\"kappa-delete-resource__confirmation\">\n <label :for=\"inputId\">{{ props.confirmationLabel }}</label>\n <Input\n :id=\"inputId\"\n v-model=\"confirmation\"\n :aria-describedby=\"resourceId\"\n :readonly=\"props.deleting\"\n :password-manager-ignore=\"true\"\n autocomplete=\"off\"\n autocapitalize=\"none\"\n :spellcheck=\"false\"\n />\n </div>\n <Banner v-if=\"props.error\" role=\"alert\" variant=\"error\" size=\"sm\">\n {{ props.error }}\n </Banner>\n </DialogLayout.Body>\n <DialogLayout.Actions\n :dismiss-label=\"props.cancelLabel\"\n :dismiss-disabled=\"props.deleting\"\n >\n <DialogLayout.Actions.Primary\n type=\"submit\"\n variant=\"destructive\"\n :disabled=\"!canConfirm\"\n :loading=\"props.deleting\"\n >\n {{ props.deleting ? props.deletingLabel : props.confirmLabel }}\n </DialogLayout.Actions.Primary>\n </DialogLayout.Actions>\n </form>\n </DialogLayout.Content>\n </DialogLayout.Alert>\n</template>\n\n<style src=\"./delete-resource.css\"></style>\n","<script setup lang=\"ts\">\nimport { computed, ref, useId, watch } from \"vue\";\nimport { Banner } from \"../../components/banner\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Input } from \"../../components/input\";\nimport type { DialogOpenChangeDetails } from \"../../components/dialog/dialog\";\nimport {\n DELETE_RESOURCE_DEFAULTS,\n type DeleteResourceEmits,\n type DeleteResourceProps,\n type DeleteResourceSlots,\n} from \"./delete-resource\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(defineProps<DeleteResourceProps>(), {\n ...DELETE_RESOURCE_DEFAULTS,\n open: undefined,\n defaultOpen: false,\n requireName: false,\n deleting: false,\n disabled: false,\n error: undefined,\n finalFocusEl: undefined,\n});\nconst emit = defineEmits<DeleteResourceEmits>();\ndefineSlots<DeleteResourceSlots>();\n\nconst inputId = `kappa-delete-resource-${useId()}`;\nconst resourceId = `${inputId}-name`;\nconst internalOpen = ref(props.defaultOpen);\nconst confirmation = ref(\"\");\nconst formEl = ref<HTMLFormElement | null>(null);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\nconst canConfirm = computed(() => !props.disabled && !props.deleting && (\n !props.requireName || (\n props.resourceName.length > 0 && confirmation.value === props.resourceName\n )\n));\n\n// Each opening and each new resource requires a fresh, explicit confirmation.\nwatch([isOpen, () => props.resourceName, () => props.requireName], () => {\n confirmation.value = \"\";\n});\n\nfunction onOpenChange(details: DialogOpenChangeDetails) {\n if (!details.open && props.deleting) return;\n internalOpen.value = details.open;\n emit(\"update:open\", details.open);\n emit(\"openChange\", details);\n}\n\nfunction initialFocusEl() {\n if (props.requireName) return formEl.value?.ownerDocument.getElementById(inputId) ?? null;\n return formEl.value?.querySelector<HTMLElement>(\n '[data-slot=\"dialog-layout-actions\"] button:not(:disabled)',\n ) ?? null;\n}\n\nfunction confirm() {\n if (canConfirm.value) emit(\"confirm\");\n}\n</script>\n\n<template>\n <DialogLayout.Alert\n :open=\"isOpen\"\n :close-on-escape=\"!props.deleting\"\n :disable-pointer-dismissal=\"true\"\n :initial-focus-el=\"initialFocusEl\"\n :final-focus-el=\"props.finalFocusEl\"\n @open-change=\"onOpenChange\"\n >\n <DialogLayout.Trigger v-if=\"$slots.trigger\" as-child>\n <slot name=\"trigger\" />\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-delete-resource\"\n data-slot=\"delete-resource\"\n :aria-busy=\"props.deleting || undefined\"\n :show-close-button=\"false\"\n size=\"sm\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description>{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <form ref=\"formEl\" class=\"kappa-delete-resource__form\" @submit.prevent=\"confirm\">\n <DialogLayout.Body class=\"kappa-delete-resource__body\">\n <p :id=\"resourceId\" class=\"kappa-delete-resource__name\">{{ props.resourceName }}</p>\n <div v-if=\"$slots.default\" class=\"kappa-delete-resource__details\"><slot /></div>\n <div v-if=\"props.requireName\" class=\"kappa-delete-resource__confirmation\">\n <label :for=\"inputId\">{{ props.confirmationLabel }}</label>\n <Input\n :id=\"inputId\"\n v-model=\"confirmation\"\n :aria-describedby=\"resourceId\"\n :readonly=\"props.deleting\"\n :password-manager-ignore=\"true\"\n autocomplete=\"off\"\n autocapitalize=\"none\"\n :spellcheck=\"false\"\n />\n </div>\n <Banner v-if=\"props.error\" role=\"alert\" variant=\"error\" size=\"sm\">\n {{ props.error }}\n </Banner>\n </DialogLayout.Body>\n <DialogLayout.Actions\n :dismiss-label=\"props.cancelLabel\"\n :dismiss-disabled=\"props.deleting\"\n >\n <DialogLayout.Actions.Primary\n type=\"submit\"\n variant=\"destructive\"\n :disabled=\"!canConfirm\"\n :loading=\"props.deleting\"\n >\n {{ props.deleting ? props.deletingLabel : props.confirmLabel }}\n </DialogLayout.Actions.Primary>\n </DialogLayout.Actions>\n </form>\n </DialogLayout.Content>\n </DialogLayout.Alert>\n</template>\n\n<style src=\"./delete-resource.css\"></style>\n"],"mappings":";;;;;AA0CA,IAAa,IAA2B;CACtC,OAAO;CACP,aAAa;CACb,cAAc;CACd,eAAe;CACf,aAAa;CACb,mBAAmB;AACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EClCA,IAAM,IAAQ,GAUR,IAAO,GAGP,IAAU,yBAAyB,EAAM,KACzC,IAAa,GAAG,EAAQ,QACxB,IAAe,EAAI,EAAM,WAAW,GACpC,IAAe,EAAI,EAAE,GACrB,IAAS,EAA4B,IAAI,GACzC,IAAS,QAAe,EAAM,QAAQ,EAAa,KAAK,GACxD,IAAa,QAAe,CAAC,EAAM,YAAY,CAAC,EAAM,aAC1D,CAAC,EAAM,eACL,EAAM,aAAa,SAAS,KAAK,EAAa,UAAU,EAAM,aAEjE;EAGD,EAAM;GAAC;SAAc,EAAM;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EAAA,EAAM,WAAW,EAAM,gBAAgB,EAAM,YAAY,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -283,50 +283,46 @@ var M = { class: "kappa-image-cropper__controls" }, N = {
|
|
|
283
283
|
});
|
|
284
284
|
//#endregion
|
|
285
285
|
//#region src/components/image-cropper/image-cropper-source.ts
|
|
286
|
-
function R(e
|
|
287
|
-
let n =
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
revokeObjectURL: (e) => URL.revokeObjectURL(e)
|
|
291
|
-
}, r = 0, i = !1, a, o;
|
|
292
|
-
function s() {
|
|
293
|
-
r += 1, a &&= (a.onload = null, a.onerror = null, a.removeAttribute("src"), void 0), o && n.revokeObjectURL(o), o = void 0;
|
|
286
|
+
function R(e) {
|
|
287
|
+
let t = 0, n = !1, r, i;
|
|
288
|
+
function a() {
|
|
289
|
+
t += 1, r &&= (r.onload = null, r.onerror = null, r.removeAttribute("src"), void 0), i && URL.revokeObjectURL(i), i = void 0;
|
|
294
290
|
}
|
|
295
|
-
function
|
|
296
|
-
if (
|
|
297
|
-
if (
|
|
291
|
+
function o(o, s) {
|
|
292
|
+
if (n) return;
|
|
293
|
+
if (a(), !o) {
|
|
298
294
|
e.status("empty");
|
|
299
295
|
return;
|
|
300
296
|
}
|
|
301
297
|
e.status("loading");
|
|
302
|
-
let
|
|
303
|
-
function
|
|
304
|
-
|
|
298
|
+
let c = t, l = () => !n && c === t;
|
|
299
|
+
function u() {
|
|
300
|
+
l() && (a(), e.status("error"), e.error(/* @__PURE__ */ Error("The image could not be loaded. Check its format and cross-origin access.")));
|
|
305
301
|
}
|
|
306
302
|
try {
|
|
307
|
-
let
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
if (!(
|
|
311
|
-
|
|
303
|
+
let t = typeof o == "string" ? o : i = URL.createObjectURL(o), n = new Image();
|
|
304
|
+
r = n, n.crossOrigin = s, n.onload = () => {
|
|
305
|
+
if (l()) {
|
|
306
|
+
if (!(n.naturalWidth > 0 && n.naturalHeight > 0)) {
|
|
307
|
+
u();
|
|
312
308
|
return;
|
|
313
309
|
}
|
|
314
310
|
e.load({
|
|
315
|
-
url:
|
|
316
|
-
width:
|
|
317
|
-
height:
|
|
318
|
-
revision:
|
|
311
|
+
url: t,
|
|
312
|
+
width: n.naturalWidth,
|
|
313
|
+
height: n.naturalHeight,
|
|
314
|
+
revision: c
|
|
319
315
|
}), e.status("ready");
|
|
320
316
|
}
|
|
321
|
-
},
|
|
317
|
+
}, n.onerror = u, n.src = t;
|
|
322
318
|
} catch {
|
|
323
|
-
|
|
319
|
+
u();
|
|
324
320
|
}
|
|
325
321
|
}
|
|
326
322
|
return {
|
|
327
|
-
load:
|
|
323
|
+
load: o,
|
|
328
324
|
dispose() {
|
|
329
|
-
|
|
325
|
+
n = !0, a();
|
|
330
326
|
}
|
|
331
327
|
};
|
|
332
328
|
}
|
|
@@ -451,4 +447,4 @@ var z = [
|
|
|
451
447
|
//#endregion
|
|
452
448
|
export { E as i, w as n, T as r, H as t };
|
|
453
449
|
|
|
454
|
-
//# sourceMappingURL=ImageCropper-
|
|
450
|
+
//# sourceMappingURL=ImageCropper-B-8niGGr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageCropper-Dfjf3OuM.js","names":[],"sources":["../src/components/image-cropper/image-cropper.ts","../src/components/image-cropper/image-cropper-geometry.ts","../src/components/image-cropper/ImageCropperEditor.vue","../src/components/image-cropper/ImageCropperEditor.vue","../src/components/image-cropper/image-cropper-source.ts","../src/components/image-cropper/ImageCropper.vue","../src/components/image-cropper/ImageCropper.vue"],"sourcesContent":["export const IMAGE_CROPPER_DEFAULT_ASPECT_RATIO = 1;\nexport const IMAGE_CROPPER_DEFAULT_MAX_ZOOM = 5;\n\nexport type ImageCropperSource = string | Blob | null;\nexport type ImageCropperStatus = \"empty\" | \"loading\" | \"ready\" | \"error\";\nexport type ImageCropperAspectRatio = number | \"free\";\n\nexport interface ImageCropperCrop {\n /** Crop coordinates in original image pixels. */\n x: number;\n y: number;\n width: number;\n height: number;\n zoom: number;\n naturalWidth: number;\n naturalHeight: number;\n}\n\nexport interface ImageCropperExportOptions {\n /** Browser-supported image MIME type. Defaults to image/png. */\n type?: \"image/png\" | \"image/jpeg\" | \"image/webp\";\n /** Encoding quality from 0 to 1 for JPEG and WebP. */\n quality?: number;\n /** Proportional output limit. Defaults to 2048 × 2048 pixels. */\n maxSize?: { width: number; height: number };\n}\n\nexport interface ImageCropperLabels {\n region: string;\n selection: string;\n instructions: string;\n zoom: string;\n reset: string;\n preview: string;\n empty: string;\n loading: string;\n error: string;\n}\n\nexport const IMAGE_CROPPER_LABELS: ImageCropperLabels = {\n region: \"Image cropper\",\n selection: \"Crop position\",\n instructions: \"Drag the crop area to move it. Drag an edge or corner to resize it. Use arrow keys to move, Alt plus an arrow to resize, and plus or minus to zoom.\",\n zoom: \"Zoom\",\n reset: \"Reset crop\",\n preview: \"Crop preview\",\n empty: \"Choose an image to start.\",\n loading: \"Loading image…\",\n error: \"The image could not be loaded.\",\n};\n\nexport interface ImageCropperProps {\n /** A URL or local Blob/File. Selection and upload belong to the application. */\n src?: ImageCropperSource;\n /** Crop width divided by height, or `free` for independent width and height. Invalid values fall back to 1. */\n aspectRatio?: ImageCropperAspectRatio;\n /** Maximum zoom, from 1 to 20. */\n maxZoom?: number;\n disabled?: boolean;\n readOnly?: boolean;\n /** Show the live, rectangular preview. */\n showPreview?: boolean;\n /** Remote images must permit CORS before they can be exported. */\n crossOrigin?: \"anonymous\" | \"use-credentials\";\n /** Replace visible and assistive labels for localization. */\n labels?: Partial<ImageCropperLabels>;\n}\n\nexport interface ImageCropperApi {\n reset: () => void;\n setZoom: (value: number) => void;\n getCrop: () => ImageCropperCrop | null;\n /** Rejects if unavailable, canvas export fails, or the source changes. */\n exportBlob: (options?: ImageCropperExportOptions) => Promise<Blob>;\n}\n\nexport interface ImageCropperErrorDetails {\n phase: \"load\" | \"export\";\n error: Error;\n}\n\nexport type ImageCropperEmits = {\n change: [crop: ImageCropperCrop];\n load: [details: { width: number; height: number }];\n error: [details: ImageCropperErrorDetails];\n statusChange: [status: ImageCropperStatus];\n};\n\nexport function resolveImageCropperAspectRatio(value: unknown): number | undefined {\n if (value === \"free\") return undefined;\n return typeof value === \"number\" && Number.isFinite(value) && value > 0\n ? value : IMAGE_CROPPER_DEFAULT_ASPECT_RATIO;\n}\n\nexport function resolveImageCropperMaxZoom(value: unknown): number {\n return typeof value === \"number\" && Number.isFinite(value)\n ? Math.min(20, Math.max(1, value)) : IMAGE_CROPPER_DEFAULT_MAX_ZOOM;\n}\n\nexport function resolveImageCropperExportOptions(options: ImageCropperExportOptions = {}) {\n const { width = 2048, height = 2048 } = options.maxSize ?? {};\n if (![width, height].every(value => Number.isFinite(value) && value >= 1 && value <= 8192)) {\n throw new RangeError(\"Image export dimensions must be between 1 and 8192 pixels.\");\n }\n if (options.quality !== undefined && (!Number.isFinite(options.quality) || options.quality < 0 || options.quality > 1)) {\n throw new RangeError(\"Image export quality must be between 0 and 1.\");\n }\n return { type: options.type ?? \"image/png\", quality: options.quality ?? 0.92,\n maxSize: { width: Math.floor(width), height: Math.floor(height) }, output: \"blob\" as const };\n}\n","import type { ImageCropperCrop } from \"./image-cropper.ts\";\n\ninterface Geometry {\n naturalSize: { width: number; height: number };\n viewportRect: { width: number; height: number };\n crop: { x: number; y: number; width: number; height: number };\n offset: { x: number; y: number };\n zoom: number;\n}\n\n/** Rectangular exports use fractional viewport measurements, not integer offsetWidth. */\nexport function getImageCropperSourceRect(value: Geometry, aspectRatio?: number): ImageCropperCrop | null {\n const { naturalSize, viewportRect, crop, offset, zoom } = value;\n if (![naturalSize.width, naturalSize.height, viewportRect.width, viewportRect.height, crop.width, crop.height, zoom]\n .every(dimension => Number.isFinite(dimension) && dimension > 0)) return null;\n const scale = Math.max(viewportRect.width / naturalSize.width, viewportRect.height / naturalSize.height) * zoom;\n const ratio = typeof aspectRatio === \"number\" && Number.isFinite(aspectRatio) && aspectRatio > 0\n ? aspectRatio : crop.width / crop.height;\n const width = Math.min(crop.width / scale, crop.height / scale * ratio, naturalSize.width, naturalSize.height * ratio);\n const height = width / ratio;\n const x = (crop.x - viewportRect.width / 2 - offset.x) / scale + naturalSize.width / 2;\n const y = (crop.y - viewportRect.height / 2 - offset.y) / scale + naturalSize.height / 2;\n return {\n x: Math.max(0, Math.min(naturalSize.width - width, x)),\n y: Math.max(0, Math.min(naturalSize.height - height, y)), width, height, zoom,\n naturalWidth: naturalSize.width, naturalHeight: naturalSize.height,\n };\n}\n\nexport function getImageCropperOutputSize(crop: ImageCropperCrop, maxSize: { width: number; height: number }) {\n const scale = Math.min(1, maxSize.width / crop.width, maxSize.height / crop.height);\n return { width: Math.max(1, Math.round(crop.width * scale)), height: Math.max(1, Math.round(crop.height * scale)) };\n}\n","<script setup lang=\"ts\">\nimport { ImageCropper as ArkImageCropper, useImageCropper } from \"@ark-ui/vue/image-cropper\";\nimport { computed, onBeforeUnmount, ref, watch } from \"vue\";\nimport { Button } from \"../button\";\nimport { Slider } from \"../slider\";\nimport { resolveImageCropperExportOptions, type ImageCropperApi, type ImageCropperCrop,\n type ImageCropperExportOptions, type ImageCropperLabels } from \"./image-cropper\";\nimport type { ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { getImageCropperOutputSize, getImageCropperSourceRect } from \"./image-cropper-geometry\";\n\nconst props = defineProps<{\n source: ImageCropperLoadedSource;\n aspectRatio?: number;\n maxZoom: number;\n disabled: boolean;\n readOnly: boolean;\n showPreview: boolean;\n crossOrigin: \"anonymous\" | \"use-credentials\";\n labels: ImageCropperLabels;\n}>();\nconst emit = defineEmits<{ change: [crop: ImageCropperCrop] }>();\nconst host = ref<HTMLDivElement>();\nlet disposed = false;\nconst HANDLE_POSITIONS = [\"n\", \"e\", \"s\", \"w\", \"ne\", \"se\", \"sw\", \"nw\"] as const;\nconst locked = computed(() => props.disabled || props.readOnly);\nconst api = useImageCropper(computed(() => ({\n aspectRatio: props.aspectRatio, fixedCropArea: false,\n minWidth: 1, minHeight: 1, minZoom: 1, maxZoom: props.maxZoom,\n translations: {\n rootLabel: props.labels.region,\n selectionLabel: () => props.labels.selection,\n selectionInstructions: props.labels.instructions,\n selectionValueText: () => {\n const crop = getCrop();\n return crop ? `X ${Math.round(crop.x)}, Y ${Math.round(crop.y)}. ${Math.round(crop.width)} by ${Math.round(crop.height)} pixels.` : \"\";\n },\n },\n})));\n\nfunction getCrop(): ImageCropperCrop | null {\n return getImageCropperSourceRect(api.value, props.aspectRatio);\n}\n\nconst crop = computed(() => getCrop());\nconst imageRatio = computed(() => props.source.width / props.source.height);\nconst previewRatio = computed(() => crop.value ? crop.value.width / crop.value.height : props.aspectRatio ?? 1);\nconst previewStyle = computed(() => {\n const area = crop.value;\n if (!area) return {};\n return {\n width: `${area.naturalWidth / area.width * 100}%`, height: `${area.naturalHeight / area.height * 100}%`,\n left: `${-area.x / area.width * 100}%`, top: `${-area.y / area.height * 100}%`,\n };\n});\n\nwatch(crop, value => { if (value) emit(\"change\", value); }, { flush: \"post\" });\nwatch(() => props.aspectRatio, () => api.value.reset(), { flush: \"post\" });\nwatch(() => props.maxZoom, value => { if (api.value.zoom > value) api.value.setZoom(value); });\n\nfunction reset() { if (!locked.value) api.value.reset(); }\nfunction setZoom(value: number) {\n if (!locked.value && Number.isFinite(value)) api.value.setZoom(Math.min(props.maxZoom, Math.max(1, value)));\n}\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const area = getCrop();\n const image = host.value?.querySelector<HTMLImageElement>('[data-part=\"image\"]');\n if (props.disabled || !area || !image?.complete) throw new Error(\"The image cropper is not ready to export.\");\n const resolved = resolveImageCropperExportOptions(options);\n const size = getImageCropperOutputSize(area, resolved.maxSize);\n const canvas = image.ownerDocument.createElement(\"canvas\");\n canvas.width = size.width; canvas.height = size.height;\n const context = canvas.getContext(\"2d\");\n if (!context) throw new Error(\"The browser could not create an image canvas.\");\n context.drawImage(image, area.x, area.y, area.width, area.height, 0, 0, size.width, size.height);\n const result = await new Promise<Blob | null>(resolve => canvas.toBlob(resolve, resolved.type, resolved.quality));\n if (disposed) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n if (!(result instanceof Blob)) throw new Error(\"The crop could not be exported. Check image access and output size.\");\n return result;\n}\n\nfunction blockInteraction(event: Event) {\n // A read-only crop can receive focus. Tab must still leave the control.\n if (event instanceof KeyboardEvent && event.key === \"Tab\") return;\n if (locked.value) { event.preventDefault(); event.stopImmediatePropagation(); }\n}\nfunction handlePointerStart(event: Event) {\n if (locked.value) {\n blockInteraction(event);\n return;\n }\n const target = event.target;\n if (target instanceof Element && target.closest('[data-scope=\"image-cropper\"][data-part=\"selection\"]')) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n}\nonBeforeUnmount(() => {\n disposed = true;\n});\ndefineExpose<ImageCropperApi>({ reset, setZoom, getCrop, exportBlob });\n</script>\n\n<template>\n <div ref=\"host\" class=\"kappa-image-cropper__editor\">\n <ArkImageCropper.RootProvider :value=\"api\" class=\"kappa-image-cropper__workspace\">\n <div class=\"kappa-image-cropper__stage\"\n @pointerdown.capture=\"handlePointerStart\" @keydown.capture=\"blockInteraction\"\n @wheel.capture=\"blockInteraction\" @touchstart.capture=\"handlePointerStart\" @touchmove.capture=\"blockInteraction\">\n <ArkImageCropper.Viewport class=\"kappa-image-cropper__viewport\"\n :style=\"{ aspectRatio: imageRatio, maxWidth: `${imageRatio * 320}px` }\">\n <ArkImageCropper.Image :src=\"source.url\" :crossorigin=\"crossOrigin\" class=\"kappa-image-cropper__image\" />\n <ArkImageCropper.Selection class=\"kappa-image-cropper__selection\"\n :tabindex=\"disabled ? -1 : 0\" :aria-disabled=\"disabled || undefined\" :aria-readonly=\"readOnly || undefined\">\n <ArkImageCropper.Grid axis=\"horizontal\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Grid axis=\"vertical\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Handle v-for=\"position in HANDLE_POSITIONS\" :key=\"position\"\n :position=\"position\" class=\"kappa-image-cropper__handle\" />\n </ArkImageCropper.Selection>\n </ArkImageCropper.Viewport>\n </div>\n <div class=\"kappa-image-cropper__controls\">\n <Slider.Root :model-value=\"[api.zoom]\" :min=\"1\" :max=\"Math.max(1.01, maxZoom)\" :step=\"0.01\" :large-step=\"0.1\"\n :aria-label=\"[labels.zoom]\" :disabled=\"disabled || maxZoom === 1\" :read-only=\"readOnly\" size=\"sm\"\n :get-aria-value-text=\"({ value }) => `${Math.round(value * 100)}%`\"\n @update:model-value=\"setZoom($event[0] ?? 1)\">\n <Slider.Label>{{ labels.zoom }}</Slider.Label>\n <span class=\"kappa-image-cropper__zoom-value\" aria-hidden=\"true\">{{ Math.round(api.zoom * 100) }}%</span>\n <Slider.Control><Slider.Track><Slider.Range /></Slider.Track><Slider.Thumb :index=\"0\"><Slider.HiddenInput /></Slider.Thumb></Slider.Control>\n </Slider.Root>\n <Button variant=\"ghost\" size=\"sm\" :disabled=\"locked\" @click=\"reset\">{{ labels.reset }}</Button>\n </div>\n </ArkImageCropper.RootProvider>\n <figure v-if=\"showPreview\" class=\"kappa-image-cropper__preview\">\n <div class=\"kappa-image-cropper__preview-frame\" :style=\"{ aspectRatio: previewRatio }\">\n <img v-if=\"crop\" :src=\"source.url\" :alt=\"labels.preview\" :style=\"previewStyle\" draggable=\"false\" />\n </div>\n <figcaption>{{ labels.preview }}<span v-if=\"crop\">{{ Math.round(crop.width) }} × {{ Math.round(crop.height) }} px</span></figcaption>\n </figure>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ImageCropper as ArkImageCropper, useImageCropper } from \"@ark-ui/vue/image-cropper\";\nimport { computed, onBeforeUnmount, ref, watch } from \"vue\";\nimport { Button } from \"../button\";\nimport { Slider } from \"../slider\";\nimport { resolveImageCropperExportOptions, type ImageCropperApi, type ImageCropperCrop,\n type ImageCropperExportOptions, type ImageCropperLabels } from \"./image-cropper\";\nimport type { ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { getImageCropperOutputSize, getImageCropperSourceRect } from \"./image-cropper-geometry\";\n\nconst props = defineProps<{\n source: ImageCropperLoadedSource;\n aspectRatio?: number;\n maxZoom: number;\n disabled: boolean;\n readOnly: boolean;\n showPreview: boolean;\n crossOrigin: \"anonymous\" | \"use-credentials\";\n labels: ImageCropperLabels;\n}>();\nconst emit = defineEmits<{ change: [crop: ImageCropperCrop] }>();\nconst host = ref<HTMLDivElement>();\nlet disposed = false;\nconst HANDLE_POSITIONS = [\"n\", \"e\", \"s\", \"w\", \"ne\", \"se\", \"sw\", \"nw\"] as const;\nconst locked = computed(() => props.disabled || props.readOnly);\nconst api = useImageCropper(computed(() => ({\n aspectRatio: props.aspectRatio, fixedCropArea: false,\n minWidth: 1, minHeight: 1, minZoom: 1, maxZoom: props.maxZoom,\n translations: {\n rootLabel: props.labels.region,\n selectionLabel: () => props.labels.selection,\n selectionInstructions: props.labels.instructions,\n selectionValueText: () => {\n const crop = getCrop();\n return crop ? `X ${Math.round(crop.x)}, Y ${Math.round(crop.y)}. ${Math.round(crop.width)} by ${Math.round(crop.height)} pixels.` : \"\";\n },\n },\n})));\n\nfunction getCrop(): ImageCropperCrop | null {\n return getImageCropperSourceRect(api.value, props.aspectRatio);\n}\n\nconst crop = computed(() => getCrop());\nconst imageRatio = computed(() => props.source.width / props.source.height);\nconst previewRatio = computed(() => crop.value ? crop.value.width / crop.value.height : props.aspectRatio ?? 1);\nconst previewStyle = computed(() => {\n const area = crop.value;\n if (!area) return {};\n return {\n width: `${area.naturalWidth / area.width * 100}%`, height: `${area.naturalHeight / area.height * 100}%`,\n left: `${-area.x / area.width * 100}%`, top: `${-area.y / area.height * 100}%`,\n };\n});\n\nwatch(crop, value => { if (value) emit(\"change\", value); }, { flush: \"post\" });\nwatch(() => props.aspectRatio, () => api.value.reset(), { flush: \"post\" });\nwatch(() => props.maxZoom, value => { if (api.value.zoom > value) api.value.setZoom(value); });\n\nfunction reset() { if (!locked.value) api.value.reset(); }\nfunction setZoom(value: number) {\n if (!locked.value && Number.isFinite(value)) api.value.setZoom(Math.min(props.maxZoom, Math.max(1, value)));\n}\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const area = getCrop();\n const image = host.value?.querySelector<HTMLImageElement>('[data-part=\"image\"]');\n if (props.disabled || !area || !image?.complete) throw new Error(\"The image cropper is not ready to export.\");\n const resolved = resolveImageCropperExportOptions(options);\n const size = getImageCropperOutputSize(area, resolved.maxSize);\n const canvas = image.ownerDocument.createElement(\"canvas\");\n canvas.width = size.width; canvas.height = size.height;\n const context = canvas.getContext(\"2d\");\n if (!context) throw new Error(\"The browser could not create an image canvas.\");\n context.drawImage(image, area.x, area.y, area.width, area.height, 0, 0, size.width, size.height);\n const result = await new Promise<Blob | null>(resolve => canvas.toBlob(resolve, resolved.type, resolved.quality));\n if (disposed) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n if (!(result instanceof Blob)) throw new Error(\"The crop could not be exported. Check image access and output size.\");\n return result;\n}\n\nfunction blockInteraction(event: Event) {\n // A read-only crop can receive focus. Tab must still leave the control.\n if (event instanceof KeyboardEvent && event.key === \"Tab\") return;\n if (locked.value) { event.preventDefault(); event.stopImmediatePropagation(); }\n}\nfunction handlePointerStart(event: Event) {\n if (locked.value) {\n blockInteraction(event);\n return;\n }\n const target = event.target;\n if (target instanceof Element && target.closest('[data-scope=\"image-cropper\"][data-part=\"selection\"]')) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n}\nonBeforeUnmount(() => {\n disposed = true;\n});\ndefineExpose<ImageCropperApi>({ reset, setZoom, getCrop, exportBlob });\n</script>\n\n<template>\n <div ref=\"host\" class=\"kappa-image-cropper__editor\">\n <ArkImageCropper.RootProvider :value=\"api\" class=\"kappa-image-cropper__workspace\">\n <div class=\"kappa-image-cropper__stage\"\n @pointerdown.capture=\"handlePointerStart\" @keydown.capture=\"blockInteraction\"\n @wheel.capture=\"blockInteraction\" @touchstart.capture=\"handlePointerStart\" @touchmove.capture=\"blockInteraction\">\n <ArkImageCropper.Viewport class=\"kappa-image-cropper__viewport\"\n :style=\"{ aspectRatio: imageRatio, maxWidth: `${imageRatio * 320}px` }\">\n <ArkImageCropper.Image :src=\"source.url\" :crossorigin=\"crossOrigin\" class=\"kappa-image-cropper__image\" />\n <ArkImageCropper.Selection class=\"kappa-image-cropper__selection\"\n :tabindex=\"disabled ? -1 : 0\" :aria-disabled=\"disabled || undefined\" :aria-readonly=\"readOnly || undefined\">\n <ArkImageCropper.Grid axis=\"horizontal\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Grid axis=\"vertical\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Handle v-for=\"position in HANDLE_POSITIONS\" :key=\"position\"\n :position=\"position\" class=\"kappa-image-cropper__handle\" />\n </ArkImageCropper.Selection>\n </ArkImageCropper.Viewport>\n </div>\n <div class=\"kappa-image-cropper__controls\">\n <Slider.Root :model-value=\"[api.zoom]\" :min=\"1\" :max=\"Math.max(1.01, maxZoom)\" :step=\"0.01\" :large-step=\"0.1\"\n :aria-label=\"[labels.zoom]\" :disabled=\"disabled || maxZoom === 1\" :read-only=\"readOnly\" size=\"sm\"\n :get-aria-value-text=\"({ value }) => `${Math.round(value * 100)}%`\"\n @update:model-value=\"setZoom($event[0] ?? 1)\">\n <Slider.Label>{{ labels.zoom }}</Slider.Label>\n <span class=\"kappa-image-cropper__zoom-value\" aria-hidden=\"true\">{{ Math.round(api.zoom * 100) }}%</span>\n <Slider.Control><Slider.Track><Slider.Range /></Slider.Track><Slider.Thumb :index=\"0\"><Slider.HiddenInput /></Slider.Thumb></Slider.Control>\n </Slider.Root>\n <Button variant=\"ghost\" size=\"sm\" :disabled=\"locked\" @click=\"reset\">{{ labels.reset }}</Button>\n </div>\n </ArkImageCropper.RootProvider>\n <figure v-if=\"showPreview\" class=\"kappa-image-cropper__preview\">\n <div class=\"kappa-image-cropper__preview-frame\" :style=\"{ aspectRatio: previewRatio }\">\n <img v-if=\"crop\" :src=\"source.url\" :alt=\"labels.preview\" :style=\"previewStyle\" draggable=\"false\" />\n </div>\n <figcaption>{{ labels.preview }}<span v-if=\"crop\">{{ Math.round(crop.width) }} × {{ Math.round(crop.height) }} px</span></figcaption>\n </figure>\n </div>\n</template>\n","import type { ImageCropperSource, ImageCropperStatus } from \"./image-cropper.ts\";\n\nexport interface ImageCropperLoadedSource {\n url: string;\n width: number;\n height: number;\n revision: number;\n}\n\ninterface SourceCallbacks {\n status: (status: ImageCropperStatus) => void;\n load: (source: ImageCropperLoadedSource) => void;\n error: (error: Error) => void;\n}\n\ninterface SourceEnvironment {\n createImage: () => HTMLImageElement;\n createObjectURL: (blob: Blob) => string;\n revokeObjectURL: (url: string) => void;\n}\n\n/** Own only URLs created here. Superseded image callbacks cannot publish state. */\nexport function createImageCropperSourceLoader(callbacks: SourceCallbacks, environment?: SourceEnvironment) {\n const env = environment ?? {\n createImage: () => new Image(),\n createObjectURL: (blob: Blob) => URL.createObjectURL(blob),\n revokeObjectURL: (url: string) => URL.revokeObjectURL(url),\n };\n let revision = 0;\n let disposed = false;\n let image: HTMLImageElement | undefined;\n let ownedUrl: string | undefined;\n\n function clear() {\n revision += 1;\n if (image) {\n image.onload = null;\n image.onerror = null;\n image.removeAttribute(\"src\");\n image = undefined;\n }\n if (ownedUrl) env.revokeObjectURL(ownedUrl);\n ownedUrl = undefined;\n }\n\n function load(source: ImageCropperSource | undefined, crossOrigin: \"anonymous\" | \"use-credentials\") {\n if (disposed) return;\n clear();\n if (!source) { callbacks.status(\"empty\"); return; }\n callbacks.status(\"loading\");\n const request = revision;\n const current = () => !disposed && request === revision;\n function fail() {\n if (!current()) return;\n clear();\n callbacks.status(\"error\");\n callbacks.error(new Error(\"The image could not be loaded. Check its format and cross-origin access.\"));\n }\n try {\n const url = typeof source === \"string\" ? source : (ownedUrl = env.createObjectURL(source));\n const pending = env.createImage();\n image = pending;\n pending.crossOrigin = crossOrigin;\n pending.onload = () => {\n if (!current()) return;\n if (!(pending.naturalWidth > 0 && pending.naturalHeight > 0)) { fail(); return; }\n callbacks.load({ url, width: pending.naturalWidth, height: pending.naturalHeight, revision: request });\n callbacks.status(\"ready\");\n };\n pending.onerror = fail;\n pending.src = url;\n } catch { fail(); }\n }\n\n return { load, dispose() { disposed = true; clear(); } };\n}\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from \"vue\";\nimport ImageCropperEditor from \"./ImageCropperEditor.vue\";\nimport { createImageCropperSourceLoader, type ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { IMAGE_CROPPER_LABELS, resolveImageCropperAspectRatio, resolveImageCropperMaxZoom,\n type ImageCropperProps, type ImageCropperEmits, type ImageCropperApi, type ImageCropperStatus,\n type ImageCropperExportOptions } from \"./image-cropper\";\n\nconst props = withDefaults(defineProps<ImageCropperProps>(), {\n src: null, aspectRatio: 1, maxZoom: 5, disabled: false, readOnly: false,\n showPreview: true, crossOrigin: \"anonymous\",\n});\nconst emit = defineEmits<ImageCropperEmits>();\nconst status = ref<ImageCropperStatus>(props.src ? \"loading\" : \"empty\");\nconst source = shallowRef<ImageCropperLoadedSource>();\nconst editor = ref<ImageCropperApi>();\nconst labels = computed(() => ({ ...IMAGE_CROPPER_LABELS, ...props.labels }));\nlet loader: ReturnType<typeof createImageCropperSourceLoader> | undefined;\nlet disposed = false;\n\nonMounted(() => {\n loader = createImageCropperSourceLoader({\n status(value) {\n status.value = value;\n if (value !== \"ready\") source.value = undefined;\n emit(\"statusChange\", value);\n },\n load(value) { source.value = value; emit(\"load\", { width: value.width, height: value.height }); },\n error(error) { emit(\"error\", { phase: \"load\", error }); },\n });\n loader.load(props.src, props.crossOrigin);\n});\nwatch(() => [props.src, props.crossOrigin] as const, () => loader?.load(props.src, props.crossOrigin), { flush: \"sync\" });\nonBeforeUnmount(() => { disposed = true; loader?.dispose(); });\n\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const revision = source.value?.revision;\n const current = editor.value;\n try {\n if (status.value !== \"ready\" || !current) throw new Error(\"The image cropper is not ready to export.\");\n const blob = await current.exportBlob(options);\n if (disposed || revision !== source.value?.revision) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n return blob;\n } catch (error) {\n if (!disposed && !(error instanceof DOMException && error.name === \"AbortError\")) {\n emit(\"error\", { phase: \"export\", error: error instanceof Error ? error : new Error(String(error)) });\n }\n throw error;\n }\n}\ndefineExpose<ImageCropperApi>({\n reset: () => editor.value?.reset(), setZoom: value => editor.value?.setZoom(value),\n getCrop: () => status.value === \"ready\" ? editor.value?.getCrop() ?? null : null,\n exportBlob,\n});\n</script>\n\n<template>\n <div class=\"kappa-image-cropper\" data-slot=\"image-cropper\" :data-state=\"status\"\n :data-disabled=\"disabled ? '' : undefined\" :data-readonly=\"readOnly ? '' : undefined\"\n :aria-busy=\"status === 'loading' || undefined\">\n <ImageCropperEditor v-if=\"source\" :key=\"source.revision\" ref=\"editor\" :source=\"source\"\n :aspect-ratio=\"resolveImageCropperAspectRatio(aspectRatio)\" :max-zoom=\"resolveImageCropperMaxZoom(maxZoom)\"\n :disabled=\"disabled\" :read-only=\"readOnly\" :show-preview=\"showPreview\" :cross-origin=\"crossOrigin\" :labels=\"labels\"\n @change=\"emit('change', $event)\" />\n <div v-else class=\"kappa-image-cropper__placeholder\" :role=\"status === 'error' ? 'alert' : 'status'\">\n <span>{{ status === 'loading' ? labels.loading : status === 'error' ? labels.error : labels.empty }}</span>\n </div>\n <p v-if=\"source && !disabled && !readOnly\" class=\"kappa-image-cropper__instructions\">{{ labels.instructions }}</p>\n </div>\n</template>\n\n<style src=\"./image-cropper.css\"></style>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from \"vue\";\nimport ImageCropperEditor from \"./ImageCropperEditor.vue\";\nimport { createImageCropperSourceLoader, type ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { IMAGE_CROPPER_LABELS, resolveImageCropperAspectRatio, resolveImageCropperMaxZoom,\n type ImageCropperProps, type ImageCropperEmits, type ImageCropperApi, type ImageCropperStatus,\n type ImageCropperExportOptions } from \"./image-cropper\";\n\nconst props = withDefaults(defineProps<ImageCropperProps>(), {\n src: null, aspectRatio: 1, maxZoom: 5, disabled: false, readOnly: false,\n showPreview: true, crossOrigin: \"anonymous\",\n});\nconst emit = defineEmits<ImageCropperEmits>();\nconst status = ref<ImageCropperStatus>(props.src ? \"loading\" : \"empty\");\nconst source = shallowRef<ImageCropperLoadedSource>();\nconst editor = ref<ImageCropperApi>();\nconst labels = computed(() => ({ ...IMAGE_CROPPER_LABELS, ...props.labels }));\nlet loader: ReturnType<typeof createImageCropperSourceLoader> | undefined;\nlet disposed = false;\n\nonMounted(() => {\n loader = createImageCropperSourceLoader({\n status(value) {\n status.value = value;\n if (value !== \"ready\") source.value = undefined;\n emit(\"statusChange\", value);\n },\n load(value) { source.value = value; emit(\"load\", { width: value.width, height: value.height }); },\n error(error) { emit(\"error\", { phase: \"load\", error }); },\n });\n loader.load(props.src, props.crossOrigin);\n});\nwatch(() => [props.src, props.crossOrigin] as const, () => loader?.load(props.src, props.crossOrigin), { flush: \"sync\" });\nonBeforeUnmount(() => { disposed = true; loader?.dispose(); });\n\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const revision = source.value?.revision;\n const current = editor.value;\n try {\n if (status.value !== \"ready\" || !current) throw new Error(\"The image cropper is not ready to export.\");\n const blob = await current.exportBlob(options);\n if (disposed || revision !== source.value?.revision) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n return blob;\n } catch (error) {\n if (!disposed && !(error instanceof DOMException && error.name === \"AbortError\")) {\n emit(\"error\", { phase: \"export\", error: error instanceof Error ? error : new Error(String(error)) });\n }\n throw error;\n }\n}\ndefineExpose<ImageCropperApi>({\n reset: () => editor.value?.reset(), setZoom: value => editor.value?.setZoom(value),\n getCrop: () => status.value === \"ready\" ? editor.value?.getCrop() ?? null : null,\n exportBlob,\n});\n</script>\n\n<template>\n <div class=\"kappa-image-cropper\" data-slot=\"image-cropper\" :data-state=\"status\"\n :data-disabled=\"disabled ? '' : undefined\" :data-readonly=\"readOnly ? '' : undefined\"\n :aria-busy=\"status === 'loading' || undefined\">\n <ImageCropperEditor v-if=\"source\" :key=\"source.revision\" ref=\"editor\" :source=\"source\"\n :aspect-ratio=\"resolveImageCropperAspectRatio(aspectRatio)\" :max-zoom=\"resolveImageCropperMaxZoom(maxZoom)\"\n :disabled=\"disabled\" :read-only=\"readOnly\" :show-preview=\"showPreview\" :cross-origin=\"crossOrigin\" :labels=\"labels\"\n @change=\"emit('change', $event)\" />\n <div v-else class=\"kappa-image-cropper__placeholder\" :role=\"status === 'error' ? 'alert' : 'status'\">\n <span>{{ status === 'loading' ? labels.loading : status === 'error' ? labels.error : labels.empty }}</span>\n </div>\n <p v-if=\"source && !disabled && !readOnly\" class=\"kappa-image-cropper__instructions\">{{ labels.instructions }}</p>\n </div>\n</template>\n\n<style src=\"./image-cropper.css\"></style>\n"],"mappings":";;;;;AAAA,IAAa,IAAqC,GACrC,IAAiC,GAsCjC,IAA2C;CACtD,QAAQ;CACR,WAAW;CACX,cAAc;CACd,MAAM;CACN,OAAO;CACP,SAAS;CACT,OAAO;CACP,SAAS;CACT,OAAO;AACT;AAuCA,SAAgB,EAA+B,GAAoC;CAC7E,UAAU,QACd,OAAO,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,KAAK,IAAQ,IAClE,IAAA;AACN;AAEA,SAAgB,EAA2B,GAAwB;CACjE,OAAO,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK,IACrD,KAAK,IAAI,IAAI,KAAK,IAAI,GAAG,CAAK,CAAC,IAAA;AACrC;AAEA,SAAgB,EAAiC,IAAqC,CAAC,GAAG;CACxF,IAAM,EAAE,WAAQ,MAAM,YAAS,SAAS,EAAQ,WAAW,CAAC;CAC5D,IAAI,CAAC,CAAC,GAAO,CAAM,CAAC,CAAC,OAAM,MAAS,OAAO,SAAS,CAAK,KAAK,KAAS,KAAK,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AAK,EAAA,YAAjC,EAAA,GAAA,EAAkH,KAAlH,GAAkH,EAA1B,EAAA,MAAO,YAAY,GAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,GAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ImageCropper-B-8niGGr.js","names":[],"sources":["../src/components/image-cropper/image-cropper.ts","../src/components/image-cropper/image-cropper-geometry.ts","../src/components/image-cropper/ImageCropperEditor.vue","../src/components/image-cropper/ImageCropperEditor.vue","../src/components/image-cropper/image-cropper-source.ts","../src/components/image-cropper/ImageCropper.vue","../src/components/image-cropper/ImageCropper.vue"],"sourcesContent":["export const IMAGE_CROPPER_DEFAULT_ASPECT_RATIO = 1;\nexport const IMAGE_CROPPER_DEFAULT_MAX_ZOOM = 5;\n\nexport type ImageCropperSource = string | Blob | null;\nexport type ImageCropperStatus = \"empty\" | \"loading\" | \"ready\" | \"error\";\nexport type ImageCropperAspectRatio = number | \"free\";\n\nexport interface ImageCropperCrop {\n /** Crop coordinates in original image pixels. */\n x: number;\n y: number;\n width: number;\n height: number;\n zoom: number;\n naturalWidth: number;\n naturalHeight: number;\n}\n\nexport interface ImageCropperExportOptions {\n /** Browser-supported image MIME type. Defaults to image/png. */\n type?: \"image/png\" | \"image/jpeg\" | \"image/webp\";\n /** Encoding quality from 0 to 1 for JPEG and WebP. */\n quality?: number;\n /** Proportional output limit. Defaults to 2048 × 2048 pixels. */\n maxSize?: { width: number; height: number };\n}\n\nexport interface ImageCropperLabels {\n region: string;\n selection: string;\n instructions: string;\n zoom: string;\n reset: string;\n preview: string;\n empty: string;\n loading: string;\n error: string;\n}\n\nexport const IMAGE_CROPPER_LABELS: ImageCropperLabels = {\n region: \"Image cropper\",\n selection: \"Crop position\",\n instructions: \"Drag the crop area to move it. Drag an edge or corner to resize it. Use arrow keys to move, Alt plus an arrow to resize, and plus or minus to zoom.\",\n zoom: \"Zoom\",\n reset: \"Reset crop\",\n preview: \"Crop preview\",\n empty: \"Choose an image to start.\",\n loading: \"Loading image…\",\n error: \"The image could not be loaded.\",\n};\n\nexport interface ImageCropperProps {\n /** A URL or local Blob/File. Selection and upload belong to the application. */\n src?: ImageCropperSource;\n /** Crop width divided by height, or `free` for independent width and height. Invalid values fall back to 1. */\n aspectRatio?: ImageCropperAspectRatio;\n /** Maximum zoom, from 1 to 20. */\n maxZoom?: number;\n disabled?: boolean;\n readOnly?: boolean;\n /** Show the live, rectangular preview. */\n showPreview?: boolean;\n /** Remote images must permit CORS before they can be exported. */\n crossOrigin?: \"anonymous\" | \"use-credentials\";\n /** Replace visible and assistive labels for localization. */\n labels?: Partial<ImageCropperLabels>;\n}\n\nexport interface ImageCropperApi {\n reset: () => void;\n setZoom: (value: number) => void;\n getCrop: () => ImageCropperCrop | null;\n /** Rejects if unavailable, canvas export fails, or the source changes. */\n exportBlob: (options?: ImageCropperExportOptions) => Promise<Blob>;\n}\n\nexport interface ImageCropperErrorDetails {\n phase: \"load\" | \"export\";\n error: Error;\n}\n\nexport type ImageCropperEmits = {\n change: [crop: ImageCropperCrop];\n load: [details: { width: number; height: number }];\n error: [details: ImageCropperErrorDetails];\n statusChange: [status: ImageCropperStatus];\n};\n\nexport function resolveImageCropperAspectRatio(value: unknown): number | undefined {\n if (value === \"free\") return undefined;\n return typeof value === \"number\" && Number.isFinite(value) && value > 0\n ? value : IMAGE_CROPPER_DEFAULT_ASPECT_RATIO;\n}\n\nexport function resolveImageCropperMaxZoom(value: unknown): number {\n return typeof value === \"number\" && Number.isFinite(value)\n ? Math.min(20, Math.max(1, value)) : IMAGE_CROPPER_DEFAULT_MAX_ZOOM;\n}\n\nexport function resolveImageCropperExportOptions(options: ImageCropperExportOptions = {}) {\n const { width = 2048, height = 2048 } = options.maxSize ?? {};\n if (![width, height].every(value => Number.isFinite(value) && value >= 1 && value <= 8192)) {\n throw new RangeError(\"Image export dimensions must be between 1 and 8192 pixels.\");\n }\n if (options.quality !== undefined && (!Number.isFinite(options.quality) || options.quality < 0 || options.quality > 1)) {\n throw new RangeError(\"Image export quality must be between 0 and 1.\");\n }\n return { type: options.type ?? \"image/png\", quality: options.quality ?? 0.92,\n maxSize: { width: Math.floor(width), height: Math.floor(height) }, output: \"blob\" as const };\n}\n","import type { ImageCropperCrop } from \"./image-cropper.ts\";\n\ninterface Geometry {\n naturalSize: { width: number; height: number };\n viewportRect: { width: number; height: number };\n crop: { x: number; y: number; width: number; height: number };\n offset: { x: number; y: number };\n zoom: number;\n}\n\n/** Rectangular exports use fractional viewport measurements, not integer offsetWidth. */\nexport function getImageCropperSourceRect(value: Geometry, aspectRatio?: number): ImageCropperCrop | null {\n const { naturalSize, viewportRect, crop, offset, zoom } = value;\n if (![naturalSize.width, naturalSize.height, viewportRect.width, viewportRect.height, crop.width, crop.height, zoom]\n .every(dimension => Number.isFinite(dimension) && dimension > 0)) return null;\n const scale = Math.max(viewportRect.width / naturalSize.width, viewportRect.height / naturalSize.height) * zoom;\n const ratio = typeof aspectRatio === \"number\" && Number.isFinite(aspectRatio) && aspectRatio > 0\n ? aspectRatio : crop.width / crop.height;\n const width = Math.min(crop.width / scale, crop.height / scale * ratio, naturalSize.width, naturalSize.height * ratio);\n const height = width / ratio;\n const x = (crop.x - viewportRect.width / 2 - offset.x) / scale + naturalSize.width / 2;\n const y = (crop.y - viewportRect.height / 2 - offset.y) / scale + naturalSize.height / 2;\n return {\n x: Math.max(0, Math.min(naturalSize.width - width, x)),\n y: Math.max(0, Math.min(naturalSize.height - height, y)), width, height, zoom,\n naturalWidth: naturalSize.width, naturalHeight: naturalSize.height,\n };\n}\n\nexport function getImageCropperOutputSize(crop: ImageCropperCrop, maxSize: { width: number; height: number }) {\n const scale = Math.min(1, maxSize.width / crop.width, maxSize.height / crop.height);\n return { width: Math.max(1, Math.round(crop.width * scale)), height: Math.max(1, Math.round(crop.height * scale)) };\n}\n","<script setup lang=\"ts\">\nimport { ImageCropper as ArkImageCropper, useImageCropper } from \"@ark-ui/vue/image-cropper\";\nimport { computed, onBeforeUnmount, ref, watch } from \"vue\";\nimport { Button } from \"../button\";\nimport { Slider } from \"../slider\";\nimport { resolveImageCropperExportOptions, type ImageCropperApi, type ImageCropperCrop,\n type ImageCropperExportOptions, type ImageCropperLabels } from \"./image-cropper\";\nimport type { ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { getImageCropperOutputSize, getImageCropperSourceRect } from \"./image-cropper-geometry\";\n\nconst props = defineProps<{\n source: ImageCropperLoadedSource;\n aspectRatio?: number;\n maxZoom: number;\n disabled: boolean;\n readOnly: boolean;\n showPreview: boolean;\n crossOrigin: \"anonymous\" | \"use-credentials\";\n labels: ImageCropperLabels;\n}>();\nconst emit = defineEmits<{ change: [crop: ImageCropperCrop] }>();\nconst host = ref<HTMLDivElement>();\nlet disposed = false;\nconst HANDLE_POSITIONS = [\"n\", \"e\", \"s\", \"w\", \"ne\", \"se\", \"sw\", \"nw\"] as const;\nconst locked = computed(() => props.disabled || props.readOnly);\nconst api = useImageCropper(computed(() => ({\n aspectRatio: props.aspectRatio, fixedCropArea: false,\n minWidth: 1, minHeight: 1, minZoom: 1, maxZoom: props.maxZoom,\n translations: {\n rootLabel: props.labels.region,\n selectionLabel: () => props.labels.selection,\n selectionInstructions: props.labels.instructions,\n selectionValueText: () => {\n const crop = getCrop();\n return crop ? `X ${Math.round(crop.x)}, Y ${Math.round(crop.y)}. ${Math.round(crop.width)} by ${Math.round(crop.height)} pixels.` : \"\";\n },\n },\n})));\n\nfunction getCrop(): ImageCropperCrop | null {\n return getImageCropperSourceRect(api.value, props.aspectRatio);\n}\n\nconst crop = computed(() => getCrop());\nconst imageRatio = computed(() => props.source.width / props.source.height);\nconst previewRatio = computed(() => crop.value ? crop.value.width / crop.value.height : props.aspectRatio ?? 1);\nconst previewStyle = computed(() => {\n const area = crop.value;\n if (!area) return {};\n return {\n width: `${area.naturalWidth / area.width * 100}%`, height: `${area.naturalHeight / area.height * 100}%`,\n left: `${-area.x / area.width * 100}%`, top: `${-area.y / area.height * 100}%`,\n };\n});\n\nwatch(crop, value => { if (value) emit(\"change\", value); }, { flush: \"post\" });\nwatch(() => props.aspectRatio, () => api.value.reset(), { flush: \"post\" });\nwatch(() => props.maxZoom, value => { if (api.value.zoom > value) api.value.setZoom(value); });\n\nfunction reset() { if (!locked.value) api.value.reset(); }\nfunction setZoom(value: number) {\n if (!locked.value && Number.isFinite(value)) api.value.setZoom(Math.min(props.maxZoom, Math.max(1, value)));\n}\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const area = getCrop();\n const image = host.value?.querySelector<HTMLImageElement>('[data-part=\"image\"]');\n if (props.disabled || !area || !image?.complete) throw new Error(\"The image cropper is not ready to export.\");\n const resolved = resolveImageCropperExportOptions(options);\n const size = getImageCropperOutputSize(area, resolved.maxSize);\n const canvas = image.ownerDocument.createElement(\"canvas\");\n canvas.width = size.width; canvas.height = size.height;\n const context = canvas.getContext(\"2d\");\n if (!context) throw new Error(\"The browser could not create an image canvas.\");\n context.drawImage(image, area.x, area.y, area.width, area.height, 0, 0, size.width, size.height);\n const result = await new Promise<Blob | null>(resolve => canvas.toBlob(resolve, resolved.type, resolved.quality));\n if (disposed) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n if (!(result instanceof Blob)) throw new Error(\"The crop could not be exported. Check image access and output size.\");\n return result;\n}\n\nfunction blockInteraction(event: Event) {\n // A read-only crop can receive focus. Tab must still leave the control.\n if (event instanceof KeyboardEvent && event.key === \"Tab\") return;\n if (locked.value) { event.preventDefault(); event.stopImmediatePropagation(); }\n}\nfunction handlePointerStart(event: Event) {\n if (locked.value) {\n blockInteraction(event);\n return;\n }\n const target = event.target;\n if (target instanceof Element && target.closest('[data-scope=\"image-cropper\"][data-part=\"selection\"]')) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n}\nonBeforeUnmount(() => {\n disposed = true;\n});\ndefineExpose<ImageCropperApi>({ reset, setZoom, getCrop, exportBlob });\n</script>\n\n<template>\n <div ref=\"host\" class=\"kappa-image-cropper__editor\">\n <ArkImageCropper.RootProvider :value=\"api\" class=\"kappa-image-cropper__workspace\">\n <div class=\"kappa-image-cropper__stage\"\n @pointerdown.capture=\"handlePointerStart\" @keydown.capture=\"blockInteraction\"\n @wheel.capture=\"blockInteraction\" @touchstart.capture=\"handlePointerStart\" @touchmove.capture=\"blockInteraction\">\n <ArkImageCropper.Viewport class=\"kappa-image-cropper__viewport\"\n :style=\"{ aspectRatio: imageRatio, maxWidth: `${imageRatio * 320}px` }\">\n <ArkImageCropper.Image :src=\"source.url\" :crossorigin=\"crossOrigin\" class=\"kappa-image-cropper__image\" />\n <ArkImageCropper.Selection class=\"kappa-image-cropper__selection\"\n :tabindex=\"disabled ? -1 : 0\" :aria-disabled=\"disabled || undefined\" :aria-readonly=\"readOnly || undefined\">\n <ArkImageCropper.Grid axis=\"horizontal\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Grid axis=\"vertical\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Handle v-for=\"position in HANDLE_POSITIONS\" :key=\"position\"\n :position=\"position\" class=\"kappa-image-cropper__handle\" />\n </ArkImageCropper.Selection>\n </ArkImageCropper.Viewport>\n </div>\n <div class=\"kappa-image-cropper__controls\">\n <Slider.Root :model-value=\"[api.zoom]\" :min=\"1\" :max=\"Math.max(1.01, maxZoom)\" :step=\"0.01\" :large-step=\"0.1\"\n :aria-label=\"[labels.zoom]\" :disabled=\"disabled || maxZoom === 1\" :read-only=\"readOnly\" size=\"sm\"\n :get-aria-value-text=\"({ value }) => `${Math.round(value * 100)}%`\"\n @update:model-value=\"setZoom($event[0] ?? 1)\">\n <Slider.Label>{{ labels.zoom }}</Slider.Label>\n <span class=\"kappa-image-cropper__zoom-value\" aria-hidden=\"true\">{{ Math.round(api.zoom * 100) }}%</span>\n <Slider.Control><Slider.Track><Slider.Range /></Slider.Track><Slider.Thumb :index=\"0\"><Slider.HiddenInput /></Slider.Thumb></Slider.Control>\n </Slider.Root>\n <Button variant=\"ghost\" size=\"sm\" :disabled=\"locked\" @click=\"reset\">{{ labels.reset }}</Button>\n </div>\n </ArkImageCropper.RootProvider>\n <figure v-if=\"showPreview\" class=\"kappa-image-cropper__preview\">\n <div class=\"kappa-image-cropper__preview-frame\" :style=\"{ aspectRatio: previewRatio }\">\n <img v-if=\"crop\" :src=\"source.url\" :alt=\"labels.preview\" :style=\"previewStyle\" draggable=\"false\" />\n </div>\n <figcaption>{{ labels.preview }}<span v-if=\"crop\">{{ Math.round(crop.width) }} × {{ Math.round(crop.height) }} px</span></figcaption>\n </figure>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport { ImageCropper as ArkImageCropper, useImageCropper } from \"@ark-ui/vue/image-cropper\";\nimport { computed, onBeforeUnmount, ref, watch } from \"vue\";\nimport { Button } from \"../button\";\nimport { Slider } from \"../slider\";\nimport { resolveImageCropperExportOptions, type ImageCropperApi, type ImageCropperCrop,\n type ImageCropperExportOptions, type ImageCropperLabels } from \"./image-cropper\";\nimport type { ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { getImageCropperOutputSize, getImageCropperSourceRect } from \"./image-cropper-geometry\";\n\nconst props = defineProps<{\n source: ImageCropperLoadedSource;\n aspectRatio?: number;\n maxZoom: number;\n disabled: boolean;\n readOnly: boolean;\n showPreview: boolean;\n crossOrigin: \"anonymous\" | \"use-credentials\";\n labels: ImageCropperLabels;\n}>();\nconst emit = defineEmits<{ change: [crop: ImageCropperCrop] }>();\nconst host = ref<HTMLDivElement>();\nlet disposed = false;\nconst HANDLE_POSITIONS = [\"n\", \"e\", \"s\", \"w\", \"ne\", \"se\", \"sw\", \"nw\"] as const;\nconst locked = computed(() => props.disabled || props.readOnly);\nconst api = useImageCropper(computed(() => ({\n aspectRatio: props.aspectRatio, fixedCropArea: false,\n minWidth: 1, minHeight: 1, minZoom: 1, maxZoom: props.maxZoom,\n translations: {\n rootLabel: props.labels.region,\n selectionLabel: () => props.labels.selection,\n selectionInstructions: props.labels.instructions,\n selectionValueText: () => {\n const crop = getCrop();\n return crop ? `X ${Math.round(crop.x)}, Y ${Math.round(crop.y)}. ${Math.round(crop.width)} by ${Math.round(crop.height)} pixels.` : \"\";\n },\n },\n})));\n\nfunction getCrop(): ImageCropperCrop | null {\n return getImageCropperSourceRect(api.value, props.aspectRatio);\n}\n\nconst crop = computed(() => getCrop());\nconst imageRatio = computed(() => props.source.width / props.source.height);\nconst previewRatio = computed(() => crop.value ? crop.value.width / crop.value.height : props.aspectRatio ?? 1);\nconst previewStyle = computed(() => {\n const area = crop.value;\n if (!area) return {};\n return {\n width: `${area.naturalWidth / area.width * 100}%`, height: `${area.naturalHeight / area.height * 100}%`,\n left: `${-area.x / area.width * 100}%`, top: `${-area.y / area.height * 100}%`,\n };\n});\n\nwatch(crop, value => { if (value) emit(\"change\", value); }, { flush: \"post\" });\nwatch(() => props.aspectRatio, () => api.value.reset(), { flush: \"post\" });\nwatch(() => props.maxZoom, value => { if (api.value.zoom > value) api.value.setZoom(value); });\n\nfunction reset() { if (!locked.value) api.value.reset(); }\nfunction setZoom(value: number) {\n if (!locked.value && Number.isFinite(value)) api.value.setZoom(Math.min(props.maxZoom, Math.max(1, value)));\n}\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const area = getCrop();\n const image = host.value?.querySelector<HTMLImageElement>('[data-part=\"image\"]');\n if (props.disabled || !area || !image?.complete) throw new Error(\"The image cropper is not ready to export.\");\n const resolved = resolveImageCropperExportOptions(options);\n const size = getImageCropperOutputSize(area, resolved.maxSize);\n const canvas = image.ownerDocument.createElement(\"canvas\");\n canvas.width = size.width; canvas.height = size.height;\n const context = canvas.getContext(\"2d\");\n if (!context) throw new Error(\"The browser could not create an image canvas.\");\n context.drawImage(image, area.x, area.y, area.width, area.height, 0, 0, size.width, size.height);\n const result = await new Promise<Blob | null>(resolve => canvas.toBlob(resolve, resolved.type, resolved.quality));\n if (disposed) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n if (!(result instanceof Blob)) throw new Error(\"The crop could not be exported. Check image access and output size.\");\n return result;\n}\n\nfunction blockInteraction(event: Event) {\n // A read-only crop can receive focus. Tab must still leave the control.\n if (event instanceof KeyboardEvent && event.key === \"Tab\") return;\n if (locked.value) { event.preventDefault(); event.stopImmediatePropagation(); }\n}\nfunction handlePointerStart(event: Event) {\n if (locked.value) {\n blockInteraction(event);\n return;\n }\n const target = event.target;\n if (target instanceof Element && target.closest('[data-scope=\"image-cropper\"][data-part=\"selection\"]')) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n}\nonBeforeUnmount(() => {\n disposed = true;\n});\ndefineExpose<ImageCropperApi>({ reset, setZoom, getCrop, exportBlob });\n</script>\n\n<template>\n <div ref=\"host\" class=\"kappa-image-cropper__editor\">\n <ArkImageCropper.RootProvider :value=\"api\" class=\"kappa-image-cropper__workspace\">\n <div class=\"kappa-image-cropper__stage\"\n @pointerdown.capture=\"handlePointerStart\" @keydown.capture=\"blockInteraction\"\n @wheel.capture=\"blockInteraction\" @touchstart.capture=\"handlePointerStart\" @touchmove.capture=\"blockInteraction\">\n <ArkImageCropper.Viewport class=\"kappa-image-cropper__viewport\"\n :style=\"{ aspectRatio: imageRatio, maxWidth: `${imageRatio * 320}px` }\">\n <ArkImageCropper.Image :src=\"source.url\" :crossorigin=\"crossOrigin\" class=\"kappa-image-cropper__image\" />\n <ArkImageCropper.Selection class=\"kappa-image-cropper__selection\"\n :tabindex=\"disabled ? -1 : 0\" :aria-disabled=\"disabled || undefined\" :aria-readonly=\"readOnly || undefined\">\n <ArkImageCropper.Grid axis=\"horizontal\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Grid axis=\"vertical\" class=\"kappa-image-cropper__grid\" />\n <ArkImageCropper.Handle v-for=\"position in HANDLE_POSITIONS\" :key=\"position\"\n :position=\"position\" class=\"kappa-image-cropper__handle\" />\n </ArkImageCropper.Selection>\n </ArkImageCropper.Viewport>\n </div>\n <div class=\"kappa-image-cropper__controls\">\n <Slider.Root :model-value=\"[api.zoom]\" :min=\"1\" :max=\"Math.max(1.01, maxZoom)\" :step=\"0.01\" :large-step=\"0.1\"\n :aria-label=\"[labels.zoom]\" :disabled=\"disabled || maxZoom === 1\" :read-only=\"readOnly\" size=\"sm\"\n :get-aria-value-text=\"({ value }) => `${Math.round(value * 100)}%`\"\n @update:model-value=\"setZoom($event[0] ?? 1)\">\n <Slider.Label>{{ labels.zoom }}</Slider.Label>\n <span class=\"kappa-image-cropper__zoom-value\" aria-hidden=\"true\">{{ Math.round(api.zoom * 100) }}%</span>\n <Slider.Control><Slider.Track><Slider.Range /></Slider.Track><Slider.Thumb :index=\"0\"><Slider.HiddenInput /></Slider.Thumb></Slider.Control>\n </Slider.Root>\n <Button variant=\"ghost\" size=\"sm\" :disabled=\"locked\" @click=\"reset\">{{ labels.reset }}</Button>\n </div>\n </ArkImageCropper.RootProvider>\n <figure v-if=\"showPreview\" class=\"kappa-image-cropper__preview\">\n <div class=\"kappa-image-cropper__preview-frame\" :style=\"{ aspectRatio: previewRatio }\">\n <img v-if=\"crop\" :src=\"source.url\" :alt=\"labels.preview\" :style=\"previewStyle\" draggable=\"false\" />\n </div>\n <figcaption>{{ labels.preview }}<span v-if=\"crop\">{{ Math.round(crop.width) }} × {{ Math.round(crop.height) }} px</span></figcaption>\n </figure>\n </div>\n</template>\n","import type { ImageCropperSource, ImageCropperStatus } from \"./image-cropper.ts\";\n\nexport interface ImageCropperLoadedSource {\n url: string;\n width: number;\n height: number;\n revision: number;\n}\n\ninterface SourceCallbacks {\n status: (status: ImageCropperStatus) => void;\n load: (source: ImageCropperLoadedSource) => void;\n error: (error: Error) => void;\n}\n\n/** Own only URLs created here. Superseded image callbacks cannot publish state. */\nexport function createImageCropperSourceLoader(callbacks: SourceCallbacks) {\n let revision = 0;\n let disposed = false;\n let image: HTMLImageElement | undefined;\n let ownedUrl: string | undefined;\n\n function clear() {\n revision += 1;\n if (image) {\n image.onload = null;\n image.onerror = null;\n image.removeAttribute(\"src\");\n image = undefined;\n }\n if (ownedUrl) URL.revokeObjectURL(ownedUrl);\n ownedUrl = undefined;\n }\n\n function load(source: ImageCropperSource | undefined, crossOrigin: \"anonymous\" | \"use-credentials\") {\n if (disposed) return;\n clear();\n if (!source) { callbacks.status(\"empty\"); return; }\n callbacks.status(\"loading\");\n const request = revision;\n const current = () => !disposed && request === revision;\n function fail() {\n if (!current()) return;\n clear();\n callbacks.status(\"error\");\n callbacks.error(new Error(\"The image could not be loaded. Check its format and cross-origin access.\"));\n }\n try {\n const url = typeof source === \"string\" ? source : (ownedUrl = URL.createObjectURL(source));\n const pending = new Image();\n image = pending;\n pending.crossOrigin = crossOrigin;\n pending.onload = () => {\n if (!current()) return;\n if (!(pending.naturalWidth > 0 && pending.naturalHeight > 0)) { fail(); return; }\n callbacks.load({ url, width: pending.naturalWidth, height: pending.naturalHeight, revision: request });\n callbacks.status(\"ready\");\n };\n pending.onerror = fail;\n pending.src = url;\n } catch { fail(); }\n }\n\n return { load, dispose() { disposed = true; clear(); } };\n}\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from \"vue\";\nimport ImageCropperEditor from \"./ImageCropperEditor.vue\";\nimport { createImageCropperSourceLoader, type ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { IMAGE_CROPPER_LABELS, resolveImageCropperAspectRatio, resolveImageCropperMaxZoom,\n type ImageCropperProps, type ImageCropperEmits, type ImageCropperApi, type ImageCropperStatus,\n type ImageCropperExportOptions } from \"./image-cropper\";\n\nconst props = withDefaults(defineProps<ImageCropperProps>(), {\n src: null, aspectRatio: 1, maxZoom: 5, disabled: false, readOnly: false,\n showPreview: true, crossOrigin: \"anonymous\",\n});\nconst emit = defineEmits<ImageCropperEmits>();\nconst status = ref<ImageCropperStatus>(props.src ? \"loading\" : \"empty\");\nconst source = shallowRef<ImageCropperLoadedSource>();\nconst editor = ref<ImageCropperApi>();\nconst labels = computed(() => ({ ...IMAGE_CROPPER_LABELS, ...props.labels }));\nlet loader: ReturnType<typeof createImageCropperSourceLoader> | undefined;\nlet disposed = false;\n\nonMounted(() => {\n loader = createImageCropperSourceLoader({\n status(value) {\n status.value = value;\n if (value !== \"ready\") source.value = undefined;\n emit(\"statusChange\", value);\n },\n load(value) { source.value = value; emit(\"load\", { width: value.width, height: value.height }); },\n error(error) { emit(\"error\", { phase: \"load\", error }); },\n });\n loader.load(props.src, props.crossOrigin);\n});\nwatch(() => [props.src, props.crossOrigin] as const, () => loader?.load(props.src, props.crossOrigin), { flush: \"sync\" });\nonBeforeUnmount(() => { disposed = true; loader?.dispose(); });\n\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const revision = source.value?.revision;\n const current = editor.value;\n try {\n if (status.value !== \"ready\" || !current) throw new Error(\"The image cropper is not ready to export.\");\n const blob = await current.exportBlob(options);\n if (disposed || revision !== source.value?.revision) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n return blob;\n } catch (error) {\n if (!disposed && !(error instanceof DOMException && error.name === \"AbortError\")) {\n emit(\"error\", { phase: \"export\", error: error instanceof Error ? error : new Error(String(error)) });\n }\n throw error;\n }\n}\ndefineExpose<ImageCropperApi>({\n reset: () => editor.value?.reset(), setZoom: value => editor.value?.setZoom(value),\n getCrop: () => status.value === \"ready\" ? editor.value?.getCrop() ?? null : null,\n exportBlob,\n});\n</script>\n\n<template>\n <div class=\"kappa-image-cropper\" data-slot=\"image-cropper\" :data-state=\"status\"\n :data-disabled=\"disabled ? '' : undefined\" :data-readonly=\"readOnly ? '' : undefined\"\n :aria-busy=\"status === 'loading' || undefined\">\n <ImageCropperEditor v-if=\"source\" :key=\"source.revision\" ref=\"editor\" :source=\"source\"\n :aspect-ratio=\"resolveImageCropperAspectRatio(aspectRatio)\" :max-zoom=\"resolveImageCropperMaxZoom(maxZoom)\"\n :disabled=\"disabled\" :read-only=\"readOnly\" :show-preview=\"showPreview\" :cross-origin=\"crossOrigin\" :labels=\"labels\"\n @change=\"emit('change', $event)\" />\n <div v-else class=\"kappa-image-cropper__placeholder\" :role=\"status === 'error' ? 'alert' : 'status'\">\n <span>{{ status === 'loading' ? labels.loading : status === 'error' ? labels.error : labels.empty }}</span>\n </div>\n <p v-if=\"source && !disabled && !readOnly\" class=\"kappa-image-cropper__instructions\">{{ labels.instructions }}</p>\n </div>\n</template>\n\n<style src=\"./image-cropper.css\"></style>\n","<script setup lang=\"ts\">\nimport { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from \"vue\";\nimport ImageCropperEditor from \"./ImageCropperEditor.vue\";\nimport { createImageCropperSourceLoader, type ImageCropperLoadedSource } from \"./image-cropper-source\";\nimport { IMAGE_CROPPER_LABELS, resolveImageCropperAspectRatio, resolveImageCropperMaxZoom,\n type ImageCropperProps, type ImageCropperEmits, type ImageCropperApi, type ImageCropperStatus,\n type ImageCropperExportOptions } from \"./image-cropper\";\n\nconst props = withDefaults(defineProps<ImageCropperProps>(), {\n src: null, aspectRatio: 1, maxZoom: 5, disabled: false, readOnly: false,\n showPreview: true, crossOrigin: \"anonymous\",\n});\nconst emit = defineEmits<ImageCropperEmits>();\nconst status = ref<ImageCropperStatus>(props.src ? \"loading\" : \"empty\");\nconst source = shallowRef<ImageCropperLoadedSource>();\nconst editor = ref<ImageCropperApi>();\nconst labels = computed(() => ({ ...IMAGE_CROPPER_LABELS, ...props.labels }));\nlet loader: ReturnType<typeof createImageCropperSourceLoader> | undefined;\nlet disposed = false;\n\nonMounted(() => {\n loader = createImageCropperSourceLoader({\n status(value) {\n status.value = value;\n if (value !== \"ready\") source.value = undefined;\n emit(\"statusChange\", value);\n },\n load(value) { source.value = value; emit(\"load\", { width: value.width, height: value.height }); },\n error(error) { emit(\"error\", { phase: \"load\", error }); },\n });\n loader.load(props.src, props.crossOrigin);\n});\nwatch(() => [props.src, props.crossOrigin] as const, () => loader?.load(props.src, props.crossOrigin), { flush: \"sync\" });\nonBeforeUnmount(() => { disposed = true; loader?.dispose(); });\n\nasync function exportBlob(options?: ImageCropperExportOptions): Promise<Blob> {\n const revision = source.value?.revision;\n const current = editor.value;\n try {\n if (status.value !== \"ready\" || !current) throw new Error(\"The image cropper is not ready to export.\");\n const blob = await current.exportBlob(options);\n if (disposed || revision !== source.value?.revision) throw new DOMException(\"The image source changed during export.\", \"AbortError\");\n return blob;\n } catch (error) {\n if (!disposed && !(error instanceof DOMException && error.name === \"AbortError\")) {\n emit(\"error\", { phase: \"export\", error: error instanceof Error ? error : new Error(String(error)) });\n }\n throw error;\n }\n}\ndefineExpose<ImageCropperApi>({\n reset: () => editor.value?.reset(), setZoom: value => editor.value?.setZoom(value),\n getCrop: () => status.value === \"ready\" ? editor.value?.getCrop() ?? null : null,\n exportBlob,\n});\n</script>\n\n<template>\n <div class=\"kappa-image-cropper\" data-slot=\"image-cropper\" :data-state=\"status\"\n :data-disabled=\"disabled ? '' : undefined\" :data-readonly=\"readOnly ? '' : undefined\"\n :aria-busy=\"status === 'loading' || undefined\">\n <ImageCropperEditor v-if=\"source\" :key=\"source.revision\" ref=\"editor\" :source=\"source\"\n :aspect-ratio=\"resolveImageCropperAspectRatio(aspectRatio)\" :max-zoom=\"resolveImageCropperMaxZoom(maxZoom)\"\n :disabled=\"disabled\" :read-only=\"readOnly\" :show-preview=\"showPreview\" :cross-origin=\"crossOrigin\" :labels=\"labels\"\n @change=\"emit('change', $event)\" />\n <div v-else class=\"kappa-image-cropper__placeholder\" :role=\"status === 'error' ? 'alert' : 'status'\">\n <span>{{ status === 'loading' ? labels.loading : status === 'error' ? labels.error : labels.empty }}</span>\n </div>\n <p v-if=\"source && !disabled && !readOnly\" class=\"kappa-image-cropper__instructions\">{{ labels.instructions }}</p>\n </div>\n</template>\n\n<style src=\"./image-cropper.css\"></style>\n"],"mappings":";;;;;AAAA,IAAa,IAAqC,GACrC,IAAiC,GAsCjC,IAA2C;CACtD,QAAQ;CACR,WAAW;CACX,cAAc;CACd,MAAM;CACN,OAAO;CACP,SAAS;CACT,OAAO;CACP,SAAS;CACT,OAAO;AACT;AAuCA,SAAgB,EAA+B,GAAoC;CAC7E,UAAU,QAC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EM,OAAA;;GAFM,OAAM;GAAoC,MAAM,EAAA,UAAM,UAAA,UAAA;EAChE,GAAA,CAAA,EAA2G,QAAA,MAAA,EAAlG,EAAA,UAAM,YAAiB,EAAA,MAAO,UAAU,EAAA,UAAM,UAAe,EAAA,MAAO,QAAQ,EAAA,MAAO,KAAK,GAAA,CAAA,CAAA,GAAA,GAAA,CAAA,IAE1F,EAAA,SAAM,CAAK,EAAA,YAAQ,CAAK,EAAA,YAAjC,EAAA,GAAA,EAAkH,KAAlH,GAAkH,EAA1B,EAAA,MAAO,YAAY,GAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,GAAA,GAAA,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./Button-Da1Xjklh.js";
|
|
2
2
|
import { t } from "./empty-DT_j6Liv.js";
|
|
3
3
|
import { t as n } from "./Loader-DclnxBId.js";
|
|
4
|
-
import { t as r } from "./dialog-layout-
|
|
4
|
+
import { t as r } from "./dialog-layout-DLOoWtT1.js";
|
|
5
5
|
import { t as i } from "./input-C2XpksEe.js";
|
|
6
6
|
import { n as a, t as o } from "./selection-list-C4yUsi8U.js";
|
|
7
7
|
import { Fragment as s, computed as c, createBlock as l, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createTextVNode as p, createVNode as m, defineComponent as h, mergeProps as g, nextTick as _, openBlock as v, ref as y, renderList as b, renderSlot as x, toDisplayString as S, unref as C, useId as w, useSlots as T, watch as E, withCtx as D } from "vue";
|
|
@@ -332,4 +332,4 @@ var A = { class: "kappa-resource-picker__search" }, j = ["aria-busy"], M = {
|
|
|
332
332
|
//#endregion
|
|
333
333
|
export { O as n, I as t };
|
|
334
334
|
|
|
335
|
-
//# sourceMappingURL=ResourcePicker-
|
|
335
|
+
//# sourceMappingURL=ResourcePicker-Ctmc4QxZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourcePicker-BbzGyL_F.js","names":["$attrs"],"sources":["../src/blocks/resource-picker/resource-picker.ts","../src/blocks/resource-picker/use-resource-picker-state.ts","../src/blocks/resource-picker/ResourcePicker.vue","../src/blocks/resource-picker/ResourcePicker.vue"],"sourcesContent":["import type { VNodeChild } from \"vue\";\n\nexport interface ResourcePickerItem {\n /** Stable resource identifier. Values must be unique. */\n value: string;\n label: string;\n description?: string;\n meta?: string;\n /** Additional terms included in local search. */\n keywords?: string[];\n disabled?: boolean;\n}\n\nexport type ResourcePickerSelectionMode = \"single\" | \"multiple\";\nexport type ResourcePickerFilterMode = \"local\" | \"external\";\n\nexport interface ResourcePickerLabels {\n trigger: string;\n search: string;\n searchPlaceholder: string;\n confirm: string;\n cancel: string;\n close: string;\n loading: string;\n emptyTitle: string;\n emptyDescription: string;\n errorTitle: string;\n retry: string;\n selectionCount: (count: number) => string;\n}\n\nexport const RESOURCE_PICKER_DEFAULT_LABELS: ResourcePickerLabels = {\n trigger: \"Choose resource\",\n search: \"Search resources\",\n searchPlaceholder: \"Search by name…\",\n confirm: \"Select\",\n cancel: \"Cancel\",\n close: \"Close resource picker\",\n loading: \"Loading resources…\",\n emptyTitle: \"No resources found\",\n emptyDescription: \"Try another search or check the available resources.\",\n errorTitle: \"Could not load resources\",\n retry: \"Try again\",\n selectionCount: count => `${count} selected`,\n};\n\nexport interface ResourcePickerProps {\n items: ResourcePickerItem[];\n /** Accessible dialog and list title. */\n title?: string;\n description?: string;\n open?: boolean;\n defaultOpen?: boolean;\n /** Committed IDs; only changes after the confirm action. */\n modelValue?: string[];\n defaultValue?: string[];\n selectionMode?: ResourcePickerSelectionMode;\n /** External mode renders the provided results without filtering them again. */\n filterMode?: ResourcePickerFilterMode;\n loading?: boolean;\n /** A non-empty message replaces the results with an error state. */\n error?: string;\n /** Permits confirming an empty selection. */\n allowEmpty?: boolean;\n disabled?: boolean;\n labels?: Partial<ResourcePickerLabels>;\n}\n\nexport type ResourcePickerEmits = {\n \"update:open\": [open: boolean];\n \"update:modelValue\": [value: string[]];\n /** Fires for search changes. Debounce and fetch in the consumer. */\n searchChange: [query: string];\n confirm: [value: string[]];\n /** Fires when dismissed without confirmation, including Escape and outside click. */\n cancel: [];\n retry: [];\n};\n\nexport interface ResourcePickerSlots {\n /** Supply one button; Dialog.Trigger supplies its behavior and ARIA attributes. */\n trigger?: () => VNodeChild;\n /** Decorative media shown before each resource name. */\n media?: (props: { item: ResourcePickerItem }) => VNodeChild;\n /** Additional non-interactive content below each resource name. */\n description?: (props: { item: ResourcePickerItem }) => VNodeChild;\n meta?: (props: { item: ResourcePickerItem }) => VNodeChild;\n empty?: (props: { query: string }) => VNodeChild;\n loading?: () => VNodeChild;\n error?: (props: { message: string; retry: () => void }) => VNodeChild;\n selection?: (props: { value: string[] }) => VNodeChild;\n}\n","import { computed, nextTick, ref, watch } from \"vue\";\nimport type { ResourcePickerEmits, ResourcePickerProps } from \"./resource-picker\";\n\ntype Emit = <Event extends keyof ResourcePickerEmits>(event: Event, ...args: ResourcePickerEmits[Event]) => void;\n\n/** Private draft state. Resource selection behavior stays in SelectionList. */\nexport function useResourcePickerState(props: Readonly<ResourcePickerProps>, emit: Emit) {\n const internalOpen = ref(props.defaultOpen ?? false);\n const internalValue = ref([...(props.defaultValue ?? [])]);\n const isOpen = computed(() => props.open ?? internalOpen.value);\n const committedValue = computed(() => props.modelValue ?? internalValue.value);\n const draft = ref<string[]>([]);\n const query = ref(\"\");\n let confirmed = false;\n\n const available = computed(() => new Map(props.items.map(item => [item.value, item])));\n const normalize = (values: string[]) => {\n const valid = [...new Set(values)].filter(value => {\n const item = available.value.get(value);\n return item ? !item.disabled : props.filterMode === \"external\";\n });\n return props.selectionMode === \"multiple\" ? valid : valid.slice(0, 1);\n };\n\n watch(isOpen, (open, previous) => {\n if (open) {\n confirmed = false;\n // Preserve unknown committed IDs while the consumer loads the results.\n const value = [...new Set(committedValue.value)].filter(id => !available.value.get(id)?.disabled);\n draft.value = props.selectionMode === \"multiple\" ? value : value.slice(0, 1);\n if (query.value) updateQuery(\"\");\n } else if (previous && !confirmed) {\n emit(\"cancel\");\n }\n }, { immediate: true, flush: \"sync\" });\n\n watch(() => props.items.filter(item => item.disabled).map(item => item.value), disabled => {\n const disabledIds = new Set(disabled);\n // Remember loss of eligibility even when a subsequent external result omits the item.\n draft.value = draft.value.filter(value => !disabledIds.has(value));\n }, { immediate: true, flush: \"sync\" });\n\n const visibleItems = computed(() => {\n const term = query.value.trim().toLocaleLowerCase();\n return props.filterMode === \"external\" || !term\n ? props.items\n : props.items.filter(item =>\n [item.label, item.description, item.meta, ...(item.keywords ?? [])]\n .filter(Boolean).join(\" \").toLocaleLowerCase().includes(term),\n );\n });\n const selected = computed(() => normalize(draft.value));\n const displayedValue = computed(() => {\n const visible = new Set(visibleItems.value.filter(item => !item.disabled).map(item => item.value));\n return selected.value.filter(value => visible.has(value));\n });\n const canConfirm = computed(() =>\n !props.disabled && !props.loading && !props.error && (Boolean(props.allowEmpty) || selected.value.length > 0),\n );\n\n function updateQuery(value: string | number) {\n query.value = String(value);\n emit(\"searchChange\", query.value);\n }\n\n function updateOpen(open: boolean) {\n if (open && props.disabled) return;\n internalOpen.value = open;\n emit(\"update:open\", open);\n }\n\n function updateDraft(value: string[]) {\n if (props.selectionMode !== \"multiple\") {\n draft.value = normalize(value);\n return;\n }\n const visibleIds = new Set(visibleItems.value.map(item => item.value));\n draft.value = normalize([...draft.value.filter(id => !visibleIds.has(id)), ...value]);\n }\n\n function confirm() {\n if (!canConfirm.value) return;\n const value = [...selected.value];\n confirmed = true;\n internalValue.value = value;\n emit(\"update:modelValue\", [...value]);\n emit(\"confirm\", [...value]);\n updateOpen(false);\n // A controlled parent may decline the close request. Later dismissal is cancellation.\n void nextTick(() => { confirmed = false; });\n }\n\n return { isOpen, query, visibleItems, selected, displayedValue, canConfirm, updateQuery, updateOpen, updateDraft, confirm };\n}\n","<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport { Button } from \"../../components/button\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Empty } from \"../../components/empty\";\nimport { Input } from \"../../components/input\";\nimport { Loader } from \"../../components/loader\";\nimport { SelectionList, createSelectionListCollection } from \"../../components/selection-list\";\nimport {\n RESOURCE_PICKER_DEFAULT_LABELS,\n type ResourcePickerEmits,\n type ResourcePickerProps,\n type ResourcePickerSlots,\n} from \"./resource-picker\";\nimport { useResourcePickerState } from \"./use-resource-picker-state\";\n\ndefineOptions({ inheritAttrs: false });\nconst props = withDefaults(defineProps<ResourcePickerProps>(), {\n title: \"Choose a resource\",\n open: undefined,\n defaultOpen: false,\n modelValue: undefined,\n defaultValue: () => [],\n selectionMode: \"single\",\n filterMode: \"local\",\n loading: false,\n allowEmpty: false,\n disabled: false,\n});\nconst emit = defineEmits<ResourcePickerEmits>();\nconst slots = defineSlots<ResourcePickerSlots>();\nconst searchId = `kappa-resource-picker-search-${useId()}`;\nconst labels = computed(() => ({ ...RESOURCE_PICKER_DEFAULT_LABELS, ...props.labels }));\nconst { isOpen, query, visibleItems, selected, displayedValue, canConfirm, updateQuery, updateOpen, updateDraft, confirm } = useResourcePickerState(props, emit);\nconst collection = computed(() => createSelectionListCollection({\n items: visibleItems.value,\n itemToValue: item => item.value,\n itemToString: item => item.label,\n isItemDisabled: item => Boolean(item.disabled),\n}));\n\nconst initialFocus = () => document.getElementById(searchId);\nconst retry = () => emit(\"retry\");\n</script>\n\n<template>\n <DialogLayout.Root :open=\"isOpen\" :initial-focus-el=\"initialFocus\" @update:open=\"updateOpen\">\n <DialogLayout.Trigger as-child :disabled=\"props.disabled\">\n <slot name=\"trigger\"><Button :disabled=\"props.disabled\" variant=\"secondary\">{{ labels.trigger }}</Button></slot>\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-resource-picker\"\n data-slot=\"resource-picker\"\n size=\"lg\"\n :close-label=\"labels.close\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description v-if=\"props.description\">{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <DialogLayout.Body class=\"kappa-resource-picker__body\">\n <SelectionList.Root\n class=\"kappa-resource-picker__list\"\n :collection=\"collection\"\n :model-value=\"displayedValue\"\n :selection-mode=\"props.selectionMode\"\n :disabled=\"props.disabled\"\n :select-on-highlight=\"false\"\n @update:model-value=\"updateDraft\"\n >\n <div class=\"kappa-resource-picker__search\">\n <SelectionList.Input as-child auto-highlight keyboard-priority=\"navigate\">\n <Input\n :id=\"searchId\"\n :model-value=\"query\"\n type=\"search\"\n :aria-label=\"labels.search\"\n :placeholder=\"labels.searchPlaceholder\"\n autocomplete=\"off\"\n @update:model-value=\"updateQuery\"\n />\n </SelectionList.Input>\n </div>\n <div class=\"kappa-resource-picker__results\" :aria-busy=\"props.loading\">\n <div v-if=\"props.loading\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"loading\"><Loader decorative size=\"sm\" /><span>{{ labels.loading }}</span></slot>\n </div>\n <div v-else-if=\"props.error\" class=\"kappa-resource-picker__state\" role=\"alert\">\n <slot name=\"error\" :message=\"props.error\" :retry=\"retry\">\n <Empty size=\"sm\">\n <Empty.Header><Empty.Title>{{ labels.errorTitle }}</Empty.Title><Empty.Description>{{ props.error }}</Empty.Description></Empty.Header>\n <Empty.Content><Button size=\"sm\" variant=\"secondary\" @click=\"retry\">{{ labels.retry }}</Button></Empty.Content>\n </Empty>\n </slot>\n </div>\n <div v-else-if=\"!collection.items.length\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"empty\" :query=\"query\">\n <Empty size=\"sm\"><Empty.Header><Empty.Title>{{ labels.emptyTitle }}</Empty.Title><Empty.Description>{{ labels.emptyDescription }}</Empty.Description></Empty.Header></Empty>\n </slot>\n </div>\n <SelectionList.Content v-else :aria-label=\"props.title\">\n <SelectionList.Item v-for=\"item in collection.items\" :key=\"item.value\" :item=\"item\">\n <SelectionList.ItemMedia v-if=\"slots.media\"><slot name=\"media\" :item=\"item\" /></SelectionList.ItemMedia>\n <SelectionList.ItemContent>\n <SelectionList.ItemText>{{ item.label }}</SelectionList.ItemText>\n <SelectionList.ItemDescription v-if=\"item.description || slots.description\"><slot name=\"description\" :item=\"item\">{{ item.description }}</slot></SelectionList.ItemDescription>\n </SelectionList.ItemContent>\n <SelectionList.ItemMeta v-if=\"item.meta || slots.meta\"><slot name=\"meta\" :item=\"item\">{{ item.meta }}</slot></SelectionList.ItemMeta>\n <SelectionList.ItemIndicator />\n </SelectionList.Item>\n </SelectionList.Content>\n </div>\n </SelectionList.Root>\n </DialogLayout.Body>\n <DialogLayout.Actions :dismiss-label=\"labels.cancel\">\n <span class=\"kappa-resource-picker__selection\" role=\"status\"><slot name=\"selection\" :value=\"selected\">{{ labels.selectionCount(selected.length) }}</slot></span>\n <Button :disabled=\"!canConfirm\" size=\"sm\" @click=\"confirm\">{{ labels.confirm }}</Button>\n </DialogLayout.Actions>\n </DialogLayout.Content>\n </DialogLayout.Root>\n</template>\n\n<style src=\"./resource-picker.css\"></style>\n","<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport { Button } from \"../../components/button\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Empty } from \"../../components/empty\";\nimport { Input } from \"../../components/input\";\nimport { Loader } from \"../../components/loader\";\nimport { SelectionList, createSelectionListCollection } from \"../../components/selection-list\";\nimport {\n RESOURCE_PICKER_DEFAULT_LABELS,\n type ResourcePickerEmits,\n type ResourcePickerProps,\n type ResourcePickerSlots,\n} from \"./resource-picker\";\nimport { useResourcePickerState } from \"./use-resource-picker-state\";\n\ndefineOptions({ inheritAttrs: false });\nconst props = withDefaults(defineProps<ResourcePickerProps>(), {\n title: \"Choose a resource\",\n open: undefined,\n defaultOpen: false,\n modelValue: undefined,\n defaultValue: () => [],\n selectionMode: \"single\",\n filterMode: \"local\",\n loading: false,\n allowEmpty: false,\n disabled: false,\n});\nconst emit = defineEmits<ResourcePickerEmits>();\nconst slots = defineSlots<ResourcePickerSlots>();\nconst searchId = `kappa-resource-picker-search-${useId()}`;\nconst labels = computed(() => ({ ...RESOURCE_PICKER_DEFAULT_LABELS, ...props.labels }));\nconst { isOpen, query, visibleItems, selected, displayedValue, canConfirm, updateQuery, updateOpen, updateDraft, confirm } = useResourcePickerState(props, emit);\nconst collection = computed(() => createSelectionListCollection({\n items: visibleItems.value,\n itemToValue: item => item.value,\n itemToString: item => item.label,\n isItemDisabled: item => Boolean(item.disabled),\n}));\n\nconst initialFocus = () => document.getElementById(searchId);\nconst retry = () => emit(\"retry\");\n</script>\n\n<template>\n <DialogLayout.Root :open=\"isOpen\" :initial-focus-el=\"initialFocus\" @update:open=\"updateOpen\">\n <DialogLayout.Trigger as-child :disabled=\"props.disabled\">\n <slot name=\"trigger\"><Button :disabled=\"props.disabled\" variant=\"secondary\">{{ labels.trigger }}</Button></slot>\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-resource-picker\"\n data-slot=\"resource-picker\"\n size=\"lg\"\n :close-label=\"labels.close\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description v-if=\"props.description\">{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <DialogLayout.Body class=\"kappa-resource-picker__body\">\n <SelectionList.Root\n class=\"kappa-resource-picker__list\"\n :collection=\"collection\"\n :model-value=\"displayedValue\"\n :selection-mode=\"props.selectionMode\"\n :disabled=\"props.disabled\"\n :select-on-highlight=\"false\"\n @update:model-value=\"updateDraft\"\n >\n <div class=\"kappa-resource-picker__search\">\n <SelectionList.Input as-child auto-highlight keyboard-priority=\"navigate\">\n <Input\n :id=\"searchId\"\n :model-value=\"query\"\n type=\"search\"\n :aria-label=\"labels.search\"\n :placeholder=\"labels.searchPlaceholder\"\n autocomplete=\"off\"\n @update:model-value=\"updateQuery\"\n />\n </SelectionList.Input>\n </div>\n <div class=\"kappa-resource-picker__results\" :aria-busy=\"props.loading\">\n <div v-if=\"props.loading\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"loading\"><Loader decorative size=\"sm\" /><span>{{ labels.loading }}</span></slot>\n </div>\n <div v-else-if=\"props.error\" class=\"kappa-resource-picker__state\" role=\"alert\">\n <slot name=\"error\" :message=\"props.error\" :retry=\"retry\">\n <Empty size=\"sm\">\n <Empty.Header><Empty.Title>{{ labels.errorTitle }}</Empty.Title><Empty.Description>{{ props.error }}</Empty.Description></Empty.Header>\n <Empty.Content><Button size=\"sm\" variant=\"secondary\" @click=\"retry\">{{ labels.retry }}</Button></Empty.Content>\n </Empty>\n </slot>\n </div>\n <div v-else-if=\"!collection.items.length\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"empty\" :query=\"query\">\n <Empty size=\"sm\"><Empty.Header><Empty.Title>{{ labels.emptyTitle }}</Empty.Title><Empty.Description>{{ labels.emptyDescription }}</Empty.Description></Empty.Header></Empty>\n </slot>\n </div>\n <SelectionList.Content v-else :aria-label=\"props.title\">\n <SelectionList.Item v-for=\"item in collection.items\" :key=\"item.value\" :item=\"item\">\n <SelectionList.ItemMedia v-if=\"slots.media\"><slot name=\"media\" :item=\"item\" /></SelectionList.ItemMedia>\n <SelectionList.ItemContent>\n <SelectionList.ItemText>{{ item.label }}</SelectionList.ItemText>\n <SelectionList.ItemDescription v-if=\"item.description || slots.description\"><slot name=\"description\" :item=\"item\">{{ item.description }}</slot></SelectionList.ItemDescription>\n </SelectionList.ItemContent>\n <SelectionList.ItemMeta v-if=\"item.meta || slots.meta\"><slot name=\"meta\" :item=\"item\">{{ item.meta }}</slot></SelectionList.ItemMeta>\n <SelectionList.ItemIndicator />\n </SelectionList.Item>\n </SelectionList.Content>\n </div>\n </SelectionList.Root>\n </DialogLayout.Body>\n <DialogLayout.Actions :dismiss-label=\"labels.cancel\">\n <span class=\"kappa-resource-picker__selection\" role=\"status\"><slot name=\"selection\" :value=\"selected\">{{ labels.selectionCount(selected.length) }}</slot></span>\n <Button :disabled=\"!canConfirm\" size=\"sm\" @click=\"confirm\">{{ labels.confirm }}</Button>\n </DialogLayout.Actions>\n </DialogLayout.Content>\n </DialogLayout.Root>\n</template>\n\n<style src=\"./resource-picker.css\"></style>\n"],"mappings":";;;;;;;;AA+BA,IAAa,IAAuD;CAClE,SAAS;CACT,QAAQ;CACR,mBAAmB;CACnB,SAAS;CACT,QAAQ;CACR,OAAO;CACP,SAAS;CACT,YAAY;CACZ,kBAAkB;CAClB,YAAY;CACZ,OAAO;CACP,iBAAgB,MAAS,GAAG,EAAM;AACpC;;;ACtCA,SAAgB,EAAuB,GAAsC,GAAY;CACvF,IAAM,IAAe,EAAI,EAAM,eAAe,EAAK,GAC7C,IAAgB,EAAI,CAAC,GAAI,EAAM,gBAAgB,CAAC,CAAE,CAAC,GACnD,IAAS,QAAe,EAAM,QAAQ,EAAa,KAAK,GACxD,IAAiB,QAAe,EAAM,cAAc,EAAc,KAAK,GACvE,IAAQ,EAAc,CAAC,CAAC,GACxB,IAAQ,EAAI,EAAE,GAChB,IAAY,IAEV,IAAY,QAAe,IAAI,IAAI,EAAM,MAAM,KAAI,MAAQ,CAAC,EAAK,OAAO,CAAI,CAAC,CAAC,CAAC,GAC/E,KAAa,MAAqB;EACtC,IAAM,IAAQ,CAAC,GAAG,IAAI,IAAI,CAAM,CAAC,CAAC,CAAC,QAAO,MAAS;GACjD,IAAM,IAAO,EAAU,MAAM,IAAI,CAAK;GACtC,OAAO,IAAO,CAAC,EAAK,WAAW,EAAM,eAAe;EACtD,CAAC;EACD,OAAO,EAAM,kBAAkB,aAAa,IAAQ,EAAM,MAAM,GAAG,CAAC;CACtE;CAcA,AAZA,EAAM,IAAS,GAAM,MAAa;EAChC,IAAI,GAAM;GACR,IAAY;GAEZ,IAAM,IAAQ,CAAC,GAAG,IAAI,IAAI,EAAe,KAAK,CAAC,CAAC,CAAC,QAAO,MAAM,CAAC,EAAU,MAAM,IAAI,CAAE,CAAC,EAAE,QAAQ;GAEhG,AADA,EAAM,QAAQ,EAAM,kB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EAAwF,EAAA,CAAA,GAAA;OAA/E,UAAQ,CAAG,EAAA,CAAA;OAAY,MAAK;OAAM,SAAO,EAAA,CAAA;;OAAS,SAAA,QAAoB,CAAjB,EAAA,EAAA,EAAA,MAAO,OAAO,GAAA,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"ResourcePicker-Ctmc4QxZ.js","names":["$attrs"],"sources":["../src/blocks/resource-picker/resource-picker.ts","../src/blocks/resource-picker/use-resource-picker-state.ts","../src/blocks/resource-picker/ResourcePicker.vue","../src/blocks/resource-picker/ResourcePicker.vue"],"sourcesContent":["import type { VNodeChild } from \"vue\";\n\nexport interface ResourcePickerItem {\n /** Stable resource identifier. Values must be unique. */\n value: string;\n label: string;\n description?: string;\n meta?: string;\n /** Additional terms included in local search. */\n keywords?: string[];\n disabled?: boolean;\n}\n\nexport type ResourcePickerSelectionMode = \"single\" | \"multiple\";\nexport type ResourcePickerFilterMode = \"local\" | \"external\";\n\nexport interface ResourcePickerLabels {\n trigger: string;\n search: string;\n searchPlaceholder: string;\n confirm: string;\n cancel: string;\n close: string;\n loading: string;\n emptyTitle: string;\n emptyDescription: string;\n errorTitle: string;\n retry: string;\n selectionCount: (count: number) => string;\n}\n\nexport const RESOURCE_PICKER_DEFAULT_LABELS: ResourcePickerLabels = {\n trigger: \"Choose resource\",\n search: \"Search resources\",\n searchPlaceholder: \"Search by name…\",\n confirm: \"Select\",\n cancel: \"Cancel\",\n close: \"Close resource picker\",\n loading: \"Loading resources…\",\n emptyTitle: \"No resources found\",\n emptyDescription: \"Try another search or check the available resources.\",\n errorTitle: \"Could not load resources\",\n retry: \"Try again\",\n selectionCount: count => `${count} selected`,\n};\n\nexport interface ResourcePickerProps {\n items: ResourcePickerItem[];\n /** Accessible dialog and list title. */\n title?: string;\n description?: string;\n open?: boolean;\n defaultOpen?: boolean;\n /** Committed IDs; only changes after the confirm action. */\n modelValue?: string[];\n defaultValue?: string[];\n selectionMode?: ResourcePickerSelectionMode;\n /** External mode renders the provided results without filtering them again. */\n filterMode?: ResourcePickerFilterMode;\n loading?: boolean;\n /** A non-empty message replaces the results with an error state. */\n error?: string;\n /** Permits confirming an empty selection. */\n allowEmpty?: boolean;\n disabled?: boolean;\n labels?: Partial<ResourcePickerLabels>;\n}\n\nexport type ResourcePickerEmits = {\n \"update:open\": [open: boolean];\n \"update:modelValue\": [value: string[]];\n /** Fires for search changes. Debounce and fetch in the consumer. */\n searchChange: [query: string];\n confirm: [value: string[]];\n /** Fires when dismissed without confirmation, including Escape and outside click. */\n cancel: [];\n retry: [];\n};\n\nexport interface ResourcePickerSlots {\n /** Supply one button; Dialog.Trigger supplies its behavior and ARIA attributes. */\n trigger?: () => VNodeChild;\n /** Decorative media shown before each resource name. */\n media?: (props: { item: ResourcePickerItem }) => VNodeChild;\n /** Additional non-interactive content below each resource name. */\n description?: (props: { item: ResourcePickerItem }) => VNodeChild;\n meta?: (props: { item: ResourcePickerItem }) => VNodeChild;\n empty?: (props: { query: string }) => VNodeChild;\n loading?: () => VNodeChild;\n error?: (props: { message: string; retry: () => void }) => VNodeChild;\n selection?: (props: { value: string[] }) => VNodeChild;\n}\n","import { computed, nextTick, ref, watch } from \"vue\";\nimport type { ResourcePickerEmits, ResourcePickerProps } from \"./resource-picker\";\n\ntype Emit = <Event extends keyof ResourcePickerEmits>(event: Event, ...args: ResourcePickerEmits[Event]) => void;\n\n/** Private draft state. Resource selection behavior stays in SelectionList. */\nexport function useResourcePickerState(props: Readonly<ResourcePickerProps>, emit: Emit) {\n const internalOpen = ref(props.defaultOpen ?? false);\n const internalValue = ref([...(props.defaultValue ?? [])]);\n const isOpen = computed(() => props.open ?? internalOpen.value);\n const committedValue = computed(() => props.modelValue ?? internalValue.value);\n const draft = ref<string[]>([]);\n const query = ref(\"\");\n let confirmed = false;\n\n const available = computed(() => new Map(props.items.map(item => [item.value, item])));\n const normalize = (values: string[]) => {\n const valid = [...new Set(values)].filter(value => {\n const item = available.value.get(value);\n return item ? !item.disabled : props.filterMode === \"external\";\n });\n return props.selectionMode === \"multiple\" ? valid : valid.slice(0, 1);\n };\n\n watch(isOpen, (open, previous) => {\n if (open) {\n confirmed = false;\n // Preserve unknown committed IDs while the consumer loads the results.\n const value = [...new Set(committedValue.value)].filter(id => !available.value.get(id)?.disabled);\n draft.value = props.selectionMode === \"multiple\" ? value : value.slice(0, 1);\n if (query.value) updateQuery(\"\");\n } else if (previous && !confirmed) {\n emit(\"cancel\");\n }\n }, { immediate: true, flush: \"sync\" });\n\n watch(() => props.items.filter(item => item.disabled).map(item => item.value), disabled => {\n const disabledIds = new Set(disabled);\n // Remember loss of eligibility even when a subsequent external result omits the item.\n draft.value = draft.value.filter(value => !disabledIds.has(value));\n }, { immediate: true, flush: \"sync\" });\n\n const visibleItems = computed(() => {\n const term = query.value.trim().toLocaleLowerCase();\n return props.filterMode === \"external\" || !term\n ? props.items\n : props.items.filter(item =>\n [item.label, item.description, item.meta, ...(item.keywords ?? [])]\n .filter(Boolean).join(\" \").toLocaleLowerCase().includes(term),\n );\n });\n const selected = computed(() => normalize(draft.value));\n const displayedValue = computed(() => {\n const visible = new Set(visibleItems.value.filter(item => !item.disabled).map(item => item.value));\n return selected.value.filter(value => visible.has(value));\n });\n const canConfirm = computed(() =>\n !props.disabled && !props.loading && !props.error && (Boolean(props.allowEmpty) || selected.value.length > 0),\n );\n\n function updateQuery(value: string | number) {\n query.value = String(value);\n emit(\"searchChange\", query.value);\n }\n\n function updateOpen(open: boolean) {\n if (open && props.disabled) return;\n internalOpen.value = open;\n emit(\"update:open\", open);\n }\n\n function updateDraft(value: string[]) {\n if (props.selectionMode !== \"multiple\") {\n draft.value = normalize(value);\n return;\n }\n const visibleIds = new Set(visibleItems.value.map(item => item.value));\n draft.value = normalize([...draft.value.filter(id => !visibleIds.has(id)), ...value]);\n }\n\n function confirm() {\n if (!canConfirm.value) return;\n const value = [...selected.value];\n confirmed = true;\n internalValue.value = value;\n emit(\"update:modelValue\", [...value]);\n emit(\"confirm\", [...value]);\n updateOpen(false);\n // A controlled parent may decline the close request. Later dismissal is cancellation.\n void nextTick(() => { confirmed = false; });\n }\n\n return { isOpen, query, visibleItems, selected, displayedValue, canConfirm, updateQuery, updateOpen, updateDraft, confirm };\n}\n","<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport { Button } from \"../../components/button\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Empty } from \"../../components/empty\";\nimport { Input } from \"../../components/input\";\nimport { Loader } from \"../../components/loader\";\nimport { SelectionList, createSelectionListCollection } from \"../../components/selection-list\";\nimport {\n RESOURCE_PICKER_DEFAULT_LABELS,\n type ResourcePickerEmits,\n type ResourcePickerProps,\n type ResourcePickerSlots,\n} from \"./resource-picker\";\nimport { useResourcePickerState } from \"./use-resource-picker-state\";\n\ndefineOptions({ inheritAttrs: false });\nconst props = withDefaults(defineProps<ResourcePickerProps>(), {\n title: \"Choose a resource\",\n open: undefined,\n defaultOpen: false,\n modelValue: undefined,\n defaultValue: () => [],\n selectionMode: \"single\",\n filterMode: \"local\",\n loading: false,\n allowEmpty: false,\n disabled: false,\n});\nconst emit = defineEmits<ResourcePickerEmits>();\nconst slots = defineSlots<ResourcePickerSlots>();\nconst searchId = `kappa-resource-picker-search-${useId()}`;\nconst labels = computed(() => ({ ...RESOURCE_PICKER_DEFAULT_LABELS, ...props.labels }));\nconst { isOpen, query, visibleItems, selected, displayedValue, canConfirm, updateQuery, updateOpen, updateDraft, confirm } = useResourcePickerState(props, emit);\nconst collection = computed(() => createSelectionListCollection({\n items: visibleItems.value,\n itemToValue: item => item.value,\n itemToString: item => item.label,\n isItemDisabled: item => Boolean(item.disabled),\n}));\n\nconst initialFocus = () => document.getElementById(searchId);\nconst retry = () => emit(\"retry\");\n</script>\n\n<template>\n <DialogLayout.Root :open=\"isOpen\" :initial-focus-el=\"initialFocus\" @update:open=\"updateOpen\">\n <DialogLayout.Trigger as-child :disabled=\"props.disabled\">\n <slot name=\"trigger\"><Button :disabled=\"props.disabled\" variant=\"secondary\">{{ labels.trigger }}</Button></slot>\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-resource-picker\"\n data-slot=\"resource-picker\"\n size=\"lg\"\n :close-label=\"labels.close\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description v-if=\"props.description\">{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <DialogLayout.Body class=\"kappa-resource-picker__body\">\n <SelectionList.Root\n class=\"kappa-resource-picker__list\"\n :collection=\"collection\"\n :model-value=\"displayedValue\"\n :selection-mode=\"props.selectionMode\"\n :disabled=\"props.disabled\"\n :select-on-highlight=\"false\"\n @update:model-value=\"updateDraft\"\n >\n <div class=\"kappa-resource-picker__search\">\n <SelectionList.Input as-child auto-highlight keyboard-priority=\"navigate\">\n <Input\n :id=\"searchId\"\n :model-value=\"query\"\n type=\"search\"\n :aria-label=\"labels.search\"\n :placeholder=\"labels.searchPlaceholder\"\n autocomplete=\"off\"\n @update:model-value=\"updateQuery\"\n />\n </SelectionList.Input>\n </div>\n <div class=\"kappa-resource-picker__results\" :aria-busy=\"props.loading\">\n <div v-if=\"props.loading\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"loading\"><Loader decorative size=\"sm\" /><span>{{ labels.loading }}</span></slot>\n </div>\n <div v-else-if=\"props.error\" class=\"kappa-resource-picker__state\" role=\"alert\">\n <slot name=\"error\" :message=\"props.error\" :retry=\"retry\">\n <Empty size=\"sm\">\n <Empty.Header><Empty.Title>{{ labels.errorTitle }}</Empty.Title><Empty.Description>{{ props.error }}</Empty.Description></Empty.Header>\n <Empty.Content><Button size=\"sm\" variant=\"secondary\" @click=\"retry\">{{ labels.retry }}</Button></Empty.Content>\n </Empty>\n </slot>\n </div>\n <div v-else-if=\"!collection.items.length\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"empty\" :query=\"query\">\n <Empty size=\"sm\"><Empty.Header><Empty.Title>{{ labels.emptyTitle }}</Empty.Title><Empty.Description>{{ labels.emptyDescription }}</Empty.Description></Empty.Header></Empty>\n </slot>\n </div>\n <SelectionList.Content v-else :aria-label=\"props.title\">\n <SelectionList.Item v-for=\"item in collection.items\" :key=\"item.value\" :item=\"item\">\n <SelectionList.ItemMedia v-if=\"slots.media\"><slot name=\"media\" :item=\"item\" /></SelectionList.ItemMedia>\n <SelectionList.ItemContent>\n <SelectionList.ItemText>{{ item.label }}</SelectionList.ItemText>\n <SelectionList.ItemDescription v-if=\"item.description || slots.description\"><slot name=\"description\" :item=\"item\">{{ item.description }}</slot></SelectionList.ItemDescription>\n </SelectionList.ItemContent>\n <SelectionList.ItemMeta v-if=\"item.meta || slots.meta\"><slot name=\"meta\" :item=\"item\">{{ item.meta }}</slot></SelectionList.ItemMeta>\n <SelectionList.ItemIndicator />\n </SelectionList.Item>\n </SelectionList.Content>\n </div>\n </SelectionList.Root>\n </DialogLayout.Body>\n <DialogLayout.Actions :dismiss-label=\"labels.cancel\">\n <span class=\"kappa-resource-picker__selection\" role=\"status\"><slot name=\"selection\" :value=\"selected\">{{ labels.selectionCount(selected.length) }}</slot></span>\n <Button :disabled=\"!canConfirm\" size=\"sm\" @click=\"confirm\">{{ labels.confirm }}</Button>\n </DialogLayout.Actions>\n </DialogLayout.Content>\n </DialogLayout.Root>\n</template>\n\n<style src=\"./resource-picker.css\"></style>\n","<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport { Button } from \"../../components/button\";\nimport { DialogLayout } from \"../../components/dialog-layout\";\nimport { Empty } from \"../../components/empty\";\nimport { Input } from \"../../components/input\";\nimport { Loader } from \"../../components/loader\";\nimport { SelectionList, createSelectionListCollection } from \"../../components/selection-list\";\nimport {\n RESOURCE_PICKER_DEFAULT_LABELS,\n type ResourcePickerEmits,\n type ResourcePickerProps,\n type ResourcePickerSlots,\n} from \"./resource-picker\";\nimport { useResourcePickerState } from \"./use-resource-picker-state\";\n\ndefineOptions({ inheritAttrs: false });\nconst props = withDefaults(defineProps<ResourcePickerProps>(), {\n title: \"Choose a resource\",\n open: undefined,\n defaultOpen: false,\n modelValue: undefined,\n defaultValue: () => [],\n selectionMode: \"single\",\n filterMode: \"local\",\n loading: false,\n allowEmpty: false,\n disabled: false,\n});\nconst emit = defineEmits<ResourcePickerEmits>();\nconst slots = defineSlots<ResourcePickerSlots>();\nconst searchId = `kappa-resource-picker-search-${useId()}`;\nconst labels = computed(() => ({ ...RESOURCE_PICKER_DEFAULT_LABELS, ...props.labels }));\nconst { isOpen, query, visibleItems, selected, displayedValue, canConfirm, updateQuery, updateOpen, updateDraft, confirm } = useResourcePickerState(props, emit);\nconst collection = computed(() => createSelectionListCollection({\n items: visibleItems.value,\n itemToValue: item => item.value,\n itemToString: item => item.label,\n isItemDisabled: item => Boolean(item.disabled),\n}));\n\nconst initialFocus = () => document.getElementById(searchId);\nconst retry = () => emit(\"retry\");\n</script>\n\n<template>\n <DialogLayout.Root :open=\"isOpen\" :initial-focus-el=\"initialFocus\" @update:open=\"updateOpen\">\n <DialogLayout.Trigger as-child :disabled=\"props.disabled\">\n <slot name=\"trigger\"><Button :disabled=\"props.disabled\" variant=\"secondary\">{{ labels.trigger }}</Button></slot>\n </DialogLayout.Trigger>\n <DialogLayout.Content\n v-bind=\"$attrs\"\n class=\"kappa-resource-picker\"\n data-slot=\"resource-picker\"\n size=\"lg\"\n :close-label=\"labels.close\"\n >\n <DialogLayout.Header>\n <DialogLayout.Title>{{ props.title }}</DialogLayout.Title>\n <DialogLayout.Description v-if=\"props.description\">{{ props.description }}</DialogLayout.Description>\n </DialogLayout.Header>\n <DialogLayout.Body class=\"kappa-resource-picker__body\">\n <SelectionList.Root\n class=\"kappa-resource-picker__list\"\n :collection=\"collection\"\n :model-value=\"displayedValue\"\n :selection-mode=\"props.selectionMode\"\n :disabled=\"props.disabled\"\n :select-on-highlight=\"false\"\n @update:model-value=\"updateDraft\"\n >\n <div class=\"kappa-resource-picker__search\">\n <SelectionList.Input as-child auto-highlight keyboard-priority=\"navigate\">\n <Input\n :id=\"searchId\"\n :model-value=\"query\"\n type=\"search\"\n :aria-label=\"labels.search\"\n :placeholder=\"labels.searchPlaceholder\"\n autocomplete=\"off\"\n @update:model-value=\"updateQuery\"\n />\n </SelectionList.Input>\n </div>\n <div class=\"kappa-resource-picker__results\" :aria-busy=\"props.loading\">\n <div v-if=\"props.loading\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"loading\"><Loader decorative size=\"sm\" /><span>{{ labels.loading }}</span></slot>\n </div>\n <div v-else-if=\"props.error\" class=\"kappa-resource-picker__state\" role=\"alert\">\n <slot name=\"error\" :message=\"props.error\" :retry=\"retry\">\n <Empty size=\"sm\">\n <Empty.Header><Empty.Title>{{ labels.errorTitle }}</Empty.Title><Empty.Description>{{ props.error }}</Empty.Description></Empty.Header>\n <Empty.Content><Button size=\"sm\" variant=\"secondary\" @click=\"retry\">{{ labels.retry }}</Button></Empty.Content>\n </Empty>\n </slot>\n </div>\n <div v-else-if=\"!collection.items.length\" class=\"kappa-resource-picker__state\" role=\"status\">\n <slot name=\"empty\" :query=\"query\">\n <Empty size=\"sm\"><Empty.Header><Empty.Title>{{ labels.emptyTitle }}</Empty.Title><Empty.Description>{{ labels.emptyDescription }}</Empty.Description></Empty.Header></Empty>\n </slot>\n </div>\n <SelectionList.Content v-else :aria-label=\"props.title\">\n <SelectionList.Item v-for=\"item in collection.items\" :key=\"item.value\" :item=\"item\">\n <SelectionList.ItemMedia v-if=\"slots.media\"><slot name=\"media\" :item=\"item\" /></SelectionList.ItemMedia>\n <SelectionList.ItemContent>\n <SelectionList.ItemText>{{ item.label }}</SelectionList.ItemText>\n <SelectionList.ItemDescription v-if=\"item.description || slots.description\"><slot name=\"description\" :item=\"item\">{{ item.description }}</slot></SelectionList.ItemDescription>\n </SelectionList.ItemContent>\n <SelectionList.ItemMeta v-if=\"item.meta || slots.meta\"><slot name=\"meta\" :item=\"item\">{{ item.meta }}</slot></SelectionList.ItemMeta>\n <SelectionList.ItemIndicator />\n </SelectionList.Item>\n </SelectionList.Content>\n </div>\n </SelectionList.Root>\n </DialogLayout.Body>\n <DialogLayout.Actions :dismiss-label=\"labels.cancel\">\n <span class=\"kappa-resource-picker__selection\" role=\"status\"><slot name=\"selection\" :value=\"selected\">{{ labels.selectionCount(selected.length) }}</slot></span>\n <Button :disabled=\"!canConfirm\" size=\"sm\" @click=\"confirm\">{{ labels.confirm }}</Button>\n </DialogLayout.Actions>\n </DialogLayout.Content>\n </DialogLayout.Root>\n</template>\n\n<style src=\"./resource-picker.css\"></style>\n"],"mappings":";;;;;;;;AA+BA,IAAa,IAAuD;CAClE,SAAS;CACT,QAAQ;CACR,mBAAmB;CACnB,SAAS;CACT,QAAQ;CACR,OAAO;CACP,SAAS;CACT,YAAY;CACZ,kBAAkB;CAClB,YAAY;CACZ,OAAO;CACP,iBAAgB,MAAS,GAAG,EAAM;AACpC;;;ACtCA,SAAgB,EAAuB,GAAsC,GAAY;CACvF,IAAM,IAAe,EAAI,EAAM,eAAe,EAAK,GAC7C,IAAgB,EAAI,CAAC,GAAI,EAAM,gBAAgB,CAAC,CAAE,CAAC,GACnD,IAAS,QAAe,EAAM,QAAQ,EAAa,KAAK,GACxD,IAAiB,QAAe,EAAM,cAAc,EAAc,KAAK,GACvE,IAAQ,EAAc,CAAC,CAAC,GACxB,IAAQ,EAAI,EAAE,GAChB,IAAY,IAEV,IAAY,QAAe,IAAI,IAAI,EAAM,MAAM,KAAI,MAAQ,CAAC,EAAK,OAAO,CAAI,CAAC,CAAC,CAAC,GAC/E,KAAa,MAAqB;EACtC,IAAM,IAAQ,CAAC,GAAG,IAAI,IAAI,CAAM,CAAC,CAAC,CAAC,QAAO,MAAS;GACjD,IAAM,IAAO,EAAU,MAAM,IAAI,CAAK;GACtC,OAAO,IAAO,CAAC,EAAK,WAAW,EAAM,eAAe;EACtD,CAAC;EACD,OAAO,EAAM,kBAAkB,aAAa,IAAQ,EAAM,MAAM,GA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OAAA,GAAA;MAC3C,SAAA,QAAgK,CAAhK,EAAgK,QAAhK,GAAgK,CAAnG,EAA4F,EAAA,QAAA,aAAA,EAApE,OAAO,EAAA,CAAA,EAAQ,SAAqD,CAAhD,EAAA,EAAA,EAAA,MAAO,eAAe,EAAA,CAAA,CAAQ,CAAC,MAAM,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAC9I,EAAwF,EAAA,CAAA,GAAA;OAA/E,UAAQ,CAAG,EAAA,CAAA;OAAY,MAAK;OAAM,SAAO,EAAA,CAAA;;OAAS,SAAA,QAAoB,CAAjB,EAAA,EAAA,EAAA,MAAO,OAAO,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "../DeleteResource-
|
|
1
|
+
import { n as e, t } from "../DeleteResource-JDnPWd7H.js";
|
|
2
2
|
export { e as DELETE_RESOURCE_DEFAULTS, t as DeleteResource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "../file-browser-
|
|
1
|
+
import { n as e, r as t, t as n } from "../file-browser-CGqaz2eI.js";
|
|
2
2
|
export { t as FILE_BROWSER_DEFAULT_LABELS, n as FileBrowser, e as FileBrowserRoot };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "../ResourcePicker-
|
|
1
|
+
import { n as e, t } from "../ResourcePicker-Ctmc4QxZ.js";
|
|
2
2
|
export { e as RESOURCE_PICKER_DEFAULT_LABELS, t as ResourcePicker };
|