@adea-ai/ui 0.142.3 → 0.143.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 (87) hide show
  1. package/dist/components/composites/accent-picker/accent-picker.d.ts +28 -0
  2. package/dist/components/composites/accent-picker/accent-picker.d.ts.map +1 -0
  3. package/dist/components/composites/accent-picker/accent-picker.js +97 -0
  4. package/dist/components/composites/accent-picker/accent-picker.js.map +1 -0
  5. package/dist/components/composites/accent-picker/index.d.ts +2 -0
  6. package/dist/components/composites/accent-picker/index.d.ts.map +1 -0
  7. package/dist/components/composites/accent-picker/index.js +2 -0
  8. package/dist/components/composites/icon-picker/icon-picker.d.ts +37 -0
  9. package/dist/components/composites/icon-picker/icon-picker.d.ts.map +1 -0
  10. package/dist/components/composites/icon-picker/icon-picker.js +187 -0
  11. package/dist/components/composites/icon-picker/icon-picker.js.map +1 -0
  12. package/dist/components/composites/icon-picker/image-data-url.d.ts +42 -0
  13. package/dist/components/composites/icon-picker/image-data-url.d.ts.map +1 -0
  14. package/dist/components/composites/icon-picker/image-data-url.js +90 -0
  15. package/dist/components/composites/icon-picker/image-data-url.js.map +1 -0
  16. package/dist/components/composites/icon-picker/index.d.ts +4 -0
  17. package/dist/components/composites/icon-picker/index.d.ts.map +1 -0
  18. package/dist/components/composites/icon-picker/index.js +4 -0
  19. package/dist/components/composites/icon-picker/shell-icons.d.ts +264 -0
  20. package/dist/components/composites/icon-picker/shell-icons.d.ts.map +1 -0
  21. package/dist/components/composites/icon-picker/shell-icons.js +334 -0
  22. package/dist/components/composites/icon-picker/shell-icons.js.map +1 -0
  23. package/dist/components/composites/terminal/terminal.js +2 -2
  24. package/dist/components/composites/terminal/terminal.js.map +1 -1
  25. package/dist/components/composites/workspace-switcher/index.d.ts +2 -0
  26. package/dist/components/composites/workspace-switcher/index.d.ts.map +1 -0
  27. package/dist/components/composites/workspace-switcher/index.js +2 -0
  28. package/dist/components/composites/workspace-switcher/workspace-switcher.d.ts +44 -0
  29. package/dist/components/composites/workspace-switcher/workspace-switcher.d.ts.map +1 -0
  30. package/dist/components/composites/workspace-switcher/workspace-switcher.js +157 -0
  31. package/dist/components/composites/workspace-switcher/workspace-switcher.js.map +1 -0
  32. package/dist/components/layout/shell-rail/index.d.ts +2 -0
  33. package/dist/components/layout/shell-rail/index.d.ts.map +1 -0
  34. package/dist/components/layout/shell-rail/index.js +2 -0
  35. package/dist/components/layout/shell-rail/shell-rail.d.ts +36 -0
  36. package/dist/components/layout/shell-rail/shell-rail.d.ts.map +1 -0
  37. package/dist/components/layout/shell-rail/shell-rail.js +124 -0
  38. package/dist/components/layout/shell-rail/shell-rail.js.map +1 -0
  39. package/dist/components/layout/shell-top-bar/index.d.ts +2 -0
  40. package/dist/components/layout/shell-top-bar/index.d.ts.map +1 -0
  41. package/dist/components/layout/shell-top-bar/index.js +2 -0
  42. package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts +68 -0
  43. package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts.map +1 -0
  44. package/dist/components/layout/shell-top-bar/shell-top-bar.js +135 -0
  45. package/dist/components/layout/shell-top-bar/shell-top-bar.js.map +1 -0
  46. package/dist/components/layout/top-bar/top-bar.d.ts +21 -6
  47. package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
  48. package/dist/components/layout/top-bar/top-bar.js +2 -2
  49. package/dist/components/layout/top-bar/top-bar.js.map +1 -1
  50. package/dist/index.d.ts +5 -0
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +8 -1
  53. package/dist/r/accent-picker.json +25 -0
  54. package/dist/r/icon-picker.json +36 -0
  55. package/dist/r/registry.json +137 -0
  56. package/dist/r/shell-rail.json +27 -0
  57. package/dist/r/shell-top-bar.json +23 -0
  58. package/dist/r/src/components/composites/accent-picker/accent-picker.tsx +85 -0
  59. package/dist/r/src/components/composites/accent-picker/index.ts +1 -0
  60. package/dist/r/src/components/composites/icon-picker/icon-picker.tsx +184 -0
  61. package/dist/r/src/components/composites/icon-picker/image-data-url.ts +107 -0
  62. package/dist/r/src/components/composites/icon-picker/index.ts +20 -0
  63. package/dist/r/src/components/composites/icon-picker/shell-icons.ts +166 -0
  64. package/dist/r/src/components/composites/workspace-switcher/index.ts +5 -0
  65. package/dist/r/src/components/composites/workspace-switcher/workspace-switcher.tsx +128 -0
  66. package/dist/r/src/components/layout/shell-rail/index.ts +1 -0
  67. package/dist/r/src/components/layout/shell-rail/shell-rail.tsx +120 -0
  68. package/dist/r/src/components/layout/shell-top-bar/index.ts +1 -0
  69. package/dist/r/src/components/layout/shell-top-bar/shell-top-bar.tsx +185 -0
  70. package/dist/r/src/components/layout/top-bar/top-bar.tsx +27 -8
  71. package/dist/r/workspace-switcher.json +26 -0
  72. package/package.json +1 -1
  73. package/registry.json +137 -0
  74. package/src/components/composites/accent-picker/accent-picker.tsx +85 -0
  75. package/src/components/composites/accent-picker/index.ts +1 -0
  76. package/src/components/composites/icon-picker/icon-picker.tsx +184 -0
  77. package/src/components/composites/icon-picker/image-data-url.ts +107 -0
  78. package/src/components/composites/icon-picker/index.ts +20 -0
  79. package/src/components/composites/icon-picker/shell-icons.ts +166 -0
  80. package/src/components/composites/workspace-switcher/index.ts +5 -0
  81. package/src/components/composites/workspace-switcher/workspace-switcher.tsx +128 -0
  82. package/src/components/layout/shell-rail/index.ts +1 -0
  83. package/src/components/layout/shell-rail/shell-rail.tsx +120 -0
  84. package/src/components/layout/shell-top-bar/index.ts +1 -0
  85. package/src/components/layout/shell-top-bar/shell-top-bar.tsx +185 -0
  86. package/src/components/layout/top-bar/top-bar.tsx +27 -8
  87. package/src/index.ts +5 -0
