@youcan/celeste 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/ai/README.md +1 -1
  2. package/ai/component-registry.json +206 -3
  3. package/ai/icons.json +2 -2
  4. package/ai/tokens.json +2 -2
  5. package/dist/celeste.css +573 -274
  6. package/dist/cjs/chunks/alpha-slider.cjs +1 -1
  7. package/dist/cjs/chunks/color-area.cjs +1 -1
  8. package/dist/cjs/chunks/color-picker.cjs +20 -25
  9. package/dist/cjs/chunks/color-swatch.cjs +4 -3
  10. package/dist/cjs/chunks/components.cjs +6 -4
  11. package/dist/cjs/chunks/gradient-picker.cjs +635 -0
  12. package/dist/cjs/chunks/textarea.cjs +1 -1
  13. package/dist/{es/chunks/use-color-model.js → cjs/chunks/tinycolor.cjs} +6 -23
  14. package/dist/cjs/gradient-picker.cjs +2 -0
  15. package/dist/cjs/gradient.cjs +71 -0
  16. package/dist/cjs/index.cjs +9 -4
  17. package/dist/cjs/use-color-model.cjs +27 -3
  18. package/dist/components/color-picker/gradient-picker.d.ts +51 -0
  19. package/dist/components/color-picker/index.d.ts +2 -0
  20. package/dist/es/chunks/alpha-slider.js +1 -1
  21. package/dist/es/chunks/color-area.js +1 -1
  22. package/dist/es/chunks/color-picker.js +12 -17
  23. package/dist/es/chunks/color-swatch.js +2 -1
  24. package/dist/es/chunks/components.js +6 -4
  25. package/dist/es/chunks/gradient-picker.js +629 -0
  26. package/dist/es/chunks/textarea.js +1 -1
  27. package/dist/{cjs/chunks/use-color-model.cjs → es/chunks/tinycolor.js} +1 -40
  28. package/dist/es/gradient-picker.js +2 -0
  29. package/dist/es/gradient.js +69 -0
  30. package/dist/es/index.js +7 -5
  31. package/dist/es/use-color-model.js +25 -1
  32. package/dist/utils/gradient.d.ts +13 -0
  33. package/dist/utils/index.d.ts +1 -0
  34. package/package.json +3 -3
  35. package/src/components/color-picker/color-picker.vue +8 -9
  36. package/src/components/color-picker/composable/use-color-model.ts +5 -0
  37. package/src/components/color-picker/gradient-picker.vue +944 -0
  38. package/src/components/color-picker/index.ts +3 -0
  39. package/src/components/color-picker/stories/gradient-picker.stories.ts +37 -0
  40. package/src/components/textarea/textarea.vue +1 -1
  41. package/src/utils/gradient.ts +90 -0
  42. package/src/utils/index.ts +1 -0
