@pairdraw/vue 0.17.0 → 0.19.0-beta.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 +4 -1
- package/dist/canvas/CanvasRoot.vue.js.map +1 -1
- package/dist/canvas/drop/use.d.ts.map +1 -1
- package/dist/canvas/drop/use.js +5 -3
- package/dist/canvas/drop/use.js.map +1 -1
- package/dist/canvas/guides/input.js +2 -1
- package/dist/canvas/guides/input.js.map +1 -1
- package/dist/canvas/pen/input.js +20 -6
- package/dist/canvas/pen/input.js.map +1 -1
- package/dist/canvas/surface/gl-surface.js +82 -4
- package/dist/canvas/surface/gl-surface.js.map +1 -1
- package/dist/canvas/surface/kit-loader.js +22 -14
- package/dist/canvas/surface/kit-loader.js.map +1 -1
- package/dist/canvas/surface/lifecycle.js +41 -3
- package/dist/canvas/surface/lifecycle.js.map +1 -1
- package/dist/canvas/surface/resize-observer.js +11 -4
- package/dist/canvas/surface/resize-observer.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.d.ts +1 -0
- package/dist/canvas/surface/use.js +3 -1
- package/dist/canvas/surface/use.js.map +1 -1
- package/dist/canvas/text-edit/editing.js +11 -8
- package/dist/canvas/text-edit/editing.js.map +1 -1
- package/dist/canvas/text-edit/keyboard.js +12 -0
- package/dist/canvas/text-edit/keyboard.js.map +1 -1
- package/dist/canvas/useCanvasInput.d.ts +240 -0
- package/dist/controls/appearance/use.d.ts +1 -1
- package/dist/controls/layout/helpers.d.ts.map +1 -1
- package/dist/controls/layout/helpers.js +36 -7
- package/dist/controls/layout/helpers.js.map +1 -1
- package/dist/controls/layout/use.d.ts +1 -0
- package/dist/controls/layout/use.d.ts.map +1 -1
- package/dist/controls/layout/use.js +3 -0
- package/dist/controls/layout/use.js.map +1 -1
- package/dist/controls/node-preview/use.js +21 -1
- package/dist/controls/node-preview/use.js.map +1 -1
- package/dist/controls/position/use.d.ts +2 -1
- package/dist/controls/position/use.d.ts.map +1 -1
- package/dist/controls/position/use.js +13 -5
- package/dist/controls/position/use.js.map +1 -1
- package/dist/controls/property-list/use.d.ts.map +1 -1
- package/dist/controls/property-list/use.js +27 -5
- package/dist/controls/property-list/use.js.map +1 -1
- package/dist/controls/selection-layout/use.d.ts.map +1 -1
- package/dist/controls/selection-layout/use.js +3 -2
- package/dist/controls/selection-layout/use.js.map +1 -1
- package/dist/controls/slots/authoring.d.ts.map +1 -1
- package/dist/controls/slots/authoring.js +2 -1
- package/dist/controls/slots/authoring.js.map +1 -1
- package/dist/controls/typography/actions.js +18 -10
- package/dist/controls/typography/actions.js.map +1 -1
- package/dist/controls/typography/axes.d.ts.map +1 -1
- package/dist/controls/typography/axes.js +62 -19
- package/dist/controls/typography/axes.js.map +1 -1
- package/dist/editor/commands/registry.d.ts +1 -0
- package/dist/editor/commands/registry.d.ts.map +1 -1
- package/dist/editor/commands/registry.js +1 -0
- package/dist/editor/commands/registry.js.map +1 -1
- package/dist/editor/commands/selection.js +12 -3
- package/dist/editor/commands/selection.js.map +1 -1
- package/dist/editor/commands/types.d.ts +1 -1
- package/dist/editor/commands/types.d.ts.map +1 -1
- package/dist/editor/menu-model/canvas.js +5 -1
- package/dist/editor/menu-model/canvas.js.map +1 -1
- package/dist/editor/selection-capabilities/use.d.ts +1 -0
- package/dist/editor/selection-capabilities/use.js +4 -0
- package/dist/editor/selection-capabilities/use.js.map +1 -1
- package/dist/editor/selection-state/nodes.js +2 -2
- package/dist/editor/selection-state/nodes.js.map +1 -1
- package/dist/i18n/locale.d.ts.map +1 -1
- package/dist/i18n/locale.js +16 -6
- package/dist/i18n/locale.js.map +1 -1
- package/dist/i18n/locales/de/ai.json.js +9 -0
- package/dist/i18n/locales/de/automation.json.js +2 -0
- package/dist/i18n/locales/de/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/de/commands.json.js +1 -0
- package/dist/i18n/locales/de/comments.json.js +1 -0
- package/dist/i18n/locales/de/diagnostics.json.js +1 -0
- package/dist/i18n/locales/de/editor.json.js +2 -2
- package/dist/i18n/locales/de/menu.json.js +1 -1
- package/dist/i18n/locales/de/variables/panel.json.js +2 -0
- package/dist/i18n/locales/es/ai.json.js +9 -0
- package/dist/i18n/locales/es/automation.json.js +2 -0
- package/dist/i18n/locales/es/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/es/commands.json.js +1 -0
- package/dist/i18n/locales/es/comments.json.js +1 -0
- package/dist/i18n/locales/es/diagnostics.json.js +1 -0
- package/dist/i18n/locales/es/editor.json.js +2 -2
- package/dist/i18n/locales/es/menu.json.js +1 -1
- package/dist/i18n/locales/es/variables/panel.json.js +2 -0
- package/dist/i18n/locales/fr/ai.json.js +9 -0
- package/dist/i18n/locales/fr/automation.json.js +2 -0
- package/dist/i18n/locales/fr/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/fr/commands.json.js +1 -0
- package/dist/i18n/locales/fr/comments.json.js +1 -0
- package/dist/i18n/locales/fr/diagnostics.json.js +1 -0
- package/dist/i18n/locales/fr/editor.json.js +2 -2
- package/dist/i18n/locales/fr/menu.json.js +1 -1
- package/dist/i18n/locales/fr/variables/panel.json.js +2 -0
- package/dist/i18n/locales/it/ai.json.js +9 -0
- package/dist/i18n/locales/it/automation.json.js +2 -0
- package/dist/i18n/locales/it/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/it/commands.json.js +1 -0
- package/dist/i18n/locales/it/comments.json.js +1 -0
- package/dist/i18n/locales/it/diagnostics.json.js +1 -0
- package/dist/i18n/locales/it/editor.json.js +2 -2
- package/dist/i18n/locales/it/menu.json.js +1 -1
- package/dist/i18n/locales/it/variables/panel.json.js +2 -0
- package/dist/i18n/locales/ja/ai.json.js +9 -0
- package/dist/i18n/locales/ja/automation.json.js +2 -0
- package/dist/i18n/locales/ja/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/ja/commands.json.js +1 -0
- package/dist/i18n/locales/ja/comments.json.js +1 -0
- package/dist/i18n/locales/ja/diagnostics.json.js +1 -0
- package/dist/i18n/locales/ja/editor.json.js +2 -2
- package/dist/i18n/locales/ja/menu.json.js +1 -1
- package/dist/i18n/locales/ja/variables/panel.json.js +2 -0
- package/dist/i18n/locales/pl/ai.json.js +9 -0
- package/dist/i18n/locales/pl/automation.json.js +2 -0
- package/dist/i18n/locales/pl/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/pl/commands.json.js +1 -0
- package/dist/i18n/locales/pl/comments.json.js +1 -0
- package/dist/i18n/locales/pl/diagnostics.json.js +1 -0
- package/dist/i18n/locales/pl/editor.json.js +2 -2
- package/dist/i18n/locales/pl/menu.json.js +1 -1
- package/dist/i18n/locales/pl/variables/panel.json.js +2 -0
- package/dist/i18n/locales/ru/ai.json.js +9 -0
- package/dist/i18n/locales/ru/automation.json.js +2 -0
- package/dist/i18n/locales/ru/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/ru/commands.json.js +1 -0
- package/dist/i18n/locales/ru/comments.json.js +1 -0
- package/dist/i18n/locales/ru/diagnostics.json.js +1 -0
- package/dist/i18n/locales/ru/editor.json.js +2 -2
- package/dist/i18n/locales/ru/menu.json.js +1 -1
- package/dist/i18n/locales/ru/variables/panel.json.js +2 -0
- package/dist/i18n/locales/zh-cn/ai.json.js +9 -0
- package/dist/i18n/locales/zh-cn/automation.json.js +2 -0
- package/dist/i18n/locales/zh-cn/cloud/portal.json.js +1 -1
- package/dist/i18n/locales/zh-cn/commands.json.js +1 -0
- package/dist/i18n/locales/zh-cn/comments.json.js +1 -0
- package/dist/i18n/locales/zh-cn/diagnostics.json.js +1 -0
- package/dist/i18n/locales/zh-cn/editor.json.js +2 -2
- package/dist/i18n/locales/zh-cn/menu.json.js +1 -1
- package/dist/i18n/locales/zh-cn/variables/panel.json.js +2 -0
- package/dist/i18n/messages/ai.d.ts +20 -0
- package/dist/i18n/messages/ai.d.ts.map +1 -1
- package/dist/i18n/messages/ai.js +10 -0
- package/dist/i18n/messages/ai.js.map +1 -1
- package/dist/i18n/messages/automation.d.ts +2 -0
- package/dist/i18n/messages/automation.d.ts.map +1 -1
- package/dist/i18n/messages/automation.js +2 -0
- package/dist/i18n/messages/automation.js.map +1 -1
- package/dist/i18n/messages/cloud/portal.d.ts +1 -1
- package/dist/i18n/messages/cloud/portal.js +1 -1
- package/dist/i18n/messages/cloud/portal.js.map +1 -1
- package/dist/i18n/messages/commands.d.ts +1 -0
- package/dist/i18n/messages/commands.d.ts.map +1 -1
- package/dist/i18n/messages/commands.js +1 -0
- package/dist/i18n/messages/commands.js.map +1 -1
- package/dist/i18n/messages/comments.d.ts +1 -0
- package/dist/i18n/messages/comments.d.ts.map +1 -1
- package/dist/i18n/messages/comments.js +1 -0
- package/dist/i18n/messages/comments.js.map +1 -1
- package/dist/i18n/messages/diagnostics.d.ts +1 -0
- package/dist/i18n/messages/diagnostics.d.ts.map +1 -1
- package/dist/i18n/messages/diagnostics.js +1 -0
- package/dist/i18n/messages/diagnostics.js.map +1 -1
- package/dist/i18n/messages/editor.d.ts +1 -1
- package/dist/i18n/messages/editor.js +1 -1
- package/dist/i18n/messages/editor.js.map +1 -1
- package/dist/i18n/messages/menu.d.ts +1 -1
- package/dist/i18n/messages/menu.js +1 -1
- package/dist/i18n/messages/menu.js.map +1 -1
- package/dist/i18n/messages/panels.d.ts +1 -1
- package/dist/i18n/messages/panels.js +1 -1
- package/dist/i18n/messages/panels.js.map +1 -1
- package/dist/i18n/messages/variables/panel.d.ts +2 -0
- package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
- package/dist/i18n/messages/variables/panel.js +2 -0
- package/dist/i18n/messages/variables/panel.js.map +1 -1
- package/dist/i18n/messages.d.ts +30 -4
- package/dist/i18n/useI18n.d.ts +116 -14
- package/dist/i18n/useI18n.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +12 -2
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +39 -10
- package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
- package/dist/primitives/ColorPicker/gesture.d.ts +40 -0
- package/dist/primitives/ColorPicker/gesture.d.ts.map +1 -0
- package/dist/primitives/ColorPicker/gesture.js +120 -0
- package/dist/primitives/ColorPicker/gesture.js.map +1 -0
- package/dist/primitives/ColorPicker/index.d.ts +2 -1
- package/dist/primitives/ColorPicker/index.js +2 -1
- package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
- package/dist/primitives/Fill/FillSwatch.vue.js +6 -1
- package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
- package/dist/primitives/Fill/types.d.ts +5 -0
- package/dist/primitives/Fill/types.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.d.ts.map +1 -1
- package/dist/primitives/Fill/useFill.js +15 -7
- package/dist/primitives/Fill/useFill.js.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +1 -0
- package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js +7 -2
- package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +2 -0
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +14 -3
- package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
- package/dist/primitives/LayerTree/model.js +1 -1
- package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.d.ts.map +1 -1
- package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js +1 -0
- package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js.map +1 -1
- package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts +2 -2
- package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts.map +1 -1
- package/dist/primitives/NumberField/NumberFieldRoot.vue.js +3 -2
- package/dist/primitives/NumberField/NumberFieldRoot.vue.js.map +1 -1
- package/dist/primitives/NumberField/types.d.ts +5 -0
- package/dist/primitives/NumberField/types.d.ts.map +1 -1
- package/dist/primitives/PageList/PageListRoot.vue.d.ts +3 -3
- package/dist/primitives/PageList/PageListRoot.vue.d.ts.map +1 -1
- package/dist/primitives/PageList/PageListRoot.vue.js +3 -2
- package/dist/primitives/PageList/PageListRoot.vue.js.map +1 -1
- package/dist/primitives/PageList/usePageList.d.ts +1 -1
- package/dist/primitives/PageList/usePageList.d.ts.map +1 -1
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts +1 -0
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts.map +1 -1
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.js +11 -13
- package/dist/primitives/PositionControls/PositionControlsRoot.vue.js.map +1 -1
- package/dist/primitives/PropertyList/PropertyListRoot.vue.d.ts.map +1 -1
- package/dist/primitives/PropertyList/PropertyListRoot.vue.js +10 -1
- package/dist/primitives/PropertyList/PropertyListRoot.vue.js.map +1 -1
- package/dist/primitives/PropertyList/index.d.ts +2 -2
- package/dist/primitives/PropertyList/types.d.ts +14 -2
- package/dist/primitives/PropertyList/types.d.ts.map +1 -1
- package/dist/shared/input/drop-target.js +2 -1
- package/dist/shared/input/drop-target.js.map +1 -1
- package/dist/shared/input/duplicate-drag.js.map +1 -1
- package/dist/shared/input/move/drag.js +25 -4
- package/dist/shared/input/move/drag.js.map +1 -1
- package/dist/shared/input/resize/start.js +2 -1
- package/dist/shared/input/resize/start.js.map +1 -1
- package/dist/shared/input/select/move.js +8 -3
- package/dist/shared/input/select/move.js.map +1 -1
- package/dist/shared/input/select.js +22 -12
- package/dist/shared/input/select.js.map +1 -1
- package/dist/shared/input/types.d.ts +2 -0
- package/dist/shared/input/types.d.ts.map +1 -1
- package/dist/shared/input/types.js.map +1 -1
- package/dist/variables/use.d.ts.map +1 -1
- package/dist/variables/use.js +2 -1
- package/dist/variables/use.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRetainedPopup } from "../../lifecycle/retention/popup.js";
|
|
2
|
+
import { usePickerGesture } from "./gesture.js";
|
|
2
3
|
import { computed, createBlock, createCommentVNode, createElementVNode, createVNode, defineComponent, isRef, normalizeClass, normalizeStyle, openBlock, renderSlot, unref, withCtx } from "vue";
|
|
3
4
|
import { PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger } from "reka-ui";
|
|
4
5
|
import { colorToCSS } from "@pairdraw/scene-graph/color";
|
|
@@ -9,28 +10,53 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
9
10
|
props: {
|
|
10
11
|
color: {},
|
|
11
12
|
label: { default: "Edit color" },
|
|
12
|
-
ui: {}
|
|
13
|
+
ui: {},
|
|
14
|
+
escapeReverts: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false
|
|
17
|
+
}
|
|
13
18
|
},
|
|
14
19
|
emits: [
|
|
15
20
|
"update",
|
|
16
21
|
"openChange",
|
|
22
|
+
"commit",
|
|
17
23
|
"cancel"
|
|
18
24
|
],
|
|
19
25
|
setup(__props, { emit: __emit }) {
|
|
20
26
|
const emit = __emit;
|
|
21
27
|
const swatchBg = computed(() => colorToCSS(__props.color));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
let pressColor = { ...__props.color };
|
|
29
|
+
const gesture = usePickerGesture({
|
|
30
|
+
open: () => popupOpen.value,
|
|
31
|
+
beforeChange: () => {
|
|
32
|
+
pressColor = { ...__props.color };
|
|
33
|
+
},
|
|
34
|
+
commit: () => emit("commit"),
|
|
35
|
+
cancel: () => {
|
|
36
|
+
emit("update", pressColor);
|
|
37
|
+
emit("cancel", "press");
|
|
38
|
+
}
|
|
25
39
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
const { open: popupOpen, portalActive } = useRetainedPopup(void 0, () => onOpenChange(false));
|
|
41
|
+
let openColor = { ...__props.color };
|
|
42
|
+
/** A press still held when the picker closes is put back, whichever way it closes. */
|
|
43
|
+
function onOpenChange(open) {
|
|
44
|
+
if (open) openColor = { ...__props.color };
|
|
45
|
+
if (!open) gesture.abort();
|
|
46
|
+
emit("openChange", open);
|
|
47
|
+
}
|
|
48
|
+
function update(next) {
|
|
49
|
+
gesture.change(() => emit("update", next));
|
|
50
|
+
}
|
|
51
|
+
function onEscapeKeyDown() {
|
|
52
|
+
if (!__props.escapeReverts) return;
|
|
53
|
+
emit("update", openColor);
|
|
54
|
+
emit("cancel", "escape");
|
|
29
55
|
}
|
|
30
56
|
return (_ctx, _cache) => {
|
|
31
57
|
return openBlock(), createBlock(unref(PopoverRoot), {
|
|
32
58
|
open: unref(popupOpen),
|
|
33
|
-
"onUpdate:open": [_cache[0] || (_cache[0] = ($event) => isRef(popupOpen) ? popupOpen.value = $event : null),
|
|
59
|
+
"onUpdate:open": [_cache[0] || (_cache[0] = ($event) => isRef(popupOpen) ? popupOpen.value = $event : null), onOpenChange]
|
|
34
60
|
}, {
|
|
35
61
|
default: withCtx(() => [createVNode(unref(PopoverTrigger), { "as-child": "" }, {
|
|
36
62
|
default: withCtx(() => [renderSlot(_ctx.$slots, "trigger", { style: normalizeStyle({ background: swatchBg.value }) }, () => [createElementVNode("button", {
|
|
@@ -46,9 +72,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
46
72
|
"side-offset": 4,
|
|
47
73
|
side: "left",
|
|
48
74
|
"data-picker-content": "",
|
|
49
|
-
onEscapeKeyDown
|
|
75
|
+
onEscapeKeyDown
|
|
50
76
|
}, {
|
|
51
|
-
default: withCtx(() => [renderSlot(_ctx.$slots, "default", {
|
|
77
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", {
|
|
78
|
+
color: __props.color,
|
|
79
|
+
update
|
|
80
|
+
})]),
|
|
52
81
|
_: 3
|
|
53
82
|
}, 8, ["class"])]),
|
|
54
83
|
_: 3
|
|
@@ -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 { colorToCSS } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { useRetainedPopup } from '#vue/lifecycle/retention/popup'\n\nexport interface ColorPickerUI {\n content?: string\n swatch?: string\n}\n\nconst {\n color,\n label = 'Edit color',\n ui\n} = defineProps<{\n color: Color\n label?: string\n ui?: ColorPickerUI\n}>()\n\nconst emit = defineEmits<{\n update: [color: Color]\n openChange: [open: boolean]\n cancel: []\n}>()\n\nconst swatchBg = computed(() => colorToCSS(color))\nconst { open: popupOpen, portalActive } = useRetainedPopup(undefined, () => {\n
|
|
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 { colorToCSS } 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'\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} = defineProps<{\n color: Color\n label?: string\n ui?: ColorPickerUI\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}>()\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(() => colorToCSS(color))\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\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 >\n <slot :color=\"color\" :update=\"update\" />\n </PopoverContent>\n </PopoverPortal>\n </PopoverRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAgCA,MAAM,OAAO;EAab,MAAM,WAAW,eAAe,WAAW,QAAA,KAAK,CAAC;EACjD,IAAI,aA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B,MAAA,aAAA,GAAA,EAAA,KAAA,EAAA,GAAA;KADG,SAAA,cAAA,CARjB,YAQiB,MAAA,cAAA,GAAA;MAPd,OAAK,eAAE,QAAA,IAAI,OAAO;MAClB,eAAa;MACd,MAAK;MACL,uBAAA;MACkB;;MAEsB,SAAA,cAAA,CAAxC,WAAwC,KAAA,QAAA,WAAA;OAAjC,OAAO,QAAA;OAAgB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//#region src/primitives/ColorPicker/gesture.d.ts
|
|
2
|
+
interface PickerGestureOptions {
|
|
3
|
+
/** Whether the picker is open; only then does a press inside it start a step. */
|
|
4
|
+
open: () => boolean;
|
|
5
|
+
/** Ends the edit made so far as one undo step. */
|
|
6
|
+
commit: () => void;
|
|
7
|
+
/** Puts back what the press being held has changed. */
|
|
8
|
+
cancel: () => void;
|
|
9
|
+
/** A held press is about to make its first change, such as the moment to note what it changes. */
|
|
10
|
+
beforeChange?: () => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Why a picker reports `cancel`: `press` when Escape, or the picker closing, put back a press's
|
|
14
|
+
* change; `escape` when Escape closed a picker that puts back the colour it opened with.
|
|
15
|
+
*/
|
|
16
|
+
type PickerCancelCause = 'press' | 'escape';
|
|
17
|
+
/**
|
|
18
|
+
* Groups a picker's changes into undo steps as Figma desktop 126 does. A press inside the picker
|
|
19
|
+
* and everything it changes until the release is one step, such as a drag over the colour area;
|
|
20
|
+
* a change made with no press held is a step of its own, such as a tab's click, a typed value, or
|
|
21
|
+
* a chosen image. A press counts in the picker or in one opened from it, such as a shader colour's.
|
|
22
|
+
* Escape while a press that changed something is held puts that back, leaves the picker open, and
|
|
23
|
+
* ends the drag: the control holding the pointer loses it, so it stops following until the
|
|
24
|
+
* release, and anything it still reports is dropped.
|
|
25
|
+
*/
|
|
26
|
+
declare function usePickerGesture({ open, commit, cancel, beforeChange }: PickerGestureOptions): {
|
|
27
|
+
/** Applies a change, unless Escape put its press back; with no press held it is a step. */
|
|
28
|
+
change(apply: () => void): void;
|
|
29
|
+
/**
|
|
30
|
+
* Applies a change that is a step of its own, such as an image that arrives once its file is
|
|
31
|
+
* read. While a press is held, even one Escape put back, it waits for the press to end, so it
|
|
32
|
+
* neither splits that step nor survives being put back with it, and steps keep their order.
|
|
33
|
+
*/
|
|
34
|
+
step(apply: () => void): void;
|
|
35
|
+
/** For the picker closing while a press is held, such as when it loses focus: drops it. */
|
|
36
|
+
abort(): void;
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { PickerCancelCause, PickerGestureOptions, usePickerGesture };
|
|
40
|
+
//# sourceMappingURL=gesture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gesture.d.ts","names":[],"sources":["../../../src/primitives/ColorPicker/gesture.ts"],"mappings":";UAEiB;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;KAOU;;;;;;;;;;iBAcI,mBAAmB,MAAM,QAAQ,QAAQ,gBAAgB;;EA+FvD,OAAA;;;;;;EAYF,KAAA"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useEventListener, useTimeoutFn } from "@vueuse/core";
|
|
2
|
+
//#region src/primitives/ColorPicker/gesture.ts
|
|
3
|
+
/** Every picker surface carries this, including one opened from inside another picker. */
|
|
4
|
+
const PICKER_CONTENT = "[data-picker-content]";
|
|
5
|
+
/**
|
|
6
|
+
* Groups a picker's changes into undo steps as Figma desktop 126 does. A press inside the picker
|
|
7
|
+
* and everything it changes until the release is one step, such as a drag over the colour area;
|
|
8
|
+
* a change made with no press held is a step of its own, such as a tab's click, a typed value, or
|
|
9
|
+
* a chosen image. A press counts in the picker or in one opened from it, such as a shader colour's.
|
|
10
|
+
* Escape while a press that changed something is held puts that back, leaves the picker open, and
|
|
11
|
+
* ends the drag: the control holding the pointer loses it, so it stops following until the
|
|
12
|
+
* release, and anything it still reports is dropped.
|
|
13
|
+
*/
|
|
14
|
+
function usePickerGesture({ open, commit, cancel, beforeChange }) {
|
|
15
|
+
let press = null;
|
|
16
|
+
let changed = false;
|
|
17
|
+
let cancelled = false;
|
|
18
|
+
/** The Escape that put a press back, whose key repeats must not close the picker. */
|
|
19
|
+
let escapeHeld = false;
|
|
20
|
+
/** Steps of their own that arrived while a press was held, applied once it ends. */
|
|
21
|
+
let waiting = [];
|
|
22
|
+
function applyWaiting() {
|
|
23
|
+
const steps = waiting;
|
|
24
|
+
waiting = [];
|
|
25
|
+
for (const apply of steps) {
|
|
26
|
+
apply();
|
|
27
|
+
commit();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function end() {
|
|
31
|
+
const step = changed && !cancelled;
|
|
32
|
+
press = null;
|
|
33
|
+
changed = false;
|
|
34
|
+
cancelled = false;
|
|
35
|
+
return step;
|
|
36
|
+
}
|
|
37
|
+
function release() {
|
|
38
|
+
releaseLater.stop();
|
|
39
|
+
if (!press) return;
|
|
40
|
+
if (end()) commit();
|
|
41
|
+
applyWaiting();
|
|
42
|
+
}
|
|
43
|
+
const releaseLater = useTimeoutFn(release, 0, { immediate: false });
|
|
44
|
+
/** Sliders, the colour area, and the gradient bar move only while they hold the pointer. */
|
|
45
|
+
function endDrag(held) {
|
|
46
|
+
for (let element = held.target; element; element = element.parentElement) {
|
|
47
|
+
if (!element.hasPointerCapture(held.pointerId)) continue;
|
|
48
|
+
element.releasePointerCapture(held.pointerId);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
useEventListener("pointerdown", (event) => {
|
|
53
|
+
if (press || event.button !== 0 || !open()) return;
|
|
54
|
+
if (!(event.target instanceof Element) || !event.target.closest(PICKER_CONTENT)) return;
|
|
55
|
+
press = {
|
|
56
|
+
target: event.target,
|
|
57
|
+
pointerId: event.pointerId
|
|
58
|
+
};
|
|
59
|
+
changed = false;
|
|
60
|
+
cancelled = false;
|
|
61
|
+
}, { capture: true });
|
|
62
|
+
useEventListener(["pointerup", "pointercancel"], (event) => {
|
|
63
|
+
if (press?.pointerId === event.pointerId) releaseLater.start();
|
|
64
|
+
}, { capture: true });
|
|
65
|
+
useEventListener(["pointerup", "pointercancel"], (event) => {
|
|
66
|
+
if (press?.pointerId === event.pointerId) release();
|
|
67
|
+
});
|
|
68
|
+
useEventListener("blur", release);
|
|
69
|
+
useEventListener("keydown", (event) => {
|
|
70
|
+
if (event.code !== "Escape" || event.isComposing) return;
|
|
71
|
+
const held = press;
|
|
72
|
+
const putBack = held !== null && changed && !cancelled;
|
|
73
|
+
if (!putBack && !(escapeHeld && event.repeat)) return;
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
event.stopPropagation();
|
|
76
|
+
if (!held || !putBack) return;
|
|
77
|
+
cancelled = true;
|
|
78
|
+
escapeHeld = true;
|
|
79
|
+
endDrag(held);
|
|
80
|
+
cancel();
|
|
81
|
+
}, { capture: true });
|
|
82
|
+
useEventListener("keyup", (event) => {
|
|
83
|
+
if (event.code === "Escape") escapeHeld = false;
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
/** Applies a change, unless Escape put its press back; with no press held it is a step. */
|
|
87
|
+
change(apply) {
|
|
88
|
+
if (cancelled) return;
|
|
89
|
+
if (press && !changed) beforeChange?.();
|
|
90
|
+
apply();
|
|
91
|
+
if (press) changed = true;
|
|
92
|
+
else commit();
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Applies a change that is a step of its own, such as an image that arrives once its file is
|
|
96
|
+
* read. While a press is held, even one Escape put back, it waits for the press to end, so it
|
|
97
|
+
* neither splits that step nor survives being put back with it, and steps keep their order.
|
|
98
|
+
*/
|
|
99
|
+
step(apply) {
|
|
100
|
+
if (press) {
|
|
101
|
+
waiting.push(apply);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
apply();
|
|
105
|
+
commit();
|
|
106
|
+
},
|
|
107
|
+
/** For the picker closing while a press is held, such as when it loses focus: drops it. */
|
|
108
|
+
abort() {
|
|
109
|
+
releaseLater.stop();
|
|
110
|
+
const putBack = press !== null && changed && !cancelled;
|
|
111
|
+
end();
|
|
112
|
+
if (putBack) cancel();
|
|
113
|
+
applyWaiting();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { usePickerGesture };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=gesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gesture.js","names":[],"sources":["../../../src/primitives/ColorPicker/gesture.ts"],"sourcesContent":["import { useEventListener, useTimeoutFn } from '@vueuse/core'\n\nexport interface PickerGestureOptions {\n /** Whether the picker is open; only then does a press inside it start a step. */\n open: () => boolean\n /** Ends the edit made so far as one undo step. */\n commit: () => void\n /** Puts back what the press being held has changed. */\n cancel: () => void\n /** A held press is about to make its first change, such as the moment to note what it changes. */\n beforeChange?: () => void\n}\n\n/**\n * Why a picker reports `cancel`: `press` when Escape, or the picker closing, put back a press's\n * change; `escape` when Escape closed a picker that puts back the colour it opened with.\n */\nexport type PickerCancelCause = 'press' | 'escape'\n\n/** Every picker surface carries this, including one opened from inside another picker. */\nconst PICKER_CONTENT = '[data-picker-content]'\n\n/**\n * Groups a picker's changes into undo steps as Figma desktop 126 does. A press inside the picker\n * and everything it changes until the release is one step, such as a drag over the colour area;\n * a change made with no press held is a step of its own, such as a tab's click, a typed value, or\n * a chosen image. A press counts in the picker or in one opened from it, such as a shader colour's.\n * Escape while a press that changed something is held puts that back, leaves the picker open, and\n * ends the drag: the control holding the pointer loses it, so it stops following until the\n * release, and anything it still reports is dropped.\n */\nexport function usePickerGesture({ open, commit, cancel, beforeChange }: PickerGestureOptions) {\n let press: { target: Element; pointerId: number } | null = null\n let changed = false\n let cancelled = false\n /** The Escape that put a press back, whose key repeats must not close the picker. */\n let escapeHeld = false\n /** Steps of their own that arrived while a press was held, applied once it ends. */\n let waiting: Array<() => void> = []\n\n function applyWaiting() {\n const steps = waiting\n waiting = []\n for (const apply of steps) {\n apply()\n commit()\n }\n }\n\n function end(): boolean {\n const step = changed && !cancelled\n press = null\n changed = false\n cancelled = false\n return step\n }\n\n function release() {\n releaseLater.stop()\n if (!press) return\n if (end()) commit()\n applyWaiting()\n }\n\n // A control that stops its release from bubbling still ends the press, once its own handler\n // has made its last change.\n const releaseLater = useTimeoutFn(release, 0, { immediate: false })\n\n /** Sliders, the colour area, and the gradient bar move only while they hold the pointer. */\n function endDrag(held: { target: Element; pointerId: number }) {\n for (let element: Element | null = held.target; element; element = element.parentElement) {\n if (!element.hasPointerCapture(held.pointerId)) continue\n element.releasePointerCapture(held.pointerId)\n return\n }\n }\n\n // Captured on the window, ahead of controls such as a slider that change on the press itself.\n useEventListener(\n 'pointerdown',\n (event: PointerEvent) => {\n if (press || event.button !== 0 || !open()) return\n if (!(event.target instanceof Element) || !event.target.closest(PICKER_CONTENT)) return\n press = { target: event.target, pointerId: event.pointerId }\n changed = false\n cancelled = false\n },\n { capture: true }\n )\n useEventListener(\n ['pointerup', 'pointercancel'],\n (event: PointerEvent) => {\n if (press?.pointerId === event.pointerId) releaseLater.start()\n },\n { capture: true }\n )\n useEventListener(['pointerup', 'pointercancel'], (event: PointerEvent) => {\n if (press?.pointerId === event.pointerId) release()\n })\n useEventListener('blur', release)\n // Ahead of the popover's own Escape, which would close the picker, as the canvas does for its\n // drags. Propagation stops, but a picker opened from this one still sees the key and puts back\n // the same press.\n useEventListener(\n 'keydown',\n (event: KeyboardEvent) => {\n if (event.code !== 'Escape' || event.isComposing) return\n const held = press\n const putBack = held !== null && changed && !cancelled\n if (!putBack && !(escapeHeld && event.repeat)) return\n event.preventDefault()\n event.stopPropagation()\n if (!held || !putBack) return\n cancelled = true\n escapeHeld = true\n endDrag(held)\n cancel()\n },\n { capture: true }\n )\n useEventListener('keyup', (event: KeyboardEvent) => {\n if (event.code === 'Escape') escapeHeld = false\n })\n\n return {\n /** Applies a change, unless Escape put its press back; with no press held it is a step. */\n change(apply: () => void) {\n if (cancelled) return\n if (press && !changed) beforeChange?.()\n apply()\n if (press) changed = true\n else commit()\n },\n /**\n * Applies a change that is a step of its own, such as an image that arrives once its file is\n * read. While a press is held, even one Escape put back, it waits for the press to end, so it\n * neither splits that step nor survives being put back with it, and steps keep their order.\n */\n step(apply: () => void) {\n if (press) {\n waiting.push(apply)\n return\n }\n apply()\n commit()\n },\n /** For the picker closing while a press is held, such as when it loses focus: drops it. */\n abort() {\n releaseLater.stop()\n const putBack = press !== null && changed && !cancelled\n end()\n if (putBack) cancel()\n applyWaiting()\n }\n }\n}\n"],"mappings":";;;AAoBA,MAAM,iBAAiB;;;;;;;;;;AAWvB,SAAgB,iBAAiB,EAAE,MAAM,QAAQ,QAAQ,gBAAsC;CAC7F,IAAI,QAAuD;CAC3D,IAAI,UAAU;CACd,IAAI,YAAY;;CAEhB,IAAI,aAAa;;CAEjB,IAAI,UAA6B,CAAC;CAElC,SAAS,eAAe;EACtB,MAAM,QAAQ;EACd,UAAU,CAAC;EACX,KAAK,MAAM,SAAS,OAAO;GACzB,MAAM;GACN,OAAO;EACT;CACF;CAEA,SAAS,MAAe;EACtB,MAAM,OAAO,WAAW,CAAC;EACzB,QAAQ;EACR,UAAU;EACV,YAAY;EACZ,OAAO;CACT;CAEA,SAAS,UAAU;EACjB,aAAa,KAAK;EAClB,IAAI,CAAC,OAAO;EACZ,IAAI,IAAI,GAAG,OAAO;EAClB,aAAa;CACf;CAIA,MAAM,eAAe,aAAa,SAAS,GAAG,EAAE,WAAW,MAAM,CAAC;;CAGlE,SAAS,QAAQ,MAA8C;EAC7D,KAAK,IAAI,UAA0B,KAAK,QAAQ,SAAS,UAAU,QAAQ,eAAe;GACxF,IAAI,CAAC,QAAQ,kBAAkB,KAAK,SAAS,GAAG;GAChD,QAAQ,sBAAsB,KAAK,SAAS;GAC5C;EACF;CACF;CAGA,iBACE,gBACC,UAAwB;EACvB,IAAI,SAAS,MAAM,WAAW,KAAK,CAAC,KAAK,GAAG;EAC5C,IAAI,EAAE,MAAM,kBAAkB,YA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
|
|
|
1
1
|
import _default from "./ColorInputRoot.vue.js";
|
|
2
|
+
import { PickerCancelCause, usePickerGesture } from "./gesture.js";
|
|
2
3
|
import _default$1 from "./ColorPickerRoot.vue.js";
|
|
3
|
-
export { _default as ColorInputRoot, _default$1 as ColorPickerRoot };
|
|
4
|
+
export { _default as ColorInputRoot, _default$1 as ColorPickerRoot, type PickerCancelCause, usePickerGesture };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import _sfc_main from "./ColorInputRoot.vue.js";
|
|
2
|
+
import { usePickerGesture } from "./gesture.js";
|
|
2
3
|
import _sfc_main$1 from "./ColorPickerRoot.vue.js";
|
|
3
|
-
export { _sfc_main as ColorInputRoot, _sfc_main$1 as ColorPickerRoot };
|
|
4
|
+
export { _sfc_main as ColorInputRoot, _sfc_main$1 as ColorPickerRoot, usePickerGesture };
|
|
@@ -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":";;KAmFK,cAAc;cA4Fb,0BAAU,gBAAA,+CAAA,qCAAA,iDAAA,aAAA,SAAA,mBAAA,oDAAA;cAGV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -9,6 +9,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
9
9
|
props: {
|
|
10
10
|
fill: {},
|
|
11
11
|
label: {},
|
|
12
|
+
ignoreBinding: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false
|
|
15
|
+
},
|
|
12
16
|
asChild: {
|
|
13
17
|
type: Boolean,
|
|
14
18
|
default: false
|
|
@@ -17,8 +21,9 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
17
21
|
},
|
|
18
22
|
setup(__props) {
|
|
19
23
|
const binding = useOptionalBindableValue();
|
|
24
|
+
const followsBinding = computed(() => !__props.ignoreBinding && bindingState.value === "bound");
|
|
20
25
|
const bindingState = computed(() => binding?.state.value);
|
|
21
|
-
const boundColor = computed(() =>
|
|
26
|
+
const boundColor = computed(() => followsBinding.value ? binding?.resolvedValue.value : void 0);
|
|
22
27
|
const effectiveFill = computed(() => __props.fill.type === "SOLID" && boundColor.value ? {
|
|
23
28
|
...__props.fill,
|
|
24
29
|
color: boundColor.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 {
|
|
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":";;;;;;;;;;;;;;;;;;;;;;EAqBA,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,KAAK,CAAC;EAC3E,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"}
|
|
@@ -26,6 +26,11 @@ interface FillSwatchProps extends PrimitiveProps {
|
|
|
26
26
|
fill: Fill;
|
|
27
27
|
/** Accessible name for the preview. */
|
|
28
28
|
label?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Shows the fill as given, even inside a bound field: a variable picker's rows each preview their
|
|
31
|
+
* own variable rather than the one the field is bound to.
|
|
32
|
+
*/
|
|
33
|
+
ignoreBinding?: boolean;
|
|
29
34
|
}
|
|
30
35
|
interface FillSwatchSlotProps {
|
|
31
36
|
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;;UAGe;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,WAAW,OAAO"}
|
|
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;;UAGe;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,WAAW,OAAO"}
|
|
@@ -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":";;;;iBA2CgB,aAAa,MAAM,OAAO;iBAI1B,kBAAkB,MAAM;iBAWxB,qBAAqB,MAAM;;iBAiB3B,QAAQ,MAAM,IAAI,OAAO,WAAW,MAAM"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { colorToCSS } from "@pairdraw/scene-graph/color";
|
|
3
|
+
import { BLACK, TRANSPARENT } from "@pairdraw/scene-graph/constants";
|
|
3
4
|
import { DEFAULT_GRADIENT_TRANSFORM, defaultGradientStops, defaultMeshPoints } from "@pairdraw/scene-graph/gradient";
|
|
4
5
|
//#region src/primitives/Fill/useFill.ts
|
|
5
6
|
const FILL_CATEGORY = {
|
|
@@ -11,6 +12,13 @@ const FILL_CATEGORY = {
|
|
|
11
12
|
MESH: "MESH",
|
|
12
13
|
IMAGE: "IMAGE"
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* A non-solid fill carries no `color` at runtime even though the model types it as required,
|
|
17
|
+
* because image and shader paints have no colour; the swatch treats that as no colour paint.
|
|
18
|
+
*/
|
|
19
|
+
function fillColor(fill, fallback) {
|
|
20
|
+
return fill.color ?? fallback;
|
|
21
|
+
}
|
|
14
22
|
function effectiveColor(color, opacity) {
|
|
15
23
|
return {
|
|
16
24
|
...color,
|
|
@@ -25,14 +33,14 @@ function fillCategory(fill) {
|
|
|
25
33
|
}
|
|
26
34
|
function fillIsTransparent(fill) {
|
|
27
35
|
if (fill.opacity < 1) return true;
|
|
28
|
-
if (fillCategory(fill) === "GRADIENT") return fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fill.
|
|
29
|
-
if (fillCategory(fill) === "MESH") return fill.meshPoints?.some((point) => point.color.a < 1) ?? fill.
|
|
30
|
-
return fill.
|
|
36
|
+
if (fillCategory(fill) === "GRADIENT") return fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1;
|
|
37
|
+
if (fillCategory(fill) === "MESH") return fill.meshPoints?.some((point) => point.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1;
|
|
38
|
+
return fillColor(fill, TRANSPARENT).a < 1;
|
|
31
39
|
}
|
|
32
40
|
function fillSwatchBackground(fill) {
|
|
33
41
|
if (fillCategory(fill) === "GRADIENT" && fill.gradientStops?.length) return `linear-gradient(to right, ${gradientCSS(fill.gradientStops, fill.opacity)})`;
|
|
34
42
|
if (fillCategory(fill) === "MESH" && fill.meshPoints?.length) return `linear-gradient(to right, ${fill.meshPoints.map((point, index) => `${colorToCSS(effectiveColor(point.color, fill.opacity))} ${index / (fill.meshPoints?.length ?? 1) * 100}%`).join(", ")})`;
|
|
35
|
-
return colorToCSS(effectiveColor(fill
|
|
43
|
+
return colorToCSS(effectiveColor(fillColor(fill, TRANSPARENT), fill.opacity));
|
|
36
44
|
}
|
|
37
45
|
/** Fill category state and immutable conversion actions without picker or popover behavior. */
|
|
38
46
|
function useFill(fill, onUpdate) {
|
|
@@ -41,7 +49,7 @@ function useFill(fill, onUpdate) {
|
|
|
41
49
|
const transparent = computed(() => fillIsTransparent(fill.value));
|
|
42
50
|
function toSolid() {
|
|
43
51
|
if (category.value === "SOLID") return;
|
|
44
|
-
const color = fill.value.gradientStops?.[0]?.color ?? fill.value.meshPoints?.[0]?.color ?? fill.value
|
|
52
|
+
const color = fill.value.gradientStops?.[0]?.color ?? fill.value.meshPoints?.[0]?.color ?? fillColor(fill.value, BLACK);
|
|
45
53
|
onUpdate({
|
|
46
54
|
...fill.value,
|
|
47
55
|
type: "SOLID",
|
|
@@ -50,7 +58,7 @@ function useFill(fill, onUpdate) {
|
|
|
50
58
|
}
|
|
51
59
|
function toGradient() {
|
|
52
60
|
if (category.value === "GRADIENT") return;
|
|
53
|
-
const gradientStops = fill.value.gradientStops?.length ? structuredClone(fill.value.gradientStops) : defaultGradientStops(fill.value
|
|
61
|
+
const gradientStops = fill.value.gradientStops?.length ? structuredClone(fill.value.gradientStops) : defaultGradientStops(fillColor(fill.value, BLACK));
|
|
54
62
|
onUpdate({
|
|
55
63
|
...fill.value,
|
|
56
64
|
type: "GRADIENT_LINEAR",
|
|
@@ -60,7 +68,7 @@ function useFill(fill, onUpdate) {
|
|
|
60
68
|
}
|
|
61
69
|
function toMesh() {
|
|
62
70
|
if (category.value === "MESH") return;
|
|
63
|
-
const color = fill.value.meshPoints?.[0]?.color ?? fill.value
|
|
71
|
+
const color = fill.value.meshPoints?.[0]?.color ?? fillColor(fill.value, BLACK);
|
|
64
72
|
onUpdate({
|
|
65
73
|
...fill.value,
|
|
66
74
|
type: "MESH",
|
|
@@ -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 { colorToCSS } from '@pairdraw/scene-graph/color'\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\nfunction effectiveColor(color: Color, opacity: number): Color {\n return { ...color, a: color.a * opacity }\n}\n\nfunction gradientCSS(stops: GradientStop[], opacity: number): string {\n return stops\n .map((stop) => `${colorToCSS(effectiveColor(stop.color, opacity))} ${stop.position * 100}%`)\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 fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fill.
|
|
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 { colorToCSS } 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): string {\n return stops\n .map((stop) => `${colorToCSS(effectiveColor(stop.color, opacity))} ${stop.position * 100}%`)\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\nexport function fillSwatchBackground(fill: Fill): string {\n if (fillCategory(fill) === 'GRADIENT' && fill.gradientStops?.length) {\n return `linear-gradient(to right, ${gradientCSS(fill.gradientStops, fill.opacity)})`\n }\n if (fillCategory(fill) === 'MESH' && fill.meshPoints?.length) {\n const stops = fill.meshPoints\n .map(\n (point, index) =>\n `${colorToCSS(effectiveColor(point.color, fill.opacity))} ${(index / (fill.meshPoints?.length ?? 1)) * 100}%`\n )\n .join(', ')\n return `linear-gradient(to right, ${stops})`\n }\n return colorToCSS(effectiveColor(fillColor(fill, TRANSPARENT), fill.opacity))\n}\n\n/** Fill category state and immutable conversion actions without picker or popover behavior. */\nexport function useFill(fill: Ref<Fill>, onUpdate: (fill: Fill) => void) {\n const category = computed(() => fillCategory(fill.value))\n const swatchBackground = computed(() => fillSwatchBackground(fill.value))\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,SAAyB;CACnE,OAAO,MACJ,KAAK,SAAS,GAAG,WAAW,eAAe,KAAK,OAAO,OAAO,CAAC,EAAE,GAAG,KAAK,WAAW,IAAI,EAAE,CAA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EAAE,SAC5B,UAAU,KAAK,OAAO,KAAK;EAC7B,SAAS;GAAE,GAAG,KAAK;GAAO,MAAM;GAAS,OAAO,EAAE,GAAG,MAAM;EAAE,CAAC;CAChE;CAEA,SAAS,aAAa;EACpB,IAAI,SAAS,UAAU,YAAY;EACnC,MAAM,gBAAgB,KAAK,MAAM,eAAe,SAC5C,gBAAgB,KAAK,MAAM,aAAa,IACxC,qBAAqB,UAAU,KAAK,OAAO,KAAK,CAAC;EACrD,SAAS;GACP,GAAG,KAAK;GACR,MAAM;GACN;GACA,mBAAmB,KAAK,MAAM,qBAAqB,EAAE,GAAG,2BAA2B;EACrF,CAAC;CACH;CAEA,SAAS,SAAS;EAChB,IAAI,SAAS,UAAU,QAAQ;EAC/B,MAAM,QAAQ,KAAK,MAAM,aAAa,EAAE,EAAE,SAAS,UAAU,KAAK,OAAO,KAAK;EAC9E,SAAS;GACP,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontPickerRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/FontPicker/FontPickerRoot.vue"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"FontPickerRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/FontPicker/FontPickerRoot.vue"],"mappings":";;;;KAuNK;EACH,oBAAoB,mBAAmB;EACvC,kBAAkB;EAClB,KAAK;EACL;EACA;EACA;EACA;;KA2DG;EACL;;KAMK,oBAAoB,cAAc;YA6ThB;;;GAA0C;;GAAqB;;;;GAAqB;;;KACtG;EACD,WAAW,cAAc;;EACzB,UAAU,cAAc;;EACxB,QAAQ,cAAc;;EACtB,aAAa,cAAc;;cAQzB,0BAAU,gBAAA,iDAAA,qCAAA;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|
|
@@ -21,6 +21,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
21
21
|
listFamilies: { type: Function },
|
|
22
22
|
localFontAccess: {},
|
|
23
23
|
ui: {},
|
|
24
|
+
searchPlaceholder: { default: "Search fonts…" },
|
|
24
25
|
emptySearchText: {},
|
|
25
26
|
emptyFontsText: {},
|
|
26
27
|
emptyFontsHint: {}
|
|
@@ -101,12 +102,16 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
101
102
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(searchTerm) ? searchTerm.value = $event : null),
|
|
102
103
|
"display-value": () => "",
|
|
103
104
|
class: normalizeClass(__props.ui?.search),
|
|
104
|
-
placeholder:
|
|
105
|
+
placeholder: __props.searchPlaceholder,
|
|
105
106
|
autocomplete: "off",
|
|
106
107
|
autocorrect: "off",
|
|
107
108
|
autocapitalize: "off",
|
|
108
109
|
spellcheck: "false"
|
|
109
|
-
}, null, 8, [
|
|
110
|
+
}, null, 8, [
|
|
111
|
+
"modelValue",
|
|
112
|
+
"class",
|
|
113
|
+
"placeholder"
|
|
114
|
+
])]), createVNode(unref(ComboboxViewport), { class: normalizeClass(__props.ui?.viewport ?? "max-h-72 overflow-y-auto") }, {
|
|
110
115
|
default: withCtx(() => [createVNode(unref(ComboboxVirtualizer), {
|
|
111
116
|
options: unref(filtered),
|
|
112
117
|
"text-content": (option) => option.family,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontPickerRoot.vue.js","names":[],"sources":["../../../src/primitives/FontPicker/FontPickerRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { templateRef, unrefElement } from '@vueuse/core'\nimport {\n ComboboxAnchor,\n ComboboxContent,\n ComboboxInput,\n ComboboxItem,\n ComboboxItemIndicator,\n ComboboxPortal,\n ComboboxRoot,\n ComboboxTrigger,\n ComboboxVirtualizer,\n ComboboxViewport,\n type AcceptableValue\n} from 'reka-ui'\nimport { nextTick, useTemplateRef, watch } from 'vue'\n\nimport type { FontFamilyOption } from '@pairdraw/core/text'\n\nimport { useRetainedPopup } from '#vue/lifecycle/retention/popup'\nimport type { FontPickerUI } from '#vue/primitives/FontPicker/types'\nimport { useFontPicker, type FontAccessController } from '#vue/primitives/FontPicker/useFontPicker'\n\nconst { listFamilies, localFontAccess, ui, emptySearchText, emptyFontsText, emptyFontsHint } =\n defineProps<{\n listFamilies: () => Promise<string[] | FontFamilyOption[]>\n localFontAccess?: FontAccessController\n ui?: FontPickerUI\n emptySearchText?: string\n emptyFontsText?: string\n emptyFontsHint?: string\n }>()\n\nconst modelValue = defineModel<string>({ required: true })\nconst emit = defineEmits<{ select: [family: string] }>()\n\nconst contentRef = templateRef<HTMLElement>('contentRef')\n\nfunction focusSearchInput() {\n nextTick(() => {\n const content = unrefElement(contentRef)\n if (!(content instanceof HTMLElement)) return\n content.querySelector<HTMLInputElement>('input')?.focus()\n })\n}\n\nconst { searchTerm, open, filtered, loading, accessState, requestAccess, select } = useFontPicker({\n modelValue,\n listFamilies,\n localFontAccess,\n onSelect: (family) => emit('select', family)\n})\nconst { portalActive } = useRetainedPopup(open)\nconst root = useTemplateRef<{ highlightItem: (value: AcceptableValue) => void }>('root')\n\n// The families arrive after the list opens, too late for Reka's own scroll to the chosen font.\nwatch(\n () => open.value && !loading.value && filtered.value.length > 0,\n async (ready) => {\n if (!ready || searchTerm.value) return\n await nextTick()\n root.value?.highlightItem(modelValue.value)\n }\n)\n\n/**\n * The list holds font options and the value is a family name; Reka compares them to find the\n * chosen font, so opening scrolls to it.\n */\nfunction sameFamily(left: unknown, right: unknown): boolean {\n return familyOf(left) === familyOf(right)\n}\n\nfunction familyOf(value: unknown): unknown {\n return typeof value === 'object' && value !== null && 'family' in value ? value.family : value\n}\n</script>\n\n<template>\n <ComboboxRoot\n ref=\"root\"\n v-model:open=\"open\"\n :model-value=\"modelValue\"\n :ignore-filter=\"true\"\n :by=\"sameFamily\"\n @update:model-value=\"\n (v: AcceptableValue) => {\n if (typeof v === 'string') select(v)\n }\n \"\n >\n <ComboboxAnchor as-child>\n <ComboboxTrigger as-child>\n <slot name=\"trigger\" :value=\"modelValue\" :open=\"open\">\n <button :class=\"ui?.trigger\">\n <span class=\"truncate\">{{ modelValue }}</span>\n </button>\n </slot>\n </ComboboxTrigger>\n </ComboboxAnchor>\n\n <ComboboxPortal v-if=\"portalActive\">\n <ComboboxContent\n :side-offset=\"2\"\n align=\"start\"\n position=\"popper\"\n :class=\"ui?.content\"\n @open-auto-focus.prevent\n ref=\"contentRef\"\n @vue:mounted=\"focusSearchInput\"\n >\n <slot name=\"search\" :search-term=\"searchTerm\">\n <ComboboxInput\n v-model=\"searchTerm\"\n :display-value=\"() => ''\"\n :class=\"ui?.search\"\n placeholder=\"Search fonts…\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n />\n </slot>\n\n <ComboboxViewport :class=\"ui?.viewport ?? 'max-h-72 overflow-y-auto'\">\n <ComboboxVirtualizer\n v-slot=\"{ option }\"\n :options=\"filtered\"\n :text-content=\"(option: FontFamilyOption) => option.family\"\n :estimate-size=\"36\"\n >\n <ComboboxItem\n :value=\"option.family\"\n :class=\"ui?.item\"\n :style=\"{ fontFamily: `'${option.family}', sans-serif` }\"\n >\n <slot\n name=\"item\"\n :family=\"option.family\"\n :source=\"option.source\"\n :selected=\"option.family === modelValue\"\n >\n <ComboboxItemIndicator>\n <slot name=\"indicator\" :selected=\"option.family === modelValue\" />\n </ComboboxItemIndicator>\n <span class=\"truncate\">{{ option.family }}</span>\n </slot>\n </ComboboxItem>\n </ComboboxVirtualizer>\n\n <div v-if=\"filtered.length === 0 && searchTerm\" :class=\"ui?.empty\">\n {{ emptySearchText ?? 'No fonts found' }}\n </div>\n <div v-else-if=\"filtered.length === 0\" :class=\"ui?.empty\">\n <div>\n <p v-if=\"accessState === 'prompt'\">\n Allow local font access to browse installed fonts.\n </p>\n <p v-else-if=\"accessState === 'denied'\">\n Local font access is blocked for this site.\n </p>\n <p v-else-if=\"accessState === 'unsupported'\">\n Local fonts are not available in this browser.\n </p>\n <p v-else>{{ emptyFontsText ?? 'No local fonts available.' }}</p>\n <p v-if=\"emptyFontsHint\" class=\"mt-1\">{{ emptyFontsHint }}</p>\n <button\n v-if=\"accessState === 'prompt'\"\n type=\"button\"\n :class=\"ui?.emptyAction\"\n :disabled=\"loading\"\n @click=\"requestAccess\"\n >\n {{ loading ? 'Loading…' : 'Allow local fonts' }}\n </button>\n </div>\n </div>\n </ComboboxViewport>\n </ComboboxContent>\n </ComboboxPortal>\n </ComboboxRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCA,MAAM,aAAa,SAAmB,SAAA,YAAmB;EACzD,MAAM,OAAO;EAEb,MAAM,aAAa,YAAyB,YAAY;EAExD,SAAS,mBAAmB;GAC1B,eAAe;IACb,MAAM,UAAU,aAAa,UAAU;IACvC,IAAI,EAAE,mBAAmB,cAAc;IACvC,QAAQ,cAAgC,OAAO,CAAC,EAAE,MAAM;GAC1D,CAAC;EACH;EAEA,MAAM,EAAE,YAAY,MAAM,UAAU,SAAS,aAAa,eAAe,WAAW,cAAc;GAChG;GACA,cAAW,QAAA;GACX,iBAAc,QAAA;GACd,WAAW,WAAW,KAAK,UAAU,MAAM;EAC7C,CAAC;EACD,MAAM,EAAE,iBAAiB,iBAAiB,IAAI;EAC9C,MAAM,OAAO,eAAoE,MAAM;EAGvF,YACQ,KAAK,SAAS,CAAC,QAAQ,SAAS,SAAS,MAAM,SAAS,GAC9D,OAAO,UAAU;GACf,IAAI,CAAC,SAAS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oot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { templateRef, unrefElement } from '@vueuse/core'\nimport {\n ComboboxAnchor,\n ComboboxContent,\n ComboboxInput,\n ComboboxItem,\n ComboboxItemIndicator,\n ComboboxPortal,\n ComboboxRoot,\n ComboboxTrigger,\n ComboboxVirtualizer,\n ComboboxViewport,\n type AcceptableValue\n} from 'reka-ui'\nimport { nextTick, useTemplateRef, watch } from 'vue'\n\nimport type { FontFamilyOption } from '@pairdraw/core/text'\n\nimport { useRetainedPopup } from '#vue/lifecycle/retention/popup'\nimport type { FontPickerUI } from '#vue/primitives/FontPicker/types'\nimport { useFontPicker, type FontAccessController } from '#vue/primitives/FontPicker/useFontPicker'\n\nconst {\n listFamilies,\n localFontAccess,\n ui,\n searchPlaceholder = 'Search fonts…',\n emptySearchText,\n emptyFontsText,\n emptyFontsHint\n} = defineProps<{\n listFamilies: () => Promise<string[] | FontFamilyOption[]>\n localFontAccess?: FontAccessController\n ui?: FontPickerUI\n searchPlaceholder?: string\n emptySearchText?: string\n emptyFontsText?: string\n emptyFontsHint?: string\n}>()\n\nconst modelValue = defineModel<string>({ required: true })\nconst emit = defineEmits<{ select: [family: string] }>()\n\nconst contentRef = templateRef<HTMLElement>('contentRef')\n\nfunction focusSearchInput() {\n nextTick(() => {\n const content = unrefElement(contentRef)\n if (!(content instanceof HTMLElement)) return\n content.querySelector<HTMLInputElement>('input')?.focus()\n })\n}\n\nconst { searchTerm, open, filtered, loading, accessState, requestAccess, select } = useFontPicker({\n modelValue,\n listFamilies,\n localFontAccess,\n onSelect: (family) => emit('select', family)\n})\nconst { portalActive } = useRetainedPopup(open)\nconst root = useTemplateRef<{ highlightItem: (value: AcceptableValue) => void }>('root')\n\n// The families arrive after the list opens, too late for Reka's own scroll to the chosen font.\nwatch(\n () => open.value && !loading.value && filtered.value.length > 0,\n async (ready) => {\n if (!ready || searchTerm.value) return\n await nextTick()\n root.value?.highlightItem(modelValue.value)\n }\n)\n\n/**\n * The list holds font options and the value is a family name; Reka compares them to find the\n * chosen font, so opening scrolls to it.\n */\nfunction sameFamily(left: unknown, right: unknown): boolean {\n return familyOf(left) === familyOf(right)\n}\n\nfunction familyOf(value: unknown): unknown {\n return typeof value === 'object' && value !== null && 'family' in value ? value.family : value\n}\n</script>\n\n<template>\n <ComboboxRoot\n ref=\"root\"\n v-model:open=\"open\"\n :model-value=\"modelValue\"\n :ignore-filter=\"true\"\n :by=\"sameFamily\"\n @update:model-value=\"\n (v: AcceptableValue) => {\n if (typeof v === 'string') select(v)\n }\n \"\n >\n <ComboboxAnchor as-child>\n <ComboboxTrigger as-child>\n <slot name=\"trigger\" :value=\"modelValue\" :open=\"open\">\n <button :class=\"ui?.trigger\">\n <span class=\"truncate\">{{ modelValue }}</span>\n </button>\n </slot>\n </ComboboxTrigger>\n </ComboboxAnchor>\n\n <ComboboxPortal v-if=\"portalActive\">\n <ComboboxContent\n :side-offset=\"2\"\n align=\"start\"\n position=\"popper\"\n :class=\"ui?.content\"\n @open-auto-focus.prevent\n ref=\"contentRef\"\n @vue:mounted=\"focusSearchInput\"\n >\n <slot name=\"search\" :search-term=\"searchTerm\">\n <ComboboxInput\n v-model=\"searchTerm\"\n :display-value=\"() => ''\"\n :class=\"ui?.search\"\n :placeholder=\"searchPlaceholder\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n />\n </slot>\n\n <ComboboxViewport :class=\"ui?.viewport ?? 'max-h-72 overflow-y-auto'\">\n <ComboboxVirtualizer\n v-slot=\"{ option }\"\n :options=\"filtered\"\n :text-content=\"(option: FontFamilyOption) => option.family\"\n :estimate-size=\"36\"\n >\n <ComboboxItem\n :value=\"option.family\"\n :class=\"ui?.item\"\n :style=\"{ fontFamily: `'${option.family}', sans-serif` }\"\n >\n <slot\n name=\"item\"\n :family=\"option.family\"\n :source=\"option.source\"\n :selected=\"option.family === modelValue\"\n >\n <ComboboxItemIndicator>\n <slot name=\"indicator\" :selected=\"option.family === modelValue\" />\n </ComboboxItemIndicator>\n <span class=\"truncate\">{{ option.family }}</span>\n </slot>\n </ComboboxItem>\n </ComboboxVirtualizer>\n\n <div v-if=\"filtered.length === 0 && searchTerm\" :class=\"ui?.empty\">\n {{ emptySearchText ?? 'No fonts found' }}\n </div>\n <div v-else-if=\"filtered.length === 0\" :class=\"ui?.empty\">\n <div>\n <p v-if=\"accessState === 'prompt'\">\n Allow local font access to browse installed fonts.\n </p>\n <p v-else-if=\"accessState === 'denied'\">\n Local font access is blocked for this site.\n </p>\n <p v-else-if=\"accessState === 'unsupported'\">\n Local fonts are not available in this browser.\n </p>\n <p v-else>{{ emptyFontsText ?? 'No local fonts available.' }}</p>\n <p v-if=\"emptyFontsHint\" class=\"mt-1\">{{ emptyFontsHint }}</p>\n <button\n v-if=\"accessState === 'prompt'\"\n type=\"button\"\n :class=\"ui?.emptyAction\"\n :disabled=\"loading\"\n @click=\"requestAccess\"\n >\n {{ loading ? 'Loading…' : 'Allow local fonts' }}\n </button>\n </div>\n </div>\n </ComboboxViewport>\n </ComboboxContent>\n </ComboboxPortal>\n </ComboboxRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,aAAa,SAAmB,SAAA,YAAmB;EACzD,MAAM,OAAO;EAEb,MAAM,aAAa,YAAyB,YAAY;EAExD,SAAS,mBAAmB;GAC1B,eAAe;IACb,MAAM,UAAU,aAAa,UAAU;IACvC,IAAI,EAAE,mBAAmB,cAAc;IACvC,QAAQ,cAAgC,OAAO,CAAC,EAAE,MAAM;GAC1D,CAAC;EACH;EAEA,MAAM,EAAE,YAAY,MAAM,UAAU,SAAS,aAAa,eAAe,WAAW,cAAc;GAChG;GACA,cAAW,QAAA;GACX,iBAAc,QAAA;GACd,WAAW,WAAW,KAAK,UAAU,MAAM;EAC7C,CAAC;EACD,MAAM,EAAE,iBAAiB,iBAAiB,IAAI;EAC9C,MAAM,OAAO,eAAoE,MAAM;EAGvF,YAC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2,6 +2,8 @@ import { LayerNode, LayerRow, LayerSelectionMode, LayerTreeVirtualizer } from ".
|
|
|
2
2
|
//#region src/primitives/LayerTree/LayerTreeRoot.vue.d.ts
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
indentPerLevel?: number;
|
|
5
|
+
/** Whether the tree selects more than one layer at a time; Reka announces it to assistive tech. */
|
|
6
|
+
multiple?: boolean;
|
|
5
7
|
};
|
|
6
8
|
declare function select(id: string, selection: boolean | LayerSelectionMode): void;
|
|
7
9
|
declare function toggleExpand(id: string): void;
|
|
@@ -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":";;KA6TK;EACH;;EAEA;;iBAkKO,OAAO,YAAY,qBAAqB;iBAwBxC,aAAa;iBAeb,eAAe,MAAM;YA8H1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAvHkB,aAAA;;;;KAwHjB;EACD,WAAW,cAAc;;cAKvB,0BAAU,gBAAA,2CAAA,qCAAA;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
|