@youcan/celeste 0.18.0 → 0.20.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 +229 -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 +638 -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 +56 -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 +632 -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 +950 -0
  38. package/src/components/color-picker/index.ts +3 -0
  39. package/src/components/color-picker/stories/gradient-picker.stories.ts +48 -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,632 @@
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
+ side: { default: "bottom" },
121
+ align: { default: "start" }
122
+ },
123
+ emits: ["update:modelValue"],
124
+ setup(__props, { emit: __emit }) {
125
+ const props = __props;
126
+ const emit = __emit;
127
+ const open = ref(false);
128
+ const state = ref(null);
129
+ const selected = ref();
130
+ const removing = ref();
131
+ const drafts = reactive({});
132
+ const preview = ref();
133
+ const bar = ref();
134
+ const area = ref();
135
+ const hue = ref();
136
+ const alpha = ref();
137
+ let uid = 0;
138
+ const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
139
+ const numeric = (raw) => raw.trim() !== "" && !Number.isNaN(Number(raw));
140
+ function hsva(color) {
141
+ const parsed = tinycolor(color);
142
+ const { h, s, v } = parsed.toHsv();
143
+ return {
144
+ h,
145
+ s: s * 100,
146
+ v: v * 100,
147
+ a: parsed.getAlpha()
148
+ };
149
+ }
150
+ function colorOf(stop) {
151
+ const color = tinycolor({
152
+ h: stop.h,
153
+ s: stop.s / 100,
154
+ v: stop.v / 100,
155
+ a: stop.a
156
+ });
157
+ return stop.a >= 1 ? color.toHexString() : color.toRgbString();
158
+ }
159
+ function toCss(value, linear = false) {
160
+ return stringifyGradient({
161
+ type: linear ? "linear" : value.type,
162
+ angle: linear ? 90 : value.angle,
163
+ shape: value.shape,
164
+ stops: value.stops.map((stop) => ({
165
+ color: colorOf(stop),
166
+ position: stop.position
167
+ }))
168
+ });
169
+ }
170
+ function load(value) {
171
+ const gradient = parseGradient(value);
172
+ state.value = gradient && {
173
+ type: gradient.type,
174
+ angle: gradient.angle,
175
+ shape: gradient.shape,
176
+ stops: gradient.stops.map((stop) => ({
177
+ id: ++uid,
178
+ ...hsva(stop.color),
179
+ position: stop.position
180
+ }))
181
+ };
182
+ selected.value = state.value?.stops[0].id;
183
+ }
184
+ const css = computed(() => state.value ? toCss(state.value) : "");
185
+ watch(() => props.modelValue, (value) => value !== css.value && load(value), { immediate: true });
186
+ const track = computed(() => state.value ? toCss(state.value, true) : "");
187
+ const current = computed(() => state.value?.stops.find((stop) => stop.id === selected.value));
188
+ const solid = computed(() => current.value && colorOf({
189
+ ...current.value,
190
+ a: 1
191
+ }));
192
+ function save() {
193
+ css.value !== props.modelValue && emit("update:modelValue", css.value);
194
+ }
195
+ function patch(changes, keepDrafts = false) {
196
+ Object.assign(current.value, changes);
197
+ keepDrafts || Object.keys(drafts).forEach((key) => delete drafts[key]);
198
+ save();
199
+ }
200
+ function field(key, value, commit) {
201
+ return {
202
+ value: drafts[key] ?? String(value),
203
+ input: (raw) => {
204
+ drafts[key] = String(raw ?? "");
205
+ commit(drafts[key].trim());
206
+ }
207
+ };
208
+ }
209
+ const fields = computed(() => current.value && {
210
+ hex: field("hex", solid.value.toUpperCase(), (raw) => /^#?[0-9a-f]{6}$/i.test(raw) && patch({
211
+ ...hsva(raw.replace(/^#?/, "#")),
212
+ a: current.value.a
213
+ }, true)),
214
+ alpha: field("alpha", Math.round(current.value.a * 100), (raw) => numeric(raw) && patch({ a: clamp(Number(raw), 0, 100) / 100 }, true)),
215
+ position: field("position", current.value.position, (raw) => numeric(raw) && patch({ position: clamp(Math.round(Number(raw)), 0, 100) }, true)),
216
+ angle: field("angle", state.value.angle, (raw) => {
217
+ if (numeric(raw)) {
218
+ state.value.angle = (Math.round(Number(raw)) % 360 + 360) % 360;
219
+ save();
220
+ }
221
+ })
222
+ });
223
+ function drag(event, move, up) {
224
+ event.preventDefault();
225
+ move(event);
226
+ const stop = () => {
227
+ window.removeEventListener("pointermove", move);
228
+ window.removeEventListener("pointerup", stop);
229
+ up?.();
230
+ };
231
+ window.addEventListener("pointermove", move);
232
+ window.addEventListener("pointerup", stop);
233
+ }
234
+ function keys(event, apply) {
235
+ const step = event.shiftKey ? 10 : 1;
236
+ const delta = {
237
+ ArrowLeft: [-step, 0],
238
+ ArrowRight: [step, 0],
239
+ ArrowUp: [0, -step],
240
+ ArrowDown: [0, step]
241
+ }[event.key];
242
+ if (delta) {
243
+ event.preventDefault();
244
+ apply(...delta);
245
+ }
246
+ }
247
+ function onHandleKey(event, id) {
248
+ selected.value = id;
249
+ if (["Delete", "Backspace"].includes(event.key) && state.value.stops.length > 2) {
250
+ event.preventDefault();
251
+ removeStop();
252
+ }
253
+ keys(event, (dx, dy) => patch({ position: clamp(current.value.position + dx - dy, 0, 100) }));
254
+ }
255
+ function relative(element, event, inset = 0) {
256
+ const rect = element.getBoundingClientRect();
257
+ return {
258
+ x: clamp((event.clientX - rect.left - inset) / (rect.width - 2 * inset), 0, 1),
259
+ y: clamp((event.clientY - rect.top - inset) / (rect.height - 2 * inset), 0, 1),
260
+ dy: event.clientY - rect.top - rect.height / 2
261
+ };
262
+ }
263
+ function colorAt(position) {
264
+ const stops = [...state.value.stops].sort((a, b) => a.position - b.position);
265
+ const after = stops.find((stop) => stop.position >= position) ?? stops.at(-1);
266
+ const before = stops.findLast((stop) => stop.position <= position) ?? stops[0];
267
+ const ratio = after.position === before.position ? 0 : (position - before.position) / (after.position - before.position);
268
+ return {
269
+ ...hsva(tinycolor.mix(colorOf({
270
+ ...before,
271
+ a: 1
272
+ }), colorOf({
273
+ ...after,
274
+ a: 1
275
+ }), ratio * 100).toHexString()),
276
+ a: before.a + (after.a - before.a) * ratio
277
+ };
278
+ }
279
+ function addAt(position) {
280
+ const id = ++uid;
281
+ state.value.stops.push({
282
+ id,
283
+ ...colorAt(position),
284
+ position
285
+ });
286
+ selected.value = id;
287
+ save();
288
+ return id;
289
+ }
290
+ function dragStop(event, id) {
291
+ selected.value = id;
292
+ Object.keys(drafts).forEach((key) => delete drafts[key]);
293
+ drag(event, (moved) => {
294
+ const { x, dy } = relative(bar.value, moved, 10);
295
+ current.value.position = Math.round(x * 100);
296
+ removing.value = state.value.stops.length > 2 && Math.abs(dy) > 40 ? id : void 0;
297
+ save();
298
+ }, () => removing.value === id && removeStop());
299
+ }
300
+ function onBar(event) {
301
+ event.target === event.currentTarget && dragStop(event, addAt(Math.round(relative(bar.value, event, 10).x * 100)));
302
+ }
303
+ function onPreview(event) {
304
+ state.value.type === "linear" && drag(event, (moved) => {
305
+ const rect = preview.value.getBoundingClientRect();
306
+ const degrees = Math.atan2(moved.clientX - rect.left - rect.width / 2, rect.top + rect.height / 2 - moved.clientY) * 180 / Math.PI + 360;
307
+ state.value.angle = Math.round(moved.shiftKey ? Math.round(degrees / 15) * 15 : degrees) % 360;
308
+ delete drafts.angle;
309
+ save();
310
+ });
311
+ }
312
+ function onArea(event) {
313
+ drag(event, (moved) => {
314
+ const { x, y } = relative(area.value, moved);
315
+ patch({
316
+ s: x * 100,
317
+ v: (1 - y) * 100
318
+ });
319
+ });
320
+ }
321
+ function onHue(event) {
322
+ drag(event, (moved) => patch({ h: Math.min(relative(hue.value, moved, 12).y * 360, 359) }));
323
+ }
324
+ function onAlpha(event) {
325
+ drag(event, (moved) => patch({ a: Math.round((1 - relative(alpha.value, moved, 12).y) * 100) / 100 }));
326
+ }
327
+ function addStop() {
328
+ const stops = [...state.value.stops].sort((a, b) => a.position - b.position);
329
+ const index = stops.indexOf(current.value);
330
+ const next = stops[index + 1] ?? stops[index - 1];
331
+ addAt(Math.round((current.value.position + next.position) / 2));
332
+ }
333
+ function removeStop() {
334
+ state.value.stops = state.value.stops.filter((stop) => stop.id !== selected.value);
335
+ selected.value = state.value.stops[0].id;
336
+ removing.value = void 0;
337
+ save();
338
+ }
339
+ function setType(type) {
340
+ state.value.type = type;
341
+ save();
342
+ }
343
+ function pick(value) {
344
+ load(value);
345
+ save();
346
+ }
347
+ async function sip() {
348
+ const result = await new window.EyeDropper().open().catch(() => void 0);
349
+ result && patch({
350
+ ...hsva(result.sRGBHex),
351
+ a: current.value.a
352
+ });
353
+ }
354
+ const fill = (color) => `linear-gradient(${color}, ${color}), repeating-conic-gradient(#e5e5e5 0 25%, #fff 0 50%) 0 0 / 8px 8px`;
355
+ const along = (fraction) => `calc(12px + (100% - 24px) * ${fraction})`;
356
+ const canSip = "EyeDropper" in window;
357
+ return (_ctx, _cache) => {
358
+ return openBlock(), createBlock(unref(popover_default), {
359
+ open: open.value,
360
+ "onUpdate:open": _cache[6] || (_cache[6] = ($event) => open.value = $event)
361
+ }, {
362
+ default: withCtx(() => [createVNode(unref(popover_trigger_default), { "as-child": "" }, {
363
+ default: withCtx(() => [createElementVNode("button", _hoisted_1, [
364
+ createElementVNode("span", {
365
+ class: "celeste-gradient-swatch",
366
+ "data-empty": !state.value,
367
+ style: normalizeStyle(state.value ? { background: css.value } : void 0)
368
+ }, null, 12, _hoisted_2),
369
+ createElementVNode("span", _hoisted_3, toDisplayString(state.value ? state.value.type === "linear" ? __props.linearLabel : __props.radialLabel : __props.placeholder), 1),
370
+ _cache[7] || (_cache[7] = createElementVNode("i", { class: "i-celeste-expand-up-down-line" }, null, -1))
371
+ ])]),
372
+ _: 1
373
+ }), createVNode(unref(popover_content_default), {
374
+ dismissible: false,
375
+ "show-tail": false,
376
+ side: __props.side,
377
+ align: __props.align,
378
+ onOpenAutoFocus: _cache[5] || (_cache[5] = withModifiers(() => {}, ["prevent"]))
379
+ }, {
380
+ 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", {
381
+ type: "button",
382
+ class: "celeste-gradient-preset",
383
+ "data-empty": "true",
384
+ title: __props.noneLabel,
385
+ "aria-label": __props.noneLabel,
386
+ onClick: _cache[0] || (_cache[0] = ($event) => open.value = false)
387
+ }, null, 8, _hoisted_8), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.presets, (preset) => {
388
+ return openBlock(), createElementBlock("button", {
389
+ key: preset,
390
+ type: "button",
391
+ class: "celeste-gradient-preset",
392
+ style: normalizeStyle({ background: preset }),
393
+ "aria-label": preset,
394
+ onClick: ($event) => pick(preset)
395
+ }, null, 12, _hoisted_9);
396
+ }), 128))])])) : current.value && fields.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
397
+ createElementVNode("div", _hoisted_10, [
398
+ createElementVNode("div", {
399
+ ref_key: "preview",
400
+ ref: preview,
401
+ class: "celeste-gradient-preview",
402
+ "data-linear": state.value.type === "linear",
403
+ onPointerdown: onPreview
404
+ }, [createElementVNode("span", {
405
+ class: "celeste-gradient-fill",
406
+ style: normalizeStyle({ background: css.value })
407
+ }, 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),
408
+ createElementVNode("div", _hoisted_13, [(openBlock(), createElementBlock(Fragment, null, renderList(["linear", "radial"], (type) => {
409
+ return createVNode(unref(tooltip_default), {
410
+ key: type,
411
+ title: type === "linear" ? __props.linearLabel : __props.radialLabel,
412
+ size: "xs",
413
+ variant: "dark"
414
+ }, {
415
+ default: withCtx(() => [createElementVNode("button", {
416
+ type: "button",
417
+ class: "celeste-gradient-type",
418
+ "data-type": type,
419
+ "data-active": state.value.type === type,
420
+ "aria-label": type === "linear" ? __props.linearLabel : __props.radialLabel,
421
+ onClick: ($event) => setType(type)
422
+ }, [..._cache[8] || (_cache[8] = [createElementVNode("span", null, null, -1)])], 8, _hoisted_14)]),
423
+ _: 2
424
+ }, 1032, ["title"]);
425
+ }), 64)), state.value.type === "linear" ? (openBlock(), createBlock(unref(text_input_default), {
426
+ key: 0,
427
+ "model-value": fields.value.angle.value,
428
+ inputmode: "numeric",
429
+ size: "xs",
430
+ "aria-label": __props.angleLabel,
431
+ class: "celeste-gradient-number",
432
+ "onUpdate:modelValue": fields.value.angle.input
433
+ }, {
434
+ trailingNode: withCtx(() => [..._cache[9] || (_cache[9] = [createTextVNode(" ° ", -1)])]),
435
+ _: 1
436
+ }, 8, [
437
+ "model-value",
438
+ "aria-label",
439
+ "onUpdate:modelValue"
440
+ ])) : createCommentVNode("", true)]),
441
+ createElementVNode("div", {
442
+ ref_key: "bar",
443
+ ref: bar,
444
+ class: "celeste-gradient-bar",
445
+ onPointerdown: onBar
446
+ }, [createElementVNode("span", {
447
+ class: "celeste-gradient-fill",
448
+ style: normalizeStyle({ background: track.value })
449
+ }, null, 4), (openBlock(true), createElementBlock(Fragment, null, renderList(state.value.stops, (stop) => {
450
+ return openBlock(), createElementBlock("button", {
451
+ key: stop.id,
452
+ type: "button",
453
+ class: "celeste-gradient-handle",
454
+ style: normalizeStyle({
455
+ left: `calc(10px + (100% - 20px) * ${stop.position / 100})`,
456
+ background: fill(colorOf(stop))
457
+ }),
458
+ "data-active": stop.id === selected.value,
459
+ "data-removing": stop.id === removing.value,
460
+ "aria-label": `${colorOf(stop)} ${stop.position}%`,
461
+ onPointerdown: withModifiers(($event) => dragStop($event, stop.id), ["stop"]),
462
+ onKeydown: ($event) => onHandleKey($event, stop.id)
463
+ }, null, 44, _hoisted_15);
464
+ }), 128))], 544),
465
+ createElementVNode("div", _hoisted_16, [
466
+ createElementVNode("span", _hoisted_17, toDisplayString(__props.colorStopLabel), 1),
467
+ createVNode(unref(compact_button_default), {
468
+ icon: "i-celeste-add-line",
469
+ variant: "ghost",
470
+ size: "md",
471
+ "aria-label": __props.addStopLabel,
472
+ onClick: addStop
473
+ }, null, 8, ["aria-label"]),
474
+ createVNode(unref(compact_button_default), {
475
+ icon: "i-celeste-subtract-line",
476
+ variant: "ghost",
477
+ size: "md",
478
+ "aria-label": __props.removeStopLabel,
479
+ disabled: state.value.stops.length <= 2,
480
+ onClick: removeStop
481
+ }, null, 8, ["aria-label", "disabled"])
482
+ ]),
483
+ createElementVNode("div", _hoisted_18, [createElementVNode("span", _hoisted_19, toDisplayString(__props.positionLabel), 1), createVNode(unref(text_input_default), {
484
+ "model-value": fields.value.position.value,
485
+ inputmode: "numeric",
486
+ size: "xs",
487
+ "aria-label": __props.positionLabel,
488
+ class: "celeste-gradient-number",
489
+ "onUpdate:modelValue": fields.value.position.input
490
+ }, {
491
+ trailingNode: withCtx(() => [..._cache[10] || (_cache[10] = [createTextVNode(" % ", -1)])]),
492
+ _: 1
493
+ }, 8, [
494
+ "model-value",
495
+ "aria-label",
496
+ "onUpdate:modelValue"
497
+ ])]),
498
+ createElementVNode("div", _hoisted_20, [
499
+ createElementVNode("span", _hoisted_21, [createElementVNode("span", {
500
+ class: "celeste-gradient-fill",
501
+ style: normalizeStyle({ background: colorOf(current.value) })
502
+ }, null, 4)]),
503
+ createVNode(unref(text_input_default), {
504
+ "model-value": fields.value.hex.value,
505
+ size: "xs",
506
+ class: "celeste-gradient-hex",
507
+ "onUpdate:modelValue": fields.value.hex.input
508
+ }, createSlots({ _: 2 }, [canSip ? {
509
+ name: "trailingNode",
510
+ fn: withCtx(() => [createVNode(unref(compact_button_default), {
511
+ icon: "i-celeste-sip-line",
512
+ variant: "ghost",
513
+ size: "md",
514
+ "aria-label": __props.eyedropperLabel,
515
+ onClick: sip
516
+ }, null, 8, ["aria-label"])]),
517
+ key: "0"
518
+ } : void 0]), 1032, ["model-value", "onUpdate:modelValue"]),
519
+ createVNode(unref(text_input_default), {
520
+ "model-value": fields.value.alpha.value,
521
+ inputmode: "numeric",
522
+ size: "xs",
523
+ "aria-label": __props.opacityLabel,
524
+ class: "celeste-gradient-number",
525
+ "onUpdate:modelValue": fields.value.alpha.input
526
+ }, {
527
+ trailingNode: withCtx(() => [..._cache[11] || (_cache[11] = [createTextVNode(" % ", -1)])]),
528
+ _: 1
529
+ }, 8, [
530
+ "model-value",
531
+ "aria-label",
532
+ "onUpdate:modelValue"
533
+ ])
534
+ ]),
535
+ createElementVNode("div", _hoisted_22, [
536
+ createElementVNode("div", {
537
+ ref_key: "area",
538
+ ref: area,
539
+ class: "celeste-gradient-area",
540
+ style: normalizeStyle({ backgroundColor: `hsl(${current.value.h}, 100%, 50%)` }),
541
+ role: "slider",
542
+ tabindex: "0",
543
+ "aria-label": __props.areaLabel,
544
+ "aria-valuenow": Math.round(current.value.s),
545
+ "aria-valuetext": `${Math.round(current.value.s)}%, ${Math.round(current.value.v)}%`,
546
+ onPointerdown: onArea,
547
+ onKeydown: _cache[1] || (_cache[1] = ($event) => keys($event, (dx, dy) => patch({
548
+ s: clamp(current.value.s + dx, 0, 100),
549
+ v: clamp(current.value.v - dy, 0, 100)
550
+ })))
551
+ }, [createElementVNode("span", {
552
+ class: "celeste-gradient-knob",
553
+ style: normalizeStyle({
554
+ left: `${current.value.s}%`,
555
+ top: `${100 - current.value.v}%`,
556
+ background: fill(colorOf(current.value))
557
+ })
558
+ }, null, 4)], 44, _hoisted_23),
559
+ createElementVNode("div", {
560
+ ref_key: "hue",
561
+ ref: hue,
562
+ class: "celeste-gradient-slider",
563
+ "data-hue": "true",
564
+ role: "slider",
565
+ tabindex: "0",
566
+ "aria-orientation": "vertical",
567
+ "aria-valuemin": "0",
568
+ "aria-valuemax": "359",
569
+ "aria-label": __props.hueLabel,
570
+ "aria-valuenow": Math.round(current.value.h),
571
+ onPointerdown: onHue,
572
+ onKeydown: _cache[2] || (_cache[2] = ($event) => keys($event, (dx, dy) => patch({ h: clamp(current.value.h + dx + dy, 0, 359) })))
573
+ }, [createElementVNode("span", {
574
+ class: "celeste-gradient-knob",
575
+ style: normalizeStyle({
576
+ top: along(current.value.h / 360),
577
+ background: fill(colorOf(current.value))
578
+ })
579
+ }, null, 4)], 40, _hoisted_24),
580
+ createElementVNode("div", {
581
+ ref_key: "alpha",
582
+ ref: alpha,
583
+ class: "celeste-gradient-slider",
584
+ role: "slider",
585
+ tabindex: "0",
586
+ "aria-orientation": "vertical",
587
+ "aria-valuemin": "0",
588
+ "aria-valuemax": "100",
589
+ "aria-label": __props.opacityLabel,
590
+ "aria-valuenow": Math.round(current.value.a * 100),
591
+ onPointerdown: onAlpha,
592
+ onKeydown: _cache[3] || (_cache[3] = ($event) => keys($event, (dx, dy) => patch({ a: clamp(Math.round(current.value.a * 100 + dx - dy), 0, 100) / 100 })))
593
+ }, [createElementVNode("span", {
594
+ class: "celeste-gradient-fill",
595
+ style: normalizeStyle({ background: `linear-gradient(${solid.value}, transparent)` })
596
+ }, null, 4), createElementVNode("span", {
597
+ class: "celeste-gradient-knob",
598
+ style: normalizeStyle({
599
+ top: along(1 - current.value.a),
600
+ background: fill(colorOf(current.value))
601
+ })
602
+ }, null, 4)], 40, _hoisted_25)
603
+ ])
604
+ ]),
605
+ 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) => {
606
+ return openBlock(), createElementBlock("button", {
607
+ key: swatch,
608
+ type: "button",
609
+ style: normalizeStyle({ background: swatch }),
610
+ title: swatch,
611
+ "aria-label": swatch,
612
+ onClick: ($event) => patch({
613
+ ...hsva(swatch),
614
+ a: current.value.a
615
+ })
616
+ }, null, 12, _hoisted_29);
617
+ }), 128))])]),
618
+ createElementVNode("div", _hoisted_30, [createElementVNode("button", {
619
+ type: "button",
620
+ class: "celeste-gradient-remove",
621
+ onClick: _cache[4] || (_cache[4] = ($event) => pick(""))
622
+ }, [_cache[12] || (_cache[12] = createElementVNode("i", { class: "i-celeste-delete-bin-line" }, null, -1)), createTextVNode(" " + toDisplayString(__props.removeLabel), 1)])])
623
+ ], 64)) : createCommentVNode("", true)])]),
624
+ _: 1
625
+ }, 8, ["side", "align"])]),
626
+ _: 1
627
+ }, 8, ["open"]);
628
+ };
629
+ }
630
+ }), [["__scopeId", "data-v-9b399aff"]]);
631
+ //#endregion
632
+ 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 };