@@ -0,0 +1,629 @@
1
+ import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
2
+ import { t as popover_content_default } from "./popover-content.js";
3
+ import { t as popover_trigger_default } from "./popover-trigger.js";
4
+ import "./button.js";
5
+ import { t as compact_button_default } from "./compact-button.js";
6
+ import "./fancy-button.js";
7
+ import "./link-button.js";
8
+ import "./social-button.js";
9
+ import { t as tinycolor } from "./tinycolor.js";
10
+ import { t as popover_default } from "./popover.js";
11
+ import "./text-input-affix.js";
12
+ import "./text-input-button.js";
13
+ import { t as text_input_default } from "./text-input.js";
14
+ import { parseGradient, stringifyGradient } from "../gradient.js";
15
+ import { t as tooltip_default } from "./tooltip.js";
16
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, normalizeStyle, openBlock, reactive, ref, renderList, toDisplayString, unref, watch, withCtx, withModifiers } from "vue";
17
+ //#region src/components/color-picker/gradient-picker.vue?vue&type=script&setup=true&lang.ts
18
+ var _hoisted_1 = {
19
+ type: "button",
20
+ class: "celeste-gradient-trigger"
21
+ };
22
+ var _hoisted_2 = ["data-empty"];
23
+ var _hoisted_3 = { class: "celeste-gradient-summary" };
24
+ var _hoisted_4 = { class: "celeste-gradient-picker" };
25
+ var _hoisted_5 = {
26
+ key: 0,
27
+ class: "celeste-gradient-section"
28
+ };
29
+ var _hoisted_6 = { class: "celeste-gradient-hint" };
30
+ var _hoisted_7 = { class: "celeste-gradient-presets" };
31
+ var _hoisted_8 = ["title", "aria-label"];
32
+ var _hoisted_9 = ["aria-label", "onClick"];
33
+ var _hoisted_10 = { class: "celeste-gradient-section" };
34
+ var _hoisted_11 = ["data-linear"];
35
+ var _hoisted_12 = {
36
+ key: 0,
37
+ class: "celeste-gradient-ring"
38
+ };
39
+ var _hoisted_13 = { class: "celeste-gradient-row" };
40
+ var _hoisted_14 = [
41
+ "data-type",
42
+ "data-active",
43
+ "aria-label",
44
+ "onClick"
45
+ ];
46
+ var _hoisted_15 = [
47
+ "data-active",
48
+ "data-removing",
49
+ "aria-label",
50
+ "onPointerdown",
51
+ "onKeydown"
52
+ ];
53
+ var _hoisted_16 = { class: "celeste-gradient-row" };
54
+ var _hoisted_17 = { class: "celeste-gradient-eyebrow" };
55
+ var _hoisted_18 = { class: "celeste-gradient-row" };
56
+ var _hoisted_19 = { class: "celeste-gradient-label" };
57
+ var _hoisted_20 = { class: "celeste-gradient-row" };
58
+ var _hoisted_21 = { class: "celeste-gradient-current" };
59
+ var _hoisted_22 = { class: "celeste-gradient-color" };
60
+ var _hoisted_23 = [
61
+ "aria-label",
62
+ "aria-valuenow",
63
+ "aria-valuetext"
64
+ ];
65
+ var _hoisted_24 = ["aria-label", "aria-valuenow"];
66
+ var _hoisted_25 = ["aria-label", "aria-valuenow"];
67
+ var _hoisted_26 = { class: "celeste-gradient-section celeste-gradient-used" };
68
+ var _hoisted_27 = { class: "celeste-gradient-label" };
69
+ var _hoisted_28 = { class: "celeste-gradient-swatches" };
70
+ var _hoisted_29 = [
71
+ "title",
72
+ "aria-label",
73
+ "onClick"
74
+ ];
75
+ var _hoisted_30 = { class: "celeste-gradient-footer" };
76
+ //#endregion
77
+ //#region src/components/color-picker/gradient-picker.vue
78
+ var gradient_picker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
79
+ __name: "gradient-picker",
80
+ props: {
81
+ modelValue: { default: "" },
82
+ placeholder: { default: "No gradient chosen" },
83
+ emptyHint: { default: "Select a gradient to begin editing" },
84
+ noneLabel: { default: "None" },
85
+ linearLabel: { default: "Linear gradient" },
86
+ radialLabel: { default: "Radial gradient" },
87
+ angleLabel: { default: "Angle" },
88
+ colorStopLabel: { default: "Color stop" },
89
+ addStopLabel: { default: "Add stop" },
90
+ removeStopLabel: { default: "Remove stop" },
91
+ positionLabel: { default: "Position" },
92
+ opacityLabel: { default: "Opacity" },
93
+ hueLabel: { default: "Hue" },
94
+ areaLabel: { default: "Saturation and brightness" },
95
+ eyedropperLabel: { default: "Pick color" },
96
+ usedLabel: { default: "Currently used" },
97
+ removeLabel: { default: "Remove gradient" },
98
+ presets: { default: () => [
99
+ "linear-gradient(135deg, #e1116f 0%, #7d52f4 100%)",
100
+ "linear-gradient(180deg, #f7f1e8 0%, #e3cfb4 100%)",
101
+ "linear-gradient(160deg, #1f3d2b 0%, #4f7a5a 100%)",
102
+ "linear-gradient(180deg, #3d3d3d 0%, #171717 100%)",
103
+ "radial-gradient(#ffffff 0%, #dbe4ee 100%)",
104
+ "linear-gradient(135deg, #e8a07a 0%, #b5532f 100%)",
105
+ "linear-gradient(200deg, #0b3c5d 0%, #1e7f8c 100%)",
106
+ "radial-gradient(#fff1f5 0%, #f7b5c9 100%)",
107
+ "linear-gradient(120deg, #d6d29a 0%, #7a7a3a 100%)",
108
+ "linear-gradient(180deg, #1b1f3b 0%, #4b3f8f 100%)",
109
+ "linear-gradient(90deg, #ffd86b 0%, #f08a24 100%)"
110
+ ] },
111
+ swatches: { default: () => [
112
+ "#ffffff",
113
+ "#171717",
114
+ "#f5f5f5",
115
+ "#222530",
116
+ "#000000",
117
+ "#335cff",
118
+ "#e1116f"
119
+ ] }
120
+ },
121
+ emits: ["update:modelValue"],
122
+ setup(__props, { emit: __emit }) {
123
+ const props = __props;
124
+ const emit = __emit;
125
+ const open = ref(false);
126
+ const state = ref(null);
127
+ const selected = ref();
128
+ const removing = ref();
129
+ const drafts = reactive({});
130
+ const preview = ref();
131
+ const bar = ref();
132
+ const area = ref();
133
+ const hue = ref();
134
+ const alpha = ref();
135
+ let uid = 0;
136
+ const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
137
+ const numeric = (raw) => raw.trim() !== "" && !Number.isNaN(Number(raw));
138
+ function hsva(color) {
139
+ const parsed = tinycolor(color);
140
+ const { h, s, v } = parsed.toHsv();
141
+ return {
142
+ h,
143
+ s: s * 100,
144
+ v: v * 100,
145
+ a: parsed.getAlpha()
146
+ };
147
+ }
148
+ function colorOf(stop) {
149
+ const color = tinycolor({
150
+ h: stop.h,
151
+ s: stop.s / 100,
152
+ v: stop.v / 100,
153
+ a: stop.a
154
+ });
155
+ return stop.a >= 1 ? color.toHexString() : color.toRgbString();
156
+ }
157
+ function toCss(value, linear = false) {
158
+ return stringifyGradient({
159
+ type: linear ? "linear" : value.type,
160
+ angle: linear ? 90 : value.angle,
161
+ shape: value.shape,
162
+ stops: value.stops.map((stop) => ({
163
+ color: colorOf(stop),
164
+ position: stop.position
165
+ }))
166
+ });
167
+ }
168
+ function load(value) {
169
+ const gradient = parseGradient(value);
170
+ state.value = gradient && {
171
+ type: gradient.type,
172
+ angle: gradient.angle,
173
+ shape: gradient.shape,
174
+ stops: gradient.stops.map((stop) => ({
175
+ id: ++uid,
176
+ ...hsva(stop.color),
177
+ position: stop.position
178
+ }))
179
+ };
180
+ selected.value = state.value?.stops[0].id;
181
+ }
182
+ const css = computed(() => state.value ? toCss(state.value) : "");
183
+ watch(() => props.modelValue, (value) => value !== css.value && load(value), { immediate: true });
184
+ const track = computed(() => state.value ? toCss(state.value, true) : "");
185
+ const current = computed(() => state.value?.stops.find((stop) => stop.id === selected.value));
186
+ const solid = computed(() => current.value && colorOf({
187
+ ...current.value,
188
+ a: 1
189
+ }));
190
+ function save() {
191
+ css.value !== props.modelValue && emit("update:modelValue", css.value);
192
+ }
193
+ function patch(changes, keepDrafts = false) {
194
+ Object.assign(current.value, changes);
195
+ keepDrafts || Object.keys(drafts).forEach((key) => delete drafts[key]);
196
+ save();
197
+ }
198
+ function field(key, value, commit) {
199
+ return {
200
+ value: drafts[key] ?? String(value),
201
+ input: (raw) => {
202
+ drafts[key] = String(raw ?? "");
203
+ commit(drafts[key].trim());
204
+ }
205
+ };
206
+ }
207
+ const fields = computed(() => current.value && {
208
+ hex: field("hex", solid.value.toUpperCase(), (raw) => /^#?[0-9a-f]{6}$/i.test(raw) && patch({
209
+ ...hsva(raw.replace(/^#?/, "#")),
210
+ a: current.value.a
211
+ }, true)),
212
+ alpha: field("alpha", Math.round(current.value.a * 100), (raw) => numeric(raw) && patch({ a: clamp(Number(raw), 0, 100) / 100 }, true)),
213
+ position: field("position", current.value.position, (raw) => numeric(raw) && patch({ position: clamp(Math.round(Number(raw)), 0, 100) }, true)),
214
+ angle: field("angle", state.value.angle, (raw) => {
215
+ if (numeric(raw)) {
216
+ state.value.angle = (Math.round(Number(raw)) % 360 + 360) % 360;
217
+ save();
218
+ }
219
+ })
220
+ });
221
+ function drag(event, move, up) {
222
+ event.preventDefault();
223
+ move(event);
224
+ const stop = () => {
225
+ window.removeEventListener("pointermove", move);
226
+ window.removeEventListener("pointerup", stop);
227
+ up?.();
228
+ };
229
+ window.addEventListener("pointermove", move);
230
+ window.addEventListener("pointerup", stop);
231
+ }
232
+ function keys(event, apply) {
233
+ const step = event.shiftKey ? 10 : 1;
234
+ const delta = {
235
+ ArrowLeft: [-step, 0],
236
+ ArrowRight: [step, 0],
237
+ ArrowUp: [0, -step],
238
+ ArrowDown: [0, step]
239
+ }[event.key];
240
+ if (delta) {
241
+ event.preventDefault();
242
+ apply(...delta);
243
+ }
244
+ }
245
+ function onHandleKey(event, id) {
246
+ selected.value = id;
247
+ if (["Delete", "Backspace"].includes(event.key) && state.value.stops.length > 2) {
248
+ event.preventDefault();
249
+ removeStop();
250
+ }
251
+ keys(event, (dx, dy) => patch({ position: clamp(current.value.position + dx - dy, 0, 100) }));
252
+ }
253
+ function relative(element, event, inset = 0) {
254
+ const rect = element.getBoundingClientRect();
255
+ return {
256
+ x: clamp((event.clientX - rect.left - inset) / (rect.width - 2 * inset), 0, 1),
257
+ y: clamp((event.clientY - rect.top - inset) / (rect.height - 2 * inset), 0, 1),
258
+ dy: event.clientY - rect.top - rect.height / 2
259
+ };
260
+ }
261
+ function colorAt(position) {
262
+ const stops = [...state.value.stops].sort((a, b) => a.position - b.position);
263
+ const after = stops.find((stop) => stop.position >= position) ?? stops.at(-1);
264
+ const before = stops.findLast((stop) => stop.position <= position) ?? stops[0];
265
+ const ratio = after.position === before.position ? 0 : (position - before.position) / (after.position - before.position);
266
+ return {
267
+ ...hsva(tinycolor.mix(colorOf({
268
+ ...before,
269
+ a: 1
270
+ }), colorOf({
271
+ ...after,
272
+ a: 1
273
+ }), ratio * 100).toHexString()),
274
+ a: before.a + (after.a - before.a) * ratio
275
+ };
276
+ }
277
+ function addAt(position) {
278
+ const id = ++uid;
279
+ state.value.stops.push({
280
+ id,
281
+ ...colorAt(position),
282
+ position
283
+ });
284
+ selected.value = id;
285
+ save();
286
+ return id;
287
+ }
288
+ function dragStop(event, id) {
289
+ selected.value = id;
290
+ Object.keys(drafts).forEach((key) => delete drafts[key]);
291
+ drag(event, (moved) => {
292
+ const { x, dy } = relative(bar.value, moved, 10);
293
+ current.value.position = Math.round(x * 100);
294
+ removing.value = state.value.stops.length > 2 && Math.abs(dy) > 40 ? id : void 0;
295
+ save();
296
+ }, () => removing.value === id && removeStop());
297
+ }
298
+ function onBar(event) {
299
+ event.target === event.currentTarget && dragStop(event, addAt(Math.round(relative(bar.value, event, 10).x * 100)));
300
+ }
301
+ function onPreview(event) {
302
+ state.value.type === "linear" && drag(event, (moved) => {
303
+ const rect = preview.value.getBoundingClientRect();
304
+ const degrees = Math.atan2(moved.clientX - rect.left - rect.width / 2, rect.top + rect.height / 2 - moved.clientY) * 180 / Math.PI + 360;
305
+ state.value.angle = Math.round(moved.shiftKey ? Math.round(degrees / 15) * 15 : degrees) % 360;
306
+ delete drafts.angle;
307
+ save();
308
+ });
309
+ }
310
+ function onArea(event) {
311
+ drag(event, (moved) => {
312
+ const { x, y } = relative(area.value, moved);
313
+ patch({
314
+ s: x * 100,
315
+ v: (1 - y) * 100
316
+ });
317
+ });
318
+ }
319
+ function onHue(event) {
320
+ drag(event, (moved) => patch({ h: Math.min(relative(hue.value, moved, 12).y * 360, 359) }));
321
+ }
322
+ function onAlpha(event) {
323
+ drag(event, (moved) => patch({ a: Math.round((1 - relative(alpha.value, moved, 12).y) * 100) / 100 }));
324
+ }
325
+ function addStop() {
326
+ const stops = [...state.value.stops].sort((a, b) => a.position - b.position);
327
+ const index = stops.indexOf(current.value);
328
+ const next = stops[index + 1] ?? stops[index - 1];
329
+ addAt(Math.round((current.value.position + next.position) / 2));
330
+ }
331
+ function removeStop() {
332
+ state.value.stops = state.value.stops.filter((stop) => stop.id !== selected.value);
333
+ selected.value = state.value.stops[0].id;
334
+ removing.value = void 0;
335
+ save();
336
+ }
337
+ function setType(type) {
338
+ state.value.type = type;
339
+ save();
340
+ }
341
+ function pick(value) {
342
+ load(value);
343
+ save();
344
+ }
345
+ async function sip() {
346
+ const result = await new window.EyeDropper().open().catch(() => void 0);
347
+ result && patch({
348
+ ...hsva(result.sRGBHex),
349
+ a: current.value.a
350
+ });
351
+ }
352
+ const fill = (color) => `linear-gradient(${color}, ${color}), repeating-conic-gradient(#e5e5e5 0 25%, #fff 0 50%) 0 0 / 8px 8px`;
353
+ const along = (fraction) => `calc(12px + (100% - 24px) * ${fraction})`;
354
+ const canSip = "EyeDropper" in window;
355
+ return (_ctx, _cache) => {
356
+ return openBlock(), createBlock(unref(popover_default), {
357
+ open: open.value,
358
+ "onUpdate:open": _cache[6] || (_cache[6] = ($event) => open.value = $event)
359
+ }, {
360
+ default: withCtx(() => [createVNode(unref(popover_trigger_default), { "as-child": "" }, {
361
+ default: withCtx(() => [createElementVNode("button", _hoisted_1, [
362
+ createElementVNode("span", {
363
+ class: "celeste-gradient-swatch",
364
+ "data-empty": !state.value,
365
+ style: normalizeStyle(state.value ? { background: css.value } : void 0)
366
+ }, null, 12, _hoisted_2),
367
+ createElementVNode("span", _hoisted_3, toDisplayString(state.value ? state.value.type === "linear" ? __props.linearLabel : __props.radialLabel : __props.placeholder), 1),
368
+ _cache[7] || (_cache[7] = createElementVNode("i", { class: "i-celeste-expand-up-down-line" }, null, -1))
369
+ ])]),
370
+ _: 1
371
+ }), createVNode(unref(popover_content_default), {
372
+ dismissible: false,
373
+ "show-tail": false,
374
+ align: "start",
375
+ onOpenAutoFocus: _cache[5] || (_cache[5] = withModifiers(() => {}, ["prevent"]))
376
+ }, {
377
+ default: withCtx(() => [createElementVNode("div", _hoisted_4, [!state.value ? (openBlock(), createElementBlock("div", _hoisted_5, [createElementVNode("span", _hoisted_6, toDisplayString(__props.emptyHint), 1), createElementVNode("div", _hoisted_7, [createElementVNode("button", {
378
+ type: "button",
379
+ class: "celeste-gradient-preset",
380
+ "data-empty": "true",
381
+ title: __props.noneLabel,
382
+ "aria-label": __props.noneLabel,
383
+ onClick: _cache[0] || (_cache[0] = ($event) => open.value = false)
384
+ }, null, 8, _hoisted_8), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.presets, (preset) => {
385
+ return openBlock(), createElementBlock("button", {
386
+ key: preset,
387
+ type: "button",
388
+ class: "celeste-gradient-preset",
389
+ style: normalizeStyle({ background: preset }),
390
+ "aria-label": preset,
391
+ onClick: ($event) => pick(preset)
392
+ }, null, 12, _hoisted_9);
393
+ }), 128))])])) : current.value && fields.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
394
+ createElementVNode("div", _hoisted_10, [
395
+ createElementVNode("div", {
396
+ ref_key: "preview",
397
+ ref: preview,
398
+ class: "celeste-gradient-preview",
399
+ "data-linear": state.value.type === "linear",
400
+ onPointerdown: onPreview
401
+ }, [createElementVNode("span", {
402
+ class: "celeste-gradient-fill",
403
+ style: normalizeStyle({ background: css.value })
404
+ }, null, 4), state.value.type === "linear" ? (openBlock(), createElementBlock("span", _hoisted_12, [createElementVNode("span", { style: normalizeStyle({ rotate: `${state.value.angle}deg` }) }, null, 4)])) : createCommentVNode("", true)], 40, _hoisted_11),
405
+ createElementVNode("div", _hoisted_13, [(openBlock(), createElementBlock(Fragment, null, renderList(["linear", "radial"], (type) => {
406
+ return createVNode(unref(tooltip_default), {
407
+ key: type,
408
+ title: type === "linear" ? __props.linearLabel : __props.radialLabel,
409
+ size: "xs",
410
+ variant: "dark"
411
+ }, {
412
+ default: withCtx(() => [createElementVNode("button", {
413
+ type: "button",
414
+ class: "celeste-gradient-type",
415
+ "data-type": type,
416
+ "data-active": state.value.type === type,
417
+ "aria-label": type === "linear" ? __props.linearLabel : __props.radialLabel,
418
+ onClick: ($event) => setType(type)
419
+ }, [..._cache[8] || (_cache[8] = [createElementVNode("span", null, null, -1)])], 8, _hoisted_14)]),
420
+ _: 2
421
+ }, 1032, ["title"]);
422
+ }), 64)), state.value.type === "linear" ? (openBlock(), createBlock(unref(text_input_default), {
423
+ key: 0,
424
+ "model-value": fields.value.angle.value,
425
+ inputmode: "numeric",
426
+ size: "xs",
427
+ "aria-label": __props.angleLabel,
428
+ class: "celeste-gradient-number",
429
+ "onUpdate:modelValue": fields.value.angle.input
430
+ }, {
431
+ trailingNode: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode(" ° ", -1)])]),
432
+ _: 1
433
+ }, 8, [
434
+ "model-value",
435
+ "aria-label",
436
+ "onUpdate:modelValue"
437
+ ])) : createCommentVNode("", true)]),
438
+ createElementVNode("div", {
439
+ ref_key: "bar",
440
+ ref: bar,
441
+ class: "celeste-gradient-bar",
442
+ onPointerdown: onBar
443
+ }, [createElementVNode("span", {
444
+ class: "celeste-gradient-fill",
445
+ style: normalizeStyle({ background: track.value })
446
+ }, null, 4), (openBlock(true), createElementBlock(Fragment, null, renderList(state.value.stops, (stop) => {
447
+ return openBlock(), createElementBlock("button", {
448
+ key: stop.id,
449
+ type: "button",
450
+ class: "celeste-gradient-handle",
451
+ style: normalizeStyle({
452
+ left: `calc(10px + (100% - 20px) * ${stop.position / 100})`,
453
+ background: fill(colorOf(stop))
454
+ }),
455
+ "data-active": stop.id === selected.value,
456
+ "data-removing": stop.id === removing.value,
457
+ "aria-label": `${colorOf(stop)} ${stop.position}%`,
458
+ onPointerdown: withModifiers(($event) => dragStop($event, stop.id), ["stop"]),
459
+ onKeydown: ($event) => onHandleKey($event, stop.id)
460
+ }, null, 44, _hoisted_15);
461
+ }), 128))], 544),
462
+ createElementVNode("div", _hoisted_16, [
463
+ createElementVNode("span", _hoisted_17, toDisplayString(__props.colorStopLabel), 1),
464
+ createVNode(unref(compact_button_default), {
465
+ icon: "i-celeste-add-line",
466
+ variant: "ghost",
467
+ size: "md",
468
+ "aria-label": __props.addStopLabel,
469
+ onClick: addStop
470
+ }, null, 8, ["aria-label"]),
471
+ createVNode(unref(compact_button_default), {
472
+ icon: "i-celeste-subtract-line",
473
+ variant: "ghost",
474
+ size: "md",
475
+ "aria-label": __props.removeStopLabel,
476
+ disabled: state.value.stops.length <= 2,
477
+ onClick: removeStop
478
+ }, null, 8, ["aria-label", "disabled"])
479
+ ]),
480
+ createElementVNode("div", _hoisted_18, [createElementVNode("span", _hoisted_19, toDisplayString(__props.positionLabel), 1), createVNode(unref(text_input_default), {
481
+ "model-value": fields.value.position.value,
482
+ inputmode: "numeric",
483
+ size: "xs",
484
+ "aria-label": __props.positionLabel,
485
+ class: "celeste-gradient-number",
486
+ "onUpdate:modelValue": fields.value.position.input
487
+ }, {
488
+ trailingNode: withCtx(() => [..._cache[10] || (_cache[10] = [createTextVNode(" % ", -1)])]),
489
+ _: 1
490
+ }, 8, [
491
+ "model-value",
492
+ "aria-label",
493
+ "onUpdate:modelValue"
494
+ ])]),
495
+ createElementVNode("div", _hoisted_20, [
496
+ createElementVNode("span", _hoisted_21, [createElementVNode("span", {
497
+ class: "celeste-gradient-fill",
498
+ style: normalizeStyle({ background: colorOf(current.value) })
499
+ }, null, 4)]),
500
+ createVNode(unref(text_input_default), {
501
+ "model-value": fields.value.hex.value,
502
+ size: "xs",
503
+ class: "celeste-gradient-hex",
504
+ "onUpdate:modelValue": fields.value.hex.input
505
+ }, createSlots({ _: 2 }, [canSip ? {
506
+ name: "trailingNode",
507
+ fn: withCtx(() => [createVNode(unref(compact_button_default), {
508
+ icon: "i-celeste-sip-line",
509
+ variant: "ghost",
510
+ size: "md",
511
+ "aria-label": __props.eyedropperLabel,
512
+ onClick: sip
513
+ }, null, 8, ["aria-label"])]),
514
+ key: "0"
515
+ } : void 0]), 1032, ["model-value", "onUpdate:modelValue"]),
516
+ createVNode(unref(text_input_default), {
517
+ "model-value": fields.value.alpha.value,
518
+ inputmode: "numeric",
519
+ size: "xs",
520
+ "aria-label": __props.opacityLabel,
521
+ class: "celeste-gradient-number",
522
+ "onUpdate:modelValue": fields.value.alpha.input
523
+ }, {
524
+ trailingNode: withCtx(() => [..._cache[11] || (_cache[11] = [createTextVNode(" % ", -1)])]),
525
+ _: 1
526
+ }, 8, [
527
+ "model-value",
528
+ "aria-label",
529
+ "onUpdate:modelValue"
530
+ ])
531
+ ]),
532
+ createElementVNode("div", _hoisted_22, [
533
+ createElementVNode("div", {
534
+ ref_key: "area",
535
+ ref: area,
536
+ class: "celeste-gradient-area",
537
+ style: normalizeStyle({ backgroundColor: `hsl(${current.value.h}, 100%, 50%)` }),
538
+ role: "slider",
539
+ tabindex: "0",
540
+ "aria-label": __props.areaLabel,
541
+ "aria-valuenow": Math.round(current.value.s),
542
+ "aria-valuetext": `${Math.round(current.value.s)}%, ${Math.round(current.value.v)}%`,
543
+ onPointerdown: onArea,
544
+ onKeydown: _cache[1] || (_cache[1] = ($event) => keys($event, (dx, dy) => patch({
545
+ s: clamp(current.value.s + dx, 0, 100),
546
+ v: clamp(current.value.v - dy, 0, 100)
547
+ })))
548
+ }, [createElementVNode("span", {
549
+ class: "celeste-gradient-knob",
550
+ style: normalizeStyle({
551
+ left: `${current.value.s}%`,
552
+ top: `${100 - current.value.v}%`,
553
+ background: fill(colorOf(current.value))
554
+ })
555
+ }, null, 4)], 44, _hoisted_23),
556
+ createElementVNode("div", {
557
+ ref_key: "hue",
558
+ ref: hue,
559
+ class: "celeste-gradient-slider",
560
+ "data-hue": "true",
561
+ role: "slider",
562
+ tabindex: "0",
563
+ "aria-orientation": "vertical",
564
+ "aria-valuemin": "0",
565
+ "aria-valuemax": "359",
566
+ "aria-label": __props.hueLabel,
567
+ "aria-valuenow": Math.round(current.value.h),
568
+ onPointerdown: onHue,
569
+ onKeydown: _cache[2] || (_cache[2] = ($event) => keys($event, (dx, dy) => patch({ h: clamp(current.value.h + dx + dy, 0, 359) })))
570
+ }, [createElementVNode("span", {
571
+ class: "celeste-gradient-knob",
572
+ style: normalizeStyle({
573
+ top: along(current.value.h / 360),
574
+ background: fill(colorOf(current.value))
575
+ })
576
+ }, null, 4)], 40, _hoisted_24),
577
+ createElementVNode("div", {
578
+ ref_key: "alpha",
579
+ ref: alpha,
580
+ class: "celeste-gradient-slider",
581
+ role: "slider",
582
+ tabindex: "0",
583
+ "aria-orientation": "vertical",
584
+ "aria-valuemin": "0",
585
+ "aria-valuemax": "100",
586
+ "aria-label": __props.opacityLabel,
587
+ "aria-valuenow": Math.round(current.value.a * 100),
588
+ onPointerdown: onAlpha,
589
+ onKeydown: _cache[3] || (_cache[3] = ($event) => keys($event, (dx, dy) => patch({ a: clamp(Math.round(current.value.a * 100 + dx - dy), 0, 100) / 100 })))
590
+ }, [createElementVNode("span", {
591
+ class: "celeste-gradient-fill",
592
+ style: normalizeStyle({ background: `linear-gradient(${solid.value}, transparent)` })
593
+ }, null, 4), createElementVNode("span", {
594
+ class: "celeste-gradient-knob",
595
+ style: normalizeStyle({
596
+ top: along(1 - current.value.a),
597
+ background: fill(colorOf(current.value))
598
+ })
599
+ }, null, 4)], 40, _hoisted_25)
600
+ ])
601
+ ]),
602
+ createElementVNode("div", _hoisted_26, [createElementVNode("span", _hoisted_27, toDisplayString(__props.usedLabel), 1), createElementVNode("div", _hoisted_28, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.swatches, (swatch) => {
603
+ return openBlock(), createElementBlock("button", {
604
+ key: swatch,
605
+ type: "button",
606
+ style: normalizeStyle({ background: swatch }),
607
+ title: swatch,
608
+ "aria-label": swatch,
609
+ onClick: ($event) => patch({
610
+ ...hsva(swatch),
611
+ a: current.value.a
612
+ })
613
+ }, null, 12, _hoisted_29);
614
+ }), 128))])]),
615
+ createElementVNode("div", _hoisted_30, [createElementVNode("button", {
616
+ type: "button",
617
+ class: "celeste-gradient-remove",
618
+ onClick: _cache[4] || (_cache[4] = ($event) => pick(""))
619
+ }, [_cache[12] || (_cache[12] = createElementVNode("i", { class: "i-celeste-delete-bin-line" }, null, -1)), createTextVNode(" " + toDisplayString(__props.removeLabel), 1)])])
620
+ ], 64)) : createCommentVNode("", true)])]),
621
+ _: 1
622
+ })]),
623
+ _: 1
624
+ }, 8, ["open"]);
625
+ };
626
+ }
627
+ }), [["__scopeId", "data-v-3f165d2c"]]);
628
+ //#endregion
629
+ export { gradient_picker_default as t };
@@ -55,6 +55,6 @@ var textarea_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PUR
55
55
  }), null, 16, _hoisted_2), [[vModelText, modelValue.value]]), __props.showCount && Number(__props.maxLength) ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(`${modelValue.value?.length || 0}/${__props.maxLength}`), 1)) : createCommentVNode("", true)], 10, _hoisted_1);
