@hazem3500/palette 0.9.131 → 0.9.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/dist/adapters/css-variables.js +1 -1
- package/dist/adapters/tailwind.d.ts +1 -1
- package/dist/adapters/tailwind.js +1 -1
- package/dist/anchors.d.ts +2 -1
- package/dist/chunk-3SNXBRAS.js +1 -0
- package/dist/chunk-JWGDIIKJ.js +1 -0
- package/dist/{chunk-UUV356RI.js → chunk-KMRWUNT7.js} +1 -1
- package/dist/{chunk-RAAJF54I.js → chunk-OAGWNW4W.js} +1 -1
- package/dist/{color-editor-I5ELNYPO.js → color-editor-GCCLM3TV.js} +1 -1
- package/dist/design-comment-LHFSWNU7.js +1 -0
- package/dist/{design-export-55QSPEWM.js → design-export-I766FRDX.js} +1 -1
- package/dist/{design-geometry-OXGWR5J2.js → design-geometry-W7PSW5J2.js} +1 -1
- package/dist/design-mode.js +1 -1
- package/dist/design-system.d.ts +1 -1
- package/dist/frame-size-E6OGNHNX.js +1 -0
- package/dist/frame-size.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{inline-text-editor-S4LVCKZL.js → inline-text-editor-5JSAHEHE.js} +1 -1
- package/dist/message-links.d.ts +2 -0
- package/dist/node.mjs +100 -21
- package/dist/open-state.d.ts +7 -0
- package/dist/postgres/011_comment_api_key_name.sql +1 -0
- package/dist/postgres/012_comment_images.sql +25 -0
- package/dist/react-props-panel-P47YFFSU.js +1 -0
- package/dist/react-props-panel.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/review-layer.d.ts +1 -0
- package/dist/server.js +97 -20
- package/dist/setup.js +1 -1
- package/dist/snapshot-CFKV3VWX.js +1 -0
- package/dist/snapshot-annotate-HW4ZWT7T.js +1 -0
- package/dist/snapshot-annotate.d.ts +16 -0
- package/dist/snapshot.d.ts +15 -4
- package/dist/thread-snapshot-2V4AV3UN.js +1 -0
- package/dist/thread-snapshot.d.ts +4 -6
- package/dist/token-adapter.d.ts +1 -0
- package/dist/{token-custom-7MJFPGVB.js → token-custom-CPPHGYMJ.js} +1 -1
- package/dist/{token-page-YQ52JS6G.js → token-page-63C3T4DY.js} +1 -1
- package/dist/{token-picker-HHT4OC3V.js → token-picker-ARVCFUCY.js} +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
- package/server/bot-tokens.ts +7 -3
- package/server/index.ts +80 -17
- package/server/migrations/0025_comment_api_key_name.sql +1 -0
- package/server/migrations/0026_comment_images.sql +22 -0
- package/server/setup-client.txt +115 -79
- package/server/snapshots.ts +2 -1
- package/server/tokens.ts +2 -2
- package/src/types.ts +4 -0
- package/dist/chunk-EVRPBA4F.js +0 -1
- package/dist/design-comment-VXRH45UI.js +0 -1
- package/dist/frame-size-EAVSR4SA.js +0 -1
- package/dist/react-props-panel-VON2NO7N.js +0 -1
- package/dist/snapshot-BFHCCGOL.js +0 -1
- package/dist/thread-snapshot-TJHRZZOR.js +0 -1
- /package/dist/{design-panel-DBAUVCIJ.js → design-panel-GU2SWV33.js} +0 -0
package/dist/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n,d as o}from"./chunk-
|
|
1
|
+
import{a as n,d as o}from"./chunk-3SNXBRAS.js";import"./chunk-KLPQTFVH.js";import"./chunk-HHUTDVTM.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-5HZI7HRR.js";import"./chunk-2BS2OWWH.js";import"./chunk-J47R52WX.js";import"./chunk-VX6XCU4E.js";import"./chunk-4HBBEVFK.js";function r(r){return(t={})=>o(n({...r,...t}))}var t=r;export{t as defineKomo,r as definePalette};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b as s,c as t,d as e,e as I,f as T,g as m,h as o,i as n,j as p,k as i,l as r,m as h,n as E,o as L}from"./chunk-JWGDIIKJ.js";export{e as ATTRIBUTE_LIMIT,t as HTML_LIMIT,o as IMAGE_BYTES,a as OPT_OUT,s as PLACEHOLDER,I as TEXT_LIMIT,E as captureSnapshot,r as imageAttachment,p as imageDataUrl,h as noteComment,n as omitInvisibleFrameStyles,T as skipped,L as snapshotFor,m as snapshotHtml,i as snapshotImage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./chunk-JWGDIIKJ.js";import{E as t,G as a}from"./chunk-4HBBEVFK.js";var r=[["pen","Pen"],["arrow","Arrow"],["rectangle","Rectangle"],["highlight","Highlight"]],o=[["Red","#fa5252"],["Yellow","#ffd43b"],["Blue","#4dabf7"],["Green","#51cf66"]];function l(e,t,a){let{points:[r,...o],tool:l,color:n}=t,p=o.at(-1)??r;if(e.save(),e.strokeStyle=e.fillStyle=n,e.lineWidth=a,e.lineJoin=e.lineCap="round",e.beginPath(),"rectangle"===l){let t=Math.abs(p.x-r.x),o=Math.abs(p.y-r.y);e.roundRect(Math.min(r.x,p.x),Math.min(r.y,p.y),t,o,Math.min(a,t/2,o/2)),e.stroke()}else if("arrow"===l){let t=Math.atan2(p.y-r.y,p.x-r.x),o=Math.min(4.5*a,.6*Math.hypot(p.x-r.x,p.y-r.y)),l={x:p.x-o*Math.cos(t),y:p.y-o*Math.sin(t)};e.moveTo(r.x,r.y),e.lineTo(l.x,l.y),e.stroke(),e.beginPath(),e.moveTo(p.x,p.y);for(let a of[-1,1])e.lineTo(l.x+a*o*.42*Math.sin(t),l.y-a*o*.42*Math.cos(t));e.closePath(),e.fill()}else{if("highlight"===l&&(e.globalAlpha=.38,e.lineWidth=5*a),e.moveTo(r.x,r.y),o.length){for(let t=0;t<o.length-1;t++){let a=o[t],r=o[t+1];e.quadraticCurveTo(a.x,a.y,(a.x+r.x)/2,(a.y+r.y)/2)}e.lineTo(p.x,p.y)}else e.lineTo(r.x+.1,r.y);e.stroke()}e.restore()}async function n(n,p,i,d,s,u){if(n.querySelector(".palette-markup[open]"))return;let h=d?.source??p,c=new Image;if(c.src=h,await c.decode(),s.aborted||!n.host.isConnected||n.querySelector(".palette-markup[open]"))return;let m=n.activeElement,f=t("dialog","palette-snapshot-viewer palette-markup");f.setAttribute("aria-label","Image preview");let g=t("style","",'\n.palette-snapshot-viewer.palette-markup{box-sizing:border-box;width:min(1040px,calc(100vw - 32px));padding:0;background:#1b1b1d;color:#f4f4f5}\n.palette-markup header{padding:10px 14px;margin:0;border-bottom:1px solid #ffffff14}\n.palette-markup h2{font-size:14px;padding:0}\n.palette-markup .palette-markup-toolbar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:2px 14px 4px}\n.palette-markup-tools,.palette-markup-colors,.palette-markup-history{display:flex;align-items:center;gap:3px}\n.palette-markup-tools{background:#ffffff0a;border:1px solid #ffffff0d;border-radius:9px;padding:2px}\n.palette-markup .palette-markup-control{border:0;border-radius:6px;background:transparent;color:#d4d4d8;padding:0 9px;min-height:34px;font:inherit;cursor:pointer}\n.palette-markup .palette-markup-control[aria-pressed=true]{background:#ffffff1a;color:#fff}\n.palette-markup .palette-markup-control:disabled{opacity:.36;cursor:default}\n.palette-markup .palette-markup-control:focus-visible,.palette-markup-swatch:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-markup-swatch{display:grid;place-items:center;width:30px;height:34px;padding:0;background:none;border:0;border-radius:6px;cursor:pointer}\n.palette-markup-swatch::before{content:"";width:13px;height:13px;border-radius:50%;background:var(--swatch)}\n.palette-markup-swatch[aria-pressed=true]::before{outline:1px solid currentColor;outline-offset:3px}\n.palette-markup .palette-markup-done{background:#e6dcfb;color:#26212e;font-weight:600}\n.palette-markup .palette-markup-history{margin-left:auto}\n.palette-markup-stage{display:grid;place-items:center;min-width:0;padding:20px;overflow:hidden;background:#101012;border-block-start:1px solid #ffffff12}\n.palette-markup-stage canvas{display:block;max-width:100%;height:auto;border-radius:4px;touch-action:none;cursor:crosshair}\n.palette-markup-stage canvas[data-tool=highlight]{cursor:cell}\n.palette-markup-status:not(:empty){margin:0;padding:0 14px 10px;color:#fda4af}\n@media(hover:hover){.palette-markup .palette-markup-control:enabled:hover{background:#ffffff19;color:#fff}.palette-markup .palette-markup-done:enabled:hover{background:#f0e9ff;color:#26212e}}\n@media(pointer:coarse){.palette-markup .palette-markup-control,.palette-markup-swatch{min-height:44px}.palette-markup-swatch{width:44px}}\n@media(max-width:520px){.palette-snapshot-viewer.palette-markup{width:calc(100vw - 16px);max-width:calc(100vw - 16px)}.palette-markup header,.palette-markup .palette-markup-toolbar{padding-inline:10px}.palette-markup .palette-markup-history{margin-left:0}.palette-markup-stage{padding:12px}}\n'),k=t("header"),x=t("div","palette-markup-toolbar");x.setAttribute("aria-label","Image annotation tools"),x.setAttribute("role","toolbar");let b=t("div","palette-markup-tools"),w=t("div","palette-markup-colors"),v=t("div","palette-markup-history"),y=t("div","palette-markup-stage"),M=t("canvas");M.setAttribute("aria-label","Image with annotations"),M.setAttribute("role","img"),M.width=c.naturalWidth,M.height=c.naturalHeight,M.style.width=`min(100%, calc(max(60px, 100dvh - 220px) * ${M.width/M.height}))`;let C=M.getContext("2d");if(!C)throw new Error("Canvas is unavailable.");let E=[...d?.marks??[]],I=[],A="pen",L=o[0][1],T=null,P=null,S=0,R=!1,K=Math.max(2,M.width/180),q=()=>{C.clearRect(0,0,M.width,M.height),C.drawImage(c,0,0);for(let e of E)l(C,e,K);P&&l(C,P,K)},B=()=>{S||=requestAnimationFrame(()=>{S=0,q()})},W=e=>{let t=M.getBoundingClientRect();return{x:Math.max(0,Math.min(M.width,(e.clientX-t.left)*M.width/t.width)),y:Math.max(0,Math.min(M.height,(e.clientY-t.top)*M.height/t.height))}},z=r.map(([e,t])=>a(t,()=>{A=e,"highlight"===e&&(L=o[1][1]),U()},"palette-markup-control")),D=o.map(([e,t])=>{let r=a(e,()=>{L=t,U()},"palette-markup-swatch");return r.textContent="",r.style.setProperty("--swatch",t),r});M.addEventListener("pointerdown",e=>{0!==e.button||null!==T||R||(M.setPointerCapture(e.pointerId),T=e.pointerId,P={tool:A,color:L,points:[W(e)]},U(),B())});let F=e=>{if(!P)return;let t=W(e);"arrow"===P.tool||"rectangle"===P.tool?P.points[1]=t:P.points.push(t)};M.addEventListener("pointermove",e=>{e.pointerId===T&&(F(e),B())}),M.addEventListener("pointerup",e=>{e.pointerId!==T||!P||(F(e),E.push(P),I.length=0,P=null,T=null,U(),B())});let G=e=>{e.pointerId===T&&(T=null,P=null,U(),B())};M.addEventListener("pointercancel",G),M.addEventListener("lostpointercapture",G);let H=a("Undo",()=>{let e=E.pop();e&&I.push(e),U(),B()},"palette-markup-control"),J=a("Redo",()=>{let e=I.pop();e&&E.push(e),U(),B()},"palette-markup-control"),j=t("p","palette-markup-status");j.setAttribute("role","status");let Y=a("Done",()=>{if(P||R)return;let t=d?.marks??[];E.length===t.length&&E.every((e,a)=>e===t[a])?f.close():(R=!0,U(),q(),e(M,{x:0,y:0,width:M.width,height:M.height},i).then(e=>{f.open&&(f.close(),u(e,{source:h,marks:E}))},()=>{j.textContent="Could not save the image.",R=!1,U()}))},"palette-markup-control palette-markup-done");function U(){M.dataset.tool=A,z.forEach((e,t)=>e.setAttribute("aria-pressed",String(A===r[t][0]))),D.forEach((e,t)=>e.setAttribute("aria-pressed",String(L===o[t][1]))),H.disabled=!E.length||!!P||R,J.disabled=!I.length||!!P||R,Y.disabled=!!P||R}b.append(...z),w.append(...D),v.append(H,J),x.append(b,w,v);let V=a("Close image preview",()=>f.close(),"icon","close");k.append(t("h2","","Image preview"),Y,V),y.append(M),f.append(g,k,x,y,j);let X=new AbortController;window.addEventListener("keydown",e=>{if(!f.open)return;let t=e.key.toLowerCase(),a=(e.metaKey||e.ctrlKey)&&("z"===t||"y"===t);("escape"===t||a)&&(e.preventDefault(),"escape"===t?f.close():("y"===t||e.shiftKey?J:H).click()),e.stopImmediatePropagation()},{capture:!0,signal:X.signal});let $=()=>{X.abort(),f.close()};s.addEventListener("abort",$,{once:!0}),f.addEventListener("close",()=>{s.removeEventListener("abort",$),X.abort(),cancelAnimationFrame(S),f.remove(),m?.isConnected&&m.focus({preventScroll:!0})},{once:!0}),n.append(f),U(),q(),f.showModal()}export{n as annotateImage};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Point = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
type Tool = "pen" | "arrow" | "rectangle" | "highlight";
|
|
6
|
+
type Mark = {
|
|
7
|
+
tool: Tool;
|
|
8
|
+
color: string;
|
|
9
|
+
points: [Point, ...Point[]];
|
|
10
|
+
};
|
|
11
|
+
export type ImageMarkup = {
|
|
12
|
+
source: string;
|
|
13
|
+
marks: Mark[];
|
|
14
|
+
};
|
|
15
|
+
export declare function annotateImage(root: ShadowRoot, src: string, limit: number, previousMarkup: ImageMarkup | undefined, signal: AbortSignal, save: (src: string, markup: ImageMarkup) => void): Promise<void>;
|
|
16
|
+
export {};
|
package/dist/snapshot.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ImageMarkup } from "./snapshot-annotate.js";
|
|
1
2
|
import type { PaletteSnapshots } from "./types.js";
|
|
2
3
|
/** Why the image was left out; the HTML snapshot then starts with a comment saying so. */
|
|
3
4
|
export type SnapshotNote = "cross-origin" | "too-large" | "unsupported" | "failed";
|
|
4
5
|
export interface CapturedSnapshot {
|
|
5
6
|
/** A `data:image/webp` URL of the element and some padding. */
|
|
6
7
|
image?: string;
|
|
8
|
+
markup?: ImageMarkup;
|
|
7
9
|
/** Trimmed outerHTML without scripts, handlers or typed values. */
|
|
8
10
|
html?: string;
|
|
9
11
|
note?: SnapshotNote;
|
|
@@ -36,8 +38,16 @@ export declare const IMAGE_BYTES = 250000;
|
|
|
36
38
|
* dropped side is written as `none` so the default does not come back.
|
|
37
39
|
*/
|
|
38
40
|
export declare function omitInvisibleFrameStyles(styles: Map<string, string>, read?: (name: string) => string | undefined, base?: Map<string, string>): void;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
type Crop = {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
47
|
+
export declare function imageDataUrl(image: CanvasImageSource, crop: Crop, limit: number, density?: number): Promise<string>;
|
|
48
|
+
/** The selected region or the whole element as WebP. */
|
|
49
|
+
export declare function snapshotImage(element: Element, options?: PaletteSnapshots, region?: Crop, freeze?: boolean): Promise<string>;
|
|
50
|
+
export declare function imageAttachment(file: File, limit: number): Promise<CapturedSnapshot>;
|
|
41
51
|
/** The server's snapshot support, from `/config`. */
|
|
42
52
|
export interface SnapshotLimits {
|
|
43
53
|
readiness?: boolean;
|
|
@@ -53,10 +63,11 @@ export declare const noteComment: (note: SnapshotNote) => string;
|
|
|
53
63
|
* that can't be read (another origin's pixels) falls back to the HTML, which then
|
|
54
64
|
* starts with a comment saying why.
|
|
55
65
|
*/
|
|
56
|
-
export declare function captureSnapshot(element: Element | null, options: PaletteSnapshots, htmlLimit?: number): Promise<CapturedSnapshot | null>;
|
|
66
|
+
export declare function captureSnapshot(element: Element | null, options: PaletteSnapshots, htmlLimit?: number, region?: Crop, freeze?: boolean): Promise<CapturedSnapshot | null>;
|
|
57
67
|
/**
|
|
58
68
|
* The snapshot of a draft's target, captured once per anchor: the composer reads it
|
|
59
69
|
* for a preview, and posting passes `post` to upload each kind as its raw file after
|
|
60
70
|
* the thread is saved. Never rejects; failed uploads are reported when supported and the comment stays posted.
|
|
61
71
|
*/
|
|
62
|
-
export declare function snapshotFor<Anchor extends object>(anchor: Anchor, resolve: (anchor: Anchor) => Element | null, options: PaletteSnapshots, limits: SnapshotLimits, post?: (kind: "image" | "html" | "status", body: Blob) => Promise<unknown
|
|
72
|
+
export declare function snapshotFor<Anchor extends object>(anchor: Anchor, resolve: (anchor: Anchor) => Element | null, options: PaletteSnapshots, limits: SnapshotLimits, post?: (kind: "image" | "html" | "status", body: Blob) => Promise<unknown>, region?: Crop, attachment?: Promise<CapturedSnapshot | null>, freeze?: boolean): Promise<CapturedSnapshot | null>;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as e,G as t}from"./chunk-4HBBEVFK.js";var n=new WeakMap;function a(t){let a=n.get(t);a?.isConnected||(a=e("style","",'.palette-snapshot{display:block;width:fit-content;margin-top:8px;padding:0;border:0;border-radius:6px;background:none;color:inherit;font:inherit;cursor:zoom-in;line-height:0}\n.palette-snapshot img{display:block;width:72px;height:48px;border-radius:6px;object-fit:contain;background:color-mix(in oklab,currentColor 8%,transparent);outline:1px solid color-mix(in oklab,currentColor 16%,transparent);outline-offset:-1px}\n.palette-snapshot:not([data-ready]){background:color-mix(in oklab,currentColor 8%,transparent)}\n.palette-snapshot:not([data-ready]) img{visibility:hidden}\n.palette-snapshot[hidden]{display:none}\n.palette-snapshot:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-snapshot[data-large]{width:auto;max-width:100%}\n.palette-snapshot[data-large] img{width:auto;height:auto;min-width:72px;min-height:48px;max-width:100%;max-height:180px;object-fit:contain}\n.thread-item>.palette-snapshot{margin:6px 12px 0 calc(12px + var(--palette-avatar,20px) + var(--palette-gutter,8px))}\n.dialog:has(.thread-navigation:not([hidden]) .palette-snapshot-view) .message .palette-snapshot{display:none}\n.palette-snapshot-view{margin-top:8px}\n.palette-snapshot-view p{margin:0 0 6px}\n.palette-snapshot-code{box-sizing:border-box;max-height:160px;margin:0;padding:8px;overflow:auto;border-radius:6px;background:color-mix(in oklab,currentColor 8%,transparent);font:11px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere;scrollbar-width:thin}\n.palette-snapshot-code:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:2px}\n.palette-snapshot-text{justify-self:start;margin-top:8px;padding:4px 8px;border:0;border-radius:6px;background:color-mix(in oklab,currentColor 8%,transparent);color:inherit;font-family:inherit;font-size:11px;line-height:1.4;cursor:pointer}\n.palette-snapshot-draft{display:grid;grid-template-columns:1fr auto;align-items:center;gap:6px;margin-top:8px;font-size:12px;color:#999}\n.palette-snapshot-draft .palette-snapshot{grid-column:1/-1;width:100%;margin:0;background:#ffffff08}\n.palette-snapshot-draft .palette-snapshot img{width:100%;height:94px;object-fit:contain}\n.palette-snapshot-draft .palette-snapshot:hover img{outline-color:var(--accent,#bda6ef)}\n.palette-snapshot-draft span{flex:1;min-width:0}\n.palette-snapshot-draft .icon{width:28px;height:28px}\n.palette-snapshot-viewer{box-sizing:border-box;max-width:min(1200px,calc(100vw - 32px));max-height:calc(100dvh - 32px);margin:auto;padding:12px;overflow:hidden;border:0;border-radius:16px;background:#242424;color:#eee;box-shadow:inset 0 0 0 1px #ffffff1f,0 24px 64px -16px rgb(0 0 0/55%);font:12px/1.4 -apple-system,BlinkMacSystemFont,"Inter","Segoe UI",sans-serif;pointer-events:auto;color-scheme:dark}\n.palette-snapshot-viewer[open]{display:flex;flex-direction:column;gap:8px;animation:palette-snapshot-in var(--duration-fast,250ms) var(--ease-smooth-out,cubic-bezier(.22,1,.36,1))}\n.palette-snapshot-viewer::backdrop{background:rgb(0 0 0/40%);pointer-events:auto}\n.palette-snapshot-viewer header{display:flex;align-items:center;gap:8px}\n.palette-snapshot-viewer h2{flex:1;margin:0;padding-left:4px;font-size:13px;font-weight:600}\n.palette-snapshot-viewer .secondary{background:#ffffff14;color:inherit}\n.palette-snapshot-viewer .primary{background:#e6dcfb;color:#242424}\n.palette-snapshot-viewer .row{flex-wrap:wrap;justify-content:flex-end}\n.palette-snapshot-viewer .icon{width:28px;height:28px;border-radius:8px;color:#bbb}\n.palette-snapshot-viewer .icon:hover{background:#ffffff14;color:#eee}\n.palette-snapshot-viewer .icon:focus-visible{outline:2px solid var(--accent,#bda6ef);outline-offset:-2px}\n.palette-snapshot-viewer img{display:block;min-height:0;max-width:100%;max-height:calc(100dvh - 104px);margin:auto;border-radius:8px;object-fit:contain}\n.palette-snapshot-viewer .palette-snapshot-code{max-height:calc(100dvh - 104px);width:min(720px,calc(100vw - 56px))}\n@keyframes palette-snapshot-in{from{opacity:0;scale:.98;translate:0 4px}}\n@media (prefers-reduced-motion:reduce){.palette-snapshot-viewer[open]{animation:none}}\n@media (pointer:coarse){.palette-snapshot-viewer .icon,.palette-snapshot-draft .icon{width:44px;height:44px}}'),n.set(t,a),t.append(a))}var o=20,r=[],i=0,s=[],p=0;function l(){let e=performance.now();for(;s.length&&e-s[0]>=6e4;)s.shift();for(;r.length&&i<2&&s.length<20;)i++,s.push(e),r.shift()();r.length&&!p&&s.length>=20&&(p=window.setTimeout(()=>(p=0,l()),6e4-(e-s[0])))}var d=new Map;function c(e,t){let n,a=t.token();try{n=new URL(e)}catch{return Promise.resolve(null)}if(!a||n.origin!==t.origin())return Promise.resolve(null);let o=`${a} ${e}`,s=d.get(o);if(s)return s;s=new Promise(e=>{r.push(()=>e(()=>(i--,l()))),l()}).then(async e=>{try{let e=await fetch(n,{headers:{Authorization:`Bearer ${a}`},credentials:"omit",signal:AbortSignal.timeout(15e3)});if(404===e.status)return null;if(!e.ok)throw new Error(String(e.status));return await e.blob()}finally{e()}}),d.set(o,s),s.catch(()=>d.get(o)===s&&d.delete(o));for(let e of d.keys())d.size>40&&d.delete(e);return s}var h,f=new WeakMap,u=new Map,m=new WeakSet,g="img[data-palette-snapshot]";function x(e){let t=f.get(e);!t||u.has(e)||!e.isConnected||c(t.url,t.context).then(n=>{if(!e.isConnected||u.has(e))return;if(!n)return t.done?.(!1);let a=URL.createObjectURL(n);u.set(e,a),e.src=a,t.done?.(!0)},()=>t.done?.(!1))}function b(e){h?h.observe(e):x(e)}function v(e){m.has(e)||(m.add(e),"function"==typeof IntersectionObserver&&(h??=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&x(t.target)})),new MutationObserver(e=>{for(let t of e){for(let e of t.removedNodes)if(e instanceof Element)for(let t of e.matches(g)?[e]:e.querySelectorAll(g))t.isConnected||h?.unobserve(t);for(let e of t.addedNodes)if(e instanceof Element&&e.isConnected)for(let t of e.matches(g)?[e]:e.querySelectorAll(g))b(t)}!function(){for(let[e,t]of u)e.isConnected||(URL.revokeObjectURL(t),u.delete(e),e.removeAttribute("src"))}()}).observe(e,{childList:!0,subtree:!0}))}function w(e){for(let t of[...C.get(e)??[]])t();for(let[t,n]of u)t.getRootNode()===e&&(URL.revokeObjectURL(n),u.delete(t),t.removeAttribute("src"),h?.unobserve(t))}function y(e){let{context:t,text:n}=e.anchor,a=(t?.label||n||"").replace(/\s+/g," ").trim();return`Snapshot of ${a?`“${a.length>60?`${a.slice(0,59)}…`:a}”`:t?.tag?`the ${t.tag} element`:"the commented element"} when the comment was left`}var k=/^<!-- (?:palette|komo): (no image snapshot, [^>]*?)\.? -->\s*/;function L(e){let t=k.exec(e);return t?{note:`${t[1][0].toUpperCase()}${t[1].slice(1)}.`,code:e.slice(t[0].length)}:{note:"",code:e}}function S(t){let n=e("pre","palette-snapshot-code");return n.textContent=t,n.tabIndex=0,n.setAttribute("role","region"),n.setAttribute("aria-label","HTML snapshot"),n}var C=new Map;async function R(n,o,r){a(n);let i=n.activeElement,s=e("dialog","palette-snapshot-viewer");s.setAttribute("aria-modal","true"),s.setAttribute("aria-label",o.alt);let p=e("header"),l=t("Close snapshot",()=>h(),"icon","close");if(l.removeAttribute("title"),p.append(e("h2","",o.src?"Snapshot":"HTML snapshot"),l),s.append(p),o.src){let t=e("img");t.alt=o.alt,t.src=o.src,s.append(t),await t.decode().catch(()=>{})}else{let{note:t,code:n}=L(o.html??"");t&&s.append(e("p","",t)),s.append(S(n))}if(!n.host.isConnected)return r?.();let d=new AbortController,{signal:c}=d,h=()=>{c.aborted||(d.abort(),C.get(n)?.delete(h),s.close(),s.remove(),r?.(),i?.isConnected&&i.focus({preventScroll:!0}))};s.addEventListener("close",h,{signal:c}),C.set(n,(C.get(n)??new Set).add(h)),window.addEventListener("keydown",e=>{e.stopImmediatePropagation(),"Escape"===e.key&&(e.preventDefault(),h())},{capture:!0,signal:c});let f=!1,u=e=>{let t=s.getBoundingClientRect();return e.target===s&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)};return s.addEventListener("pointerdown",e=>f=u(e),{signal:c}),s.addEventListener("click",e=>f&&u(e)&&h(),{signal:c}),n.append(s),s.showModal(),l.focus(),s}function A(t,n,a,o=!1,r){let i=y(n),s=e("img");s.alt=i,s.dataset.paletteSnapshot="",s.decoding="async";let p=e("button","palette-snapshot");return p.type="button",p.setAttribute("aria-haspopup","dialog"),o&&(p.dataset.large=""),p.append(s),f.set(s,{url:t,context:a,done:e=>{e?p.dataset.ready="":p.dataset.ready||(r?r():p.hidden=!0)}}),p.addEventListener("click",()=>{c(t,a).then(e=>{if(!e)return;let t=URL.createObjectURL(e);R(a.root,{src:t,alt:i},()=>URL.revokeObjectURL(t))})}),p}function E(e,t,n){v(n),e.replaceWith(t);let a=t.querySelector(g);a?.isConnected&&b(a)}function M(e,t,n,o){a(t.root),E(e,A(n,{anchor:o},t),t.root)}function U(n,o,r,i,s){let{image:p,html:l}=i.snapshot??{};if(a(o.root),3===r)return void s?.then(a=>{a&&(a.image||a.html)&&n.isConnected&&!o.dropped.has(i.anchor)&&E(n,function(n,a,o){let r=e("div","palette-snapshot-draft"),i=y({anchor:a});if(n.image){let t=e("button","palette-snapshot");t.type="button",t.dataset.ready="",t.setAttribute("aria-haspopup","dialog"),t.setAttribute("aria-label","Open image preview");let s=e("img");s.alt=i,s.src=n.image,t.append(s),t.addEventListener("click",()=>{o.annotate?o.annotate(a,n):R(o.root,{src:n.image,alt:i})}),r.append(t)}r.append(e("span","",n.image?n.html?"Snapshot and HTML attached":"Snapshot attached":"HTML snapshot attached"));let s=t("Remove snapshot",()=>{o.dropped.add(a),r.closest("form")?.querySelector("textarea")?.focus(),r.remove()},"icon","trash");return r.append(s),r}(a,i.anchor,o),o.root)});let d=r>1?(p||l)&&function(t,n){let{image:a,html:o}=t.snapshot,r=e("div","palette-snapshot-view"),i=()=>{if(!o)return r.remove();c(o,n).then(async t=>{if(!t)return r.remove();let{note:n,code:a}=L(await t.text());r.replaceChildren(e("p","",n||"How it looked, as HTML:"),S(a))},()=>r.remove())};return r.append(e("p","","How it looked:")),a?r.append(A(a,t,n,!0,i)):i(),r}(i,o):p?A(p,i,o):r&&l&&function(e,n,a){let o=t("HTML snapshot",()=>{c(e,a).then(async e=>{e&&R(a.root,{html:await e.text(),alt:y(n)})})},"palette-snapshot-text");return o.removeAttribute("title"),o.setAttribute("aria-haspopup","dialog"),o}(l,i,o);if(4===r){let t=e("div");t.append(function(t,n){let a=new URL(t.page,location.origin);a.searchParams.set("comment",t.id);let o=e("a","thread-route",t.page);o.href=a.href,o.addEventListener("click",e=>{e.preventDefault(),n.go(a)});let r=e("p","","Left on ");return r.append(o),r}(i,o),...d?[d]:[]),d=t}d&&E(n,d,o.root)}function j(e,t){t.notify("Remove this comment’s snapshot?",{label:"Remove",run:()=>{t.remove(e),t.notify("Snapshot removed")}})}export{o as READS_PER_MINUTE,j as confirmRemove,w as disposeSnapshots,M as mountCommentImage,U as mountSnapshot,R as openSnapshotViewer,c as readSnapshot,y as snapshotAlt,L as splitNote};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CapturedSnapshot } from "./snapshot.js";
|
|
1
2
|
import type { Thread } from "./types.js";
|
|
2
3
|
export interface SnapshotContext {
|
|
3
4
|
root: ShadowRoot;
|
|
@@ -7,6 +8,7 @@ export interface SnapshotContext {
|
|
|
7
8
|
origin(): string;
|
|
8
9
|
/** Drafts whose capture is left out when they post. */
|
|
9
10
|
dropped: WeakSet<Thread["anchor"]>;
|
|
11
|
+
annotate?(anchor: Thread["anchor"], shot: CapturedSnapshot): void;
|
|
10
12
|
/** Opens a page through Palette's navigation (the host router when there is one). */
|
|
11
13
|
go(url: URL): void;
|
|
12
14
|
notify(text: string, action?: {
|
|
@@ -17,11 +19,6 @@ export interface SnapshotContext {
|
|
|
17
19
|
remove(thread: Thread): void;
|
|
18
20
|
}
|
|
19
21
|
type Snapshotted = Pick<Thread, "anchor" | "snapshot" | "page" | "id">;
|
|
20
|
-
type Pending = {
|
|
21
|
-
image?: string;
|
|
22
|
-
html?: string;
|
|
23
|
-
note?: string;
|
|
24
|
-
};
|
|
25
22
|
export declare const READS_PER_MINUTE = 20;
|
|
26
23
|
export declare function readSnapshot(url: string, context: SnapshotContext): Promise<Blob | null>;
|
|
27
24
|
/** Revokes the blob URLs shown in `root`, when its Palette unmounts. */
|
|
@@ -41,6 +38,7 @@ export declare function openSnapshotViewer(root: ShadowRoot, content: {
|
|
|
41
38
|
html?: string;
|
|
42
39
|
alt: string;
|
|
43
40
|
}, release?: () => void): Promise<void | HTMLDialogElement>;
|
|
41
|
+
export declare function mountCommentImage(slot: HTMLElement, context: SnapshotContext, url: string, anchor: Thread["anchor"]): void;
|
|
44
42
|
/**
|
|
45
43
|
* Fills a slot Palette's core left for a snapshot. Modes: 0 a list row (images only),
|
|
46
44
|
* 1 the open card (the image's thumbnail, or a button that opens the HTML as text),
|
|
@@ -48,7 +46,7 @@ export declare function openSnapshotViewer(root: ShadowRoot, content: {
|
|
|
48
46
|
* 4 a card whose element isn't on this page: its route, then how it looked.
|
|
49
47
|
* Nothing is fetched until an image is on screen.
|
|
50
48
|
*/
|
|
51
|
-
export declare function mountSnapshot(slot: HTMLElement, context: SnapshotContext, mode: number, thread: Snapshotted, capture?: Promise<
|
|
49
|
+
export declare function mountSnapshot(slot: HTMLElement, context: SnapshotContext, mode: number, thread: Snapshotted, capture?: Promise<CapturedSnapshot | null>): undefined;
|
|
52
50
|
/** Confirms, then removes a thread's snapshots at once; a failed delete puts them back. */
|
|
53
51
|
export declare function confirmRemove(thread: Thread, context: SnapshotContext): void;
|
|
54
52
|
export {};
|
package/dist/token-adapter.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DesignEditChange, DesignSystem, DesignToken, ThemeState, TokenAdapter, TokenUsage } from "./design-system.js";
|
|
2
|
+
export declare function clearCustomTokenOverride(element: Element, property: string): void;
|
|
2
3
|
export declare function rememberTokenUsage(element: Element, property: string, usage: TokenUsage | undefined, adapter: TokenAdapter, tokens: readonly DesignToken[]): TokenUsage | undefined;
|
|
3
4
|
export declare function originalTokenUsage(element: Element | null, property: string): TokenUsage | undefined;
|
|
4
5
|
export declare function refreshTokenBaseline(element: Element, adapter: TokenAdapter, tokens: readonly DesignToken[], restore?: Iterable<string>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,b as t,d as l,e as i}from"./chunk-KIVVWQD7.js";import{E as o}from"./chunk-4HBBEVFK.js";var a=/^([+-]?(?:\d*\.)?\d+)([a-z%]*)$/i;function p(e){return e.filter(e=>!e.hidden).map(e=>[...e.inset?["inset"]:[],...e.lengths,e.color].filter(Boolean).join(" ")).join(", ")||"none"}var n=["px","%","rem","em","vw","vh","ch","vmin","vmax","dvh"];function r(e,t,l,i){let a=o("button","palette-typed__icon");return a.type="button",a.innerHTML=t,a.title=e,a.setAttribute("aria-label",e),void 0!==i&&a.setAttribute("aria-pressed",String(i)),a.onclick=l,a}function d(e,t,l,i,p,{unitless:r=!1,optional:d=!1}={}){let s=o("div","palette-typed__field"),f=o("span");t?f.textContent=t:f.innerHTML='<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M1 6h10M3 4 1 6l2 2M9 4l2 2-2 2"/></svg>',f.title=`${e} · drag to adjust`;let u=o("input");u.setAttribute("aria-label",e),u.inputMode="decimal",u.autocomplete="off",u.spellcheck=!1;let c=o("select");c.setAttribute("aria-label",`${e} unit`);let h=a.exec(l)??["","",""];u.value=h[1];let y=h[2]||(r||!h[1]&&d?"":"px");for(let e of new Set([y,...n,...r?[""]:[]])){let t=o("option","",e||"—");t.value=e,e||(t.title="No unit"),c.append(t)}c.value=y;let g=!1,_=e=>{let t=d&&!u.value.trim(),l=t||a.test(u.value.trim()+c.value);l?p.delete(u):p.add(u);let o=l&&i(t?"":u.value.trim()+c.value,e);return u.setAttribute("aria-invalid",String(!l)),e&&(g=!1),o},x=(e,t)=>{let l=a.exec(function(e,t){let l=a.exec(e.trim());if(!l)return e;let i=!l[2]||/^r?em$/i.test(l[2]);return`${Math.round(1e3*(parseFloat(l[1])+t*(i?.1:1)))/1e3}${l[2]}`}(u.value.trim()+c.value,e));l&&(u.value=l[1],_(t))};return u.oninput=()=>{g=!0,_(!1)},u.onkeydown=e=>{"Enter"===e.key?(e.preventDefault(),e.stopPropagation(),_(!0)):("ArrowUp"===e.key||"ArrowDown"===e.key)&&(e.preventDefault(),x(("ArrowUp"===e.key?1:-1)*(e.shiftKey?10:1),!0))},u.onblur=()=>{g&&_(!0)},c.onchange=()=>_(!0),f.onpointerdown=e=>{if(e.button)return;e.preventDefault(),f.setPointerCapture?.(e.pointerId);let t=e.clientX,l=!1;f.onpointermove=e=>{let i=Math.trunc((e.clientX-t)/2);i&&(t+=2*i,l=!0,x(i*(e.shiftKey?10:1),!1))},f.onpointerup=f.onpointercancel=()=>{f.onpointermove=f.onpointerup=f.onpointercancel=null,l?_(!0):u.focus()}},s.append(f,u,c),s}function s(n,s,f,u,c,h,y=[],g=()=>{}){let _=o("div","palette-typed"),x=o("details","palette-typed palette-typed__advanced"),m=o("summary","","Edit as CSS");m.onclick=e=>{e.preventDefault(),e.stopPropagation(),x.open=!x.open};let v=o("div","palette-typed__field");u.title=s,u.autocomplete="off",u.spellcheck=!1,v.append(o("span","","CSS"),u),x.append(m,v),n.append(_,x);let b=!1,w=new Set;u.oninput=()=>{b=!0,c(u.value,!1)&&S(u.value,!0)},u.onkeydown=e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),b=!1,c(u.value,!0))},u.onblur=()=>{b&&(b=!1,c(u.value,!0))};let k=(e,t,l,i,a,p)=>{let n=o("select","palette-typed__menu");n.setAttribute("aria-label",e);for(let[e,l]of t){let t=o("option","",l);t.value=e,t.title=e,p&&e&&(t.style[p]=e),n.append(t)}return n.value=l,n.onchange=()=>i(n.value),a&&n.addEventListener("palette-preview",e=>{let t=e.detail;g(null===t?void 0:a(t))}),n};function S(n,f=!1){if(f||(u.value=n),w.clear(),_.replaceChildren(),"font-family"===s){let e=o("div","palette-typed__sample"),l=o("b","","Aa"),i=o("span","",t(n));e.title=n,l.style.fontFamily=n,e.append(l,i),_.append(e);let a=y.filter(e=>"fontFamily"===e.type&&e.value&&CSS.supports(s,e.value));a.length?_.append(k("Font family choices",[[n,`Custom · ${t(n)}`],...a.map(e=>[e.value,e.label||t(e.value)])],n,e=>{c(e,!0)&&S(e)},e=>e,"fontFamily")):x.open=!0}else if(/^(box|text)-shadow$/.test(s)){let t=function(t,l="box-shadow"){if("none"===t)return[];let i=[];for(let o of e(t,!0)){let t=e(o),p=[],n="",r=!1,d=!1;for(let e of t)if("inset"!==e||"box-shadow"!==l||r)if(a.test(e)){if(d)return;p.push(e)}else{if(n||/var\(/i.test(e)||!CSS.supports("color",e))return;n=e,d=p.length>0}else r=!0;if(p.length<2||p.length>("box-shadow"===l?4:3))return;i.push({lengths:p,color:n,inset:r})}return i.length?i:void 0}(n,s);if(!t)return _.append(o("span","palette-typed__hint","Complex shadow · edit it as CSS below.")),void(x.open=!0);let l="box-shadow"===s,i=o("div","palette-typed__tile"),f=o("i","",l?"":"Ag");i.setAttribute("aria-hidden","true"),i.append(f);let u=e=>(f.style.setProperty(s,p(t)),c(p(t),e));f.style.setProperty(s,p(t));let h=o("div","palette-typed__head");h.append(o("b","","Layers"),r("Add shadow layer",'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9"/></svg>',()=>{t.push({lengths:["0px","2px","4px","0px"].slice(0,l?4:3),color:"#00000040",inset:!1}),u(!0)&&S(p(t))})),_.append(i,h),t.forEach((e,i)=>{let a=`Layer ${i+1}`,n=o("div","palette-typed__layer");n.setAttribute("role","group"),n.setAttribute("aria-label",`Shadow layer ${i+1}`),n.toggleAttribute("data-hidden",!!e.hidden);let s=o("div","palette-typed__row");l&&s.append(k(`${a} type`,[["drop","Drop"],["inner","Inner"]],e.inset?"inner":"drop",t=>{e.inset="inner"===t,u(!0)}));let f=o("button","palette-typed__color");f.type="button",f.setAttribute("aria-label",`${a} color`),f.setAttribute("aria-expanded","false");let c=o("i"),h=o("span"),g=o("span","palette-typed__alpha");f.append(c,h,g);let x,m=()=>{let[t,l="100%"]=function(e){let t=document.createElement("i").style;t.color=e.trim(),t.color&&(e=t.color);let l=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+)(%?))?\s*\)$/i.exec(e.trim());if(!l)return e||"currentColor";let i=`#${l.slice(1,4).map(e=>Math.round(Number(e)).toString(16).padStart(2,"0")).join("")}`,o=void 0===l[4]?1:Number(l[4])/(l[5]?100:1);return o<1?`${i} · ${Math.round(100*o)}%`:i}(e.color).split(" · ");c.style.setProperty("--c",e.color||"currentColor"),h.textContent=t.replace(/^#/,"").toUpperCase(),g.textContent=e.color?l:"",f.title=e.color||"currentColor"};m(),f.onclick=async()=>{if(x)return x.remove(),x=void 0,void f.setAttribute("aria-expanded","false");f.setAttribute("aria-expanded","true");let{pickerEditor:t}=await import("./color-editor-I5ELNYPO.js");!f.isConnected||x||(x=t({trigger:f,tokens:y,property:"color",onSelect(){},custom:{value:e.color||"#000000",onPreview:()=>()=>{},onSelect(){}}},{preview(t){e.color=t,m(),u(!1)},commit(t){e.color=t,m(),u(!0)},token(t){e.color=t.value,m(),u(!0)}}),n.append(x))};let v=r(`${a} visible`,'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/></svg>',()=>{e.hidden=!e.hidden,v.setAttribute("aria-pressed",String(!e.hidden)),n.toggleAttribute("data-hidden",!!e.hidden),u(!0)},!e.hidden);s.append(f,v,r(`Remove layer ${i+1}`,'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h9"/></svg>',()=>{t.splice(i,1),u(!0)&&S(p(t))}));let b=o("div","palette-typed__grid");[["X offset","X"],["Y offset","Y"],["Blur","Blur"],["Spread","Spread"]].slice(0,l?4:3).forEach(([t,l],i)=>b.append(d(`${a} ${t.toLowerCase()}`,l,e.lengths[i]||"0px",(t,l)=>{for(;e.lengths.length<=i;)e.lengths.push("0px");return e.lengths[i]=t,!w.size&&u(l)},w))),n.append(s,b),_.append(n)})}else if("font"===s){let e=l(n);if(!e)return _.append(o("span","palette-typed__hint","Custom expression · edit it as CSS below.")),void(x.open=!0);let a=o("div","palette-typed__sample"),p=o("b","","Aa"),r=o("span");a.setAttribute("aria-hidden","true"),a.append(p,r);let s=()=>{Object.assign(p.style,{fontStyle:e.style,fontWeight:e.weight,fontFamily:e.family}),r.textContent=[e.family?t(e.family):"Inherited family",e.weight,e.size+(e.lineHeight?`/${e.lineHeight}`:"")].filter(Boolean).join(" · ")},f=t=>(s(),c(i(e),t));s();let u=y.filter(t=>"fontFamily"===t.type&&t.value&&CSS.supports("font-family",t.value)&&t.value!==e.family),h=o("div","palette-typed__grid palette-typed__font");h.append(k("Font weight",[...new Set([e.weight||"400","100","200","300","400","500","600","700","800","900"])].map(e=>[e,e]),e.weight||"400",t=>{e.weight=t,f(!0)},t=>i({...e,weight:t}),"fontWeight"),d("Font size","Size",e.size,(t,l)=>(e.size=t,!w.size&&f(l)),w),d("Line height","LH",e.lineHeight,(t,l)=>(e.lineHeight=t,!w.size&&f(l)),w,{unitless:!0,optional:!0})),_.append(a,k("Font family",[[e.family,e.family?t(e.family):"Inherited family"],...u.map(e=>[e.value,e.label||t(e.value)])],e.family,t=>{e.family=t,f(!0)},t=>i({...e,family:t}),"fontFamily"),h)}else if(h?.values?.length)_.append(k(h.label,[...new Set([n,...h.values])].map(e=>[e,e]),n,e=>c(e,!0),e=>e));else{let t=e(n),l=/^(padding|margin|border-(width|radius)|gap)$/.test(s);if(t.length&&t.every(e=>a.test(e))&&(1===t.length||l&&t.length<=4)){let e=h?.label||s,l=1===t.length?[[e,""]]:"gap"===s?[["Row gap","Row"],["Column gap","Col"]]:"border-radius"===s?[["Top left","TL"],["Top right","TR"],["Bottom right","BR"],["Bottom left","BL"]]:[["Top","T"],["Right","R"],["Bottom","B"],["Left","L"]];if(t.length>1&&"gap"!==s){let[e,l=e,i=e,o=l]=t;t.splice(0,t.length,e,l,i,o)}let i=t.map((e,i)=>d(l[i][0],l[i][1],e,(e,l)=>(t[i]=e,!w.size&&c(t.join(" "),l)),w));if(i.length>1){let e=o("div","palette-typed__grid");e.append(...i),_.append(e)}else _.append(...i)}else _.append(o("span","palette-typed__hint","Custom expression · preserved exactly below.")),x.open=!0}}return S(f),S}function f(e,t){let{property:i}=e,a=e.custom.value,p=o("div","palette-custom"),n=o("div","palette-custom__body"),r=o("input");r.value=a,r.setAttribute("aria-label","CSS value");let d=!1,f=!1;p.append(o("style","",".palette-custom{display:flex;flex:1;flex-direction:column;min-height:0}.palette-custom__body{display:grid;gap:8px;padding:8px;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}.palette-typed{display:grid;gap:6px;min-width:0}.palette-typed__grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}.palette-typed__field,.palette-typed__color,.palette-typed__menu{display:flex;align-items:center;box-sizing:border-box;width:100%;min-width:0;height:28px;border-radius:6px;background:#ffffff0a;box-shadow:none;color:#f1efeb;font:inherit;font-size:11px}.palette-typed__field:hover,.palette-typed__color:hover,.palette-typed__menu:hover{box-shadow:inset 0 0 0 1px #ffffff1c}.palette-typed__field:focus-within,.palette-typed__color:focus-visible,.palette-typed__menu:focus-visible{outline:0;box-shadow:inset 0 0 0 1px #bda6ef}.palette-typed__field>span{flex:none;display:grid;place-items:center;min-width:24px;height:100%;padding:0 2px 0 6px;color:#77736f;font-size:10px;font-weight:500;cursor:ew-resize;user-select:none;touch-action:none}.palette-typed__field>span:hover{color:#e9e6e1}.palette-typed__field>span svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.1}.palette-typed__field input{flex:1;width:100%;min-width:0;height:100%;margin:0;padding:0 2px;border:0;border-radius:0;outline:0;box-shadow:none;background:none;color:inherit;font:inherit;font-variant-numeric:tabular-nums}.palette-typed__field input:focus,.palette-typed__field input:focus-visible,.palette-typed__field select:focus,.palette-typed__field select:focus-visible{outline:0;box-shadow:none}.palette-typed__field select{flex:none;width:auto;max-width:44px;height:100%;margin:0;padding:0 8px 0 2px;border:0;border-radius:0 6px 6px 0;box-shadow:none;appearance:none;background:none;color:#77736f;font:inherit;font-size:10px;text-align:right;cursor:pointer}.palette-typed__field select:hover{color:#f1efeb}.palette-typed__menu{padding:0 20px 0 8px;border:0;appearance:none;background:#ffffff0a url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M1.5 3 4 5.5 6.5 3' fill='none' stroke='%23898680' stroke-width='1.2'/%3E%3C/svg%3E\") right 7px center/8px no-repeat;cursor:pointer}.palette-typed [aria-invalid=true]{color:#f8a898}.palette-typed__layer{display:grid;gap:6px}.palette-typed__layer[data-hidden] .palette-typed__grid{opacity:.45}.palette-typed__row{display:flex;align-items:center;gap:4px;min-width:0}.palette-typed__row>.palette-typed__menu{flex:none;width:64px}.palette-typed__row>.palette-typed__color{flex:1;gap:6px;padding:0 6px}.palette-typed__color .palette-typed__alpha{flex:none;margin-left:auto;color:#898680;font-size:10px}.palette-typed button.palette-typed__icon{display:grid;place-items:center;flex:none;width:24px;padding:0}.palette-typed__icon svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round}.palette-typed__tile{display:grid;place-items:center;height:56px;border-radius:6px;background:repeating-conic-gradient(#ffffff0a 0 25%,#ffffff04 0 50%) 0 0/12px 12px}.palette-typed__tile i{display:grid;place-items:center;width:32px;height:32px;border-radius:6px;background:#f1efeb;color:#f1efeb;font-style:normal;font-size:20px;font-weight:600}.palette-typed__tile i:not(:empty){width:auto;height:auto;background:none}.palette-typed__layer+.palette-typed__layer{padding-top:8px;border-top:1px solid #ffffff0d}.palette-typed__head{display:flex;align-items:center;gap:2px;min-height:24px}.palette-typed__head b{flex:1;color:#b5b1ab;font-size:10px;font-weight:500}.palette-typed button:not(.palette-typed__color,.palette-color *){height:24px;padding:0 8px;border:0;border-radius:5px;background:none;color:#898680;font:inherit;font-size:10px;cursor:pointer}.palette-typed button:not(.palette-typed__color,.palette-color *):hover{background:#ffffff14;color:#f1efeb}.palette-typed button[aria-pressed=true]{background:#bda6ef24;color:#e6dcfb}.palette-typed button:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px}.palette-typed__color{gap:8px;padding:0 8px;border:0;justify-content:flex-start;text-align:left;font-variant-numeric:tabular-nums;cursor:pointer}.palette-typed__color i{flex:none;width:14px;height:14px;border-radius:3px;box-shadow:inset 0 0 0 1px #ffffff26;background:linear-gradient(var(--c),var(--c)),repeating-conic-gradient(#ffffff40 0 25%,#ffffff12 0 50%) 0 0/8px 8px}.palette-typed__color span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.palette-typed .palette-color{padding:0}.palette-typed__sample{display:flex;align-items:center;gap:8px;min-width:0;height:36px;padding:0 8px;border-radius:6px;background:#ffffff08}.palette-typed__sample b{flex:none;font-size:20px;font-weight:400}.palette-typed__sample span{overflow:hidden;color:#b5b1ab;text-overflow:ellipsis;white-space:nowrap}.palette-typed__hint{color:#898680;font-size:10px;line-height:1.5}.palette-custom .palette-typed__advanced>summary{display:flex;align-items:center;height:auto;min-height:24px;color:#77736f;font-size:10px;font-weight:500;list-style:none;cursor:pointer}.palette-typed__advanced>summary::-webkit-details-marker{display:none}.palette-custom .palette-typed__advanced>summary:hover{color:#e9e6e1}.palette-typed__advanced>summary:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px;border-radius:4px}@media (max-width:520px){.palette-typed__font{grid-template-columns:minmax(0,1fr)}}@media (pointer:coarse){.palette-typed__field,.palette-typed__color,.palette-typed__menu{height:36px}.palette-typed button:not(.palette-typed__color,.palette-color *){height:32px}}"),n);let u=s(n,i,a,r,(e,o)=>{if(f)return!1;d=!0;let a=!!e.trim()&&(CSS.supports(i,e)||"font"===i&&!!l(e))&&!/[{};]/.test(e);return r.setAttribute("aria-invalid",String(!a)),!!a&&(r!==r.getRootNode().activeElement&&(r.value=e),o?t.commit(e):t.preview(e),!0)},e.custom?.field,e.tokens,e=>{f||t.hover?.(e)});return Object.assign(p,{live:!0,destroy(){f=!0},refresh(e){if(d)return;let{selectionStart:t,selectionEnd:l}=r;u(e),null!==t&&null!==l&&r.setSelectionRange(t,l)}})}export{f as pickerEditor};
|
|
1
|
+
import{a as e,b as t,d as l,e as i}from"./chunk-KIVVWQD7.js";import{E as o}from"./chunk-4HBBEVFK.js";var a=/^([+-]?(?:\d*\.)?\d+)([a-z%]*)$/i;function p(e){return e.filter(e=>!e.hidden).map(e=>[...e.inset?["inset"]:[],...e.lengths,e.color].filter(Boolean).join(" ")).join(", ")||"none"}var n=["px","%","rem","em","vw","vh","ch","vmin","vmax","dvh"];function r(e,t,l,i){let a=o("button","palette-typed__icon");return a.type="button",a.innerHTML=t,a.title=e,a.setAttribute("aria-label",e),void 0!==i&&a.setAttribute("aria-pressed",String(i)),a.onclick=l,a}function d(e,t,l,i,p,{unitless:r=!1,optional:d=!1}={}){let s=o("div","palette-typed__field"),f=o("span");t?f.textContent=t:f.innerHTML='<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M1 6h10M3 4 1 6l2 2M9 4l2 2-2 2"/></svg>',f.title=`${e} · drag to adjust`;let u=o("input");u.setAttribute("aria-label",e),u.inputMode="decimal",u.autocomplete="off",u.spellcheck=!1;let c=o("select");c.setAttribute("aria-label",`${e} unit`);let h=a.exec(l)??["","",""];u.value=h[1];let y=h[2]||(r||!h[1]&&d?"":"px");for(let e of new Set([y,...n,...r?[""]:[]])){let t=o("option","",e||"—");t.value=e,e||(t.title="No unit"),c.append(t)}c.value=y;let g=!1,_=e=>{let t=d&&!u.value.trim(),l=t||a.test(u.value.trim()+c.value);l?p.delete(u):p.add(u);let o=l&&i(t?"":u.value.trim()+c.value,e);return u.setAttribute("aria-invalid",String(!l)),e&&(g=!1),o},x=(e,t)=>{let l=a.exec(function(e,t){let l=a.exec(e.trim());if(!l)return e;let i=!l[2]||/^r?em$/i.test(l[2]);return`${Math.round(1e3*(parseFloat(l[1])+t*(i?.1:1)))/1e3}${l[2]}`}(u.value.trim()+c.value,e));l&&(u.value=l[1],_(t))};return u.oninput=()=>{g=!0,_(!1)},u.onkeydown=e=>{"Enter"===e.key?(e.preventDefault(),e.stopPropagation(),_(!0)):("ArrowUp"===e.key||"ArrowDown"===e.key)&&(e.preventDefault(),x(("ArrowUp"===e.key?1:-1)*(e.shiftKey?10:1),!0))},u.onblur=()=>{g&&_(!0)},c.onchange=()=>_(!0),f.onpointerdown=e=>{if(e.button)return;e.preventDefault(),f.setPointerCapture?.(e.pointerId);let t=e.clientX,l=!1;f.onpointermove=e=>{let i=Math.trunc((e.clientX-t)/2);i&&(t+=2*i,l=!0,x(i*(e.shiftKey?10:1),!1))},f.onpointerup=f.onpointercancel=()=>{f.onpointermove=f.onpointerup=f.onpointercancel=null,l?_(!0):u.focus()}},s.append(f,u,c),s}function s(n,s,f,u,c,h,y=[],g=()=>{}){let _=o("div","palette-typed"),x=o("details","palette-typed palette-typed__advanced"),m=o("summary","","Edit as CSS");m.onclick=e=>{e.preventDefault(),e.stopPropagation(),x.open=!x.open};let v=o("div","palette-typed__field");u.title=s,u.autocomplete="off",u.spellcheck=!1,v.append(o("span","","CSS"),u),x.append(m,v),n.append(_,x);let b=!1,w=new Set;u.oninput=()=>{b=!0,c(u.value,!1)&&S(u.value,!0)},u.onkeydown=e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),b=!1,c(u.value,!0))},u.onblur=()=>{b&&(b=!1,c(u.value,!0))};let k=(e,t,l,i,a,p)=>{let n=o("select","palette-typed__menu");n.setAttribute("aria-label",e);for(let[e,l]of t){let t=o("option","",l);t.value=e,t.title=e,p&&e&&(t.style[p]=e),n.append(t)}return n.value=l,n.onchange=()=>i(n.value),a&&n.addEventListener("palette-preview",e=>{let t=e.detail;g(null===t?void 0:a(t))}),n};function S(n,f=!1){if(f||(u.value=n),w.clear(),_.replaceChildren(),"font-family"===s){let e=o("div","palette-typed__sample"),l=o("b","","Aa"),i=o("span","",t(n));e.title=n,l.style.fontFamily=n,e.append(l,i),_.append(e);let a=y.filter(e=>"fontFamily"===e.type&&e.value&&CSS.supports(s,e.value));a.length?_.append(k("Font family choices",[[n,`Custom · ${t(n)}`],...a.map(e=>[e.value,e.label||t(e.value)])],n,e=>{c(e,!0)&&S(e)},e=>e,"fontFamily")):x.open=!0}else if(/^(box|text)-shadow$/.test(s)){let t=function(t,l="box-shadow"){if("none"===t)return[];let i=[];for(let o of e(t,!0)){let t=e(o),p=[],n="",r=!1,d=!1;for(let e of t)if("inset"!==e||"box-shadow"!==l||r)if(a.test(e)){if(d)return;p.push(e)}else{if(n||/var\(/i.test(e)||!CSS.supports("color",e))return;n=e,d=p.length>0}else r=!0;if(p.length<2||p.length>("box-shadow"===l?4:3))return;i.push({lengths:p,color:n,inset:r})}return i.length?i:void 0}(n,s);if(!t)return _.append(o("span","palette-typed__hint","Complex shadow · edit it as CSS below.")),void(x.open=!0);let l="box-shadow"===s,i=o("div","palette-typed__tile"),f=o("i","",l?"":"Ag");i.setAttribute("aria-hidden","true"),i.append(f);let u=e=>(f.style.setProperty(s,p(t)),c(p(t),e));f.style.setProperty(s,p(t));let h=o("div","palette-typed__head");h.append(o("b","","Layers"),r("Add shadow layer",'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9"/></svg>',()=>{t.push({lengths:["0px","2px","4px","0px"].slice(0,l?4:3),color:"#00000040",inset:!1}),u(!0)&&S(p(t))})),_.append(i,h),t.forEach((e,i)=>{let a=`Layer ${i+1}`,n=o("div","palette-typed__layer");n.setAttribute("role","group"),n.setAttribute("aria-label",`Shadow layer ${i+1}`),n.toggleAttribute("data-hidden",!!e.hidden);let s=o("div","palette-typed__row");l&&s.append(k(`${a} type`,[["drop","Drop"],["inner","Inner"]],e.inset?"inner":"drop",t=>{e.inset="inner"===t,u(!0)}));let f=o("button","palette-typed__color");f.type="button",f.setAttribute("aria-label",`${a} color`),f.setAttribute("aria-expanded","false");let c=o("i"),h=o("span"),g=o("span","palette-typed__alpha");f.append(c,h,g);let x,m=()=>{let[t,l="100%"]=function(e){let t=document.createElement("i").style;t.color=e.trim(),t.color&&(e=t.color);let l=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:\s*[,/]\s*([\d.]+)(%?))?\s*\)$/i.exec(e.trim());if(!l)return e||"currentColor";let i=`#${l.slice(1,4).map(e=>Math.round(Number(e)).toString(16).padStart(2,"0")).join("")}`,o=void 0===l[4]?1:Number(l[4])/(l[5]?100:1);return o<1?`${i} · ${Math.round(100*o)}%`:i}(e.color).split(" · ");c.style.setProperty("--c",e.color||"currentColor"),h.textContent=t.replace(/^#/,"").toUpperCase(),g.textContent=e.color?l:"",f.title=e.color||"currentColor"};m(),f.onclick=async()=>{if(x)return x.remove(),x=void 0,void f.setAttribute("aria-expanded","false");f.setAttribute("aria-expanded","true");let{pickerEditor:t}=await import("./color-editor-GCCLM3TV.js");!f.isConnected||x||(x=t({trigger:f,tokens:y,property:"color",onSelect(){},custom:{value:e.color||"#000000",onPreview:()=>()=>{},onSelect(){}}},{preview(t){e.color=t,m(),u(!1)},commit(t){e.color=t,m(),u(!0)},token(t){e.color=t.value,m(),u(!0)}}),n.append(x))};let v=r(`${a} visible`,'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8 12.1 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/></svg>',()=>{e.hidden=!e.hidden,v.setAttribute("aria-pressed",String(!e.hidden)),n.toggleAttribute("data-hidden",!!e.hidden),u(!0)},!e.hidden);s.append(f,v,r(`Remove layer ${i+1}`,'<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h9"/></svg>',()=>{t.splice(i,1),u(!0)&&S(p(t))}));let b=o("div","palette-typed__grid");[["X offset","X"],["Y offset","Y"],["Blur","Blur"],["Spread","Spread"]].slice(0,l?4:3).forEach(([t,l],i)=>b.append(d(`${a} ${t.toLowerCase()}`,l,e.lengths[i]||"0px",(t,l)=>{for(;e.lengths.length<=i;)e.lengths.push("0px");return e.lengths[i]=t,!w.size&&u(l)},w))),n.append(s,b),_.append(n)})}else if("font"===s){let e=l(n);if(!e)return _.append(o("span","palette-typed__hint","Custom expression · edit it as CSS below.")),void(x.open=!0);let a=o("div","palette-typed__sample"),p=o("b","","Aa"),r=o("span");a.setAttribute("aria-hidden","true"),a.append(p,r);let s=()=>{Object.assign(p.style,{fontStyle:e.style,fontWeight:e.weight,fontFamily:e.family}),r.textContent=[e.family?t(e.family):"Inherited family",e.weight,e.size+(e.lineHeight?`/${e.lineHeight}`:"")].filter(Boolean).join(" · ")},f=t=>(s(),c(i(e),t));s();let u=y.filter(t=>"fontFamily"===t.type&&t.value&&CSS.supports("font-family",t.value)&&t.value!==e.family),h=o("div","palette-typed__grid palette-typed__font");h.append(k("Font weight",[...new Set([e.weight||"400","100","200","300","400","500","600","700","800","900"])].map(e=>[e,e]),e.weight||"400",t=>{e.weight=t,f(!0)},t=>i({...e,weight:t}),"fontWeight"),d("Font size","Size",e.size,(t,l)=>(e.size=t,!w.size&&f(l)),w),d("Line height","LH",e.lineHeight,(t,l)=>(e.lineHeight=t,!w.size&&f(l)),w,{unitless:!0,optional:!0})),_.append(a,k("Font family",[[e.family,e.family?t(e.family):"Inherited family"],...u.map(e=>[e.value,e.label||t(e.value)])],e.family,t=>{e.family=t,f(!0)},t=>i({...e,family:t}),"fontFamily"),h)}else if(h?.values?.length)_.append(k(h.label,[...new Set([n,...h.values])].map(e=>[e,e]),n,e=>c(e,!0),e=>e));else{let t=e(n),l=/^(padding|margin|border-(width|radius)|gap)$/.test(s);if(t.length&&t.every(e=>a.test(e))&&(1===t.length||l&&t.length<=4)){let e=h?.label||s,l=1===t.length?[[e,""]]:"gap"===s?[["Row gap","Row"],["Column gap","Col"]]:"border-radius"===s?[["Top left","TL"],["Top right","TR"],["Bottom right","BR"],["Bottom left","BL"]]:[["Top","T"],["Right","R"],["Bottom","B"],["Left","L"]];if(t.length>1&&"gap"!==s){let[e,l=e,i=e,o=l]=t;t.splice(0,t.length,e,l,i,o)}let i=t.map((e,i)=>d(l[i][0],l[i][1],e,(e,l)=>(t[i]=e,!w.size&&c(t.join(" "),l)),w));if(i.length>1){let e=o("div","palette-typed__grid");e.append(...i),_.append(e)}else _.append(...i)}else _.append(o("span","palette-typed__hint","Custom expression · preserved exactly below.")),x.open=!0}}return S(f),S}function f(e,t){let{property:i}=e,a=e.custom.value,p=o("div","palette-custom"),n=o("div","palette-custom__body"),r=o("input");r.value=a,r.setAttribute("aria-label","CSS value");let d=!1,f=!1;p.append(o("style","",".palette-custom{display:flex;flex:1;flex-direction:column;min-height:0}.palette-custom__body{display:grid;gap:8px;padding:8px;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}.palette-typed{display:grid;gap:6px;min-width:0}.palette-typed__grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}.palette-typed__field,.palette-typed__color,.palette-typed__menu{display:flex;align-items:center;box-sizing:border-box;width:100%;min-width:0;height:28px;border-radius:6px;background:#ffffff0a;box-shadow:none;color:#f1efeb;font:inherit;font-size:11px}.palette-typed__field:hover,.palette-typed__color:hover,.palette-typed__menu:hover{box-shadow:inset 0 0 0 1px #ffffff1c}.palette-typed__field:focus-within,.palette-typed__color:focus-visible,.palette-typed__menu:focus-visible{outline:0;box-shadow:inset 0 0 0 1px #bda6ef}.palette-typed__field>span{flex:none;display:grid;place-items:center;min-width:24px;height:100%;padding:0 2px 0 6px;color:#77736f;font-size:10px;font-weight:500;cursor:ew-resize;user-select:none;touch-action:none}.palette-typed__field>span:hover{color:#e9e6e1}.palette-typed__field>span svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.1}.palette-typed__field input{flex:1;width:100%;min-width:0;height:100%;margin:0;padding:0 2px;border:0;border-radius:0;outline:0;box-shadow:none;background:none;color:inherit;font:inherit;font-variant-numeric:tabular-nums}.palette-typed__field input:focus,.palette-typed__field input:focus-visible,.palette-typed__field select:focus,.palette-typed__field select:focus-visible{outline:0;box-shadow:none}.palette-typed__field select{flex:none;width:auto;max-width:44px;height:100%;margin:0;padding:0 8px 0 2px;border:0;border-radius:0 6px 6px 0;box-shadow:none;appearance:none;background:none;color:#77736f;font:inherit;font-size:10px;text-align:right;cursor:pointer}.palette-typed__field select:hover{color:#f1efeb}.palette-typed__menu{padding:0 20px 0 8px;border:0;appearance:none;background:#ffffff0a url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath d='M1.5 3 4 5.5 6.5 3' fill='none' stroke='%23898680' stroke-width='1.2'/%3E%3C/svg%3E\") right 7px center/8px no-repeat;cursor:pointer}.palette-typed [aria-invalid=true]{color:#f8a898}.palette-typed__layer{display:grid;gap:6px}.palette-typed__layer[data-hidden] .palette-typed__grid{opacity:.45}.palette-typed__row{display:flex;align-items:center;gap:4px;min-width:0}.palette-typed__row>.palette-typed__menu{flex:none;width:64px}.palette-typed__row>.palette-typed__color{flex:1;gap:6px;padding:0 6px}.palette-typed__color .palette-typed__alpha{flex:none;margin-left:auto;color:#898680;font-size:10px}.palette-typed button.palette-typed__icon{display:grid;place-items:center;flex:none;width:24px;padding:0}.palette-typed__icon svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round}.palette-typed__tile{display:grid;place-items:center;height:56px;border-radius:6px;background:repeating-conic-gradient(#ffffff0a 0 25%,#ffffff04 0 50%) 0 0/12px 12px}.palette-typed__tile i{display:grid;place-items:center;width:32px;height:32px;border-radius:6px;background:#f1efeb;color:#f1efeb;font-style:normal;font-size:20px;font-weight:600}.palette-typed__tile i:not(:empty){width:auto;height:auto;background:none}.palette-typed__layer+.palette-typed__layer{padding-top:8px;border-top:1px solid #ffffff0d}.palette-typed__head{display:flex;align-items:center;gap:2px;min-height:24px}.palette-typed__head b{flex:1;color:#b5b1ab;font-size:10px;font-weight:500}.palette-typed button:not(.palette-typed__color,.palette-color *){height:24px;padding:0 8px;border:0;border-radius:5px;background:none;color:#898680;font:inherit;font-size:10px;cursor:pointer}.palette-typed button:not(.palette-typed__color,.palette-color *):hover{background:#ffffff14;color:#f1efeb}.palette-typed button[aria-pressed=true]{background:#bda6ef24;color:#e6dcfb}.palette-typed button:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px}.palette-typed__color{gap:8px;padding:0 8px;border:0;justify-content:flex-start;text-align:left;font-variant-numeric:tabular-nums;cursor:pointer}.palette-typed__color i{flex:none;width:14px;height:14px;border-radius:3px;box-shadow:inset 0 0 0 1px #ffffff26;background:linear-gradient(var(--c),var(--c)),repeating-conic-gradient(#ffffff40 0 25%,#ffffff12 0 50%) 0 0/8px 8px}.palette-typed__color span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.palette-typed .palette-color{padding:0}.palette-typed__sample{display:flex;align-items:center;gap:8px;min-width:0;height:36px;padding:0 8px;border-radius:6px;background:#ffffff08}.palette-typed__sample b{flex:none;font-size:20px;font-weight:400}.palette-typed__sample span{overflow:hidden;color:#b5b1ab;text-overflow:ellipsis;white-space:nowrap}.palette-typed__hint{color:#898680;font-size:10px;line-height:1.5}.palette-custom .palette-typed__advanced>summary{display:flex;align-items:center;height:auto;min-height:24px;color:#77736f;font-size:10px;font-weight:500;list-style:none;cursor:pointer}.palette-typed__advanced>summary::-webkit-details-marker{display:none}.palette-custom .palette-typed__advanced>summary:hover{color:#e9e6e1}.palette-typed__advanced>summary:focus-visible{outline:1px solid #bda6ef;outline-offset:-1px;border-radius:4px}@media (max-width:520px){.palette-typed__font{grid-template-columns:minmax(0,1fr)}}@media (pointer:coarse){.palette-typed__field,.palette-typed__color,.palette-typed__menu{height:36px}.palette-typed button:not(.palette-typed__color,.palette-color *){height:32px}}"),n);let u=s(n,i,a,r,(e,o)=>{if(f)return!1;d=!0;let a=!!e.trim()&&(CSS.supports(i,e)||"font"===i&&!!l(e))&&!/[{};]/.test(e);return r.setAttribute("aria-invalid",String(!a)),!!a&&(r!==r.getRootNode().activeElement&&(r.value=e),o?t.commit(e):t.preview(e),!0)},e.custom?.field,e.tokens,e=>{f||t.hover?.(e)});return Object.assign(p,{live:!0,destroy(){f=!0},refresh(e){if(d)return;let{selectionStart:t,selectionEnd:l}=r;u(e),null!==t&&null!==l&&r.setSelectionRange(t,l)}})}export{f as pickerEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e,t,z as n}from"./chunk-4HBBEVFK.js";var o=(e,t)=>`${t??""} ${e}`,i=e=>e.replace(/→/g,"->").replace(/\s+/g," ").trim()||"(unset)";function r(t){let n=[];for(let o of Array.isArray(t?.themes)?t.themes:[])if(Array.isArray(o?.options)&&!(o.options.length<2))try{n.push(String(o.current(e())))}catch{}return n.length?n.join("+"):void 0}function a(t,n={}){let i,r=()=>!!n.before?.(),a=new Map,s=[],l=[],d="",p=o=>{let r=o.map(({path:e,value:t,theme:n,alias:o})=>({path:e,value:t,...n?{theme:n}:{},...o?{alias:o}:{}})),a=n.theme?.(),s=r.length?JSON.stringify([a,r]):"";if(s===d)return;let l=i;i=void 0,d=s;try{l?.()}catch{}if(r.length&&t.previewValues)try{i=t.previewValues(r,a,e())}catch{}},c=()=>p(r()?[]:[...a.values()]),g=e=>[...a].filter(([t])=>t!==e).map(([,e])=>e);return{get size(){return a.size},get canUndo(){return s.length>0},get steps(){return s},list:()=>[...a.values()],get:(e,t)=>a.get(o(e,t)),set(e){let t=o(e.path,e.theme),n=a.get(t);return(n?.to??e.from)!==e.to&&(s.push({key:t,edit:n}),l.length=0,e.to===e.from?a.delete(t):a.set(t,e),c(),!0)},preview:e=>(p(r()?[]:[...g(o(e.path,e.theme)),...e.to===e.from?[]:[e]]),c),undo(){let e=s.pop();e&&(l.push({key:e.key,edit:a.get(e.key)}),e.edit?a.set(e.key,e.edit):a.delete(e.key),c())},redo(){let e=l.pop();e&&(s.push({key:e.key,edit:a.get(e.key)}),e.edit?a.set(e.key,e.edit):a.delete(e.key),c())},reset(e,t){let n=o(e,t);a.delete(n);for(let e=s.length;e--;)s[e].key===n&&s.splice(e,1);c()},resetAll(){a.clear(),s.length=0,c()},sync:c,stop(){a.clear(),s.length=0,p([])}}}function s(e,t){if(e.length)return["Proposed token changes (preview only)",...e.map(e=>`Token: ${e.path}${e.theme?` (${e.theme})`:""} ${i(e.from)} → ${i(e.to)}`),`Token adapter: ${t}`].join("\n")}function l(e){return e.map(({path:e,theme:t,from:n,to:o})=>({kind:"token-value",path:e,...t?{theme:t}:{},from:n,to:o}))}var d={color:"color",dimension:"width",fontFamily:"font-family",fontWeight:"font-weight",lineHeight:"line-height",letterSpacing:"letter-spacing",shadow:"box-shadow",typography:"font",duration:"transition-duration"},p=e=>"typography"===e.type?"font":e.properties?.[0]??d[e.type]??"--token",c=".design-inspector[data-tokens] .design-inspector__identity{visibility:visible}.design-inspector[data-tokens] .design-inspector__controls{display:flex;flex-direction:column;place-items:stretch;overflow:hidden}.design-inspector[data-tokens] .design-inspector__parent{display:none}.design-inspector[data-tokens]>.design-inspector__bar:not(.design-token-bar),.design-inspector[data-tokens] .design-inspector__pending,.design-inspector:not([data-tokens])>.design-token-bar{display:none}.design-token-page{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;height:min(520px,calc(100dvh - 190px))}:host([data-sidebar=background]) .design-token-page{height:auto}.design-token-page>.palette-tokens__bar{flex:none;padding:0 12px 8px;background:none;border:0}.design-token-page>p{margin:0 12px 8px;color:#e7c27d;font-size:11px}.design-token-page>p[hidden]{display:none}.design-token-page__list{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:0 8px 8px}.design-token-page__list small{position:sticky;top:0;z-index:1;display:block;padding:8px 8px 4px;background:#0d0d0d;color:#77736f;font-size:10px;font-weight:500}.design-token-page__list>p{margin:0;padding:12px 8px;color:#77736f}.design-token-row{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 24px;align-items:center;gap:2px;border-radius:7px}.design-token-row:hover{background:#ffffff0a}.design-token-row>button{border:0;background:none;color:inherit;font:inherit}.design-token-row>button:first-child{display:grid;grid-template-columns:20px minmax(0,1fr) auto;align-items:center;gap:8px;min-width:0;min-height:32px;padding:6px 8px;border-radius:7px;color:#d9d6d1;text-align:left}.design-token-row b{overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.design-token-row i{max-width:110px;overflow:hidden;color:#77736f;font-style:normal;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.design-token-row[data-changed] b{color:#e6dcfb}.design-token-row[data-changed]::before{content:'';position:absolute;top:calc(50% - 2px);left:-2px;width:4px;height:4px;border-radius:50%;background:#bda6ef}.design-token-row>button+button{display:grid;place-items:center;width:24px;height:24px;padding:0;border-radius:5px;color:#77736f}.design-token-row>button+button:disabled{visibility:hidden}.design-token-row>button+button:hover{background:#ffffff14;color:#f1efeb}.design-token-row svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.design-token-row .palette-tokens{font-size:11px}@media (pointer:coarse){.design-token-row>button:first-child{min-height:44px}.design-token-row>button+button{width:32px;height:32px}}",g=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="${e}"/></svg>`,u=g("M2.5 2.5v3h3M3 5.5a5.5 5.5 0 1 1-.5 2.5"),h=g("M5.5 3.5 2.5 6.5l3 3m-3-3h7a4 4 0 0 1 0 8h-2"),f=new WeakMap;async function b(o,i){let l=await Promise.all([import("./token-picker-HHT4OC3V.js"),import("./react-props-panel-VON2NO7N.js"),import("./design-export-55QSPEWM.js")]),d=f.get(o);d||f.set(o,d=function(o,i,[l,d,g]){let b=i.design?.tokens??d.cssVariableTokens(),m="function"==typeof b.previewValues,v=()=>o.hasAttribute("data-before"),y=a(b,{before:v,theme:()=>r(i.design)}),w=k("style");w.textContent=c,i.root.append(w),l.stylePicker(o);let x=k("section","design-token-page");x.setAttribute("aria-label","Tokens");let _=k("p","","No live preview · edits are recorded as proposals");_.hidden=m;let C=k("div","palette-tokens__bar"),A=k("input");A.type="search",A.placeholder="Search tokens",A.autocomplete="off",A.spellcheck=!1,A.setAttribute("aria-label","Search tokens"),C.append(A);let $=k("div","design-token-page__list");x.append(_,C,$);let L=(e,t)=>{let n=t.getBoundingClientRect(),i=o.getBoundingClientRect();i.left-16>e.offsetWidth?(e.style.left=i.left-8-e.offsetWidth/2+"px",e.style.top=`${n.top+(n.height-e.offsetHeight)/2}px`):i.top-16>e.offsetHeight&&(e.style.top=i.top-8-e.offsetHeight+"px")},E=k("div","design-inspector__bar design-token-bar"),S=k("span","design-inspector__count"),T=k("div","design-inspector__compare");T.setAttribute("role","group"),T.setAttribute("aria-label","Compare with the page");let M=["Before","After"].map((e,t)=>{let n=k("button","",e);return n.type="button",n.dataset.tip=`${e} · ${t?"→":"←"} or B`,n.addEventListener("click",()=>U(!t)),T.append(n),n}),z=k("p","design-inspector__status");z.setAttribute("role","status");let P=k("div","design-inspector__actions"),j=(e,t,n)=>{let o=k("button","design-inspector__tool");return o.type="button",o.dataset.tip=e,o.setAttribute("aria-label",e),o.innerHTML=t,o.addEventListener("click",()=>{U(!1),n(),J()}),o},B=j("Undo",h,()=>y.undo()),H=j("Reset all",u,()=>y.resetAll()),N=k("button","","Comment");N.type="button";let V=()=>s(y.list(),b.id),O=()=>{y.resetAll(),J()};N.addEventListener("click",()=>{let t=V();t&&(O(),i.onComment(e().document.body,t))}),P.append(B,H,N),E.append(S,T,z,P);let K,R=[],W=0,q=new Map;function U(e){e!==v()&&o.querySelectorAll(".design-inspector__bar:not(.design-token-bar) .design-inspector__compare button")[e?0:1]?.click(),y.sync(),F()}function F(){let e=y.size;S.textContent=e?`${e} change${e>1?"s":""}`:"",E.toggleAttribute("data-changes",e>0||y.canUndo),B.disabled=!y.canUndo,H.disabled=N.disabled=!e,T.hidden=!m||!e&&!v(),M.forEach((e,t)=>e.setAttribute("aria-pressed",String(!t===v()))),e?o.dataset.tokenEdits=String(e):delete o.dataset.tokenEdits,oe?.()}function J(){for(let e of q.values())e();F()}let D=e=>{let t=R.find(t=>t.path===e);return t?l.tokenLabel(t):e};function I(e,t){let n=r(i.design),o=y.get(e.path,n),a=e.alias?`{${e.alias}}`:e.value,s=(t,o)=>({path:e.path,value:t,from:a,to:o?`{${o}}`:t,...n?{theme:n}:{},...o?{alias:o}:{}}),d=e=>{y.set(e)&&J()},c=e.alias?R.filter(t=>t.type===e.type&&t.path!==e.path&&t.alias!==e.path):[];l.openTokenPicker({trigger:t,tokens:c,property:p(e),title:l.tokenLabel(e),current:o?o.alias:e.alias,onPreview:e=>y.preview(s(e.value,e.path)),onSelect:e=>d(s(e.value,e.path)),custom:{value:o?.value??e.value,onPreview:e=>y.preview(s(e)),onSelect:e=>d(s(e))}},!0)}let Q=new Map;function G(e){let t=()=>Q.get(e.path)??e,n=k("div","design-token-row"),o=k("button");o.type="button",o.setAttribute("aria-haspopup","dialog");let a=k("b","",l.tokenLabel(e)),s=k("i"),d=k("button");d.type="button",d.title="Reset to page value",d.setAttribute("aria-label",`Reset ${e.path}`),d.innerHTML=u,n.append(o,d);let p=()=>{let e=t();a.textContent=l.tokenLabel(e);let p=y.get(e.path,r(i.design)),c=p?p.alias:e.alias,g=p?.value??e.value;s.textContent=c?D(c):g,o.replaceChildren(l.tokenPreview({...e,value:g}),a,s),o.dataset.tip=[e.path,e.ref,c?`${c} · ${g}`:g,e.description].filter(Boolean).join(" · "),o.setAttribute("aria-label",`${a.textContent}, ${s.textContent}${p?", edited":""}`),n.toggleAttribute("data-changed",!!p),d.disabled=!p};return o.addEventListener("click",()=>I(t(),o)),d.addEventListener("click",()=>{U(!1),y.reset(e.path,r(i.design)),J(),o.focus({preventScroll:!0})}),q.set(e.path,p),p(),n}let X="";function Y(){for(let e of R)Q.set(e.path,e);let e=A.value.toLowerCase().split(/\s+/).filter(Boolean),t=new Map([["",[]]]);for(let n of R){let o=y.get(n.path,r(i.design))?.to??n.value,a=`${l.tokenLabel(n)} ${n.path} ${n.ref??""} ${o}`.toLowerCase();if(!e.every(e=>a.includes(e)))continue;let s=n.group??"";t.set(s,[...t.get(s)??[],n])}let n=JSON.stringify([...t].map(([e,t])=>[e,t.map(e=>e.path)]));if(n===X&&q.size)return J();X=n,q.clear(),$.replaceChildren();let a=0;for(let[e,n]of t){if(!n.length)continue;let t=$;if(e){t=k("div"),t.setAttribute("role","group");let n=k("small","",e);n.id="design-token-group-"+ ++a,t.setAttribute("aria-labelledby",n.id),t.append(n),$.append(t)}for(let e of n)t.append(G(e))}q.size||$.append(k("p","",e.length?"No matching tokens":"No tokens"));let s=o.querySelector(".design-inspector__identity small");s&&(s.textContent=`${R.length} token${1===R.length?"":"s"}`),F()}async function Z(){let e=++W,t=[];try{t=await d.listTokens(b,d.themeState(i.design))}catch{z.textContent="Tokens unavailable · try again"}y.sync(),e===W&&x.isConnected&&(R=t,Y())}function ee(){K?.abort(),K=void 0,o.removeAttribute("data-tokens"),E.remove()}let te=new AbortController;new MutationObserver((e,t)=>{if("true"===o.getAttribute("aria-hidden")&&d.restoreThemes(o),o.isConnected)return y.sync(),F();t.disconnect(),te.abort(),ee(),y.stop(),oe?.(),w.remove(),f.delete(o)}).observe(o,{attributes:!0,attributeFilter:["data-before","aria-hidden"]}),i.root.addEventListener("palette-theme-change",()=>y.sync(),{signal:te.signal}),A.addEventListener("input",Y);let ne={open(){let e=o.querySelector(".design-inspector__controls");if(e){if(!x.isConnected){K=new AbortController;let{signal:r}=K;o.toggleAttribute("data-tokens",!0),e.replaceChildren(x),o.append(E);let a=o.querySelector(".design-inspector__target");a&&(a.textContent="Tokens");let s=new MutationObserver(()=>{x.isConnected||ee()});s.observe(e,{childList:!0}),r.addEventListener("abort",()=>s.disconnect(),{once:!0}),d.attachThemeSwitcher(x,i.design,()=>{Z()},i.root,r),i.root.addEventListener("palette-theme-change",()=>{Z()},{signal:r});let l=!1,p=e=>{l||g.footerTips(E,i.root,r,e),l=!0};E.addEventListener("pointerover",p,{signal:r}),E.addEventListener("focusin",p,{signal:r});let c=!1,u=e=>{c||g.footerTips($,i.root,r,e,L),c=!0};$.addEventListener("pointerover",u,{signal:r}),$.addEventListener("focusin",u,{signal:r});let h=e=>{let t=e.key.toLowerCase(),o=e.composedPath()[0];T.hidden||e.metaKey||e.ctrlKey||e.altKey||!["b","arrowleft","arrowright"].includes(t)||n(o)||"b"!==t&&o.matches?.("input,select,[role=slider],[role=radio]")||(e.preventDefault(),e.stopImmediatePropagation(),U("b"===t?!v():"arrowleft"===t))};document.addEventListener("keydown",h,{capture:!0,signal:r}),t("keydown",h,{capture:!0,signal:r}),Y(),Z()}globalThis.matchMedia?.("(pointer:coarse)")?.matches||A.focus({preventScroll:!0})}}},oe=i.link?.({get size(){return y.size},get steps(){return y.steps},undo(){y.undo(),J()},redo(){y.redo(),J()},reset:O,proposal:V,open:ne.open});return ne}(o,i,l)),d.open()}function k(e,t="",n){let o=document.createElement(e);return o.className=t,void 0!==n&&(o.textContent=n),o}export{b as openTokenPage,r as themeKey,a as tokenEdits,s as tokenProposal,l as tokenValueChanges};
|
|
1
|
+
import{e,t,z as n}from"./chunk-4HBBEVFK.js";var o=(e,t)=>`${t??""} ${e}`,i=e=>e.replace(/→/g,"->").replace(/\s+/g," ").trim()||"(unset)";function r(t){let n=[];for(let o of Array.isArray(t?.themes)?t.themes:[])if(Array.isArray(o?.options)&&!(o.options.length<2))try{n.push(String(o.current(e())))}catch{}return n.length?n.join("+"):void 0}function a(t,n={}){let i,r=()=>!!n.before?.(),a=new Map,s=[],l=[],d="",p=o=>{let r=o.map(({path:e,value:t,theme:n,alias:o})=>({path:e,value:t,...n?{theme:n}:{},...o?{alias:o}:{}})),a=n.theme?.(),s=r.length?JSON.stringify([a,r]):"";if(s===d)return;let l=i;i=void 0,d=s;try{l?.()}catch{}if(r.length&&t.previewValues)try{i=t.previewValues(r,a,e())}catch{}},c=()=>p(r()?[]:[...a.values()]),g=e=>[...a].filter(([t])=>t!==e).map(([,e])=>e);return{get size(){return a.size},get canUndo(){return s.length>0},get steps(){return s},list:()=>[...a.values()],get:(e,t)=>a.get(o(e,t)),set(e){let t=o(e.path,e.theme),n=a.get(t);return(n?.to??e.from)!==e.to&&(s.push({key:t,edit:n}),l.length=0,e.to===e.from?a.delete(t):a.set(t,e),c(),!0)},preview:e=>(p(r()?[]:[...g(o(e.path,e.theme)),...e.to===e.from?[]:[e]]),c),undo(){let e=s.pop();e&&(l.push({key:e.key,edit:a.get(e.key)}),e.edit?a.set(e.key,e.edit):a.delete(e.key),c())},redo(){let e=l.pop();e&&(s.push({key:e.key,edit:a.get(e.key)}),e.edit?a.set(e.key,e.edit):a.delete(e.key),c())},reset(e,t){let n=o(e,t);a.delete(n);for(let e=s.length;e--;)s[e].key===n&&s.splice(e,1);c()},resetAll(){a.clear(),s.length=0,c()},sync:c,stop(){a.clear(),s.length=0,p([])}}}function s(e,t){if(e.length)return["Proposed token changes (preview only)",...e.map(e=>`Token: ${e.path}${e.theme?` (${e.theme})`:""} ${i(e.from)} → ${i(e.to)}`),`Token adapter: ${t}`].join("\n")}function l(e){return e.map(({path:e,theme:t,from:n,to:o})=>({kind:"token-value",path:e,...t?{theme:t}:{},from:n,to:o}))}var d={color:"color",dimension:"width",fontFamily:"font-family",fontWeight:"font-weight",lineHeight:"line-height",letterSpacing:"letter-spacing",shadow:"box-shadow",typography:"font",duration:"transition-duration"},p=e=>"typography"===e.type?"font":e.properties?.[0]??d[e.type]??"--token",c=".design-inspector[data-tokens] .design-inspector__identity{visibility:visible}.design-inspector[data-tokens] .design-inspector__controls{display:flex;flex-direction:column;place-items:stretch;overflow:hidden}.design-inspector[data-tokens] .design-inspector__parent{display:none}.design-inspector[data-tokens]>.design-inspector__bar:not(.design-token-bar),.design-inspector[data-tokens] .design-inspector__pending,.design-inspector:not([data-tokens])>.design-token-bar{display:none}.design-token-page{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;height:min(520px,calc(100dvh - 190px))}:host([data-sidebar=background]) .design-token-page{height:auto}.design-token-page>.palette-tokens__bar{flex:none;padding:0 12px 8px;background:none;border:0}.design-token-page>p{margin:0 12px 8px;color:#e7c27d;font-size:11px}.design-token-page>p[hidden]{display:none}.design-token-page__list{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:0 8px 8px}.design-token-page__list small{position:sticky;top:0;z-index:1;display:block;padding:8px 8px 4px;background:#0d0d0d;color:#77736f;font-size:10px;font-weight:500}.design-token-page__list>p{margin:0;padding:12px 8px;color:#77736f}.design-token-row{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 24px;align-items:center;gap:2px;border-radius:7px}.design-token-row:hover{background:#ffffff0a}.design-token-row>button{border:0;background:none;color:inherit;font:inherit}.design-token-row>button:first-child{display:grid;grid-template-columns:20px minmax(0,1fr) auto;align-items:center;gap:8px;min-width:0;min-height:32px;padding:6px 8px;border-radius:7px;color:#d9d6d1;text-align:left}.design-token-row b{overflow:hidden;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.design-token-row i{max-width:110px;overflow:hidden;color:#77736f;font-style:normal;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.design-token-row[data-changed] b{color:#e6dcfb}.design-token-row[data-changed]::before{content:'';position:absolute;top:calc(50% - 2px);left:-2px;width:4px;height:4px;border-radius:50%;background:#bda6ef}.design-token-row>button+button{display:grid;place-items:center;width:24px;height:24px;padding:0;border-radius:5px;color:#77736f}.design-token-row>button+button:disabled{visibility:hidden}.design-token-row>button+button:hover{background:#ffffff14;color:#f1efeb}.design-token-row svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.design-token-row .palette-tokens{font-size:11px}@media (pointer:coarse){.design-token-row>button:first-child{min-height:44px}.design-token-row>button+button{width:32px;height:32px}}",g=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="${e}"/></svg>`,u=g("M2.5 2.5v3h3M3 5.5a5.5 5.5 0 1 1-.5 2.5"),h=g("M5.5 3.5 2.5 6.5l3 3m-3-3h7a4 4 0 0 1 0 8h-2"),f=new WeakMap;async function b(o,i){let l=await Promise.all([import("./token-picker-ARVCFUCY.js"),import("./react-props-panel-P47YFFSU.js"),import("./design-export-I766FRDX.js")]),d=f.get(o);d||f.set(o,d=function(o,i,[l,d,g]){let b=i.design?.tokens??d.cssVariableTokens(),m="function"==typeof b.previewValues,v=()=>o.hasAttribute("data-before"),y=a(b,{before:v,theme:()=>r(i.design)}),w=k("style");w.textContent=c,i.root.append(w),l.stylePicker(o);let x=k("section","design-token-page");x.setAttribute("aria-label","Tokens");let _=k("p","","No live preview · edits are recorded as proposals");_.hidden=m;let C=k("div","palette-tokens__bar"),A=k("input");A.type="search",A.placeholder="Search tokens",A.autocomplete="off",A.spellcheck=!1,A.setAttribute("aria-label","Search tokens"),C.append(A);let $=k("div","design-token-page__list");x.append(_,C,$);let L=(e,t)=>{let n=t.getBoundingClientRect(),i=o.getBoundingClientRect();i.left-16>e.offsetWidth?(e.style.left=i.left-8-e.offsetWidth/2+"px",e.style.top=`${n.top+(n.height-e.offsetHeight)/2}px`):i.top-16>e.offsetHeight&&(e.style.top=i.top-8-e.offsetHeight+"px")},E=k("div","design-inspector__bar design-token-bar"),S=k("span","design-inspector__count"),T=k("div","design-inspector__compare");T.setAttribute("role","group"),T.setAttribute("aria-label","Compare with the page");let M=["Before","After"].map((e,t)=>{let n=k("button","",e);return n.type="button",n.dataset.tip=`${e} · ${t?"→":"←"} or B`,n.addEventListener("click",()=>O(!t)),T.append(n),n}),z=k("p","design-inspector__status");z.setAttribute("role","status");let P=k("div","design-inspector__actions"),j=(e,t,n)=>{let o=k("button","design-inspector__tool");return o.type="button",o.dataset.tip=e,o.setAttribute("aria-label",e),o.innerHTML=t,o.addEventListener("click",()=>{O(!1),n(),D()}),o},B=j("Undo",h,()=>y.undo()),F=j("Reset all",u,()=>y.resetAll()),H=k("button","","Comment");H.type="button";let R=()=>s(y.list(),b.id),V=()=>{y.resetAll(),D()};H.addEventListener("click",()=>{let t=R();t&&(V(),i.onComment(e().document.body,t))}),P.append(B,F,H),E.append(S,T,z,P);let N,U=[],K=0,q=new Map;function O(e){e!==v()&&o.querySelectorAll(".design-inspector__bar:not(.design-token-bar) .design-inspector__compare button")[e?0:1]?.click(),y.sync(),W()}function W(){let e=y.size;S.textContent=e?`${e} change${e>1?"s":""}`:"",E.toggleAttribute("data-changes",e>0||y.canUndo),B.disabled=!y.canUndo,F.disabled=H.disabled=!e,T.hidden=!m||!e&&!v(),M.forEach((e,t)=>e.setAttribute("aria-pressed",String(!t===v()))),e?o.dataset.tokenEdits=String(e):delete o.dataset.tokenEdits,oe?.()}function D(){for(let e of q.values())e();W()}let I=e=>{let t=U.find(t=>t.path===e);return t?l.tokenLabel(t):e};function J(e,t){let n=r(i.design),o=y.get(e.path,n),a=e.alias?`{${e.alias}}`:e.value,s=(t,o)=>({path:e.path,value:t,from:a,to:o?`{${o}}`:t,...n?{theme:n}:{},...o?{alias:o}:{}}),d=e=>{y.set(e)&&D()},c=e.alias?U.filter(t=>t.type===e.type&&t.path!==e.path&&t.alias!==e.path):[];l.openTokenPicker({trigger:t,tokens:c,property:p(e),title:l.tokenLabel(e),current:o?o.alias:e.alias,onPreview:e=>y.preview(s(e.value,e.path)),onSelect:e=>d(s(e.value,e.path)),custom:{value:o?.value??e.value,onPreview:e=>y.preview(s(e)),onSelect:e=>d(s(e))}},!0)}let Y=new Map;function X(e){let t=()=>Y.get(e.path)??e,n=k("div","design-token-row"),o=k("button");o.type="button",o.setAttribute("aria-haspopup","dialog");let a=k("b","",l.tokenLabel(e)),s=k("i"),d=k("button");d.type="button",d.title="Reset to page value",d.setAttribute("aria-label",`Reset ${e.path}`),d.innerHTML=u,n.append(o,d);let p=()=>{let e=t();a.textContent=l.tokenLabel(e);let p=y.get(e.path,r(i.design)),c=p?p.alias:e.alias,g=p?.value??e.value;s.textContent=c?I(c):g,o.replaceChildren(l.tokenPreview({...e,value:g}),a,s),o.dataset.tip=[e.path,e.ref,c?`${c} · ${g}`:g,e.description].filter(Boolean).join(" · "),o.setAttribute("aria-label",`${a.textContent}, ${s.textContent}${p?", edited":""}`),n.toggleAttribute("data-changed",!!p),d.disabled=!p};return o.addEventListener("click",()=>J(t(),o)),d.addEventListener("click",()=>{O(!1),y.reset(e.path,r(i.design)),D(),o.focus({preventScroll:!0})}),q.set(e.path,p),p(),n}let G="";function Q(){for(let e of U)Y.set(e.path,e);let e=A.value.toLowerCase().split(/\s+/).filter(Boolean),t=new Map([["",[]]]);for(let n of U){let o=y.get(n.path,r(i.design))?.to??n.value,a=`${l.tokenLabel(n)} ${n.path} ${n.ref??""} ${o}`.toLowerCase();if(!e.every(e=>a.includes(e)))continue;let s=n.group??"";t.set(s,[...t.get(s)??[],n])}let n=JSON.stringify([...t].map(([e,t])=>[e,t.map(e=>e.path)]));if(n===G&&q.size)return D();G=n,q.clear(),$.replaceChildren();let a=0;for(let[e,n]of t){if(!n.length)continue;let t=$;if(e){t=k("div"),t.setAttribute("role","group");let n=k("small","",e);n.id="design-token-group-"+ ++a,t.setAttribute("aria-labelledby",n.id),t.append(n),$.append(t)}for(let e of n)t.append(X(e))}q.size||$.append(k("p","",e.length?"No matching tokens":"No tokens"));let s=o.querySelector(".design-inspector__identity small");s&&(s.textContent=`${U.length} token${1===U.length?"":"s"}`),W()}async function Z(){let e=++K,t=[];try{t=await d.listTokens(b,d.themeState(i.design))}catch{z.textContent="Tokens unavailable · try again"}y.sync(),e===K&&x.isConnected&&(U=t,Q())}function ee(){N?.abort(),N=void 0,o.removeAttribute("data-tokens"),E.remove()}let te=new AbortController;new MutationObserver((e,t)=>{if("true"===o.getAttribute("aria-hidden")&&d.restoreThemes(o),o.isConnected)return y.sync(),W();t.disconnect(),te.abort(),ee(),y.stop(),oe?.(),w.remove(),f.delete(o)}).observe(o,{attributes:!0,attributeFilter:["data-before","aria-hidden"]}),i.root.addEventListener("palette-theme-change",()=>y.sync(),{signal:te.signal}),A.addEventListener("input",Q);let ne={open(){let e=o.querySelector(".design-inspector__controls");if(e){if(!x.isConnected){N=new AbortController;let{signal:r}=N;o.toggleAttribute("data-tokens",!0),e.replaceChildren(x),o.append(E);let a=o.querySelector(".design-inspector__target");a&&(a.textContent="Tokens");let s=new MutationObserver(()=>{x.isConnected||ee()});s.observe(e,{childList:!0}),r.addEventListener("abort",()=>s.disconnect(),{once:!0}),d.attachThemeSwitcher(x,i.design,()=>{Z()},i.root,r),i.root.addEventListener("palette-theme-change",()=>{Z()},{signal:r});let l=!1,p=e=>{l||g.footerTips(E,i.root,r,e),l=!0};E.addEventListener("pointerover",p,{signal:r}),E.addEventListener("focusin",p,{signal:r});let c=!1,u=e=>{c||g.footerTips($,i.root,r,e,L),c=!0};$.addEventListener("pointerover",u,{signal:r}),$.addEventListener("focusin",u,{signal:r});let h=e=>{let t=e.key.toLowerCase(),o=e.composedPath()[0];T.hidden||e.metaKey||e.ctrlKey||e.altKey||!["b","arrowleft","arrowright"].includes(t)||n(o)||"b"!==t&&o.matches?.("input,select,[role=slider],[role=radio]")||(e.preventDefault(),e.stopImmediatePropagation(),O("b"===t?!v():"arrowleft"===t))};document.addEventListener("keydown",h,{capture:!0,signal:r}),t("keydown",h,{capture:!0,signal:r}),Q(),Z()}globalThis.matchMedia?.("(pointer:coarse)")?.matches||A.focus({preventScroll:!0})}}},oe=i.link?.({get size(){return y.size},get steps(){return y.steps},undo(){y.undo(),D()},redo(){y.redo(),D()},reset:V,proposal:R,open:ne.open});return ne}(o,i,l)),d.open()}function k(e,t="",n){let o=document.createElement(e);return o.className=t,void 0!==n&&(o.textContent=n),o}export{b as openTokenPage,r as themeKey,a as tokenEdits,s as tokenProposal,l as tokenValueChanges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as e,n as t}from"./chunk-UUV356RI.js";import{a as o,b as n,c as i}from"./chunk-PF4NYFZK.js";import"./chunk-4FX5IS2U.js";import"./chunk-XOMOONGK.js";import{E as l}from"./chunk-4HBBEVFK.js";var r,a={font:"Typography","box-shadow":"Shadow","text-shadow":"Text shadow"},s=new WeakSet,p=0;function d(e){return e.label||e.path.slice(e.path.lastIndexOf(".")+1)||e.path}var c=(e,t,o)=>Math.min(o,Math.max(t,e));function f(e){let t=l("span","palette-tokens__pv");t.setAttribute("aria-hidden","true");let o=e=>{let o=l("span",`palette-tokens__${e}`);return t.append(o),o},n=e.value??"",{type:i}=e;if("color"===i){let e=o("sw"),t=l("span");u(n)?t.style.background=n:(t.dataset.unresolved="",t.textContent="?"),e.append(t)}else if("dimension"===i||"letterSpacing"===i){let i=function(e){let t=/^(-?[\d.]+)(px|r?em)?$/.exec(e.trim());return t?parseFloat(t[1])*(t[2]?"px"===t[2]?1:16:1):void 0}(n);if(void 0===i)return t;let l=/radius/.test(`${e.path} ${e.properties?.join(" ")}`),r=o(l?"corner":"dim");l?r.style.borderTopLeftRadius=`${c(i,0,12)}px`:r.style.width=`${c(i/2,2,24)}px`}else if("shadow"===i)o("shadow").style.boxShadow=n;else if("typography"===i||"fontWeight"===i||"fontFamily"===i){let e=o("ag");e.textContent="Ag","typography"===i?(e.style.font=n,e.style.fontSize="13px",e.style.lineHeight="1"):"fontWeight"===i?e.style.fontWeight=n:e.style.fontFamily=n}return t}function u(e){if(!e||/var\(/i.test(e))return!1;let t=l("span").style;return t.color=e,!!t.color}function h(e,o,n,i){let r=l("div");r.id=o,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(n));let a=l("span","palette-tokens__name"),s=l("span","",d(e));a.append(s);let p=l("span","palette-tokens__check");p.setAttribute("aria-hidden","true");let c="color"===e.type&&!u(e.value),h=i.flatMap(t=>{let o=t.values.get(e.path);return o&&"color"===e.type?[`${t.label} ${o}`]:[]}),g=h.length>1?h.join(", "):e.value??"",m=l("span","palette-tokens__sub",[e.path,g].filter(Boolean).join(" · "));return m.setAttribute("aria-hidden","true"),r.append(f(e),a,p,m),r.setAttribute("aria-label",[e.label,t(e,g,c?"Unresolved; no swatch available":"")].filter(Boolean).join(" · ")),r}function g(e){let t=e.getRootNode();if((t instanceof ShadowRoot||t===document)&&!s.has(t)){s.add(t);let e=l("style");e.textContent=o+".palette-tokens{display:flex;flex-direction:column;overflow:hidden}.palette-tokens__head{flex:none;display:flex;align-items:center;gap:4px;min-height:36px;padding:0 12px;color:#f1efeb;font-weight:500}.palette-tokens__back{display:grid;place-items:center;width:20px;height:20px;margin-left:-6px;padding:0;border:0;border-radius:5px;background:none;color:#898680;cursor:pointer}.palette-tokens__back:hover{background:#ffffff14;color:#f1efeb}.palette-tokens__back svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.palette-tokens__bar{flex:none;display:flex;gap:4px;padding:0 8px 8px;background:#232323;border-bottom:1px solid #ffffff0d}.palette-tokens__bar input{flex:1;min-width:0;height:28px;box-sizing:border-box;margin:0;padding:0 8px;border:0;border-radius:6px;outline:0;box-shadow:none;background:#ffffff0a;color:#f1efeb;font:inherit}.palette-tokens__bar input:focus{outline:0;box-shadow:inset 0 0 0 1px #bda6ef}.palette-tokens__widen{flex:none;height:28px;margin:0 4px 4px;padding:0 8px;border:0;border-radius:6px;background:none;color:#898680;font:inherit;text-align:left;cursor:pointer}.palette-tokens__widen:hover,.palette-tokens__more:hover{background:#ffffff0f;color:#f1efeb}.palette-tokens__more{flex:none;display:flex;align-items:center;gap:8px;min-height:36px;padding:0 12px;border:0;border-top:1px solid #ffffff0d;background:none;color:#d9d6d1;font:inherit;text-align:left;cursor:pointer}.palette-tokens__more b{margin-right:auto;font-weight:500}.palette-tokens__more i{flex:none;width:14px;height:14px;border-radius:3px;box-shadow:inset 0 0 0 1px #ffffff26;background:linear-gradient(var(--c),var(--c)),repeating-conic-gradient(#ffffff40 0 25%,#ffffff12 0 50%) 0 0/8px 8px}.palette-tokens__more span{max-width:50%;overflow:hidden;color:#898680;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.palette-tokens [role=listbox]{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:0 4px 4px}.palette-tokens small:not(.palette-select *){position:sticky;top:0;z-index:1;display:block;padding:8px 8px 4px;background:#232323;color:#77736f;font-size:10px;font-weight:500}.palette-tokens [role=option]:not(.palette-select *){display:grid;grid-template-columns:20px minmax(0,1fr) 14px;align-items:center;gap:4px 8px;box-sizing:border-box;min-height:32px;padding:6px 8px;border-radius:7px;cursor:pointer}.palette-tokens [data-active]{background:#ffffff14;color:#f1efeb}.palette-tokens [aria-selected=true] .palette-tokens__name{color:#e6dcfb}.palette-tokens__name{grid-column:2;min-width:0;font-weight:500}.palette-tokens__name>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.palette-tokens__sub{grid-column:2/4;display:none;min-width:0;overflow:hidden;color:#77736f;font-size:10px;text-overflow:ellipsis;white-space:nowrap}.palette-tokens [data-active] .palette-tokens__sub{display:block}.palette-tokens__check{grid-column:3;justify-self:center}.palette-tokens [aria-selected=true] .palette-tokens__check{width:7px;height:3.5px;margin-top:-3px;border:solid #bda6ef;border-width:0 0 1.5px 1.5px;rotate:-45deg}.palette-tokens__pv{display:flex;align-items:center;height:16px;overflow:hidden}.palette-tokens__sw{display:flex;width:16px;height:16px;border-radius:4px;overflow:hidden;background:repeating-conic-gradient(#ffffff40 0 25%,#ffffff0d 0 50%) 0 0/8px 8px;outline:1px solid #ffffff1f;outline-offset:-1px}.palette-tokens__sw>span{flex:1}.palette-tokens__sw>[data-unresolved]{display:grid;place-items:center;background:#393939;color:#b6b1aa;font-size:10px}.palette-tokens__dim{height:4px;min-width:2px;border-radius:2px;background:#bda6ef}.palette-tokens__corner{width:12px;height:12px;box-sizing:border-box;border:solid #bda6ef;border-width:1.5px 0 0 1.5px}.palette-tokens__shadow{width:16px;height:12px;margin-left:2px;border-radius:3px;background:#f1efeb}.palette-tokens__ag{color:#f1efeb;font-size:13px;line-height:1;white-space:nowrap}.palette-tokens__empty{padding:12px 8px;color:#77736f}@media (pointer:coarse){.palette-tokens{font-size:13px}.palette-tokens [role=option]:not(.palette-select *){min-height:44px}.palette-tokens__bar input,.palette-tokens__bar button{height:36px}}.palette-tokens__custom{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}.palette-tokens__custom>.palette-custom{flex:none}.palette-tokens__custom .palette-custom__body{overflow:visible}.palette-tokens [hidden]{display:none!important}.palette-tokens button:focus-visible,.palette-tokens [role=listbox]:focus-visible{outline:1px solid #bda6ef;outline-offset:-2px}.palette-tokens[popover]{position:fixed;inset:auto;margin:0;border:0;padding:0}",(t instanceof ShadowRoot?t:document.head).append(e)}return t}function m(e,t){r?.trigger===e&&r.refresh(t)}function b(t,o=!1){let s=t.trigger.dataset.start;if(delete t.trigger.dataset.start,o&&r?.trigger===t.trigger)return r.close(!0);r?.close();let{trigger:f,property:u}=t,m=t.tokens,b=g(f),x="palette-tokens-"+ ++p,k=/color|^(fill|stroke)$/.test(u),v=l("div","palette-tokens");v.id=`${x}-popup`,v.setAttribute("role","dialog"),v.setAttribute("aria-label",`Edit ${u}`);let _=l("div","palette-tokens__head"),w=l("button","palette-tokens__back");w.type="button",w.setAttribute("aria-label","Back to tokens"),w.innerHTML='<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M7.5 2.5 4 6l3.5 3.5"/></svg>';let y=l("span","",t.title||t.custom?.field?.label||a[u]||u);_.append(w,y);let A=l("div","palette-tokens__bar"),E=l("input");E.type="text",E.placeholder="Search tokens",E.autocomplete="off",E.spellcheck=!1,E.setAttribute("role","combobox"),E.setAttribute("aria-expanded","true"),E.setAttribute("aria-controls",x),E.setAttribute("aria-autocomplete","list"),E.setAttribute("aria-label",`Search tokens for ${u}`);let $=l("div","palette-tokens__list");$.id=x,$.tabIndex=0,$.setAttribute("role","listbox"),$.setAttribute("aria-label",`Tokens for ${u}`);let S=e(m,u),L=!S.length,C=l("button","palette-tokens__widen");C.type="button",A.append(E);let M=l("button","palette-tokens__more");M.type="button";let H=l("i"),T=l("span");M.append(l("b","","Custom…"),H,T);let P=l("div","palette-tokens__custom");v.append(_,A,$,C,M),t.custom&&v.append(P);let j,z,B,I,N=()=>new Map(m.map(e=>[e,`${d(e)} ${e.path} ${e.ref??""} ${e.value??""}`.toLowerCase()])),R=N(),U=[],F=[],K=0,D=-1,O=$,V=-1,W=!1,q=!1,G=!1,X=()=>{let e=z;z=void 0,V=-1,e?.()},Y=e=>{X(),B=e,z=t.custom?.onPreview(e)},J=()=>{V<0||(X(),void 0!==B&&Y(B))},Z=()=>!t.custom||!!S.length,Q=()=>{let e=Z()&&!G,o=L||E.value?m:S;$.hidden=A.hidden=!e,E.hidden=!e||!q&&o.length<=8&&!E.value,A.hidden||=E.hidden,C.hidden=!e||!!E.value||!S.length||S.length===m.length,C.textContent=L?"Show relevant tokens":`Show all ${m.length} tokens`,C.setAttribute("aria-pressed",String(L)),M.hidden=!e||!t.custom,P.hidden=e,w.hidden=!G||!Z(),y.textContent=G&&Z()?k?"Custom colour":"Custom value":t.title||t.custom?.field?.label||a[u]||u,v.toggleAttribute("data-custom",!e);let n=t.custom?.value??"",i=/^rgba?\((\d+)[ ,]+(\d+)[ ,]+(\d+)(?:[ ,/]+([\d.]+))?/.exec(n);T.textContent=k?i?i.slice(1,4).map(e=>Number(e).toString(16).padStart(2,"0")).join("").toUpperCase()+(i[4]&&+i[4]<1?` ${Math.round(100*+i[4])}%`:""):n.replace(/^#/,"").toUpperCase():n,H.hidden=!k||!n,H.style.setProperty("--c",n),M.title=n},ee=e=>{for(;K<Math.min(e,F.length);K++){let{token:e,group:o}=F[K];if(o!==j&&(j=o,O=$,o)){O=l("div"),O.setAttribute("role","group");let e=l("small");e.id=`${x}-g${K}`,e.textContent=o,O.setAttribute("aria-labelledby",e.id),O.append(e),$.append(O)}O.append(h(e,`${x}-${K}`,e.path===t.current,U))}},te=e=>$.querySelector(`#${x}-${e}`),oe=(e,o=!0,n=!0)=>{if(e<0||e>=F.length)return;if(e!==V&&n){X(),V=e;let o=F[e].token;o.path!==t.current&&(z=t.onPreview?.(o))}ee(e+60),te(D)?.removeAttribute("data-active"),D=e;let i=te(e);if(i.toggleAttribute("data-active",!0),E.setAttribute("aria-activedescendant",i.id),$.setAttribute("aria-activedescendant",i.id),!o)return;let l=i.offsetTop-(i.parentElement===$?0:i.parentElement.firstElementChild.offsetHeight),r=i.offsetTop+i.offsetHeight;l<$.scrollTop?$.scrollTop=l-4:r>$.scrollTop+$.clientHeight&&($.scrollTop=r-$.clientHeight+4)},ne=(e=!1,t=!1)=>{let o=t?F[D]?.token.path:void 0,n=$.scrollTop,i=t?K:60;V>=0&&X();let r=E.value.toLowerCase().split(/\s+/).filter(Boolean),a=L||r.length?m:S,s=r.length?a.filter(e=>r.every(t=>R.get(e).includes(t))):a,p=L?s:[...s.filter(e=>S.includes(e)),...s.filter(e=>!S.includes(e))],d=new Map([["",[]]]);for(let e of p){let t=e.group??"";d.set(t,[...d.get(t)??[],e])}if(F=[...[...d].flatMap(([e,t])=>t.map(t=>({token:t,group:e})))],$.replaceChildren(),$.scrollTop=0,K=0,D=-1,j=void 0,E.removeAttribute("aria-activedescendant"),$.removeAttribute("aria-activedescendant"),Q(),!F.length){let e=l("div","palette-tokens__empty",r.length?"No matching tokens":"No tokens");return void $.append(e)}ee(i),oe(Math.max(0,F.findIndex(e=>e.token.path===o)),!1,e),t&&($.scrollTop=n)},ie=new AbortController,{signal:le}=ie,re=!!globalThis.matchMedia?.("(pointer:coarse)")?.matches;function ae(e=!1,o=!1){if(r?.close!==ae)return;r=void 0;let n=I?.live&&B;X(),n&&!o&&(t.custom?.onCommit??t.custom?.onSelect)?.(n),t.custom?.[o?"onCancel":"onDone"]?.(),ie.abort(),I?.destroy(),v.remove(),f.setAttribute("aria-expanded","false"),f.removeAttribute("aria-controls"),e&&f.isConnected&&f.focus({preventScroll:!0})}r={trigger:f,close:ae,refresh(o){if(!o)return W||=V>=0,X();let n=W||V>=0;W=!1,t=o,m=o.tokens,S=e(m,u),R=N(),U=[],ne(n&&!G,!0),t.current&&t.custom&&I?.refresh(t.custom.value),V<0&&!z&&void 0!==B&&Y(B),ve()}};let se=e=>{X(),B=void 0,t.custom?.onCancel?.(),ae(!0),e.path!==t.current&&t.onSelect(e)},pe=t.custom?k?import("./color-editor-I5ELNYPO.js"):import("./token-custom-7MJFPGVB.js"):void 0;function de(e,o=!re){J(),G=e,Q(),ge="",me(),G?async function(e){let o=await pe;if(r?.close!==ae)return;I||(I=o.pickerEditor(t,{preview:Y,commit(e){if(!t.custom?.onCommit)return Y(e);X(),B=void 0,t.custom.onCommit(e)},token:se,hover(e){X(),void 0!==e?z=t.custom?.onPreview(e):void 0!==B&&Y(B)}}),P.append(I)),ge="",me();let n=!!v.getClientRects().length,i=[...v.querySelectorAll("input,select,summary,button")].filter(e=>(!n||e.getClientRects().length)&&!e.closest("[hidden]")&&!e.matches("details:not([open]) :not(summary)"));e&&(i.find(e=>e instanceof HTMLInputElement&&P.contains(e))??i[0])?.focus({preventScroll:!0})}(o):o&&(E.hidden?M:E).focus({preventScroll:!0})}let ce=e=>{let t=F[e]?.token;t&&se(t)};M.addEventListener("click",()=>de(!0),{signal:le}),w.addEventListener("click",()=>de(!1),{signal:le}),E.addEventListener("input",()=>ne(!0),{signal:le}),C.addEventListener("click",()=>{L=!L,ne(!0),re||(E.hidden?$:E).focus({preventScroll:!0})},{signal:le}),addEventListener("keydown",e=>{if(!f.isConnected)return ae();let t=e.composedPath();if(!t.includes(v)&&!t.includes(f))return;let{key:o}=e,n={ArrowDown:1,ArrowUp:-1,PageDown:8,PageUp:-8}[o];if(!(e.ctrlKey||e.metaKey||e.altKey||"Escape"===o&&t[0]instanceof HTMLSelectElement&&t[0]!==f&&"true"===t[0].getAttribute("aria-expanded"))){if("Escape"===o)ae(!0,!0);else if("Tab"===o){let o=[...v.querySelectorAll("button,input,select,summary,[tabindex='0']")].filter(e=>!e.closest("[hidden]")&&!e.matches("details:not([open]) :not(summary)")&&e.getClientRects().length);if(t[0]!==o[e.shiftKey?0:o.length-1])return;o[e.shiftKey?o.length-1:0]?.focus()}else if(t[0]===M&&"ArrowUp"===o&&F.length)$.focus({preventScroll:!0}),oe(F.length-1);else{if($.hidden||t[0]!==E&&t[0]!==f&&t[0]!==$)return;if(n>0&&t[0]===$&&D===F.length-1&&!M.hidden)J(),M.focus({preventScroll:!0});else if(n)oe(c(D+n,0,F.length-1));else if("Home"!==o&&"End"!==o||t[0]===E)if("Enter"===o)ce(D);else{if(t[0]!==$||1!==o.length||" "===o)return;q=!0,E.value+=o,ne(!0),E.focus({preventScroll:!0})}else oe("Home"===o?0:F.length-1)}e.preventDefault(),e.stopImmediatePropagation()}},{capture:!0,signal:le}),addEventListener("pointerdown",e=>{let t=e.composedPath();!t.includes(v)&&!t.includes(f)&&ae()},{capture:!0,signal:le}),addEventListener("focusin",e=>{let t=e.composedPath();!t.includes(v)&&!t.includes(f)&&ae()},{capture:!0,signal:le});let fe=e=>{e.target===$?$.scrollTop+$.clientHeight>$.scrollHeight-200&&ee(K+60):e.target instanceof Node&&v.contains(e.target)||ae()};addEventListener("scroll",fe,{capture:!0,signal:le}),b.addEventListener("scroll",fe,{capture:!0,signal:le}),addEventListener("resize",()=>ae(),{signal:le}),i(f,()=>ae(),le),$.addEventListener("mousedown",e=>e.preventDefault(),{signal:le});let ue=e=>{let t=e.target.closest?.("[role=option]");return t&&$.contains(t)?Number(t.id.slice(x.length+1)):-1};$.addEventListener("pointermove",e=>{let t=ue(e);t>=0&&oe(t,!1)},{signal:le}),$.addEventListener("pointerleave",J,{signal:le}),M.addEventListener("focusin",J,{signal:le}),P.addEventListener("focusin",J,{signal:le}),v.addEventListener("click",e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLButtonElement||e.preventDefault();let t=ue(e);t>=0&&ce(t)},{signal:le}),ne();let he=f.closest(".design-field")??f.parentElement;v.popover="manual",he.append(v),v.showPopover?.(),he.addEventListener("palette-field-sync",()=>{z||!t.custom||(I?.refresh(t.custom.value),Q())},{signal:le}),f.setAttribute("aria-expanded","true"),f.setAttribute("aria-controls",v.id);let ge="",me=()=>{let e=he.getBoundingClientRect();if(ge===`${e.left} ${e.top}`)return;ge=`${e.left} ${e.top}`;let t=n(he),o=c(t.right-t.left-8,120,256),i=innerHeight-e.bottom-12,l=e.top-12;v.style.maxHeight="";let r=i<Math.min(460,Math.max(v.scrollHeight,200))&&l>i,a=Math.min(460,innerHeight-16,Math.max(r?l:i,200));v.style.width=`${o}px`,v.style.maxHeight=`${a}px`,v.style.left=`${c(e.left,t.left+4,t.right-o-4)}px`,v.style.top=r?"":`${Math.min(e.bottom+4,innerHeight-8-a)}px`,v.style.bottom=r?`${Math.min(innerHeight-e.top+4,innerHeight-8-a)}px`:"",v.toggleAttribute("data-up",r)};me();let be=new MutationObserver(me);be.observe(b,{attributes:!0,childList:!0,subtree:!0}),le.addEventListener("abort",()=>be.disconnect());let xe=F.findIndex(e=>e.token.path===t.current);xe>=0&&oe(xe,!0,!1),!Z()||"custom"===s&&t.custom?de(!0):re||(E.hidden?$:E).focus({preventScroll:!0,focusVisible:!1});let ke=0;function ve(){let e=++ke;Promise.resolve(t.themes?.()).then(t=>{!t||t.length<2||r?.close!==ae||e!==ke||(U=t,$.hidden||ne(V>=0,!0))},()=>{})}return ve(),()=>ae()}export{b as openTokenPicker,m as refreshTokenPicker,g as stylePicker,d as tokenLabel,f as tokenPreview};
|
|
1
|
+
import{l as e,o as t}from"./chunk-KMRWUNT7.js";import{a as o,b as n,c as i}from"./chunk-PF4NYFZK.js";import"./chunk-4FX5IS2U.js";import"./chunk-XOMOONGK.js";import{E as l}from"./chunk-4HBBEVFK.js";var r,a={font:"Typography","box-shadow":"Shadow","text-shadow":"Text shadow"},s=new WeakSet,p=0;function d(e){return e.label||e.path.slice(e.path.lastIndexOf(".")+1)||e.path}var c=(e,t,o)=>Math.min(o,Math.max(t,e));function f(e){let t=l("span","palette-tokens__pv");t.setAttribute("aria-hidden","true");let o=e=>{let o=l("span",`palette-tokens__${e}`);return t.append(o),o},n=e.value??"",{type:i}=e;if("color"===i){let e=o("sw"),t=l("span");u(n)?t.style.background=n:(t.dataset.unresolved="",t.textContent="?"),e.append(t)}else if("dimension"===i||"letterSpacing"===i){let i=function(e){let t=/^(-?[\d.]+)(px|r?em)?$/.exec(e.trim());return t?parseFloat(t[1])*(t[2]?"px"===t[2]?1:16:1):void 0}(n);if(void 0===i)return t;let l=/radius/.test(`${e.path} ${e.properties?.join(" ")}`),r=o(l?"corner":"dim");l?r.style.borderTopLeftRadius=`${c(i,0,12)}px`:r.style.width=`${c(i/2,2,24)}px`}else if("shadow"===i)o("shadow").style.boxShadow=n;else if("typography"===i||"fontWeight"===i||"fontFamily"===i){let e=o("ag");e.textContent="Ag","typography"===i?(e.style.font=n,e.style.fontSize="13px",e.style.lineHeight="1"):"fontWeight"===i?e.style.fontWeight=n:e.style.fontFamily=n}return t}function u(e){if(!e||/var\(/i.test(e))return!1;let t=l("span").style;return t.color=e,!!t.color}function h(e,o,n,i){let r=l("div");r.id=o,r.setAttribute("role","option"),r.setAttribute("aria-selected",String(n));let a=l("span","palette-tokens__name"),s=l("span","",d(e));a.append(s);let p=l("span","palette-tokens__check");p.setAttribute("aria-hidden","true");let c="color"===e.type&&!u(e.value),h=i.flatMap(t=>{let o=t.values.get(e.path);return o&&"color"===e.type?[`${t.label} ${o}`]:[]}),g=h.length>1?h.join(", "):e.value??"",m=l("span","palette-tokens__sub",[e.path,g].filter(Boolean).join(" · "));return m.setAttribute("aria-hidden","true"),r.append(f(e),a,p,m),r.setAttribute("aria-label",[e.label,t(e,g,c?"Unresolved; no swatch available":"")].filter(Boolean).join(" · ")),r}function g(e){let t=e.getRootNode();if((t instanceof ShadowRoot||t===document)&&!s.has(t)){s.add(t);let e=l("style");e.textContent=o+".palette-tokens{display:flex;flex-direction:column;overflow:hidden}.palette-tokens__head{flex:none;display:flex;align-items:center;gap:4px;min-height:36px;padding:0 12px;color:#f1efeb;font-weight:500}.palette-tokens__back{display:grid;place-items:center;width:20px;height:20px;margin-left:-6px;padding:0;border:0;border-radius:5px;background:none;color:#898680;cursor:pointer}.palette-tokens__back:hover{background:#ffffff14;color:#f1efeb}.palette-tokens__back svg{width:12px;height:12px;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.palette-tokens__bar{flex:none;display:flex;gap:4px;padding:0 8px 8px;background:#232323;border-bottom:1px solid #ffffff0d}.palette-tokens__bar input{flex:1;min-width:0;height:28px;box-sizing:border-box;margin:0;padding:0 8px;border:0;border-radius:6px;outline:0;box-shadow:none;background:#ffffff0a;color:#f1efeb;font:inherit}.palette-tokens__bar input:focus{outline:0;box-shadow:inset 0 0 0 1px #bda6ef}.palette-tokens__widen{flex:none;height:28px;margin:0 4px 4px;padding:0 8px;border:0;border-radius:6px;background:none;color:#898680;font:inherit;text-align:left;cursor:pointer}.palette-tokens__widen:hover,.palette-tokens__more:hover{background:#ffffff0f;color:#f1efeb}.palette-tokens__more{flex:none;display:flex;align-items:center;gap:8px;min-height:36px;padding:0 12px;border:0;border-top:1px solid #ffffff0d;background:none;color:#d9d6d1;font:inherit;text-align:left;cursor:pointer}.palette-tokens__more b{margin-right:auto;font-weight:500}.palette-tokens__more i{flex:none;width:14px;height:14px;border-radius:3px;box-shadow:inset 0 0 0 1px #ffffff26;background:linear-gradient(var(--c),var(--c)),repeating-conic-gradient(#ffffff40 0 25%,#ffffff12 0 50%) 0 0/8px 8px}.palette-tokens__more span{max-width:50%;overflow:hidden;color:#898680;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}.palette-tokens [role=listbox]{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:0 4px 4px}.palette-tokens small:not(.palette-select *){position:sticky;top:0;z-index:1;display:block;padding:8px 8px 4px;background:#232323;color:#77736f;font-size:10px;font-weight:500}.palette-tokens [role=option]:not(.palette-select *){display:grid;grid-template-columns:20px minmax(0,1fr) 14px;align-items:center;gap:4px 8px;box-sizing:border-box;min-height:32px;padding:6px 8px;border-radius:7px;cursor:pointer}.palette-tokens [data-active]{background:#ffffff14;color:#f1efeb}.palette-tokens [aria-selected=true] .palette-tokens__name{color:#e6dcfb}.palette-tokens__name{grid-column:2;min-width:0;font-weight:500}.palette-tokens__name>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.palette-tokens__sub{grid-column:2/4;display:none;min-width:0;overflow:hidden;color:#77736f;font-size:10px;text-overflow:ellipsis;white-space:nowrap}.palette-tokens [data-active] .palette-tokens__sub{display:block}.palette-tokens__check{grid-column:3;justify-self:center}.palette-tokens [aria-selected=true] .palette-tokens__check{width:7px;height:3.5px;margin-top:-3px;border:solid #bda6ef;border-width:0 0 1.5px 1.5px;rotate:-45deg}.palette-tokens__pv{display:flex;align-items:center;height:16px;overflow:hidden}.palette-tokens__sw{display:flex;width:16px;height:16px;border-radius:4px;overflow:hidden;background:repeating-conic-gradient(#ffffff40 0 25%,#ffffff0d 0 50%) 0 0/8px 8px;outline:1px solid #ffffff1f;outline-offset:-1px}.palette-tokens__sw>span{flex:1}.palette-tokens__sw>[data-unresolved]{display:grid;place-items:center;background:#393939;color:#b6b1aa;font-size:10px}.palette-tokens__dim{height:4px;min-width:2px;border-radius:2px;background:#bda6ef}.palette-tokens__corner{width:12px;height:12px;box-sizing:border-box;border:solid #bda6ef;border-width:1.5px 0 0 1.5px}.palette-tokens__shadow{width:16px;height:12px;margin-left:2px;border-radius:3px;background:#f1efeb}.palette-tokens__ag{color:#f1efeb;font-size:13px;line-height:1;white-space:nowrap}.palette-tokens__empty{padding:12px 8px;color:#77736f}@media (pointer:coarse){.palette-tokens{font-size:13px}.palette-tokens [role=option]:not(.palette-select *){min-height:44px}.palette-tokens__bar input,.palette-tokens__bar button{height:36px}}.palette-tokens__custom{display:flex;flex:1 1 auto;flex-direction:column;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}.palette-tokens__custom>.palette-custom{flex:none}.palette-tokens__custom .palette-custom__body{overflow:visible}.palette-tokens [hidden]{display:none!important}.palette-tokens button:focus-visible,.palette-tokens [role=listbox]:focus-visible{outline:1px solid #bda6ef;outline-offset:-2px}.palette-tokens[popover]{position:fixed;inset:auto;margin:0;border:0;padding:0}",(t instanceof ShadowRoot?t:document.head).append(e)}return t}function m(e,t){r?.trigger===e&&r.refresh(t)}function b(t,o=!1){let s=t.trigger.dataset.start;if(delete t.trigger.dataset.start,o&&r?.trigger===t.trigger)return r.close(!0);r?.close();let{trigger:f,property:u}=t,m=t.tokens,b=g(f),x="palette-tokens-"+ ++p,k=/color|^(fill|stroke)$/.test(u),v=l("div","palette-tokens");v.id=`${x}-popup`,v.setAttribute("role","dialog"),v.setAttribute("aria-label",`Edit ${u}`);let _=l("div","palette-tokens__head"),w=l("button","palette-tokens__back");w.type="button",w.setAttribute("aria-label","Back to tokens"),w.innerHTML='<svg viewBox="0 0 12 12" aria-hidden="true"><path d="M7.5 2.5 4 6l3.5 3.5"/></svg>';let y=l("span","",t.title||t.custom?.field?.label||a[u]||u);_.append(w,y);let A=l("div","palette-tokens__bar"),E=l("input");E.type="text",E.placeholder="Search tokens",E.autocomplete="off",E.spellcheck=!1,E.setAttribute("role","combobox"),E.setAttribute("aria-expanded","true"),E.setAttribute("aria-controls",x),E.setAttribute("aria-autocomplete","list"),E.setAttribute("aria-label",`Search tokens for ${u}`);let $=l("div","palette-tokens__list");$.id=x,$.tabIndex=0,$.setAttribute("role","listbox"),$.setAttribute("aria-label",`Tokens for ${u}`);let C=e(m,u),S=!C.length,L=l("button","palette-tokens__widen");L.type="button",A.append(E);let M=l("button","palette-tokens__more");M.type="button";let T=l("i"),H=l("span");M.append(l("b","","Custom…"),T,H);let P=l("div","palette-tokens__custom");v.append(_,A,$,L,M),t.custom&&v.append(P);let j,z,B,K,N=()=>new Map(m.map(e=>[e,`${d(e)} ${e.path} ${e.ref??""} ${e.value??""}`.toLowerCase()])),R=N(),I=[],U=[],F=0,D=-1,O=$,W=-1,q=!1,G=!1,V=!1,X=()=>{let e=z;z=void 0,W=-1,e?.()},Y=e=>{X(),B=e,z=t.custom?.onPreview(e)},J=()=>{W<0||(X(),void 0!==B&&Y(B))},Z=()=>!t.custom||!!C.length,Q=()=>{let e=Z()&&!V,o=S||E.value?m:C;$.hidden=A.hidden=!e,E.hidden=!e||!G&&o.length<=8&&!E.value,A.hidden||=E.hidden,L.hidden=!e||!!E.value||!C.length||C.length===m.length,L.textContent=S?"Show relevant tokens":`Show all ${m.length} tokens`,L.setAttribute("aria-pressed",String(S)),M.hidden=!e||!t.custom,P.hidden=e,w.hidden=!V||!Z(),y.textContent=V&&Z()?k?"Custom colour":"Custom value":t.title||t.custom?.field?.label||a[u]||u,v.toggleAttribute("data-custom",!e);let n=t.custom?.value??"",i=/^rgba?\((\d+)[ ,]+(\d+)[ ,]+(\d+)(?:[ ,/]+([\d.]+))?/.exec(n);H.textContent=k?i?i.slice(1,4).map(e=>Number(e).toString(16).padStart(2,"0")).join("").toUpperCase()+(i[4]&&+i[4]<1?` ${Math.round(100*+i[4])}%`:""):n.replace(/^#/,"").toUpperCase():n,T.hidden=!k||!n,T.style.setProperty("--c",n),M.title=n},ee=e=>{for(;F<Math.min(e,U.length);F++){let{token:e,group:o}=U[F];if(o!==j&&(j=o,O=$,o)){O=l("div"),O.setAttribute("role","group");let e=l("small");e.id=`${x}-g${F}`,e.textContent=o,O.setAttribute("aria-labelledby",e.id),O.append(e),$.append(O)}O.append(h(e,`${x}-${F}`,e.path===t.current,I))}},te=e=>$.querySelector(`#${x}-${e}`),oe=(e,o=!0,n=!0)=>{if(e<0||e>=U.length)return;if(e!==W&&n){X(),W=e;let o=U[e].token;o.path!==t.current&&(z=t.onPreview?.(o))}ee(e+60),te(D)?.removeAttribute("data-active"),D=e;let i=te(e);if(i.toggleAttribute("data-active",!0),E.setAttribute("aria-activedescendant",i.id),$.setAttribute("aria-activedescendant",i.id),!o)return;let l=i.offsetTop-(i.parentElement===$?0:i.parentElement.firstElementChild.offsetHeight),r=i.offsetTop+i.offsetHeight;l<$.scrollTop?$.scrollTop=l-4:r>$.scrollTop+$.clientHeight&&($.scrollTop=r-$.clientHeight+4)},ne=(e=!1,t=!1)=>{let o=t?U[D]?.token.path:void 0,n=$.scrollTop,i=t?F:60;W>=0&&X();let r=E.value.toLowerCase().split(/\s+/).filter(Boolean),a=S||r.length?m:C,s=r.length?a.filter(e=>r.every(t=>R.get(e).includes(t))):a,p=S?s:[...s.filter(e=>C.includes(e)),...s.filter(e=>!C.includes(e))],d=new Map([["",[]]]);for(let e of p){let t=e.group??"";d.set(t,[...d.get(t)??[],e])}if(U=[...[...d].flatMap(([e,t])=>t.map(t=>({token:t,group:e})))],$.replaceChildren(),$.scrollTop=0,F=0,D=-1,j=void 0,E.removeAttribute("aria-activedescendant"),$.removeAttribute("aria-activedescendant"),Q(),!U.length){let e=l("div","palette-tokens__empty",r.length?"No matching tokens":"No tokens");return void $.append(e)}ee(i),oe(Math.max(0,U.findIndex(e=>e.token.path===o)),!1,e),t&&($.scrollTop=n)},ie=new AbortController,{signal:le}=ie,re=!!globalThis.matchMedia?.("(pointer:coarse)")?.matches;function ae(e=!1,o=!1){if(r?.close!==ae)return;r=void 0;let n=K?.live&&B;X(),n&&!o&&(t.custom?.onCommit??t.custom?.onSelect)?.(n),t.custom?.[o?"onCancel":"onDone"]?.(),ie.abort(),K?.destroy(),v.remove(),f.setAttribute("aria-expanded","false"),f.removeAttribute("aria-controls"),e&&f.isConnected&&f.focus({preventScroll:!0})}r={trigger:f,close:ae,refresh(o){if(!o)return q||=W>=0,X();let n=q||W>=0;q=!1,t=o,m=o.tokens,C=e(m,u),R=N(),I=[],ne(n&&!V,!0),t.current&&t.custom&&K?.refresh(t.custom.value),W<0&&!z&&void 0!==B&&Y(B),ve()}};let se=e=>{X(),B=void 0,t.custom?.onCancel?.(),ae(!0),e.path!==t.current&&t.onSelect(e)},pe=t.custom?k?import("./color-editor-GCCLM3TV.js"):import("./token-custom-CPPHGYMJ.js"):void 0;function de(e,o=!re){J(),V=e,Q(),ge="",me(),V?async function(e){let o=await pe;if(r?.close!==ae)return;K||(K=o.pickerEditor(t,{preview:Y,commit(e){if(!t.custom?.onCommit)return Y(e);X(),B=void 0,t.custom.onCommit(e)},token:se,hover(e){X(),void 0!==e?z=t.custom?.onPreview(e):void 0!==B&&Y(B)}}),P.append(K)),ge="",me();let n=!!v.getClientRects().length,i=[...v.querySelectorAll("input,select,summary,button")].filter(e=>(!n||e.getClientRects().length)&&!e.closest("[hidden]")&&!e.matches("details:not([open]) :not(summary)"));e&&(i.find(e=>e instanceof HTMLInputElement&&P.contains(e))??i[0])?.focus({preventScroll:!0})}(o):o&&(E.hidden?M:E).focus({preventScroll:!0})}let ce=e=>{let t=U[e]?.token;t&&se(t)};M.addEventListener("click",()=>de(!0),{signal:le}),w.addEventListener("click",()=>de(!1),{signal:le}),E.addEventListener("input",()=>ne(!0),{signal:le}),L.addEventListener("click",()=>{S=!S,ne(!0),re||(E.hidden?$:E).focus({preventScroll:!0})},{signal:le}),addEventListener("keydown",e=>{if(!f.isConnected)return ae();let t=e.composedPath();if(!t.includes(v)&&!t.includes(f))return;let{key:o}=e,n={ArrowDown:1,ArrowUp:-1,PageDown:8,PageUp:-8}[o];if(!(e.ctrlKey||e.metaKey||e.altKey||"Escape"===o&&t[0]instanceof HTMLSelectElement&&t[0]!==f&&"true"===t[0].getAttribute("aria-expanded"))){if("Escape"===o)ae(!0,!0);else if("Tab"===o){let o=[...v.querySelectorAll("button,input,select,summary,[tabindex='0']")].filter(e=>!e.closest("[hidden]")&&!e.matches("details:not([open]) :not(summary)")&&e.getClientRects().length);if(t[0]!==o[e.shiftKey?0:o.length-1])return;o[e.shiftKey?o.length-1:0]?.focus()}else if(t[0]===M&&"ArrowUp"===o&&U.length)$.focus({preventScroll:!0}),oe(U.length-1);else{if($.hidden||t[0]!==E&&t[0]!==f&&t[0]!==$)return;if(n>0&&t[0]===$&&D===U.length-1&&!M.hidden)J(),M.focus({preventScroll:!0});else if(n)oe(c(D+n,0,U.length-1));else if("Home"!==o&&"End"!==o||t[0]===E)if("Enter"===o)ce(D);else{if(t[0]!==$||1!==o.length||" "===o)return;G=!0,E.value+=o,ne(!0),E.focus({preventScroll:!0})}else oe("Home"===o?0:U.length-1)}e.preventDefault(),e.stopImmediatePropagation()}},{capture:!0,signal:le}),addEventListener("pointerdown",e=>{let t=e.composedPath();!t.includes(v)&&!t.includes(f)&&ae()},{capture:!0,signal:le}),addEventListener("focusin",e=>{let t=e.composedPath();!t.includes(v)&&!t.includes(f)&&ae()},{capture:!0,signal:le});let fe=e=>{e.target===$?$.scrollTop+$.clientHeight>$.scrollHeight-200&&ee(F+60):e.target instanceof Node&&v.contains(e.target)||ae()};addEventListener("scroll",fe,{capture:!0,signal:le}),b.addEventListener("scroll",fe,{capture:!0,signal:le}),addEventListener("resize",()=>ae(),{signal:le}),i(f,()=>ae(),le),$.addEventListener("mousedown",e=>e.preventDefault(),{signal:le});let ue=e=>{let t=e.target.closest?.("[role=option]");return t&&$.contains(t)?Number(t.id.slice(x.length+1)):-1};$.addEventListener("pointermove",e=>{let t=ue(e);t>=0&&oe(t,!1)},{signal:le}),$.addEventListener("pointerleave",J,{signal:le}),M.addEventListener("focusin",J,{signal:le}),P.addEventListener("focusin",J,{signal:le}),v.addEventListener("click",e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLSelectElement||e.target instanceof HTMLButtonElement||e.preventDefault();let t=ue(e);t>=0&&ce(t)},{signal:le}),ne();let he=f.closest(".design-field")??f.parentElement;v.popover="manual",he.append(v),v.showPopover?.(),he.addEventListener("palette-field-sync",()=>{z||!t.custom||(K?.refresh(t.custom.value),Q())},{signal:le}),f.setAttribute("aria-expanded","true"),f.setAttribute("aria-controls",v.id);let ge="",me=()=>{let e=he.getBoundingClientRect();if(ge===`${e.left} ${e.top}`)return;ge=`${e.left} ${e.top}`;let t=n(he),o=c(t.right-t.left-8,120,256),i=innerHeight-e.bottom-12,l=e.top-12;v.style.maxHeight="";let r=i<Math.min(460,Math.max(v.scrollHeight,200))&&l>i,a=Math.min(460,innerHeight-16,Math.max(r?l:i,200));v.style.width=`${o}px`,v.style.maxHeight=`${a}px`,v.style.left=`${c(e.left,t.left+4,t.right-o-4)}px`,v.style.top=r?"":`${Math.min(e.bottom+4,innerHeight-8-a)}px`,v.style.bottom=r?`${Math.min(innerHeight-e.top+4,innerHeight-8-a)}px`:"",v.toggleAttribute("data-up",r)};me();let be=new MutationObserver(me);be.observe(b,{attributes:!0,childList:!0,subtree:!0}),le.addEventListener("abort",()=>be.disconnect());let xe=U.findIndex(e=>e.token.path===t.current);xe>=0&&oe(xe,!0,!1),!Z()||"custom"===s&&t.custom?de(!0):re||(E.hidden?$:E).focus({preventScroll:!0,focusVisible:!1});let ke=0;function ve(){let e=++ke;Promise.resolve(t.themes?.()).then(t=>{!t||t.length<2||r?.close!==ae||e!==ke||(I=t,$.hidden||ne(W>=0,!0))},()=>{})}return ve(),()=>ae()}export{b as openTokenPicker,m as refreshTokenPicker,g as stylePicker,d as tokenLabel,f as tokenPreview};
|
package/dist/types.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export interface Comment {
|
|
|
36
36
|
id: string;
|
|
37
37
|
body: string;
|
|
38
38
|
author: Identity;
|
|
39
|
+
/** Display name of the personal access key that posted this comment. */
|
|
40
|
+
apiKeyName?: string;
|
|
41
|
+
/** Authenticated URL for an image the author attached. */
|
|
42
|
+
image?: string;
|
|
39
43
|
createdAt: number;
|
|
40
44
|
editedAt: number | null;
|
|
41
45
|
reactions: Record<string, string[]>;
|
package/package.json
CHANGED
package/server/bot-tokens.ts
CHANGED
|
@@ -31,8 +31,12 @@ export async function authenticateBotToken(env: Env, bearer: string, project: st
|
|
|
31
31
|
const stored = row?.token_hash ?? "0".repeat(64);
|
|
32
32
|
check(row && stored.length === given.length && timingSafeEqual(new TextEncoder().encode(stored), new TextEncoder().encode(given)) && row.revoked_at === null && row.project === project, 401, "Invalid or revoked bot token.");
|
|
33
33
|
const path = new URL(request.url).pathname;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const comments = /^\/threads\/[^/]+\/comments(?:\/[^/]+\/(image|reactions))?$/;
|
|
35
|
+
const action = comments.exec(path);
|
|
36
|
+
const read = request.method === "GET" && (path === "/threads" || path === "/me" || path === "/config" ||
|
|
37
|
+
/^\/threads\/[^/]+\/snapshot(?:\/image)?$/.test(path) || action?.[1] === "image");
|
|
38
|
+
const write = (request.method === "POST" && action && action[1] !== "image") ||
|
|
39
|
+
(request.method === "PUT" && action?.[1] === "image");
|
|
40
|
+
check(access && (read || write), 403, "Bot tokens may read threads, reply, attach reply images and react.");
|
|
37
41
|
return row;
|
|
38
42
|
}
|