@pairdraw/vue 0.20.0 → 0.21.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/dist/canvas/CanvasRoot.vue.js +3 -0
- package/dist/canvas/CanvasRoot.vue.js.map +1 -1
- package/dist/canvas/surface/color-space.d.ts +1 -0
- package/dist/canvas/surface/color-space.d.ts.map +1 -1
- package/dist/canvas/surface/gl-surface.js +16 -2
- package/dist/canvas/surface/gl-surface.js.map +1 -1
- package/dist/canvas/surface/lifecycle.js +4 -2
- package/dist/canvas/surface/lifecycle.js.map +1 -1
- package/dist/canvas/surface/origin.js +14 -0
- package/dist/canvas/surface/origin.js.map +1 -0
- package/dist/canvas/surface/shader/plan.js +40 -0
- package/dist/canvas/surface/shader/plan.js.map +1 -0
- package/dist/canvas/surface/shader/playback.js +132 -36
- package/dist/canvas/surface/shader/playback.js.map +1 -1
- package/dist/canvas/surface/shader/stage.d.ts.map +1 -1
- package/dist/canvas/surface/shader/stage.js +42 -5
- package/dist/canvas/surface/shader/stage.js.map +1 -1
- package/dist/canvas/surface/types.d.ts +16 -0
- package/dist/canvas/surface/types.d.ts.map +1 -1
- package/dist/canvas/surface/use.js +3 -1
- package/dist/canvas/surface/use.js.map +1 -1
- package/dist/canvas/useCanvasInput.d.ts +8 -8
- package/dist/controls/binding-provider/pairdraw.js +1 -1
- package/dist/controls/binding-provider/pairdraw.js.map +1 -1
- package/dist/controls/color-model/types.d.ts +6 -0
- package/dist/controls/color-model/types.d.ts.map +1 -1
- package/dist/controls/color-model/use.d.ts.map +1 -1
- package/dist/controls/color-model/use.js +5 -3
- package/dist/controls/color-model/use.js.map +1 -1
- package/dist/controls/document-colors/index.d.ts +2 -2
- package/dist/controls/document-colors/index.js +2 -2
- package/dist/controls/document-colors/use.d.ts +7 -1
- package/dist/controls/document-colors/use.d.ts.map +1 -1
- package/dist/controls/document-colors/use.js +9 -1
- package/dist/controls/document-colors/use.js.map +1 -1
- package/dist/controls/node-props/use.d.ts +3 -3
- package/dist/controls/okhcl/use.d.ts +2 -2
- package/dist/controls/shader/catalog.d.ts +11 -0
- package/dist/controls/shader/catalog.d.ts.map +1 -1
- package/dist/controls/shader/catalog.js +35 -6
- package/dist/controls/shader/catalog.js.map +1 -1
- package/dist/controls/shader/gallery.d.ts +1 -1
- package/dist/controls/shader/gallery.d.ts.map +1 -1
- package/dist/controls/shader/gallery.js +292 -0
- package/dist/controls/shader/gallery.js.map +1 -1
- package/dist/controls/shader/index.d.ts +3 -1
- package/dist/controls/shader/index.js +3 -1
- package/dist/controls/shader/shapes.d.ts +18 -0
- package/dist/controls/shader/shapes.d.ts.map +1 -0
- package/dist/controls/shader/shapes.js +227 -0
- package/dist/controls/shader/shapes.js.map +1 -0
- package/dist/controls/shader/stops.d.ts +22 -0
- package/dist/controls/shader/stops.d.ts.map +1 -0
- package/dist/controls/shader/stops.js +73 -0
- package/dist/controls/shader/stops.js.map +1 -0
- package/dist/controls/variable-modes/helpers.d.ts.map +1 -1
- package/dist/controls/variable-modes/helpers.js +4 -2
- package/dist/controls/variable-modes/helpers.js.map +1 -1
- package/dist/editor/commands/shortcut.d.ts.map +1 -1
- package/dist/editor/commands/shortcut.js +9 -1
- package/dist/editor/commands/shortcut.js.map +1 -1
- package/dist/i18n/create.d.ts +1 -1
- package/dist/i18n/create.d.ts.map +1 -1
- package/dist/i18n/create.js +1 -0
- package/dist/i18n/create.js.map +1 -1
- package/dist/i18n/locale.d.ts +5 -4
- package/dist/i18n/locale.d.ts.map +1 -1
- package/dist/i18n/locale.js +4 -0
- package/dist/i18n/locale.js.map +1 -1
- package/dist/i18n/locales/de/ai.json.js +15 -0
- package/dist/i18n/locales/de/code.json.js +2 -0
- package/dist/i18n/locales/de/comments.json.js +1 -1
- package/dist/i18n/locales/de/panels.json.js +16 -1
- package/dist/i18n/locales/es/ai.json.js +15 -0
- package/dist/i18n/locales/es/code.json.js +2 -0
- package/dist/i18n/locales/es/comments.json.js +1 -1
- package/dist/i18n/locales/es/panels.json.js +16 -1
- package/dist/i18n/locales/fr/ai.json.js +15 -0
- package/dist/i18n/locales/fr/code.json.js +2 -0
- package/dist/i18n/locales/fr/comments.json.js +1 -1
- package/dist/i18n/locales/fr/panels.json.js +16 -1
- package/dist/i18n/locales/id/agents.json.js +31 -0
- package/dist/i18n/locales/id/agents.json.js.map +1 -0
- package/dist/i18n/locales/id/ai.json.js +608 -0
- package/dist/i18n/locales/id/ai.json.js.map +1 -0
- package/dist/i18n/locales/id/automation.json.js +150 -0
- package/dist/i18n/locales/id/automation.json.js.map +1 -0
- package/dist/i18n/locales/id/browser.json.js +50 -0
- package/dist/i18n/locales/id/browser.json.js.map +1 -0
- package/dist/i18n/locales/id/chat-context.json.js +62 -0
- package/dist/i18n/locales/id/chat-context.json.js.map +1 -0
- package/dist/i18n/locales/id/cloud/editor.json.js +337 -0
- package/dist/i18n/locales/id/cloud/editor.json.js.map +1 -0
- package/dist/i18n/locales/id/cloud/portal.json.js +435 -0
- package/dist/i18n/locales/id/cloud/portal.json.js.map +1 -0
- package/dist/i18n/locales/id/code.json.js +45 -0
- package/dist/i18n/locales/id/code.json.js.map +1 -0
- package/dist/i18n/locales/id/collaboration.json.js +84 -0
- package/dist/i18n/locales/id/collaboration.json.js.map +1 -0
- package/dist/i18n/locales/id/commands.json.js +111 -0
- package/dist/i18n/locales/id/commands.json.js.map +1 -0
- package/dist/i18n/locales/id/comments.json.js +37 -0
- package/dist/i18n/locales/id/comments.json.js.map +1 -0
- package/dist/i18n/locales/id/common.json.js +51 -0
- package/dist/i18n/locales/id/common.json.js.map +1 -0
- package/dist/i18n/locales/id/credentials.json.js +21 -0
- package/dist/i18n/locales/id/credentials.json.js.map +1 -0
- package/dist/i18n/locales/id/design-check.json.js +101 -0
- package/dist/i18n/locales/id/design-check.json.js.map +1 -0
- package/dist/i18n/locales/id/design-memory.json.js +61 -0
- package/dist/i18n/locales/id/design-memory.json.js.map +1 -0
- package/dist/i18n/locales/id/diagnostics.json.js +78 -0
- package/dist/i18n/locales/id/diagnostics.json.js.map +1 -0
- package/dist/i18n/locales/id/editor.json.js +62 -0
- package/dist/i18n/locales/id/editor.json.js.map +1 -0
- package/dist/i18n/locales/id/explore.json.js +30 -0
- package/dist/i18n/locales/id/explore.json.js.map +1 -0
- package/dist/i18n/locales/id/figjam.json.js +39 -0
- package/dist/i18n/locales/id/figjam.json.js.map +1 -0
- package/dist/i18n/locales/id/files.json.js +86 -0
- package/dist/i18n/locales/id/files.json.js.map +1 -0
- package/dist/i18n/locales/id/fonts.json.js +54 -0
- package/dist/i18n/locales/id/fonts.json.js.map +1 -0
- package/dist/i18n/locales/id/index.js +85 -0
- package/dist/i18n/locales/id/index.js.map +1 -0
- package/dist/i18n/locales/id/media.json.js +52 -0
- package/dist/i18n/locales/id/media.json.js.map +1 -0
- package/dist/i18n/locales/id/menu.json.js +118 -0
- package/dist/i18n/locales/id/menu.json.js.map +1 -0
- package/dist/i18n/locales/id/pages.json.js +16 -0
- package/dist/i18n/locales/id/pages.json.js.map +1 -0
- package/dist/i18n/locales/id/panels.json.js +838 -0
- package/dist/i18n/locales/id/panels.json.js.map +1 -0
- package/dist/i18n/locales/id/recovery.json.js +36 -0
- package/dist/i18n/locales/id/recovery.json.js.map +1 -0
- package/dist/i18n/locales/id/rename.json.js +19 -0
- package/dist/i18n/locales/id/rename.json.js.map +1 -0
- package/dist/i18n/locales/id/rendering.json.js +18 -0
- package/dist/i18n/locales/id/rendering.json.js.map +1 -0
- package/dist/i18n/locales/id/settings.json.js +169 -0
- package/dist/i18n/locales/id/settings.json.js.map +1 -0
- package/dist/i18n/locales/id/shaders.json.js +24 -0
- package/dist/i18n/locales/id/shaders.json.js.map +1 -0
- package/dist/i18n/locales/id/shapes.json.js +48 -0
- package/dist/i18n/locales/id/shapes.json.js.map +1 -0
- package/dist/i18n/locales/id/slides.json.js +27 -0
- package/dist/i18n/locales/id/slides.json.js.map +1 -0
- package/dist/i18n/locales/id/statuses.json.js +38 -0
- package/dist/i18n/locales/id/statuses.json.js.map +1 -0
- package/dist/i18n/locales/id/storage.json.js +21 -0
- package/dist/i18n/locales/id/storage.json.js.map +1 -0
- package/dist/i18n/locales/id/tools.json.js +27 -0
- package/dist/i18n/locales/id/tools.json.js.map +1 -0
- package/dist/i18n/locales/id/updates.json.js +31 -0
- package/dist/i18n/locales/id/updates.json.js.map +1 -0
- package/dist/i18n/locales/id/variables/panel.json.js +175 -0
- package/dist/i18n/locales/id/variables/panel.json.js.map +1 -0
- package/dist/i18n/locales/id/variables/types.json.js +15 -0
- package/dist/i18n/locales/id/variables/types.json.js.map +1 -0
- package/dist/i18n/locales/id/variations.json.js +23 -0
- package/dist/i18n/locales/id/variations.json.js.map +1 -0
- package/dist/i18n/locales/it/ai.json.js +15 -0
- package/dist/i18n/locales/it/code.json.js +2 -0
- package/dist/i18n/locales/it/comments.json.js +1 -1
- package/dist/i18n/locales/it/panels.json.js +16 -1
- package/dist/i18n/locales/ja/ai.json.js +15 -0
- package/dist/i18n/locales/ja/code.json.js +2 -0
- package/dist/i18n/locales/ja/comments.json.js +1 -1
- package/dist/i18n/locales/ja/panels.json.js +16 -1
- package/dist/i18n/locales/pl/ai.json.js +15 -0
- package/dist/i18n/locales/pl/code.json.js +2 -0
- package/dist/i18n/locales/pl/comments.json.js +1 -1
- package/dist/i18n/locales/pl/panels.json.js +16 -1
- package/dist/i18n/locales/ru/ai.json.js +15 -0
- package/dist/i18n/locales/ru/code.json.js +2 -0
- package/dist/i18n/locales/ru/comments.json.js +1 -1
- package/dist/i18n/locales/ru/panels.json.js +16 -1
- package/dist/i18n/locales/zh-cn/ai.json.js +15 -0
- package/dist/i18n/locales/zh-cn/code.json.js +2 -0
- package/dist/i18n/locales/zh-cn/comments.json.js +1 -1
- package/dist/i18n/locales/zh-cn/panels.json.js +16 -1
- package/dist/i18n/messages/ai.d.ts +33 -0
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +17 -0
- package/dist/i18n/messages/ai.js.map +1 -1
- package/dist/i18n/messages/code.d.ts +4 -0
- package/dist/i18n/messages/code.d.ts.map +1 -1
- package/dist/i18n/messages/code.js +3 -1
- package/dist/i18n/messages/code.js.map +1 -1
- package/dist/i18n/messages/comments.d.ts +2 -2
- package/dist/i18n/messages/comments.js +2 -2
- package/dist/i18n/messages/comments.js.map +1 -1
- package/dist/i18n/messages/panels.d.ts +17 -0
- package/dist/i18n/messages/panels.d.ts.map +1 -1
- package/dist/i18n/messages/panels.js +15 -0
- package/dist/i18n/messages/panels.js.map +1 -1
- package/dist/i18n/messages.d.ts +53 -1
- package/dist/i18n/useI18n.d.ts +212 -4
- package/dist/i18n/useI18n.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts +6 -0
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.js +3 -1
- package/dist/primitives/ColorPicker/ColorInputRoot.vue.js.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +6 -0
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +3 -2
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
- package/dist/primitives/Fill/FillRoot.vue.d.ts +2 -1
- package/dist/primitives/Fill/FillRoot.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillRoot.vue.js +5 -2
- package/dist/primitives/Fill/FillRoot.vue.js.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.js +2 -1
- package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
- package/dist/primitives/Fill/types.d.ts +6 -1
- package/dist/primitives/Fill/types.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.d.ts +10 -4
- package/dist/primitives/Fill/useFill.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.js +14 -10
- package/dist/primitives/Fill/useFill.js.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts +2 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js +5 -2
- package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.js +4 -3
- package/dist/primitives/GradientEditor/GradientEditorStop.vue.js.map +1 -1
- package/dist/primitives/GradientEditor/types.d.ts +3 -1
- package/dist/primitives/GradientEditor/types.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/useGradientStops.d.ts +5 -3
- package/dist/primitives/GradientEditor/useGradientStops.d.ts.map +1 -1
- package/dist/primitives/GradientEditor/useGradientStops.js +9 -4
- package/dist/primitives/GradientEditor/useGradientStops.js.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +6 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +16 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerRoot.vue.js","names":[],"sources":["../../../src/primitives/ColorPicker/ColorPickerRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport {
|
|
1
|
+
{"version":3,"file":"ColorPickerRoot.vue.js","names":[],"sources":["../../../src/primitives/ColorPicker/ColorPickerRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport type { DocumentColorSpace } from '@pairdraw/scene-graph'\nimport { colorToPreviewCSS } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { useRetainedPopup } from '#vue/lifecycle/retention/popup'\n\nimport { usePickerGesture, type PickerCancelCause } from './gesture'\nimport { pickerOutsideHandlers, type PickerKeepOpen } from './outside'\n\nexport interface ColorPickerUI {\n content?: string\n swatch?: string\n}\n\nconst {\n color,\n label = 'Edit color',\n ui,\n escapeReverts = false,\n keepOpen,\n colorProfile = 'srgb'\n} = defineProps<{\n color: Color\n label?: string\n ui?: ColorPickerUI\n /**\n * The profile the color is stored in; the trigger's swatch then draws the color the canvas draws.\n * Defaults to sRGB.\n */\n colorProfile?: DocumentColorSpace\n /**\n * For a colour with no undo history, such as a preference: Escape closing the picker puts back\n * the colour it opened with. Otherwise Escape keeps the edit, as Figma's picker does.\n */\n escapeReverts?: boolean\n /** Whether a press outside the picker should leave it open, such as one that samples the canvas. */\n keepOpen?: PickerKeepOpen\n}>()\n\nconst emit = defineEmits<{\n update: [color: Color]\n openChange: [open: boolean]\n /** Ends the edit made so far as one undo step: a press's release, or a change with none held. */\n commit: []\n /**\n * `press`: Escape during a press that changed the colour, or the picker closing during one; the\n * colour from before the press has just come back through `update`. `escape`: with\n * `escapeReverts`, Escape closed the picker after the colour it opened with came back.\n */\n cancel: [cause: PickerCancelCause]\n}>()\n\nconst swatchBg = computed(() => colorToPreviewCSS(color, colorProfile))\nlet pressColor: Color = { ...color }\nconst gesture = usePickerGesture({\n open: () => popupOpen.value,\n // The colour the press found when it first changed it, so a change from elsewhere since the\n // press began is not put back.\n beforeChange: () => {\n pressColor = { ...color }\n },\n commit: () => emit('commit'),\n cancel: () => {\n emit('update', pressColor)\n emit('cancel', 'press')\n }\n})\nconst { open: popupOpen, portalActive } = useRetainedPopup(undefined, () => onOpenChange(false))\n\nconst outside = pickerOutsideHandlers(() => keepOpen)\n\nlet openColor: Color = { ...color }\n\n/** A press still held when the picker closes is put back, whichever way it closes. */\nfunction onOpenChange(open: boolean) {\n if (open) openColor = { ...color }\n if (!open) gesture.abort()\n emit('openChange', open)\n}\n\nfunction update(next: Color) {\n gesture.change(() => emit('update', next))\n}\n\nfunction onEscapeKeyDown() {\n if (!escapeReverts) return\n emit('update', openColor)\n emit('cancel', 'escape')\n}\n</script>\n\n<template>\n <PopoverRoot v-model:open=\"popupOpen\" @update:open=\"onOpenChange\">\n <PopoverTrigger as-child>\n <slot name=\"trigger\" :style=\"{ background: swatchBg }\">\n <button\n type=\"button\"\n :aria-label=\"label\"\n :class=\"ui?.swatch\"\n :style=\"{ background: swatchBg }\"\n />\n </slot>\n </PopoverTrigger>\n\n <PopoverPortal v-if=\"portalActive\">\n <PopoverContent\n :class=\"ui?.content\"\n :side-offset=\"4\"\n side=\"left\"\n data-picker-content\n @escape-key-down=\"onEscapeKeyDown\"\n @pointer-down-outside=\"outside.onPointerDownOutside\"\n @focus-outside=\"outside.onFocusOutside\"\n >\n <slot :color=\"color\" :update=\"update\" />\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,OAAO;EAab,MAAM,WAAW,eAAe,kBAAkB,QAAA,OAAO,QAAA,YAAY,CAAC;EACtE,IAAI,aAAoB,EAAE,GAAG,QAAA,MAAM;EACnC,MAAM,UAAU,iBAAiB;GAC/B,YAAY,UAAU;GAGtB,oBAAoB;IAClB,aAAa,EAAE,GAAG,QAAA,MAAM;GAC1B;GACA,cAAc,KAAK,QAAQ;GAC3B,cAAc;IACZ,KAAK,UAAU,UAAU;IACzB,KAAK,UAAU,OAAO;GACxB;EACF,CAAC;EACD,MAAM,EAAE,MAAM,WAAW,iBAAiB,iBAAiB,KAAA,SAAiB,aAAa,KAAK,CAAC;EAE/F,MAAM,UAAU,4BAA4B,QAAA,QAAQ;EAEpD,IAAI,YAAmB,EAAE,GAAG,QAAA,MAAM;;EAGlC,SAAS,aAA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lots } from "./types.js";
|
|
2
|
-
import { Fill } from "@pairdraw/scene-graph";
|
|
2
|
+
import { DocumentColorSpace, Fill } from "@pairdraw/scene-graph";
|
|
3
3
|
//#region src/primitives/Fill/FillRoot.vue.d.ts
|
|
4
4
|
type __VLS_Props = {
|
|
5
5
|
fill: Fill;
|
|
6
|
+
colorProfile?: DocumentColorSpace;
|
|
6
7
|
};
|
|
7
8
|
type __VLS_Slots = FillRootSlots;
|
|
8
9
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FillRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/Fill/FillRoot.vue"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"FillRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/Fill/FillRoot.vue"],"mappings":";;;KAsCK;EAAgB,MAAM;EAAM,eAAe;;KAK3C,cAAc;cAqCb,0BAAU,gBAAA,2CAAA,qCAAA;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -3,11 +3,14 @@ import { computed, defineComponent, renderSlot, unref } from "vue";
|
|
|
3
3
|
//#region src/primitives/Fill/FillRoot.vue
|
|
4
4
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
5
5
|
__name: "FillRoot",
|
|
6
|
-
props: {
|
|
6
|
+
props: {
|
|
7
|
+
fill: {},
|
|
8
|
+
colorProfile: {}
|
|
9
|
+
},
|
|
7
10
|
emits: ["update"],
|
|
8
11
|
setup(__props, { emit: __emit }) {
|
|
9
12
|
const emit = __emit;
|
|
10
|
-
const model = useFill(computed(() => __props.fill), (updated) => emit("update", updated));
|
|
13
|
+
const model = useFill(computed(() => __props.fill), (updated) => emit("update", updated), { colorProfile: () => __props.colorProfile });
|
|
11
14
|
return (_ctx, _cache) => {
|
|
12
15
|
return renderSlot(_ctx.$slots, "default", {
|
|
13
16
|
fill: __props.fill,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FillRoot.vue.js","names":[],"sources":["../../../src/primitives/Fill/FillRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { Fill } from '@pairdraw/scene-graph'\n\nimport type { FillRootSlots } from './types'\nimport { useFill } from './useFill'\n\nconst { fill } = defineProps<{ fill: Fill }>()\nconst emit = defineEmits<{ update: [fill: Fill] }>()\ndefineSlots<FillRootSlots>()\n\nconst model = useFill(\n computed(() => fill),\n (updated) => emit('update', updated)\n)\n</script>\n\n<template>\n <slot\n :fill=\"fill\"\n :category=\"model.category.value\"\n :swatch-background=\"model.swatchBackground.value\"\n :transparent=\"model.transparent.value\"\n :actions=\"model.actions\"\n />\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FillRoot.vue.js","names":[],"sources":["../../../src/primitives/Fill/FillRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport type { DocumentColorSpace, Fill } from '@pairdraw/scene-graph'\n\nimport type { FillRootSlots } from './types'\nimport { useFill } from './useFill'\n\nconst { fill, colorProfile } = defineProps<{ fill: Fill; colorProfile?: DocumentColorSpace }>()\nconst emit = defineEmits<{ update: [fill: Fill] }>()\ndefineSlots<FillRootSlots>()\n\nconst model = useFill(\n computed(() => fill),\n (updated) => emit('update', updated),\n { colorProfile: () => colorProfile }\n)\n</script>\n\n<template>\n <slot\n :fill=\"fill\"\n :category=\"model.category.value\"\n :swatch-background=\"model.swatchBackground.value\"\n :transparent=\"model.transparent.value\"\n :actions=\"model.actions\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;EASA,MAAM,OAAO;EAGb,MAAM,QAAQ,QACZ,eAAe,QAAA,IAAI,IAClB,YAAY,KAAK,UAAU,OAAO,GACnC,EAAE,oBAAoB,QAAA,aAAa,CACrC;;GAIE,OAAA,WAME,KAAA,QAAA,WAAA;IALC,MAAM,QAAA;IACN,UAAU,MAAA,KAAA,CAAK,CAAC,SAAS;IACzB,kBAAmB,MAAA,KAAA,CAAK,CAAC,iBAAiB;IAC1C,aAAa,MAAA,KAAA,CAAK,CAAC,YAAY;IAC/B,SAAS,MAAA,KAAA,CAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FillSwatch.vue.d.ts","names":[],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"FillSwatch.vue.d.ts","names":[],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"mappings":";;KAqFK,cAAc;cA4Fb,0BAAU,gBAAA,+CAAA,qCAAA,iDAAA,aAAA,SAAA,mBAAA,oDAAA;cAGV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -13,6 +13,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
13
13
|
type: Boolean,
|
|
14
14
|
default: false
|
|
15
15
|
},
|
|
16
|
+
colorProfile: { default: "srgb" },
|
|
16
17
|
asChild: {
|
|
17
18
|
type: Boolean,
|
|
18
19
|
default: false
|
|
@@ -29,7 +30,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
29
30
|
color: boundColor.value
|
|
30
31
|
} : __props.fill);
|
|
31
32
|
const category = computed(() => fillCategory(effectiveFill.value));
|
|
32
|
-
const background = computed(() => fillSwatchBackground(effectiveFill.value));
|
|
33
|
+
const background = computed(() => fillSwatchBackground(effectiveFill.value, __props.colorProfile));
|
|
33
34
|
const transparent = computed(() => fillIsTransparent(effectiveFill.value));
|
|
34
35
|
const accessibleLabel = computed(() => __props.label ?? `${category.value.toLowerCase()} fill`);
|
|
35
36
|
const stateAttrs = computed(() => binding?.stateAttrs.value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FillSwatch.vue.js","names":["$attrs"],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Primitive } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { useOptionalBindableValue } from '#vue/primitives/BindableValue/context'\n\nimport type { FillSwatchProps, FillSwatchSlots } from './types'\nimport { fillCategory, fillIsTransparent, fillSwatchBackground } from './useFill'\n\nconst {\n fill,\n label,\n as = 'span',\n asChild = false,\n ignoreBinding = false\n} = defineProps<FillSwatchProps>()\ndefineSlots<FillSwatchSlots>()\ndefineOptions({ inheritAttrs: false })\n\nconst binding = useOptionalBindableValue<Color>()\nconst followsBinding = computed(() => !ignoreBinding && bindingState.value === 'bound')\nconst bindingState = computed(() => binding?.state.value)\nconst boundColor = computed(() => (followsBinding.value ? binding?.resolvedValue.value : undefined))\nconst effectiveFill = computed(() =>\n fill.type === 'SOLID' && boundColor.value ? { ...fill, color: boundColor.value } : fill\n)\nconst category = computed(() => fillCategory(effectiveFill.value))\nconst background = computed(() => fillSwatchBackground(effectiveFill.value))\nconst transparent = computed(() => fillIsTransparent(effectiveFill.value))\nconst accessibleLabel = computed(() => label ?? `${category.value.toLowerCase()} fill`)\nconst stateAttrs = computed(() => binding?.stateAttrs.value)\nconst slotProps = computed(() => ({\n fill: effectiveFill.value,\n color: effectiveFill.value.color,\n category: category.value,\n background: background.value,\n transparent: transparent.value,\n bindingState: bindingState.value,\n stateAttrs: stateAttrs.value\n}))\n</script>\n\n<template>\n <Primitive\n v-bind=\"{ ...$attrs, ...stateAttrs }\"\n :as=\"as\"\n :as-child=\"asChild\"\n :aria-label=\"accessibleLabel\"\n :data-fill-type=\"effectiveFill.type\"\n :data-fill-category=\"category\"\n :data-transparent=\"transparent ? '' : undefined\"\n :style=\"{ '--pairdraw-fill-swatch-background': background }\"\n role=\"img\"\n aria-roledescription=\"fill swatch\"\n data-slot=\"swatch\"\n >\n <slot v-bind=\"slotProps\" />\n </Primitive>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"FillSwatch.vue.js","names":["$attrs"],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Primitive } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { useOptionalBindableValue } from '#vue/primitives/BindableValue/context'\n\nimport type { FillSwatchProps, FillSwatchSlots } from './types'\nimport { fillCategory, fillIsTransparent, fillSwatchBackground } from './useFill'\n\nconst {\n fill,\n label,\n as = 'span',\n asChild = false,\n ignoreBinding = false,\n colorProfile = 'srgb'\n} = defineProps<FillSwatchProps>()\ndefineSlots<FillSwatchSlots>()\ndefineOptions({ inheritAttrs: false })\n\nconst binding = useOptionalBindableValue<Color>()\nconst followsBinding = computed(() => !ignoreBinding && bindingState.value === 'bound')\nconst bindingState = computed(() => binding?.state.value)\nconst boundColor = computed(() => (followsBinding.value ? binding?.resolvedValue.value : undefined))\nconst effectiveFill = computed(() =>\n fill.type === 'SOLID' && boundColor.value ? { ...fill, color: boundColor.value } : fill\n)\nconst category = computed(() => fillCategory(effectiveFill.value))\nconst background = computed(() => fillSwatchBackground(effectiveFill.value, colorProfile))\nconst transparent = computed(() => fillIsTransparent(effectiveFill.value))\nconst accessibleLabel = computed(() => label ?? `${category.value.toLowerCase()} fill`)\nconst stateAttrs = computed(() => binding?.stateAttrs.value)\nconst slotProps = computed(() => ({\n fill: effectiveFill.value,\n color: effectiveFill.value.color,\n category: category.value,\n background: background.value,\n transparent: transparent.value,\n bindingState: bindingState.value,\n stateAttrs: stateAttrs.value\n}))\n</script>\n\n<template>\n <Primitive\n v-bind=\"{ ...$attrs, ...stateAttrs }\"\n :as=\"as\"\n :as-child=\"asChild\"\n :aria-label=\"accessibleLabel\"\n :data-fill-type=\"effectiveFill.type\"\n :data-fill-category=\"category\"\n :data-transparent=\"transparent ? '' : undefined\"\n :style=\"{ '--pairdraw-fill-swatch-background': background }\"\n role=\"img\"\n aria-roledescription=\"fill swatch\"\n data-slot=\"swatch\"\n >\n <slot v-bind=\"slotProps\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAsBA,MAAM,UAAU,yBAAgC;EAChD,MAAM,iBAAiB,eAAe,CAAC,QAAA,iBAAiB,aAAa,UAAU,OAAO;EACtF,MAAM,eAAe,eAAe,SAAS,MAAM,KAAK;EACxD,MAAM,aAAa,eAAgB,eAAe,QAAQ,SAAS,cAAc,QAAQ,KAAA,CAAU;EACnG,MAAM,gBAAgB,eACpB,QAAA,KAAK,SAAS,WAAW,WAAW,QAAQ;GAAE,GAAG,QAAA;GAAM,OAAO,WAAW;EAAM,IAAI,QAAA,IACrF;EACA,MAAM,WAAW,eAAe,aAAa,cAAc,KAAK,CAAC;EACjE,MAAM,aAAa,eAAe,qBAAqB,cAAc,OAAO,QAAA,YAAY,CAAC;EACzF,MAAM,cAAc,eAAe,kBAAkB,cAAc,KAAK,CAAC;EACzE,MAAM,kBAAkB,eAAe,QAAA,SAAS,GAAG,SAAS,MAAM,YAAY,EAAE,MAAM;EACtF,MAAM,aAAa,eAAe,SAAS,WAAW,KAAK;EAC3D,MAAM,YAAY,gBAAgB;GAChC,MAAM,cAAc;GACpB,OAAO,cAAc,MAAM;GAC3B,UAAU,SAAS;GACnB,YAAY,WAAW;GACvB,aAAa,YAAY;GACzB,cAAc,aAAa;GAC3B,YAAY,WAAW;EACzB,EAAE;;GAIA,OAAA,UAAA,GAAA,YAcY,MAAA,SAAA,GAdZ,WAcY;IAAA,GAbGA,KAAAA;IAAM,GAAK,WAAA;GAAU,GAAA;IACjC,IAAI,QAAA;IACJ,YAAU,QAAA;IACV,cAAY,gBAAA;IACZ,kBAAgB,cAAA,MAAc;IAC9B,sBAAoB,SAAA;IACpB,oBAAkB,YAAA,QAAW,KAAQ,KAAA;IACrC,OAAK,EAAA,qCAAyC,WAAA,MAAU;IACzD,MAAK;IACL,wBAAqB;IACrB,aAAU;;IAEiB,SAAA,cAAA,CAA3B,WAA2B,KAAA,QAAA,WAAA,eAAA,mBAAb,UAAA,KAAS,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BindingState } from "../../controls/binding-provider/types.js";
|
|
2
2
|
import { BindableValueStateAttrs } from "../BindableValue/types.js";
|
|
3
3
|
import { PrimitiveProps } from "reka-ui";
|
|
4
|
-
import { Fill } from "@pairdraw/scene-graph";
|
|
4
|
+
import { DocumentColorSpace, Fill } from "@pairdraw/scene-graph";
|
|
5
5
|
import { Color as Color$1 } from "@pairdraw/scene-graph/primitives";
|
|
6
6
|
//#region src/primitives/Fill/types.d.ts
|
|
7
7
|
type FillCategory = 'SOLID' | 'GRADIENT' | 'MESH' | 'IMAGE';
|
|
@@ -31,6 +31,11 @@ interface FillSwatchProps extends PrimitiveProps {
|
|
|
31
31
|
* own variable rather than the one the field is bound to.
|
|
32
32
|
*/
|
|
33
33
|
ignoreBinding?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The profile the fill's color is stored in; a Display P3 document's swatch then draws the color
|
|
36
|
+
* in its own profile, the one the canvas draws. Defaults to sRGB.
|
|
37
|
+
*/
|
|
38
|
+
colorProfile?: DocumentColorSpace;
|
|
34
39
|
}
|
|
35
40
|
interface FillSwatchSlotProps {
|
|
36
41
|
fill: Fill;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/Fill/types.ts"],"mappings":";;;;;;KAQY;UAEK;EACf;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,UAAU;EACV;EACA;EACA,SAAS;;UAGM;EACf,WAAW,OAAO;;UAGH,wBAAwB;;EAEvC,MAAM;;EAEN;;;;;EAKA;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/Fill/types.ts"],"mappings":";;;;;;KAQY;UAEK;EACf;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,UAAU;EACV;EACA;EACA,SAAS;;UAGM;EACf,WAAW,OAAO;;UAGH,wBAAwB;;EAEvC,MAAM;;EAEN;;;;;EAKA;;;;;EAKA,eAAe;;UAGA;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,WAAW,OAAO"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { FillCategory } from "./types.js";
|
|
2
|
-
import { Ref } from "vue";
|
|
3
|
-
import { Fill } from "@pairdraw/scene-graph";
|
|
2
|
+
import { MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
+
import { DocumentColorSpace, Fill } from "@pairdraw/scene-graph";
|
|
4
4
|
//#region src/primitives/Fill/useFill.d.ts
|
|
5
5
|
declare function fillCategory(fill: Fill): FillCategory;
|
|
6
6
|
declare function fillIsTransparent(fill: Fill): boolean;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A fill's swatch as CSS in `profile`: a Display P3 document's stored components are written in
|
|
9
|
+
* its own profile, so the swatch shows the color the canvas draws.
|
|
10
|
+
*/
|
|
11
|
+
declare function fillSwatchBackground(fill: Fill, profile?: DocumentColorSpace): string;
|
|
8
12
|
/** Fill category state and immutable conversion actions without picker or popover behavior. */
|
|
9
|
-
declare function useFill(fill: Ref<Fill>, onUpdate: (fill: Fill) => void
|
|
13
|
+
declare function useFill(fill: Ref<Fill>, onUpdate: (fill: Fill) => void, options?: {
|
|
14
|
+
colorProfile?: MaybeRefOrGetter<DocumentColorSpace | undefined>;
|
|
15
|
+
}): {
|
|
10
16
|
category: import("vue").ComputedRef<FillCategory>;
|
|
11
17
|
swatchBackground: import("vue").ComputedRef<string>;
|
|
12
18
|
transparent: import("vue").ComputedRef<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFill.d.ts","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useFill.d.ts","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"mappings":";;;;iBA8CgB,aAAa,MAAM,OAAO;iBAI1B,kBAAkB,MAAM;;;;;iBAexB,qBAAqB,MAAM,MAAM,UAAS;;iBAiB1C,QACd,MAAM,IAAI,OACV,WAAW,MAAM,eACjB;EAAW,eAAe,iBAAiB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
2
|
-
import {
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
import { colorToPreviewCSS } from "@pairdraw/scene-graph/color";
|
|
3
3
|
import { BLACK, TRANSPARENT } from "@pairdraw/scene-graph/constants";
|
|
4
4
|
import { DEFAULT_GRADIENT_TRANSFORM, defaultGradientStops, defaultMeshPoints } from "@pairdraw/scene-graph/gradient";
|
|
5
5
|
//#region src/primitives/Fill/useFill.ts
|
|
@@ -25,8 +25,8 @@ function effectiveColor(color, opacity) {
|
|
|
25
25
|
a: color.a * opacity
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
function gradientCSS(stops, opacity) {
|
|
29
|
-
return stops.map((stop) => `${
|
|
28
|
+
function gradientCSS(stops, opacity, profile) {
|
|
29
|
+
return stops.map((stop) => `${colorToPreviewCSS(effectiveColor(stop.color, opacity), profile)} ${stop.position * 100}%`).join(", ");
|
|
30
30
|
}
|
|
31
31
|
function fillCategory(fill) {
|
|
32
32
|
return FILL_CATEGORY[fill.type] ?? "SOLID";
|
|
@@ -37,15 +37,19 @@ function fillIsTransparent(fill) {
|
|
|
37
37
|
if (fillCategory(fill) === "MESH") return fill.meshPoints?.some((point) => point.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1;
|
|
38
38
|
return fillColor(fill, TRANSPARENT).a < 1;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
/**
|
|
41
|
+
* A fill's swatch as CSS in `profile`: a Display P3 document's stored components are written in
|
|
42
|
+
* its own profile, so the swatch shows the color the canvas draws.
|
|
43
|
+
*/
|
|
44
|
+
function fillSwatchBackground(fill, profile = "srgb") {
|
|
45
|
+
if (fillCategory(fill) === "GRADIENT" && fill.gradientStops?.length) return `linear-gradient(to right, ${gradientCSS(fill.gradientStops, fill.opacity, profile)})`;
|
|
46
|
+
if (fillCategory(fill) === "MESH" && fill.meshPoints?.length) return `linear-gradient(to right, ${fill.meshPoints.map((point, index) => `${colorToPreviewCSS(effectiveColor(point.color, fill.opacity), profile)} ${index / (fill.meshPoints?.length ?? 1) * 100}%`).join(", ")})`;
|
|
47
|
+
return colorToPreviewCSS(effectiveColor(fillColor(fill, TRANSPARENT), fill.opacity), profile);
|
|
44
48
|
}
|
|
45
49
|
/** Fill category state and immutable conversion actions without picker or popover behavior. */
|
|
46
|
-
function useFill(fill, onUpdate) {
|
|
50
|
+
function useFill(fill, onUpdate, options = {}) {
|
|
47
51
|
const category = computed(() => fillCategory(fill.value));
|
|
48
|
-
const swatchBackground = computed(() => fillSwatchBackground(fill.value));
|
|
52
|
+
const swatchBackground = computed(() => fillSwatchBackground(fill.value, toValue(options.colorProfile) ?? "srgb"));
|
|
49
53
|
const transparent = computed(() => fillIsTransparent(fill.value));
|
|
50
54
|
function toSolid() {
|
|
51
55
|
if (category.value === "SOLID") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFill.js","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"sourcesContent":["import { computed } from 'vue'\nimport type { Ref } from 'vue'\n\nimport type { Fill, GradientStop } from '@pairdraw/scene-graph'\nimport {
|
|
1
|
+
{"version":3,"file":"useFill.js","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"sourcesContent":["import { computed, toValue } from 'vue'\nimport type { MaybeRefOrGetter, Ref } from 'vue'\n\nimport type { DocumentColorSpace, Fill, GradientStop } from '@pairdraw/scene-graph'\nimport { colorToPreviewCSS } from '@pairdraw/scene-graph/color'\nimport { BLACK, TRANSPARENT } from '@pairdraw/scene-graph/constants'\nimport {\n DEFAULT_GRADIENT_TRANSFORM,\n defaultGradientStops,\n defaultMeshPoints\n} from '@pairdraw/scene-graph/gradient'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FillCategory } from './types'\n\nconst FILL_CATEGORY: Partial<Record<Fill['type'], FillCategory>> = {\n SOLID: 'SOLID',\n GRADIENT_LINEAR: 'GRADIENT',\n GRADIENT_RADIAL: 'GRADIENT',\n GRADIENT_ANGULAR: 'GRADIENT',\n GRADIENT_DIAMOND: 'GRADIENT',\n MESH: 'MESH',\n IMAGE: 'IMAGE'\n}\n\n/**\n * A non-solid fill carries no `color` at runtime even though the model types it as required,\n * because image and shader paints have no colour; the swatch treats that as no colour paint.\n */\nfunction fillColor(fill: Fill, fallback: Color): Color {\n return (fill as { color?: Color }).color ?? fallback\n}\n\nfunction effectiveColor(color: Color, opacity: number): Color {\n return { ...color, a: color.a * opacity }\n}\n\nfunction gradientCSS(stops: GradientStop[], opacity: number, profile: DocumentColorSpace): string {\n return stops\n .map(\n (stop) =>\n `${colorToPreviewCSS(effectiveColor(stop.color, opacity), profile)} ${stop.position * 100}%`\n )\n .join(', ')\n}\n\nexport function fillCategory(fill: Fill): FillCategory {\n return FILL_CATEGORY[fill.type] ?? 'SOLID'\n}\n\nexport function fillIsTransparent(fill: Fill): boolean {\n if (fill.opacity < 1) return true\n if (fillCategory(fill) === 'GRADIENT')\n return (\n fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1\n )\n if (fillCategory(fill) === 'MESH')\n return fill.meshPoints?.some((point) => point.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1\n return fillColor(fill, TRANSPARENT).a < 1\n}\n\n/**\n * A fill's swatch as CSS in `profile`: a Display P3 document's stored components are written in\n * its own profile, so the swatch shows the color the canvas draws.\n */\nexport function fillSwatchBackground(fill: Fill, profile: DocumentColorSpace = 'srgb'): string {\n if (fillCategory(fill) === 'GRADIENT' && fill.gradientStops?.length) {\n return `linear-gradient(to right, ${gradientCSS(fill.gradientStops, fill.opacity, profile)})`\n }\n if (fillCategory(fill) === 'MESH' && fill.meshPoints?.length) {\n const stops = fill.meshPoints\n .map(\n (point, index) =>\n `${colorToPreviewCSS(effectiveColor(point.color, fill.opacity), profile)} ${(index / (fill.meshPoints?.length ?? 1)) * 100}%`\n )\n .join(', ')\n return `linear-gradient(to right, ${stops})`\n }\n return colorToPreviewCSS(effectiveColor(fillColor(fill, TRANSPARENT), fill.opacity), profile)\n}\n\n/** Fill category state and immutable conversion actions without picker or popover behavior. */\nexport function useFill(\n fill: Ref<Fill>,\n onUpdate: (fill: Fill) => void,\n options: { colorProfile?: MaybeRefOrGetter<DocumentColorSpace | undefined> } = {}\n) {\n const category = computed(() => fillCategory(fill.value))\n const swatchBackground = computed(() =>\n fillSwatchBackground(fill.value, toValue(options.colorProfile) ?? 'srgb')\n )\n const transparent = computed(() => fillIsTransparent(fill.value))\n\n function toSolid() {\n if (category.value === 'SOLID') return\n const color =\n fill.value.gradientStops?.[0]?.color ??\n fill.value.meshPoints?.[0]?.color ??\n fillColor(fill.value, BLACK)\n onUpdate({ ...fill.value, type: 'SOLID', color: { ...color } })\n }\n\n function toGradient() {\n if (category.value === 'GRADIENT') return\n const gradientStops = fill.value.gradientStops?.length\n ? structuredClone(fill.value.gradientStops)\n : defaultGradientStops(fillColor(fill.value, BLACK))\n onUpdate({\n ...fill.value,\n type: 'GRADIENT_LINEAR',\n gradientStops,\n gradientTransform: fill.value.gradientTransform ?? { ...DEFAULT_GRADIENT_TRANSFORM }\n })\n }\n\n function toMesh() {\n if (category.value === 'MESH') return\n const color = fill.value.meshPoints?.[0]?.color ?? fillColor(fill.value, BLACK)\n onUpdate({\n ...fill.value,\n type: 'MESH',\n meshColumns: 1,\n meshRows: 1,\n meshPoints: defaultMeshPoints(color)\n })\n }\n\n function toImage() {\n if (category.value === 'IMAGE') return\n onUpdate({ ...fill.value, type: 'IMAGE' })\n }\n\n const actions = { toSolid, toGradient, toMesh, toImage }\n\n return {\n category,\n swatchBackground,\n transparent,\n actions,\n toSolid,\n toGradient,\n toMesh,\n toImage\n }\n}\n"],"mappings":";;;;;AAeA,MAAM,gBAA6D;CACjE,OAAO;CACP,iBAAiB;CACjB,iBAAiB;CACjB,kBAAkB;CAClB,kBAAkB;CAClB,MAAM;CACN,OAAO;AACT;;;;;AAMA,SAAS,UAAU,MAAY,UAAwB;CACrD,OAAQ,KAA2B,SAAS;AAC9C;AAEA,SAAS,eAAe,OAAc,SAAwB;CAC5D,OAAO;EAAE,GAAG;EAAO,GAAG,MAAM,IAAI;CAAQ;AAC1C;AAEA,SAAS,YAAY,OAAuB,SAAiB,SAAqC;CAChG,OAAO,MACJ,KACE,SACC,GAAG,kBAAkB,eAAe,KAAK,OAAO,OAAO,GAAG,OAAO,EAAE,GAAG,KAAK,WAAW,IAAI,EAC9F,CAAC,CACA,KAAK,IAAI;AACd;AAEA,SAAgB,aAAa,MAA0B;CACrD,OAAO,cAAc,KAAK,SAAS;AACrC;AAEA,SAAgB,kBAAkB,MAAqB;CACrD,IAAI,KAAK,UAAU,GAAG,OAAO;CAC7B,IAAI,aAAa,IAAI,MAAM,YACzB,OACE,KAAK,eAAe,MAAM,SAAS,KAAK,MAAM,IAAI,CAAC,KAAK,UAAU,MAAM,WAAW,CAAC,CAAC,IAAI;CAE7F,IAAI,aAAa,IAAI,MAAM,QACzB,OAAO,KAAK,YAAY,MAAM,UAAU,MAAM,MAAM,IAAI,CAAC,KAAK,UAAU,MAAM,WAAW,CAAC,CAAC,IAAI;CACjG,OAAO,UAAU,MAAM,WAAW,CAAC,CAAC,IAAI;AAC1C;;;;;AAMA,SAAgB,qBAAqB,MAAY,UAA8B,QAAgB;CAC7F,IAAI,aAAa,IAAI,MAAM,cAAc,KAAK,eAAe,QAC3D,OAAO,6BAA6B,YAAY,KAAK,eAAe,KAAK,SAAS,OAAO,EAAE;CAE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ACP,GAAG,KAAK;GACR,MAAM;GACN,aAAa;GACb,UAAU;GACV,YAAY,kBAAkB,KAAK;EACrC,CAAC;CACH;CAEA,SAAS,UAAU;EACjB,IAAI,SAAS,UAAU,SAAS;EAChC,SAAS;GAAE,GAAG,KAAK;GAAO,MAAM;EAAQ,CAAC;CAC3C;CAIA,OAAO;EACL;EACA;EACA;EACA,SAAA;GANgB;GAAS;GAAY;GAAQ;EAMvC;EACN;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Fill } from "@pairdraw/scene-graph";
|
|
1
|
+
import { ColorProfile, Fill } from "@pairdraw/scene-graph";
|
|
2
2
|
//#region src/primitives/GradientEditor/GradientEditorRoot.vue.d.ts
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
fill: Fill;
|
|
5
|
+
colorProfile?: ColorProfile;
|
|
5
6
|
};
|
|
6
7
|
type __VLS_ModelProps = {
|
|
7
8
|
/** The selected stop, which the canvas handles can also change. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GradientEditorRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/GradientEditorRoot.vue"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"GradientEditorRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/GradientEditorRoot.vue"],"mappings":";;KA8EK;EAAgB,MAAM;EAAM,eAAe;;KAsD3C;;EAEL;;KAMK,oBAAoB,cAAc;YAkCnC;;;;;;;;;;;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,gBAAA,iDAAA,qCAAA;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -3,7 +3,10 @@ import { computed, defineComponent, mergeModels, renderSlot, unref, useModel, wa
|
|
|
3
3
|
//#region src/primitives/GradientEditor/GradientEditorRoot.vue
|
|
4
4
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
5
5
|
__name: "GradientEditorRoot",
|
|
6
|
-
props: /*@__PURE__*/ mergeModels({
|
|
6
|
+
props: /*@__PURE__*/ mergeModels({
|
|
7
|
+
fill: {},
|
|
8
|
+
colorProfile: {}
|
|
9
|
+
}, {
|
|
7
10
|
"activeStopIndex": {},
|
|
8
11
|
"activeStopIndexModifiers": {}
|
|
9
12
|
}),
|
|
@@ -12,7 +15,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
12
15
|
const emit = __emit;
|
|
13
16
|
/** The selected stop, which the canvas handles can also change. */
|
|
14
17
|
const selectedStop = useModel(__props, "activeStopIndex");
|
|
15
|
-
const { activeStopIndex, stops, subtype, subtypes, activeColor, barBackground, setSubtype, selectStop, addStop, removeStop, updateStopPosition, updateStopColor, updateStopOpacity, updateActiveColor, dragStop } = useGradientStops(computed(() => __props.fill), (updated) => emit("update", updated));
|
|
18
|
+
const { activeStopIndex, stops, subtype, subtypes, activeColor, barBackground, setSubtype, selectStop, addStop, removeStop, updateStopPosition, updateStopColor, updateStopOpacity, updateActiveColor, dragStop } = useGradientStops(computed(() => __props.fill), (updated) => emit("update", updated), { colorProfile: () => __props.colorProfile ?? "srgb" });
|
|
16
19
|
watch(selectedStop, (index) => {
|
|
17
20
|
if (index !== void 0 && index !== activeStopIndex.value) activeStopIndex.value = index;
|
|
18
21
|
}, { immediate: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GradientEditorRoot.vue.js","names":[],"sources":["../../../src/primitives/GradientEditor/GradientEditorRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, watch } from 'vue'\n\nimport type { Fill } from '@pairdraw/scene-graph'\n\nimport { useGradientStops } from '#vue/primitives/GradientEditor/useGradientStops'\n\nconst { fill } = defineProps<{ fill: Fill }>()\nconst emit = defineEmits<{ update: [fill: Fill] }>()\n/** The selected stop, which the canvas handles can also change. */\nconst selectedStop = defineModel<number>('activeStopIndex')\n\nconst {\n activeStopIndex,\n stops,\n subtype,\n subtypes,\n activeColor,\n barBackground,\n setSubtype,\n selectStop,\n addStop,\n removeStop,\n updateStopPosition,\n updateStopColor,\n updateStopOpacity,\n updateActiveColor,\n dragStop\n} = useGradientStops(\n computed(() => fill),\n (updated) => emit('update', updated)\n)\n\nwatch(\n selectedStop,\n (index) => {\n if (index !== undefined && index !== activeStopIndex.value) activeStopIndex.value = index\n },\n { immediate: true }\n)\nwatch(activeStopIndex, (index) => {\n if (index !== selectedStop.value) selectedStop.value = index\n})\n\nconst actions = {\n setSubtype,\n selectStop,\n addStop,\n removeStop,\n updateStopPosition,\n updateStopColor,\n updateStopOpacity,\n updateActiveColor,\n dragStop\n}\n</script>\n\n<template>\n <slot\n :stops=\"stops\"\n :subtype=\"subtype\"\n :subtypes=\"subtypes\"\n :active-stop-index=\"activeStopIndex\"\n :active-color=\"activeColor\"\n :bar-background=\"barBackground\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"GradientEditorRoot.vue.js","names":[],"sources":["../../../src/primitives/GradientEditor/GradientEditorRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, watch } from 'vue'\n\nimport type { ColorProfile, Fill } from '@pairdraw/scene-graph'\n\nimport { useGradientStops } from '#vue/primitives/GradientEditor/useGradientStops'\n\nconst { fill, colorProfile } = defineProps<{ fill: Fill; colorProfile?: ColorProfile }>()\nconst emit = defineEmits<{ update: [fill: Fill] }>()\n/** The selected stop, which the canvas handles can also change. */\nconst selectedStop = defineModel<number>('activeStopIndex')\n\nconst {\n activeStopIndex,\n stops,\n subtype,\n subtypes,\n activeColor,\n barBackground,\n setSubtype,\n selectStop,\n addStop,\n removeStop,\n updateStopPosition,\n updateStopColor,\n updateStopOpacity,\n updateActiveColor,\n dragStop\n} = useGradientStops(\n computed(() => fill),\n (updated) => emit('update', updated),\n { colorProfile: () => colorProfile ?? 'srgb' }\n)\n\nwatch(\n selectedStop,\n (index) => {\n if (index !== undefined && index !== activeStopIndex.value) activeStopIndex.value = index\n },\n { immediate: true }\n)\nwatch(activeStopIndex, (index) => {\n if (index !== selectedStop.value) selectedStop.value = index\n})\n\nconst actions = {\n setSubtype,\n selectStop,\n addStop,\n removeStop,\n updateStopPosition,\n updateStopColor,\n updateStopOpacity,\n updateActiveColor,\n dragStop\n}\n</script>\n\n<template>\n <slot\n :stops=\"stops\"\n :subtype=\"subtype\"\n :subtypes=\"subtypes\"\n :active-stop-index=\"activeStopIndex\"\n :active-color=\"activeColor\"\n :bar-background=\"barBackground\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;EAQA,MAAM,OAAO;;EAEb,MAAM,eAAe,SAAmB,SAAC,iBAAiB;EAE1D,MAAM,EACJ,iBACA,OACA,SACA,UACA,aACA,eACA,YACA,YACA,SACA,YACA,oBACA,iBACA,mBACA,mBACA,aACE,iBACF,eAAe,QAAA,IAAI,IAClB,YAAY,KAAK,UAAU,OAAO,GACnC,EAAE,oBAAoB,QAAA,gBAAgB,OAAO,CAC/C;EAEA,MACE,eACC,UAAU;GACT,IAAI,UAAU,KAAA,KAAa,UAAU,gBAAgB,OAAO,gBAAgB,QAAQ;EACtF,GACA,EAAE,WAAW,KAAK,CACpB;EACA,MAAM,kBAAkB,UAAU;GAChC,IAAI,UAAU,aAAa,OAAO,aAAa,QAAQ;EACzD,CAAC;EAED,MAAM,UAAU;GACd;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;;GAIE,OAAA,WAQE,KAAA,QAAA,WAAA;IAPC,OAAO,MAAA,KAAA;IACP,SAAS,MAAA,OAAA;IACT,UAAU,MAAA,QAAA;IACV,iBAAmB,MAAA,eAAA;IACnB,aAAc,MAAA,WAAA;IACd,eAAgB,MAAA,aAAA;IACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GradientEditorStop.vue.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/GradientEditorStop.vue"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"GradientEditorStop.vue.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/GradientEditorStop.vue"],"mappings":";;KAiJK,cAAc;cA2Ib,0BAAU,gBAAA,uDAAA,qCAAA;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, createBlock, defineComponent, mergeProps, openBlock, renderSlot, unref, withCtx } from "vue";
|
|
2
2
|
import { Primitive } from "reka-ui";
|
|
3
|
-
import {
|
|
3
|
+
import { colorToHexRaw, colorToPreviewCSS, convertColor } from "@pairdraw/scene-graph/color";
|
|
4
4
|
//#region src/primitives/GradientEditor/GradientEditorStop.vue
|
|
5
5
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
6
|
inheritAttrs: false,
|
|
@@ -23,6 +23,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
23
23
|
},
|
|
24
24
|
positionStep: { default: 1 },
|
|
25
25
|
label: {},
|
|
26
|
+
colorProfile: { default: "srgb" },
|
|
26
27
|
asChild: {
|
|
27
28
|
type: Boolean,
|
|
28
29
|
default: false
|
|
@@ -40,8 +41,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
40
41
|
const emit = __emit;
|
|
41
42
|
const positionPercent = computed(() => Math.round(__props.stop.position * 100));
|
|
42
43
|
const opacityPercent = computed(() => Math.round(__props.stop.color.a * 100));
|
|
43
|
-
const hex = computed(() => colorToHexRaw(__props.stop.color));
|
|
44
|
-
const css = computed(() =>
|
|
44
|
+
const hex = computed(() => colorToHexRaw(convertColor(__props.stop.color, __props.colorProfile, "srgb")));
|
|
45
|
+
const css = computed(() => colorToPreviewCSS(__props.stop.color, __props.colorProfile));
|
|
45
46
|
const accessibleLabel = computed(() => __props.label ?? `Gradient stop ${__props.index + 1}`);
|
|
46
47
|
const actions = {
|
|
47
48
|
select: () => emit("select", __props.index),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GradientEditorStop.vue.js","names":["$attrs"],"sources":["../../../src/primitives/GradientEditor/GradientEditorStop.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Primitive } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport {
|
|
1
|
+
{"version":3,"file":"GradientEditorStop.vue.js","names":["$attrs"],"sources":["../../../src/primitives/GradientEditor/GradientEditorStop.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Primitive } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { colorToHexRaw, colorToPreviewCSS, convertColor } from '@pairdraw/scene-graph/color'\n\nimport type {\n GradientEditorStopActions,\n GradientEditorStopProps,\n GradientEditorStopSlots\n} from '#vue/primitives/GradientEditor/types'\n\nconst {\n stop,\n index,\n active,\n dragging = false,\n interactive = true,\n removable = true,\n positionStep = 1,\n label,\n as = 'div',\n asChild = false,\n colorProfile = 'srgb'\n} = defineProps<GradientEditorStopProps>()\n\nconst emit = defineEmits<{\n select: [index: number]\n updatePosition: [index: number, position: number]\n updateColor: [index: number, hex: string]\n updateOpacity: [index: number, opacity: number]\n remove: [index: number]\n}>()\n\ndefineSlots<GradientEditorStopSlots>()\ndefineOptions({ inheritAttrs: false })\n\nconst positionPercent = computed(() => Math.round(stop.position * 100))\nconst opacityPercent = computed(() => Math.round(stop.color.a * 100))\nconst hex = computed(() => colorToHexRaw(convertColor(stop.color, colorProfile, 'srgb')))\nconst css = computed(() => colorToPreviewCSS(stop.color, colorProfile))\nconst accessibleLabel = computed(() => label ?? `Gradient stop ${index + 1}`)\nconst actions: GradientEditorStopActions = {\n select: () => emit('select', index),\n updatePosition: (position) => emit('updatePosition', index, position),\n updateColor: (hexValue) => emit('updateColor', index, hexValue),\n updateOpacity: (opacity) => emit('updateOpacity', index, opacity),\n remove: () => emit('remove', index)\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n if (!interactive) return\n const amount = positionStep * (event.shiftKey ? 10 : 1)\n let nextPosition: number | undefined\n if (event.code === 'ArrowLeft' || event.code === 'ArrowDown')\n nextPosition = positionPercent.value - amount\n else if (event.code === 'ArrowRight' || event.code === 'ArrowUp')\n nextPosition = positionPercent.value + amount\n else if (event.code === 'Home') nextPosition = 0\n else if (event.code === 'End') nextPosition = 100\n else if ((event.code === 'Delete' || event.code === 'Backspace') && removable) {\n event.preventDefault()\n event.stopPropagation()\n actions.remove()\n return\n }\n if (nextPosition === undefined) return\n event.preventDefault()\n event.stopPropagation()\n actions.updatePosition(Math.max(0, Math.min(100, nextPosition)))\n}\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :as=\"as\"\n :as-child=\"asChild\"\n :data-selected=\"active ? '' : undefined\"\n :data-dragging=\"dragging ? '' : undefined\"\n :role=\"interactive ? 'slider' : undefined\"\n :tabindex=\"interactive ? 0 : undefined\"\n :aria-label=\"interactive ? accessibleLabel : undefined\"\n :aria-valuemin=\"interactive ? 0 : undefined\"\n :aria-valuemax=\"interactive ? 100 : undefined\"\n :aria-valuenow=\"interactive ? positionPercent : undefined\"\n :aria-valuetext=\"interactive ? `${positionPercent}%` : undefined\"\n data-slot=\"stop\"\n @click=\"actions.select\"\n @focus=\"actions.select\"\n @keydown=\"onKeydown\"\n >\n <slot\n :stop=\"stop\"\n :index=\"index\"\n :active=\"active\"\n :selected=\"active\"\n :dragging=\"dragging\"\n :position-percent=\"positionPercent\"\n :opacity-percent=\"opacityPercent\"\n :hex=\"hex\"\n :css=\"css\"\n :actions=\"actions\"\n />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BA,MAAM,OAAO;EAWb,MAAM,kBAAkB,eAAe,KAAK,MAAM,QAAA,KAAK,WAAW,GAAG,CAAC;EACtE,MAAM,iBAAiB,eAAe,KAAK,MAAM,QAAA,KAAK,MAAM,I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A,SAAM,KAAQ,KAAA;IAC7B,iBAAe,QAAA,WAAQ,KAAQ,KAAA;IAC/B,MAAM,QAAA,cAAW,WAAc,KAAA;IAC/B,UAAU,QAAA,cAAW,IAAO,KAAA;IAC5B,cAAY,QAAA,cAAc,gBAAA,QAAkB,KAAA;IAC5C,iBAAe,QAAA,cAAW,IAAO,KAAA;IACjC,iBAAe,QAAA,cAAW,MAAS,KAAA;IACnC,iBAAe,QAAA,cAAc,gBAAA,QAAkB,KAAA;IAC/C,kBAAgB,QAAA,cAAW,GAAM,gBAAA,MAAe,KAAM,KAAA;IACvD,aAAU;IACT,SAAO,QAAQ;IACf,SAAO,QAAQ;IACN;;IAaR,SAAA,cAAA,CAXF,WAWE,KAAA,QAAA,WAAA;KAVC,MAAM,QAAA;KACN,OAAO,QAAA;KACP,QAAQ,QAAA;KACR,UAAU,QAAA;KACV,UAAU,QAAA;KACV,iBAAkB,gBAAA;KAClB,gBAAiB,eAAA;KACjB,KAAK,IAAA;KACL,KAAK,IAAA;KACI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrimitiveProps } from "reka-ui";
|
|
2
|
-
import { GradientStop } from "@pairdraw/scene-graph";
|
|
2
|
+
import { ColorProfile, GradientStop } from "@pairdraw/scene-graph";
|
|
3
3
|
//#region src/primitives/GradientEditor/types.d.ts
|
|
4
4
|
interface GradientEditorStopProps extends PrimitiveProps {
|
|
5
5
|
stop: GradientStop;
|
|
@@ -10,6 +10,8 @@ interface GradientEditorStopProps extends PrimitiveProps {
|
|
|
10
10
|
removable?: boolean;
|
|
11
11
|
positionStep?: number;
|
|
12
12
|
label?: string;
|
|
13
|
+
/** The profile the stop's color is stored in; the hex reads it as the sRGB color drawn. */
|
|
14
|
+
colorProfile?: ColorProfile;
|
|
13
15
|
}
|
|
14
16
|
interface GradientEditorStopActions {
|
|
15
17
|
select: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/types.ts"],"mappings":";;;UAIiB,gCAAgC;EAC/C,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/types.ts"],"mappings":";;;UAIiB,gCAAgC;EAC/C,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,eAAe;;UAGA;EACf;EACA,iBAAiB;EACjB,cAAc;EACd,gBAAgB;EAChB;;UAGe;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf,WAAW,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ref } from "vue";
|
|
2
|
-
import { Fill, GradientStop } from "@pairdraw/scene-graph";
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from "vue";
|
|
2
|
+
import { ColorProfile, Fill, GradientStop } from "@pairdraw/scene-graph";
|
|
3
3
|
import { Color } from "@pairdraw/scene-graph/primitives";
|
|
4
4
|
//#region src/primitives/GradientEditor/useGradientStops.d.ts
|
|
5
5
|
type GradientSubtype = 'GRADIENT_LINEAR' | 'GRADIENT_RADIAL' | 'GRADIENT_ANGULAR' | 'GRADIENT_DIAMOND';
|
|
@@ -9,7 +9,9 @@ type GradientSubtype = 'GRADIENT_LINEAR' | 'GRADIENT_RADIAL' | 'GRADIENT_ANGULAR
|
|
|
9
9
|
* Use this composable for gradient editors that need subtype switching,
|
|
10
10
|
* active-stop selection, stop dragging, and stop color/opacity editing.
|
|
11
11
|
*/
|
|
12
|
-
declare function useGradientStops(fill: Ref<Fill>, onUpdate: (fill: Fill) => void
|
|
12
|
+
declare function useGradientStops(fill: Ref<Fill>, onUpdate: (fill: Fill) => void, options?: {
|
|
13
|
+
colorProfile?: MaybeRefOrGetter<ColorProfile>;
|
|
14
|
+
}): {
|
|
13
15
|
activeStopIndex: Ref<number, number>;
|
|
14
16
|
stops: import("vue").ComputedRef<GradientStop[]>;
|
|
15
17
|
subtype: import("vue").ComputedRef<GradientSubtype>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGradientStops.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/useGradientStops.ts"],"mappings":";;;;KASK;;;;;;;iBAmBW,
|
|
1
|
+
{"version":3,"file":"useGradientStops.d.ts","names":[],"sources":["../../../src/primitives/GradientEditor/useGradientStops.ts"],"mappings":";;;;KASK;;;;;;;iBAmBW,iBACd,MAAM,IAAI,OACV,WAAW,MAAM,eACjB;EAAW,eAAe,iBAAiB;;;;;;IAhBpB,OAAA;IAAwB;;;;EA0CrB,aAAA,MAAA;EAQC,aAAA;;EAaA,aAAA;EAMQ,qBAAA,eAAM;EAMT,kBAAA,eAAM;EAKJ,oBAAA,eAAM;EASN,oBAAA,OAAA;EAaT,WAAA,eAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useColorModel } from "../../controls/color-model/use.js";
|
|
2
|
-
import { computed, ref } from "vue";
|
|
3
|
-
import {
|
|
2
|
+
import { computed, ref, toValue } from "vue";
|
|
3
|
+
import { colorToPreviewCSS } from "@pairdraw/scene-graph/color";
|
|
4
4
|
import { DEFAULT_GRADIENT_TRANSFORM } from "@pairdraw/scene-graph/gradient";
|
|
5
5
|
//#region src/primitives/GradientEditor/useGradientStops.ts
|
|
6
6
|
const SUBTYPES = [
|
|
@@ -27,7 +27,7 @@ const SUBTYPES = [
|
|
|
27
27
|
* Use this composable for gradient editors that need subtype switching,
|
|
28
28
|
* active-stop selection, stop dragging, and stop color/opacity editing.
|
|
29
29
|
*/
|
|
30
|
-
function useGradientStops(fill, onUpdate) {
|
|
30
|
+
function useGradientStops(fill, onUpdate, options = {}) {
|
|
31
31
|
const activeStopIndex = ref(0);
|
|
32
32
|
const stops = computed(() => fill.value.gradientStops ?? []);
|
|
33
33
|
const subtype = computed(() => fill.value.type);
|
|
@@ -36,7 +36,11 @@ function useGradientStops(fill, onUpdate) {
|
|
|
36
36
|
if (!s.length) return fill.value.color;
|
|
37
37
|
return s[Math.min(activeStopIndex.value, s.length - 1)].color;
|
|
38
38
|
});
|
|
39
|
-
const barBackground = computed(() =>
|
|
39
|
+
const barBackground = computed(() => {
|
|
40
|
+
if (!stops.value.length) return "";
|
|
41
|
+
const profile = toValue(options.colorProfile ?? "srgb");
|
|
42
|
+
return `linear-gradient(to right, ${stops.value.map((s) => `${colorToPreviewCSS(s.color, profile)} ${s.position * 100}%`).join(", ")})`;
|
|
43
|
+
});
|
|
40
44
|
function emitStops(newStops) {
|
|
41
45
|
onUpdate({
|
|
42
46
|
...fill.value,
|
|
@@ -106,6 +110,7 @@ function useGradientStops(fill, onUpdate) {
|
|
|
106
110
|
}
|
|
107
111
|
const colorModel = useColorModel({
|
|
108
112
|
color: activeColor,
|
|
113
|
+
colorProfile: options.colorProfile,
|
|
109
114
|
onUpdate: updateActiveColor
|
|
110
115
|
});
|
|
111
116
|
function dragStop(index, position) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGradientStops.js","names":[],"sources":["../../../src/primitives/GradientEditor/useGradientStops.ts"],"sourcesContent":["import { computed, ref, type Ref } from 'vue'\n\nimport type { Fill, GradientStop, GradientTransform } from '@pairdraw/scene-graph'\nimport {
|
|
1
|
+
{"version":3,"file":"useGradientStops.js","names":[],"sources":["../../../src/primitives/GradientEditor/useGradientStops.ts"],"sourcesContent":["import { computed, ref, toValue, type MaybeRefOrGetter, type Ref } from 'vue'\n\nimport type { ColorProfile, Fill, GradientStop, GradientTransform } from '@pairdraw/scene-graph'\nimport { colorToPreviewCSS } from '@pairdraw/scene-graph/color'\nimport { DEFAULT_GRADIENT_TRANSFORM } from '@pairdraw/scene-graph/gradient'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { useColorModel } from '#vue/controls/color-model/use'\n\ntype GradientSubtype =\n | 'GRADIENT_LINEAR'\n | 'GRADIENT_RADIAL'\n | 'GRADIENT_ANGULAR'\n | 'GRADIENT_DIAMOND'\n\nconst SUBTYPES: { value: GradientSubtype; label: string }[] = [\n { value: 'GRADIENT_LINEAR', label: 'Linear' },\n { value: 'GRADIENT_RADIAL', label: 'Radial' },\n { value: 'GRADIENT_ANGULAR', label: 'Angular' },\n { value: 'GRADIENT_DIAMOND', label: 'Diamond' }\n]\n\n/**\n * Returns gradient-stop state and mutation helpers for a fill.\n *\n * Use this composable for gradient editors that need subtype switching,\n * active-stop selection, stop dragging, and stop color/opacity editing.\n */\nexport function useGradientStops(\n fill: Ref<Fill>,\n onUpdate: (fill: Fill) => void,\n options: { colorProfile?: MaybeRefOrGetter<ColorProfile> } = {}\n) {\n const activeStopIndex = ref(0)\n const stops = computed(() => fill.value.gradientStops ?? [])\n const subtype = computed(() => fill.value.type as GradientSubtype)\n\n const activeColor = computed(() => {\n const s = stops.value\n if (!s.length) return fill.value.color\n return s[Math.min(activeStopIndex.value, s.length - 1)].color\n })\n\n const barBackground = computed(() => {\n if (!stops.value.length) return ''\n const profile = toValue(options.colorProfile ?? 'srgb')\n const paints = stops.value.map(\n (s) => `${colorToPreviewCSS(s.color, profile)} ${s.position * 100}%`\n )\n return `linear-gradient(to right, ${paints.join(', ')})`\n })\n\n function emitStops(newStops: GradientStop[]) {\n onUpdate({ ...fill.value, gradientStops: newStops })\n }\n\n /** Figma keeps the transform across kinds, so a radial gradient grows from the linear line. */\n function setSubtype(type: GradientSubtype) {\n if (type === fill.value.type) return\n const gradientTransform: GradientTransform = fill.value.gradientTransform ?? {\n ...DEFAULT_GRADIENT_TRANSFORM\n }\n onUpdate({ ...fill.value, type, gradientTransform })\n }\n\n function selectStop(index: number) {\n activeStopIndex.value = index\n }\n\n function addStop() {\n const s = [...stops.value]\n const pos = s.length >= 2 ? (s[s.length - 2].position + s[s.length - 1].position) / 2 : 0.5\n s.push({ color: { ...activeColor.value }, position: pos })\n s.sort((a, b) => a.position - b.position)\n activeStopIndex.value = s.findIndex((stop) => stop.position === pos)\n emitStops(s)\n }\n\n function removeStop(index: number) {\n if (stops.value.length <= 2) return\n emitStops(stops.value.filter((_, i) => i !== index))\n activeStopIndex.value = Math.min(activeStopIndex.value, stops.value.length - 2)\n }\n\n function updateStopPosition(index: number, position: number) {\n const s = [...stops.value]\n s[index] = { ...s[index], position: Math.max(0, Math.min(1, position / 100)) }\n emitStops(s)\n }\n\n function updateStopColor(index: number, hex: string) {\n selectStop(index)\n colorModel.updateHex(hex)\n }\n\n function updateStopOpacity(index: number, opacity: number) {\n const s = [...stops.value]\n s[index] = {\n ...s[index],\n color: { ...s[index].color, a: Math.max(0, Math.min(1, opacity / 100)) }\n }\n emitStops(s)\n }\n\n function updateActiveColor(color: Color) {\n const s = [...stops.value]\n const idx = Math.min(activeStopIndex.value, s.length - 1)\n s[idx] = { ...s[idx], color }\n emitStops(s)\n }\n\n const colorModel = useColorModel({\n color: activeColor,\n colorProfile: options.colorProfile,\n onUpdate: updateActiveColor\n })\n\n function dragStop(index: number, position: number) {\n const s = [...stops.value]\n s[index] = { ...s[index], position }\n emitStops(s)\n }\n\n return {\n activeStopIndex,\n stops,\n subtype,\n subtypes: SUBTYPES,\n activeColor,\n barBackground,\n setSubtype,\n selectStop,\n addStop,\n removeStop,\n updateStopPosition,\n updateStopColor,\n updateStopOpacity,\n updateActiveColor,\n dragStop\n }\n}\n"],"mappings":";;;;;AAeA,MAAM,WAAwD;CAC5D;EAAE,OAAO;EAAmB,OAAO;CAAS;CAC5C;EAAE,OAAO;EAAmB,OAAO;CAAS;CAC5C;EAAE,OAAO;EAAoB,OAAO;CAAU;CAC9C;EAAE,OAAO;EAAoB,OAAO;CAAU;AAChD;;;;;;;AAQA,SAAgB,iBACd,MACA,UACA,UAA6D,CAAC,GAC9D;CACA,MAAM,kBAAkB,IAAI,CAAC;CAC7B,MAAM,QAAQ,eAAe,KAAK,MAAM,iBAAiB,CAAC,CAAC;CAC3D,MAAM,UAAU,eAAe,KAAK,MAAM,IAAuB;CAEjE,MAAM,cAAc,eAAe;EACjC,MAAM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ether the tree selects more than one layer at a time; Reka announces it to assistive tech. */
|
|
6
6
|
multiple?: boolean;
|
|
7
7
|
};
|
|
8
|
+
/** Moves the list to a row without selecting it, for keyboard focus and Tab. */
|
|
9
|
+
declare function reveal(id: string): void;
|
|
8
10
|
declare function select(id: string, selection: boolean | LayerSelectionMode): void;
|
|
9
11
|
declare function toggleExpand(id: string): void;
|
|
10
12
|
declare function setVirtualizer(next: LayerTreeVirtualizer): void;
|
|
@@ -86,6 +88,7 @@ declare var __VLS_8: {
|
|
|
86
88
|
actions: {
|
|
87
89
|
select: typeof select;
|
|
88
90
|
toggleExpand: typeof toggleExpand;
|
|
91
|
+
reveal: typeof reveal;
|
|
89
92
|
setFocused: (value: boolean) => void;
|
|
90
93
|
setVirtualizer: typeof setVirtualizer;
|
|
91
94
|
};
|
|
@@ -93,7 +96,9 @@ declare var __VLS_8: {
|
|
|
93
96
|
type __VLS_Slots = {} & {
|
|
94
97
|
default?: (props: typeof __VLS_8) => any;
|
|
95
98
|
};
|
|
96
|
-
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
99
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
100
|
+
visibleRows: import("vue").ComputedRef<LayerRow[]>;
|
|
101
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
97
102
|
select: (id: string, additive: boolean) => any;
|
|
98
103
|
rename: (id: string, name: string) => any;
|
|
99
104
|
toggleVisibility: (id: string) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayerTreeRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/LayerTree/LayerTreeRoot.vue"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"LayerTreeRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/LayerTree/LayerTreeRoot.vue"],"mappings":";;KAsUK;EACH;;EAEA;;;iBA6HO,OAAO;iBAyCP,OAAO,YAAY,qBAAqB;iBAyBxC,aAAa;iBAeb,eAAe,MAAM;YAmI1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA3HkB,aAAA;;;;KA4HjB;EACD,WAAW,cAAc;;cAKvB,0BAAU,gBAAA;yCAAA;;;;;;;;;;;;;0CAId;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -21,7 +21,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
21
21
|
"toggleLock",
|
|
22
22
|
"rename"
|
|
23
23
|
],
|
|
24
|
-
setup(__props, { emit: __emit }) {
|
|
24
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
25
25
|
const emit = __emit;
|
|
26
26
|
const editor = useEditor();
|
|
27
27
|
const items = ref([]);
|
|
@@ -109,6 +109,18 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
109
109
|
rowRefs.get(id)?.scrollIntoView({ block: "nearest" });
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
+
/** Moves the list to a row without selecting it, for keyboard focus and Tab. */
|
|
113
|
+
function reveal(id) {
|
|
114
|
+
const index = visibleRows.value.findIndex((row) => row.node.id === id);
|
|
115
|
+
if (index !== -1 && virtualizer) {
|
|
116
|
+
virtualizer.scrollToIndex(index, { align: "auto" });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
rowRefs.get(id)?.scrollIntoView({
|
|
120
|
+
block: "nearest",
|
|
121
|
+
inline: "nearest"
|
|
122
|
+
});
|
|
123
|
+
}
|
|
112
124
|
function onSelectionChanged(ids) {
|
|
113
125
|
expandSelectionAncestors(ids);
|
|
114
126
|
if (applyingSelection) return;
|
|
@@ -173,11 +185,14 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
173
185
|
const actions = {
|
|
174
186
|
select,
|
|
175
187
|
toggleExpand,
|
|
188
|
+
reveal,
|
|
176
189
|
setFocused: (value) => {
|
|
177
190
|
focused.value = value;
|
|
178
191
|
},
|
|
179
192
|
setVirtualizer
|
|
180
193
|
};
|
|
194
|
+
/** The rows as listed, top to bottom, for a consumer that sizes or measures them. */
|
|
195
|
+
__expose({ visibleRows });
|
|
181
196
|
provideLayerTree({
|
|
182
197
|
editor,
|
|
183
198
|
items,
|