56
56
  };
57
57
  }
58
- }), [["__scopeId", "data-v-20f36cd5"]]);
58
+ }), [["__scopeId", "data-v-0f93b4b8"]]);
59
59
  //#endregion
60
60
  export { textarea_default as t };
@@ -1,4 +1,3 @@
1
- let vue = require("vue");
2
1
  //#region ../../node_modules/.pnpm/tinycolor2@1.6.0/node_modules/tinycolor2/esm/tinycolor.js
3
2
  function _typeof(obj) {
4
3
  "@babel/helpers - typeof";
@@ -897,42 +896,4 @@ function validateWCAG2Parms(parms) {
897
896
  };
898
897
  }
899
898
  //#endregion
900
- //#region src/components/color-picker/composable/use-color-model.ts
901
- var ColorPickerEmits = ["update:modelValue"];
902
- function defineColorModel(props, emit) {
903
- let originalFormat;
904
- return (0, vue.computed)({
905
- get: () => {
906
- const colorInput = props.modelValue;
907
- const value = tinycolor(colorInput);
908
- originalFormat = value.getFormat();
909
- return value;
910
- },
911
- set: (newValue) => {
912
- emit("update:modelValue", transformToOriginalInputFormat(tinycolor(newValue), originalFormat));
913
- }
914
- });
915
- }
916
- function transformToOriginalInputFormat(color, originalFormat) {
917
- if (originalFormat === "hex" && color.getAlpha() < 1) return color.toString("hex8");
918
- return color.toString(originalFormat);
919
- }
920
- //#endregion
921
- Object.defineProperty(exports, "ColorPickerEmits", {
922
- enumerable: true,
923
- get: function() {
924
- return ColorPickerEmits;
925
- }
926
- });
927
- Object.defineProperty(exports, "defineColorModel", {
928
- enumerable: true,
929
- get: function() {
930
- return defineColorModel;
931
- }
932
- });
933
- Object.defineProperty(exports, "tinycolor", {
934
- enumerable: true,
935
- get: function() {
936
- return tinycolor;
937
- }
938
- });
899
+ export { tinycolor as t };
@@ -0,0 +1,2 @@
1
+ import { t as gradient_picker_default } from "./chunks/gradient-picker.js";
2
+ export { gradient_picker_default as default };