@@ -0,0 +1,28 @@
1
+ import type { JSX } from 'solid-js';
2
+ /**
3
+ * AccentPicker.
4
+ *
5
+ * A row of accent swatches with a leading "none" choice, for a setting that
6
+ * overrides the accent it would otherwise inherit: a project's icon colour, a
7
+ * workspace's colour over the app's. `null` is a real value, not an empty one:
8
+ * it means "do not override", so the swatch row never has an unchecked state and
9
+ * the control can say what the inherited colour is through `inheritLabel`.
10
+ *
11
+ * The swatches are the theme's own accent presets, each carrying its light and
12
+ * dark colour and switching on the `dark` class, so a swatch is the colour the
13
+ * setting will produce in whichever appearance is in force and the picker needs
14
+ * no theme provider.
15
+ */
16
+ export type AccentPickerProps = {
17
+ /** The group's accessible name, e.g. "Icon colour". */
18
+ label: string;
19
+ /** An accent preset id, or `null` for no override. */
20
+ value: string | null;
21
+ onValueChange(value: string | null): void;
22
+ /** What `null` means here, e.g. "Inherit workspace accent". Also the first swatch's name. */
23
+ inheritLabel?: string;
24
+ disabled?: boolean;
25
+ class?: string;
26
+ };
27
+ export declare function AccentPicker(props: AccentPickerProps): JSX.Element;
28
+ //# sourceMappingURL=accent-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accent-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/accent-picker/accent-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAKnC;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;IACb,sDAAsD;IACtD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IACzC,6FAA6F;IAC7F,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eA6BpD"}
@@ -0,0 +1,97 @@
1
+ import { cn } from "../../../lib/utils.js";
2
+ import { accents } from "../../../lib/accent-presets.js";
3
+ import { createComponent, effect, insert, memo, setStyleProperty, template } from "solid-js/web";
4
+ import { Ban } from "lucide-solid";
5
+ import { For } from "solid-js";
6
+ import { RadioGroup } from "@kobalte/core/radio-group";
7
+ //#region src/components/composites/accent-picker/accent-picker.tsx
8
+ var _tmpl$ = /*#__PURE__*/ template(`<span aria-hidden=true class="block size-full rounded-full bg-(--swatch-light) dark:bg-(--swatch-dark)">`);
9
+ var _tmpl$2 = /*#__PURE__*/ template(`<span class=sr-only>`);
10
+ var NONE = "__none__";
11
+ function AccentPicker(props) {
12
+ return createComponent(RadioGroup, {
13
+ "data-slot": "swatch-picker",
14
+ get ["aria-label"]() {
15
+ return props.label;
16
+ },
17
+ get value() {
18
+ return props.value ?? NONE;
19
+ },
20
+ get disabled() {
21
+ return props.disabled;
22
+ },
23
+ onChange: (id) => props.onValueChange(id === NONE ? null : id),
24
+ get ["class"]() {
25
+ return cn("flex flex-wrap items-center gap-2", props.class);
26
+ },
27
+ get children() {
28
+ return [createComponent(SwatchItem, {
29
+ id: NONE,
30
+ get label() {
31
+ return props.inheritLabel ?? "No colour override";
32
+ },
33
+ get children() {
34
+ return createComponent(Ban, {
35
+ "class": "size-4 text-muted-foreground",
36
+ "aria-hidden": "true"
37
+ });
38
+ }
39
+ }), createComponent(For, {
40
+ each: accents,
41
+ children: (accent) => createComponent(SwatchItem, {
42
+ get id() {
43
+ return accent.id;
44
+ },
45
+ get label() {
46
+ return accent.label;
47
+ },
48
+ get children() {
49
+ var _el$ = _tmpl$();
50
+ effect((_p$) => {
51
+ var _v$ = accent.light ?? "currentColor", _v$2 = accent.dark ?? accent.light ?? "currentColor";
52
+ _v$ !== _p$.e && setStyleProperty(_el$, "--swatch-light", _p$.e = _v$);
53
+ _v$2 !== _p$.t && setStyleProperty(_el$, "--swatch-dark", _p$.t = _v$2);
54
+ return _p$;
55
+ }, {
56
+ e: void 0,
57
+ t: void 0
58
+ });
59
+ return _el$;
60
+ }
61
+ })
62
+ })];
63
+ }
64
+ });
65
+ }
66
+ function SwatchItem(props) {
67
+ return createComponent(RadioGroup.Item, {
68
+ get value() {
69
+ return props.id;
70
+ },
71
+ get ["data-accent-option"]() {
72
+ return props.id;
73
+ },
74
+ "class": "contents",
75
+ get children() {
76
+ return [createComponent(RadioGroup.ItemInput, { "class": "peer" }), createComponent(RadioGroup.ItemLabel, {
77
+ get title() {
78
+ return props.label;
79
+ },
80
+ get ["class"]() {
81
+ return cn("flex size-7 cursor-pointer items-center justify-center rounded-full border border-border p-0.5", "peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle", "data-[checked]:border-primary data-[checked]:ring-1 data-[checked]:ring-primary", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50");
82
+ },
83
+ get children() {
84
+ return [memo(() => props.children), (() => {
85
+ var _el$2 = _tmpl$2();
86
+ insert(_el$2, () => props.label);
87
+ return _el$2;
88
+ })()];
89
+ }
90
+ })];
91
+ }
92
+ });
93
+ }
94
+ //#endregion
95
+ export { AccentPicker };
96
+
97
+ //# sourceMappingURL=accent-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accent-picker.js","names":["RadioGroup","Radio","Ban","JSX","For","accents","cn","AccentPickerProps","label","value","onValueChange","inheritLabel","disabled","class","NONE","AccentPicker","props","_$createComponent","aria-label","onChange","id","children","SwatchItem","each","accent","_el$","_tmpl$","_$effect","_p$","_v$","light","_v$2","dark","e","_$setStyleProperty","t","undefined","Element","Item","data-accent-option","ItemInput","ItemLabel","title","_$memo","_el$2","_tmpl$2","_$insert","_$createComponent","Radio","_$setStyleProperty","_$memo"],"sources":["../../../../src/components/composites/accent-picker/accent-picker.tsx"],"sourcesContent":["import { RadioGroup as Radio } from '@kobalte/core/radio-group'\nimport { Ban } from 'lucide-solid'\nimport type { JSX } from 'solid-js'\nimport { For } from 'solid-js'\nimport { accents } from '#lib/accent-presets'\nimport { cn } from '#lib/utils'\n\n/**\n * AccentPicker.\n *\n * A row of accent swatches with a leading \"none\" choice, for a setting that\n * overrides the accent it would otherwise inherit: a project's icon colour, a\n * workspace's colour over the app's. `null` is a real value, not an empty one:\n * it means \"do not override\", so the swatch row never has an unchecked state and\n * the control can say what the inherited colour is through `inheritLabel`.\n *\n * The swatches are the theme's own accent presets, each carrying its light and\n * dark colour and switching on the `dark` class, so a swatch is the colour the\n * setting will produce in whichever appearance is in force and the picker needs\n * no theme provider.\n */\nexport type AccentPickerProps = {\n /** The group's accessible name, e.g. \"Icon colour\". */\n label: string\n /** An accent preset id, or `null` for no override. */\n value: string | null\n onValueChange(value: string | null): void\n /** What `null` means here, e.g. \"Inherit workspace accent\". Also the first swatch's name. */\n inheritLabel?: string\n disabled?: boolean\n class?: string\n}\n\nconst NONE = '__none__'\n\nexport function AccentPicker(props: AccentPickerProps) {\n return (\n <Radio\n data-slot=\"swatch-picker\"\n aria-label={props.label}\n value={props.value ?? NONE}\n disabled={props.disabled}\n onChange={(id) => props.onValueChange(id === NONE ? null : id)}\n class={cn('flex flex-wrap items-center gap-2', props.class)}\n >\n <SwatchItem id={NONE} label={props.inheritLabel ?? 'No colour override'}>\n <Ban class=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n </SwatchItem>\n <For each={accents}>\n {(accent) => (\n <SwatchItem id={accent.id} label={accent.label}>\n <span\n aria-hidden=\"true\"\n class=\"block size-full rounded-full bg-(--swatch-light) dark:bg-(--swatch-dark)\"\n style={{\n '--swatch-light': accent.light ?? 'currentColor',\n '--swatch-dark': accent.dark ?? accent.light ?? 'currentColor',\n }}\n />\n </SwatchItem>\n )}\n </For>\n </Radio>\n )\n}\n\nfunction SwatchItem(props: { id: string; label: string; children: JSX.Element }) {\n return (\n <Radio.Item value={props.id} data-accent-option={props.id} class=\"contents\">\n <Radio.ItemInput class=\"peer\" />\n <Radio.ItemLabel\n title={props.label}\n class={cn(\n 'flex size-7 cursor-pointer items-center justify-center rounded-full border border-border p-0.5',\n 'peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle',\n 'data-[checked]:border-primary data-[checked]:ring-1 data-[checked]:ring-primary',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50'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A;MAAA,OAAAX;KAAA;IAAA,CAAA;GAIrE,CAAA,CAAA;EAAA;CAAA,CAAA;AAIT;AAEA,SAASH,WAAWN,OAA6D;CAC/E,OAAAC,gBACGhB,WAAMqC,MAAI;EAAA,IAAC7B,QAAK;GAAA,OAAEO,MAAMI;EAAE;EAAA,KAAA,wBAAA;GAAA,OAAsBJ,MAAMI;EAAE;EAAA,SAAA;EAAA,IAAAC,WAAA;GAAA,OAAA,CAAAJ,gBACtDhB,WAAMuC,WAAS,EAAA,SAAA,OAAA,CAAA,GAAAvB,gBACfhB,WAAMwC,WAAS;IAAA,IACdC,QAAK;KAAA,OAAE1B,MAAMR;IAAK;IAAA,KAAA,WAAA;KAAA,OACXF,GACL,kGACA,mGACA,mFACA,gEACF;IAAC;IAAA,IAAAe,WAAA;KAAA,OAAA,CAAAsB,WAEA3B,MAAMK,QAAQ,UAAA;MAAA,IAAAuB,QAAAC,QAAA;MAAAC,OAAAF,aACQ5B,MAAMR,KAAK;MAAA,OAAAoC;KAAA,EAAA,CAAA,CAAA;IAAA;GAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAI1C"}
@@ -0,0 +1,2 @@
1
+ export { AccentPicker, type AccentPickerProps } from './accent-picker';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/accent-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { AccentPicker } from "./accent-picker.js";
2
+ export { AccentPicker };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * IconPicker.
3
+ *
4
+ * The control behind "choose an icon" for a workspace or a project: a grid of
5
+ * curated glyphs, and optionally an uploaded picture in their place.
6
+ *
7
+ * It is a single-choice group. The glyph grid is a Kobalte radio group, so
8
+ * arrow keys move the choice and Tab enters and leaves the grid as one stop,
9
+ * which is the contract a 56-cell grid needs to stay usable from a keyboard. An
10
+ * uploaded image is a separate state, not a 57th cell: while `image` is set no
11
+ * glyph is checked, and choosing a glyph asks the caller to drop the image, so
12
+ * the stored mark is never both.
13
+ *
14
+ * The picker does not persist anything. The caller owns `value` and `image`
15
+ * and saves them with the rest of its form; the image arrives already resized
16
+ * to the stored square (see `markImageFromFile`).
17
+ */
18
+ export type IconPickerProps = {
19
+ /** The group's accessible name, e.g. "Workspace icon". */
20
+ label: string;
21
+ /** The checked icon key; ignored while `image` is set. */
22
+ value: string | undefined;
23
+ onValueChange(key: string): void;
24
+ /** The key the surface treats as unset, labelled "default" in the grid. */
25
+ defaultKey?: string;
26
+ /** An uploaded mark (a data URL) currently chosen in place of a glyph. */
27
+ image?: string;
28
+ /**
29
+ * Called with the resized upload, or `undefined` for Remove. Omit it for a
30
+ * surface that offers glyphs only; the upload row then does not render.
31
+ */
32
+ onImageChange?(image: string | undefined): void;
33
+ disabled?: boolean;
34
+ class?: string;
35
+ };
36
+ export declare function IconPicker(props: IconPickerProps): import("solid-js").JSX.Element;
37
+ //# sourceMappingURL=icon-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-picker.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/icon-picker/icon-picker.tsx"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAA;IACb,0DAA0D;IAC1D,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,kCAsIhD"}
@@ -0,0 +1,187 @@
1
+ import { cn } from "../../../lib/utils.js";
2
+ import { Button } from "../../ui/button/button.js";
3
+ import { MARK_IMAGE_MAX_SOURCE_BYTES, MarkImageError, markImageFromFile, markImageProblemCopy } from "./image-data-url.js";
4
+ import { resolveShellIcon, shellIconEntries } from "./shell-icons.js";
5
+ import { className, createComponent, effect, insert, memo, setAttribute, template, use } from "solid-js/web";
6
+ import { ImageUp, Trash2 } from "lucide-solid";
7
+ import { For, Show, createSignal, createUniqueId } from "solid-js";
8
+ import { RadioGroup } from "@kobalte/core/radio-group";
9
+ //#region src/components/composites/icon-picker/icon-picker.tsx
10
+ var _tmpl$ = /*#__PURE__*/ template(`<div class="flex items-center gap-3"data-slot=icon-picker-upload><span aria-hidden=true class="flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-muted"></span><div class="flex flex-wrap items-center gap-2"><input type=file class=sr-only tabindex=-1 aria-hidden=true accept=image/png,image/jpeg,image/webp,image/gif>`);
11
+ var _tmpl$2 = /*#__PURE__*/ template(`<p class="text-xs text-muted-foreground">PNG, JPEG, WebP or GIF up to <!> MB. It is cropped to a square.`);
12
+ var _tmpl$3 = /*#__PURE__*/ template(`<div data-slot=icon-picker>`);
13
+ var _tmpl$4 = /*#__PURE__*/ template(`<img alt class="size-full object-cover">`);
14
+ var _tmpl$5 = /*#__PURE__*/ template(`<p role=alert class="text-sm text-destructive">`);
15
+ var _tmpl$6 = /*#__PURE__*/ template(`<span class=sr-only>`);
16
+ function IconPicker(props) {
17
+ const inputId = createUniqueId();
18
+ const [problem, setProblem] = createSignal();
19
+ const [busy, setBusy] = createSignal(false);
20
+ const [fileInput, setFileInput] = createSignal();
21
+ const upload = async (file) => {
22
+ if (!file || !props.onImageChange) return;
23
+ setProblem(void 0);
24
+ setBusy(true);
25
+ try {
26
+ props.onImageChange(await markImageFromFile(file));
27
+ } catch (error) {
28
+ setProblem(markImageProblemCopy[error instanceof MarkImageError ? error.problem : "unreadable"]);
29
+ } finally {
30
+ setBusy(false);
31
+ }
32
+ };
33
+ return (() => {
34
+ var _el$ = _tmpl$3();
35
+ insert(_el$, createComponent(Show, {
36
+ get when() {
37
+ return props.onImageChange;
38
+ },
39
+ get children() {
40
+ return [
41
+ (() => {
42
+ var _el$2 = _tmpl$(), _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.firstChild;
43
+ insert(_el$3, createComponent(Show, {
44
+ get when() {
45
+ return props.image;
46
+ },
47
+ get fallback() {
48
+ return createComponent(ImageUp, {
49
+ "class": "size-5 text-muted-foreground",
50
+ "aria-hidden": "true"
51
+ });
52
+ },
53
+ children: (src) => (() => {
54
+ var _el$0 = _tmpl$4();
55
+ effect(() => setAttribute(_el$0, "src", src()));
56
+ return _el$0;
57
+ })()
58
+ }));
59
+ _el$5.addEventListener("change", (event) => {
60
+ const input = event.currentTarget;
61
+ upload(input.files?.[0]);
62
+ input.value = "";
63
+ });
64
+ use(setFileInput, _el$5);
65
+ setAttribute(_el$5, "id", inputId);
66
+ insert(_el$4, createComponent(Button, {
67
+ type: "button",
68
+ variant: "outline",
69
+ size: "sm",
70
+ get disabled() {
71
+ return props.disabled || busy();
72
+ },
73
+ onClick: () => fileInput()?.click(),
74
+ get children() {
75
+ return [createComponent(ImageUp, { "aria-hidden": "true" }), memo(() => props.image ? "Replace image" : "Upload image")];
76
+ }
77
+ }), null);
78
+ insert(_el$4, createComponent(Show, {
79
+ get when() {
80
+ return props.image;
81
+ },
82
+ get children() {
83
+ return createComponent(Button, {
84
+ type: "button",
85
+ variant: "ghost",
86
+ size: "sm",
87
+ get disabled() {
88
+ return props.disabled || busy();
89
+ },
90
+ onClick: () => {
91
+ setProblem(void 0);
92
+ props.onImageChange?.(void 0);
93
+ },
94
+ get children() {
95
+ return [createComponent(Trash2, { "aria-hidden": "true" }), "Remove image"];
96
+ }
97
+ });
98
+ }
99
+ }), null);
100
+ effect((_p$) => {
101
+ var _v$ = props.image ? "Replace image" : "Upload image", _v$2 = props.disabled;
102
+ _v$ !== _p$.e && setAttribute(_el$5, "aria-label", _p$.e = _v$);
103
+ _v$2 !== _p$.t && (_el$5.disabled = _p$.t = _v$2);
104
+ return _p$;
105
+ }, {
106
+ e: void 0,
107
+ t: void 0
108
+ });
109
+ return _el$2;
110
+ })(),
111
+ createComponent(Show, {
112
+ get when() {
113
+ return problem();
114
+ },
115
+ children: (message) => (() => {
116
+ var _el$1 = _tmpl$5();
117
+ insert(_el$1, message);
118
+ return _el$1;
119
+ })()
120
+ }),
121
+ (() => {
122
+ var _el$6 = _tmpl$2(), _el$9 = _el$6.firstChild.nextSibling;
123
+ _el$9.nextSibling;
124
+ insert(_el$6, MARK_IMAGE_MAX_SOURCE_BYTES / 1024 / 1024, _el$9);
125
+ return _el$6;
126
+ })()
127
+ ];
128
+ }
129
+ }), null);
130
+ insert(_el$, createComponent(RadioGroup, {
131
+ get ["aria-label"]() {
132
+ return props.label;
133
+ },
134
+ get value() {
135
+ return memo(() => !!props.image)() ? "" : props.value ?? "";
136
+ },
137
+ get disabled() {
138
+ return props.disabled;
139
+ },
140
+ onChange: (key) => {
141
+ if (key) props.onValueChange(key);
142
+ },
143
+ "class": "grid grid-cols-[repeat(auto-fill,minmax(2.5rem,1fr))] gap-1.5",
144
+ get children() {
145
+ return createComponent(For, {
146
+ each: shellIconEntries,
147
+ children: (entry) => {
148
+ const Icon = resolveShellIcon(entry.key);
149
+ return createComponent(RadioGroup.Item, {
150
+ get value() {
151
+ return entry.key;
152
+ },
153
+ "class": "contents",
154
+ get children() {
155
+ return [createComponent(RadioGroup.ItemInput, { "class": "peer" }), createComponent(RadioGroup.ItemLabel, {
156
+ get title() {
157
+ return memo(() => entry.key === props.defaultKey)() ? `${entry.label} (default)` : entry.label;
158
+ },
159
+ get ["class"]() {
160
+ return cn("flex size-10 cursor-pointer items-center justify-center rounded-lg border border-border bg-card text-muted-foreground", "transition-colors ease-out", "hover:bg-surface-hover hover:text-foreground", "peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle", "data-[checked]:border-primary data-[checked]:bg-primary-subtle data-[checked]:text-primary", "data-[disabled]:pointer-events-none data-[disabled]:opacity-50");
161
+ },
162
+ get children() {
163
+ return [createComponent(Icon, {
164
+ "class": "size-5",
165
+ "aria-hidden": "true"
166
+ }), (() => {
167
+ var _el$10 = _tmpl$6();
168
+ insert(_el$10, () => entry.label, null);
169
+ insert(_el$10, () => entry.key === props.defaultKey ? " (default)" : "", null);
170
+ return _el$10;
171
+ })()];
172
+ }
173
+ })];
174
+ }
175
+ });
176
+ }
177
+ });
178
+ }
179
+ }), null);
180
+ effect(() => className(_el$, cn("flex flex-col gap-3", props.class)));
181
+ return _el$;
182
+ })();
183
+ }
184
+ //#endregion
185
+ export { IconPicker };
186
+
187
+ //# sourceMappingURL=icon-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icon-picker.js","names":["RadioGroup","Radio","ImageUp","Trash2","For","Show","createSignal","createUniqueId","cn","Button","MarkImageError","markImageFromFile","markImageProblemCopy","MARK_IMAGE_MAX_SOURCE_BYTES","resolveShellIcon","shellIconEntries","IconPickerProps","label","value","onValueChange","key","defaultKey","image","onImageChange","disabled","class","IconPicker","props","inputId","problem","setProblem","busy","setBusy","fileInput","setFileInput","HTMLInputElement","upload","file","File","undefined","error","_el$","_tmpl$3","_$insert","_$createComponent","when","children","_el$2","_tmpl$","_el$3","firstChild","_el$4","nextSibling","_el$5","fallback","src","_el$0","_tmpl$4","_$effect","_$setAttribute","addEventListener","event","input","currentTarget","files","_$use","type","variant","size","onClick","click","_$memo","_p$","_v$","_v$2","e","t","message","_el$1","_tmpl$5","_el$6","_tmpl$2","_el$7","_el$9","_el$8","aria-label","onChange","each","entry","Icon","Item","ItemInput","ItemLabel","title","_el$10","_tmpl$6","_$className","_$createComponent","_$setAttribute","_$memo","Radio","_$className"],"sources":["../../../../src/components/composites/icon-picker/icon-picker.tsx"],"sourcesContent":["import { RadioGroup as Radio } from '@kobalte/core/radio-group'\nimport { ImageUp, Trash2 } from 'lucide-solid'\nimport { For, Show, createSignal, createUniqueId } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport {\n MarkImageError,\n markImageFromFile,\n markImageProblemCopy,\n MARK_IMAGE_MAX_SOURCE_BYTES,\n} from './image-data-url'\nimport { resolveShellIcon, shellIconEntries } from './shell-icons'\n\n/**\n * IconPicker.\n *\n * The control behind \"choose an icon\" for a workspace or a project: a grid of\n * curated glyphs, and optionally an uploaded picture in their place.\n *\n * It is a single-choice group. The glyph grid is a Kobalte radio group, so\n * arrow keys move the choice and Tab enters and leaves the grid as one stop,\n * which is the contract a 56-cell grid needs to stay usable from a keyboard. An\n * uploaded image is a separate state, not a 57th cell: while `image` is set no\n * glyph is checked, and choosing a glyph asks the caller to drop the image, so\n * the stored mark is never both.\n *\n * The picker does not persist anything. The caller owns `value` and `image`\n * and saves them with the rest of its form; the image arrives already resized\n * to the stored square (see `markImageFromFile`).\n */\nexport type IconPickerProps = {\n /** The group's accessible name, e.g. \"Workspace icon\". */\n label: string\n /** The checked icon key; ignored while `image` is set. */\n value: string | undefined\n onValueChange(key: string): void\n /** The key the surface treats as unset, labelled \"default\" in the grid. */\n defaultKey?: string\n /** An uploaded mark (a data URL) currently chosen in place of a glyph. */\n image?: string\n /**\n * Called with the resized upload, or `undefined` for Remove. Omit it for a\n * surface that offers glyphs only; the upload row then does not render.\n */\n onImageChange?(image: string | undefined): void\n disabled?: boolean\n class?: string\n}\n\nexport function IconPicker(props: IconPickerProps) {\n const inputId = createUniqueId()\n const [problem, setProblem] = createSignal<string>()\n const [busy, setBusy] = createSignal(false)\n const [fileInput, setFileInput] = createSignal<HTMLInputElement>()\n\n const upload = async (file: File | undefined) => {\n if (!file || !props.onImageChange) return\n setProblem(undefined)\n setBusy(true)\n try {\n props.onImageChange(await markImageFromFile(file))\n } catch (error) {\n setProblem(\n markImageProblemCopy[error instanceof MarkImageError ? error.problem : 'unreadable']\n )\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <div data-slot=\"icon-picker\" class={cn('flex flex-col gap-3', props.class)}>\n <Show when={props.onImageChange}>\n <div class=\"flex items-center gap-3\" data-slot=\"icon-picker-upload\">\n <span\n aria-hidden=\"true\"\n class=\"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-muted\"\n >\n <Show\n when={props.image}\n fallback={<ImageUp class=\"size-5 text-muted-foreground\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full object-cover\" />}\n </Show>\n </span>\n <div class=\"flex flex-wrap items-center gap-2\">\n <input\n ref={setFileInput}\n id={inputId}\n type=\"file\"\n class=\"sr-only\"\n tabIndex={-1}\n // The visible button drives this input; hide the duplicate from assistive\n // technology but keep a name so the form-label rule is satisfied.\n aria-hidden=\"true\"\n aria-label={props.image ? 'Replace image' : 'Upload image'}\n accept=\"image/png,image/jpeg,image/webp,image/gif\"\n disabled={props.disabled}\n onChange={(event) => {\n const input = event.currentTarget\n void upload(input.files?.[0])\n // Clearing the value lets the same file be chosen again after Remove.\n input.value = ''\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={props.disabled || busy()}\n onClick={() => fileInput()?.click()}\n >\n <ImageUp aria-hidden=\"true\" />\n {props.image ? 'Replace image' : 'Upload image'}\n </Button>\n <Show when={props.image}>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={props.disabled || busy()}\n onClick={() => {\n setProblem(undefined)\n props.onImageChange?.(undefined)\n }}\n >\n <Trash2 aria-hidden=\"true\" />\n Remove image\n </Button>\n </Show>\n </div>\n </div>\n <Show when={problem()}>\n {(message) => (\n <p role=\"alert\" class=\"text-sm text-destructive\">\n {message()}\n </p>\n )}\n </Show>\n <p class=\"text-xs text-muted-foreground\">\n PNG, JPEG, WebP or GIF up to {MARK_IMAGE_MAX_SOURCE_BYTES / 1024 / 1024} MB. It is cropped\n to a square.\n </p>\n </Show>\n <Radio\n aria-label={props.label}\n value={props.image ? '' : (props.value ?? '')}\n disabled={props.disabled}\n onChange={(key) => {\n if (key) props.onValueChange(key)\n }}\n class=\"grid grid-cols-[repeat(auto-fill,minmax(2.5rem,1fr))] gap-1.5\"\n >\n <For each={shellIconEntries}>\n {(entry) => {\n const Icon = resolveShellIcon(entry.key)\n return (\n <Radio.Item value={entry.key} class=\"contents\">\n <Radio.ItemInput class=\"peer\" />\n <Radio.ItemLabel\n title={entry.key === props.defaultKey ? `${entry.label} (default)` : entry.label}\n class={cn(\n 'flex size-10 cursor-pointer items-center justify-center rounded-lg border border-border bg-card text-muted-foreground',\n 'transition-colors ease-out',\n 'hover:bg-surface-hover hover:text-foreground',\n 'peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle',\n 'data-[checked]:border-primary data-[checked]:bg-primary-subtle data-[checked]:text-primary',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50'\n )}\n >\n <Icon class=\"size-5\" aria-hidden=\"true\" />\n <span class=\"sr-only\">\n {entry.label}\n {entry.key === props.defaultKey ? ' (default)' : ''}\n </span>\n </Radio.ItemLabel>\n </Radio.Item>\n )\n }}\n </For>\n </Radio>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,SAAgB0B,WAAWC,OAAwB;CACjD,MAAMC,UAAUrB,eAAe;CAC/B,MAAM,CAACsB,SAASC,cAAcxB,aAAqB;CACnD,MAAM,CAACyB,MAAMC,WAAW1B,aAAa,KAAK;CAC1C,MAAM,CAAC2B,WAAWC,gBAAgB5B,aAA+B;CAEjE,MAAM8B,SAAS,OAAOC,SAA2B;EAC/C,IAAI,CAACA,QAAQ,CAACV,MAAMJ,eAAe;EACnCO,WAAWS,KAAA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;SAAA;QAAA,CAAA,CAAA;OAAA;MAAA,CAAA;KAK7D;IAAC,CAAA;GAAA;EAAA,CAAA,GAAA,IAAA;EAAApC,aAAAsC,UAAAvD,MA3G6BjC,GAAG,uBAAuBmB,MAAMF,KAAK,CAAC,CAAA;EAAA,OAAAgB;CAAA,EAAA,CAAA;AAgH9E"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Turning an uploaded picture into the small square mark a workspace stores.
3
+ *
4
+ * The mark travels with the workspace record (it is shown in every list the
5
+ * workspace appears in), so it is resized to a fixed square and re-encoded
6
+ * before it leaves the browser rather than stored as the user's original file.
7
+ * Re-encoding also drops metadata and any embedded script an SVG could carry:
8
+ * only raster images are accepted and the result is always a `data:image/webp`
9
+ * or `data:image/png` URL.
10
+ */
11
+ /** The edge, in pixels, of the stored square. 2x the largest tile the apps draw. */
12
+ export declare const MARK_IMAGE_SIZE = 128;
13
+ /** The largest source file read, before resizing. */
14
+ export declare const MARK_IMAGE_MAX_SOURCE_BYTES: number;
15
+ /** The largest encoded result kept; a stored mark never exceeds this many characters. */
16
+ export declare const MARK_IMAGE_MAX_DATA_URL_LENGTH: number;
17
+ export type MarkImageProblem = 'type' | 'size' | 'unreadable' | 'too-large';
18
+ /** Thrown by {@link markImageFromFile}; `problem` keys {@link markImageProblemCopy}. */
19
+ export declare class MarkImageError extends Error {
20
+ readonly problem: MarkImageProblem;
21
+ constructor(problem: MarkImageProblem);
22
+ }
23
+ export declare const markImageProblemCopy: Readonly<Record<MarkImageProblem, string>>;
24
+ /** Whether a stored value is a mark image this module could have produced. */
25
+ export declare function isMarkImageDataUrl(value: unknown): value is string;
26
+ /** Pre-flight checks that need no decoding; `undefined` means the file may be read. */
27
+ export declare function checkMarkImageFile(file: Readonly<{
28
+ type: string;
29
+ size: number;
30
+ }>): MarkImageProblem | undefined;
31
+ /** The source rectangle of the largest centred square, so the mark is a cover crop. */
32
+ export declare function centredSquare(width: number, height: number): Readonly<{
33
+ x: number;
34
+ y: number;
35
+ side: number;
36
+ }>;
37
+ /**
38
+ * Resize an image file to the stored mark. Rejects with a {@link MarkImageError}
39
+ * so the caller can show `markImageProblemCopy[error.problem]`.
40
+ */
41
+ export declare function markImageFromFile(file: File): Promise<string>;
42
+ //# sourceMappingURL=image-data-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-data-url.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/icon-picker/image-data-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,oFAAoF;AACpF,eAAO,MAAM,eAAe,MAAM,CAAA;AAClC,qDAAqD;AACrD,eAAO,MAAM,2BAA2B,QAAkB,CAAA;AAC1D,yFAAyF;AACzF,eAAO,MAAM,8BAA8B,QAAY,CAAA;AAIvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,CAAA;AAE3E,wFAAwF;AACxF,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;IAClC,YAAY,OAAO,EAAE,gBAAgB,EAIpC;CACF;AAED,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAK3E,CAAA;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAMlE;AAED,uFAAuF;AACvF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7C,gBAAgB,GAAG,SAAS,CAI9B;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,QAAQ,CAAC;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAGlD;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCnE"}
@@ -0,0 +1,90 @@
1
+ //#region src/components/composites/icon-picker/image-data-url.ts
2
+ /**
3
+ * Turning an uploaded picture into the small square mark a workspace stores.
4
+ *
5
+ * The mark travels with the workspace record (it is shown in every list the
6
+ * workspace appears in), so it is resized to a fixed square and re-encoded
7
+ * before it leaves the browser rather than stored as the user's original file.
8
+ * Re-encoding also drops metadata and any embedded script an SVG could carry:
9
+ * only raster images are accepted and the result is always a `data:image/webp`
10
+ * or `data:image/png` URL.
11
+ */
12
+ /** The edge, in pixels, of the stored square. 2x the largest tile the apps draw. */
13
+ var MARK_IMAGE_SIZE = 128;
14
+ /** The largest source file read, before resizing. */
15
+ var MARK_IMAGE_MAX_SOURCE_BYTES = 8388608;
16
+ /** The largest encoded result kept; a stored mark never exceeds this many characters. */
17
+ var MARK_IMAGE_MAX_DATA_URL_LENGTH = 49152;
18
+ var ACCEPTED_TYPES = /* @__PURE__ */ new Set([
19
+ "image/png",
20
+ "image/jpeg",
21
+ "image/webp",
22
+ "image/gif"
23
+ ]);
24
+ /** Thrown by {@link markImageFromFile}; `problem` keys {@link markImageProblemCopy}. */
25
+ var MarkImageError = class extends Error {
26
+ problem;
27
+ constructor(problem) {
28
+ super(problem);
29
+ this.name = "MarkImageError";
30
+ this.problem = problem;
31
+ }
32
+ };
33
+ var markImageProblemCopy = {
34
+ type: "Choose a PNG, JPEG, WebP or GIF image.",
35
+ size: "That image is larger than 8 MB. Choose a smaller one.",
36
+ unreadable: "That image could not be read. Try a different file.",
37
+ "too-large": "That image is too detailed to store as a mark. Try a simpler one."
38
+ };
39
+ /** Whether a stored value is a mark image this module could have produced. */
40
+ function isMarkImageDataUrl(value) {
41
+ return typeof value === "string" && value.length <= 49152 && /^data:image\/(?:webp|png);base64,[A-Za-z0-9+/]+={0,2}$/.test(value);
42
+ }
43
+ /** Pre-flight checks that need no decoding; `undefined` means the file may be read. */
44
+ function checkMarkImageFile(file) {
45
+ if (!ACCEPTED_TYPES.has(file.type)) return "type";
46
+ if (file.size > 8388608) return "size";
47
+ }
48
+ /** The source rectangle of the largest centred square, so the mark is a cover crop. */
49
+ function centredSquare(width, height) {
50
+ const side = Math.min(width, height);
51
+ return {
52
+ x: Math.floor((width - side) / 2),
53
+ y: Math.floor((height - side) / 2),
54
+ side
55
+ };
56
+ }
57
+ /**
58
+ * Resize an image file to the stored mark. Rejects with a {@link MarkImageError}
59
+ * so the caller can show `markImageProblemCopy[error.problem]`.
60
+ */
61
+ async function markImageFromFile(file) {
62
+ const problem = checkMarkImageFile(file);
63
+ if (problem) throw new MarkImageError(problem);
64
+ let bitmap;
65
+ try {
66
+ bitmap = await createImageBitmap(file);
67
+ } catch {
68
+ throw new MarkImageError("unreadable");
69
+ }
70
+ try {
71
+ const canvas = document.createElement("canvas");
72
+ canvas.width = 128;
73
+ canvas.height = 128;
74
+ const context = canvas.getContext("2d");
75
+ if (!context) throw new MarkImageError("unreadable");
76
+ const crop = centredSquare(bitmap.width, bitmap.height);
77
+ context.drawImage(bitmap, crop.x, crop.y, crop.side, crop.side, 0, 0, 128, 128);
78
+ for (const type of ["image/webp", "image/png"]) {
79
+ const url = canvas.toDataURL(type, .85);
80
+ if (url.startsWith(`data:${type}`) && isMarkImageDataUrl(url)) return url;
81
+ }
82
+ throw new MarkImageError("too-large");
83
+ } finally {
84
+ bitmap.close();
85
+ }
86
+ }
87
+ //#endregion
88
+ export { MARK_IMAGE_MAX_DATA_URL_LENGTH, MARK_IMAGE_MAX_SOURCE_BYTES, MARK_IMAGE_SIZE, MarkImageError, centredSquare, checkMarkImageFile, isMarkImageDataUrl, markImageFromFile, markImageProblemCopy };
89
+
90
+ //# sourceMappingURL=image-data-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image-data-url.js","names":[],"sources":["../../../../src/components/composites/icon-picker/image-data-url.ts"],"sourcesContent":["/**\n * Turning an uploaded picture into the small square mark a workspace stores.\n *\n * The mark travels with the workspace record (it is shown in every list the\n * workspace appears in), so it is resized to a fixed square and re-encoded\n * before it leaves the browser rather than stored as the user's original file.\n * Re-encoding also drops metadata and any embedded script an SVG could carry:\n * only raster images are accepted and the result is always a `data:image/webp`\n * or `data:image/png` URL.\n */\n\n/** The edge, in pixels, of the stored square. 2x the largest tile the apps draw. */\nexport const MARK_IMAGE_SIZE = 128\n/** The largest source file read, before resizing. */\nexport const MARK_IMAGE_MAX_SOURCE_BYTES = 8 * 1024 * 1024\n/** The largest encoded result kept; a stored mark never exceeds this many characters. */\nexport const MARK_IMAGE_MAX_DATA_URL_LENGTH = 48 * 1024\n\nconst ACCEPTED_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif'])\n\nexport type MarkImageProblem = 'type' | 'size' | 'unreadable' | 'too-large'\n\n/** Thrown by {@link markImageFromFile}; `problem` keys {@link markImageProblemCopy}. */\nexport class MarkImageError extends Error {\n readonly problem: MarkImageProblem\n constructor(problem: MarkImageProblem) {\n super(problem)\n this.name = 'MarkImageError'\n this.problem = problem\n }\n}\n\nexport const markImageProblemCopy: Readonly<Record<MarkImageProblem, string>> = {\n type: 'Choose a PNG, JPEG, WebP or GIF image.',\n size: 'That image is larger than 8 MB. Choose a smaller one.',\n unreadable: 'That image could not be read. Try a different file.',\n 'too-large': 'That image is too detailed to store as a mark. Try a simpler one.',\n}\n\n/** Whether a stored value is a mark image this module could have produced. */\nexport function isMarkImageDataUrl(value: unknown): value is string {\n return (\n typeof value === 'string' &&\n value.length <= MARK_IMAGE_MAX_DATA_URL_LENGTH &&\n /^data:image\\/(?:webp|png);base64,[A-Za-z0-9+/]+={0,2}$/.test(value)\n )\n}\n\n/** Pre-flight checks that need no decoding; `undefined` means the file may be read. */\nexport function checkMarkImageFile(\n file: Readonly<{ type: string; size: number }>\n): MarkImageProblem | undefined {\n if (!ACCEPTED_TYPES.has(file.type)) return 'type'\n if (file.size > MARK_IMAGE_MAX_SOURCE_BYTES) return 'size'\n return undefined\n}\n\n/** The source rectangle of the largest centred square, so the mark is a cover crop. */\nexport function centredSquare(\n width: number,\n height: number\n): Readonly<{ x: number; y: number; side: number }> {\n const side = Math.min(width, height)\n return { x: Math.floor((width - side) / 2), y: Math.floor((height - side) / 2), side }\n}\n\n/**\n * Resize an image file to the stored mark. Rejects with a {@link MarkImageError}\n * so the caller can show `markImageProblemCopy[error.problem]`.\n */\nexport async function markImageFromFile(file: File): Promise<string> {\n const problem = checkMarkImageFile(file)\n if (problem) throw new MarkImageError(problem)\n let bitmap: ImageBitmap\n try {\n bitmap = await createImageBitmap(file)\n } catch {\n throw new MarkImageError('unreadable')\n }\n try {\n const canvas = document.createElement('canvas')\n canvas.width = MARK_IMAGE_SIZE\n canvas.height = MARK_IMAGE_SIZE\n const context = canvas.getContext('2d')\n if (!context) throw new MarkImageError('unreadable')\n const crop = centredSquare(bitmap.width, bitmap.height)\n context.drawImage(\n bitmap,\n crop.x,\n crop.y,\n crop.side,\n crop.side,\n 0,\n 0,\n MARK_IMAGE_SIZE,\n MARK_IMAGE_SIZE\n )\n // WebP where the browser can encode it; PNG is the always-available fallback.\n for (const type of ['image/webp', 'image/png']) {\n const url = canvas.toDataURL(type, 0.85)\n if (url.startsWith(`data:${type}`) && isMarkImageDataUrl(url)) return url\n }\n throw new MarkImageError('too-large')\n } finally {\n bitmap.close()\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,kBAAkB;;AAE/B,IAAa,8BAA8B;;AAE3C,IAAa,iCAAiC;AAE9C,IAAM,iCAAiB,IAAI,IAAI;CAAC;CAAa;CAAc;CAAc;AAAW,CAAC;;AAKrF,IAAa,iBAAb,cAAoC,MAAM;CACxC;CACA,YAAY,SAA2B;EACrC,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,UAAU;CACjB;AACF;AAEA,IAAa,uBAAmE;CAC9E,MAAM;CACN,MAAM;CACN,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, type IconPickerProps } from './icon-picker';
2
+ export { MARK_IMAGE_MAX_DATA_URL_LENGTH, MARK_IMAGE_MAX_SOURCE_BYTES, MARK_IMAGE_SIZE, MarkImageError, centredSquare, checkMarkImageFile, isMarkImageDataUrl, markImageFromFile, markImageProblemCopy, type MarkImageProblem, } from './image-data-url';
3
+ export { isShellIconKey, resolveShellIcon, shellIconEntries, shellIconLabel, type ShellIconKey, } from './shell-icons';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/icon-picker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,eAAe,EACf,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,KAAK,YAAY,GAClB,MAAM,eAAe,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { MARK_IMAGE_MAX_DATA_URL_LENGTH, MARK_IMAGE_MAX_SOURCE_BYTES, MARK_IMAGE_SIZE, MarkImageError, centredSquare, checkMarkImageFile, isMarkImageDataUrl, markImageFromFile, markImageProblemCopy } from "./image-data-url.js";
2
+ import { isShellIconKey, resolveShellIcon, shellIconEntries, shellIconLabel } from "./shell-icons.js";
3
+ import { IconPicker } from "./icon-picker.js";
4
+ export { IconPicker, MARK_IMAGE_MAX_DATA_URL_LENGTH, MARK_IMAGE_MAX_SOURCE_BYTES, MARK_IMAGE_SIZE, MarkImageError, centredSquare, checkMarkImageFile, isMarkImageDataUrl, isShellIconKey, markImageFromFile, markImageProblemCopy, resolveShellIcon, shellIconEntries, shellIconLabel };