@pure-ds/core 0.7.16 → 0.7.18
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/.cursorrules +22 -11
- package/.github/copilot-instructions.md +22 -11
- package/custom-elements.json +38 -0
- package/dist/types/pds.d.ts +0 -1
- package/dist/types/public/assets/js/pds-manager.d.ts +44 -44
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-form.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-omnibox.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-treeview.d.ts +9 -0
- package/dist/types/public/assets/pds/components/pds-treeview.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-runtime.d.ts.map +1 -1
- package/package.json +1 -1
- package/packages/pds-cli/bin/pds-mcp-health.js +2 -1
- package/packages/pds-cli/lib/pds-mcp-core.js +95 -3
- package/packages/pds-cli/lib/pds-mcp-eval-cases.json +13 -0
- package/public/assets/js/app.js +4 -4
- package/public/assets/js/pds-manager.js +144 -162
- package/public/assets/js/pds.js +2 -2
- package/public/assets/pds/components/pds-calendar.js +19 -11
- package/public/assets/pds/components/pds-form.js +85 -2
- package/public/assets/pds/components/pds-omnibox.js +9 -6
- package/public/assets/pds/components/pds-treeview.js +321 -24
- package/public/assets/pds/core/pds-manager.js +144 -162
- package/public/assets/pds/core.js +2 -2
- package/public/assets/pds/vscode-custom-data.json +4 -0
- package/readme.md +12 -59
- package/src/js/pds-core/pds-generator.js +7 -7
- package/src/js/pds-core/pds-live.js +1 -13
- package/src/js/pds-core/pds-ontology.js +2 -2
- package/src/js/pds-core/pds-runtime.js +18 -2
- package/src/js/pds.d.ts +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var De=Object.defineProperty;var Pe=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})};var Y=class{constructor(){this._mode="static",this._staticPaths={tokens:"/assets/pds/styles/pds-tokens.css.js",primitives:"/assets/pds/styles/pds-primitives.css.js",components:"/assets/pds/styles/pds-components.css.js",utilities:"/assets/pds/styles/pds-utilities.css.js",styles:"/assets/pds/styles/pds-styles.css.js"}}setLiveMode(){this._mode="live"}setStaticMode(t={}){this._mode="static",this._staticPaths={...this._staticPaths,...t}}async getStylesheet(t){if(this._mode==="live")return null;try{return(await import(this._staticPaths[t]))[t]}catch(n){console.error(`[PDS Registry] Failed to load static ${t}:`,n),console.error(`[PDS Registry] Looking for: ${this._staticPaths[t]}`),console.error("[PDS Registry] Make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let r=new CSSStyleSheet;return r.replaceSync("/* Failed to load "+t+" */"),r}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},M=new Y;async function ue(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await M.getStylesheet("primitives");e.adoptedStyleSheets=[r,...t]}catch(r){let c=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${c}> failed to adopt primitives:`,r),e.adoptedStyleSheets=t}}async function de(e,t=["primitives"],n=[],r=null){try{let s=(await Promise.all(t.map(async l=>{if(r)switch(l){case"tokens":return r.tokensStylesheet;case"primitives":return r.primitivesStylesheet;case"components":return r.componentsStylesheet;case"utilities":return r.utilitiesStylesheet;default:break}return M.getStylesheet(l)}))).filter(l=>l!==null);e.adoptedStyleSheets=[...s,...n]}catch(c){let s=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${s}> failed to adopt layers:`,c),e.adoptedStyleSheets=n}}function pe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var fe={FontWeights:{light:300,normal:400,medium:500,semibold:600,bold:700},LineHeights:{tight:1.25,normal:1.5,relaxed:1.75},BorderWidths:{hairline:.5,thin:1,medium:2,thick:3},RadiusSizes:{none:0,small:4,medium:8,large:16,xlarge:24,xxlarge:32},ShadowDepths:{none:"none",light:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",medium:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",deep:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",extreme:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},TransitionSpeeds:{fast:150,normal:250,slow:350},AnimationEasings:{linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},TouchTargetSizes:{compact:36,standard:44,comfortable:48,spacious:56},LinkStyles:{inline:"inline",block:"block",button:"button"},FocusStyles:{ring:"ring",outline:"outline",border:"border",glow:"glow"},TabSizes:{compact:2,standard:4,wide:8},SelectIcons:{chevron:"chevron",arrow:"arrow",caret:"caret",none:"none"},IconSizes:{xs:16,sm:20,md:24,lg:32,xl:48,"2xl":64,"3xl":96}};var ee={};Pe(ee,{deepMerge:()=>me,fragmentFromTemplateLike:()=>Me,isObject:()=>I,parseHTML:()=>Z});function I(e){return e&&typeof e=="object"&&!Array.isArray(e)}function me(e,t){let n={...e};return I(e)&&I(t)&&Object.keys(t).forEach(r=>{I(t[r])?r in e?n[r]=me(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function Me(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],r=new Set,c=[],s=/(\s)(\.[\w-]+)=\s*$/;for(let a=0;a<t.length;a+=1){let w=t[a]??"",m=w.match(s);if(m&&a<n.length){let S=m[2].slice(1),L=`pds-val-${a}`;w=w.replace(s,`$1data-pds-prop="${S}:${L}"`),r.add(a)}c.push(w),a<n.length&&!r.has(a)&&c.push(`<!--pds-val-${a}-->`)}let l=document.createElement("template");l.innerHTML=c.join("");let g=(a,w)=>{let m=a.parentNode;if(!m)return;if(w==null){m.removeChild(a);return}let E=S=>{if(S!=null){if(S instanceof Node){m.insertBefore(S,a);return}if(Array.isArray(S)){S.forEach(L=>E(L));return}m.insertBefore(document.createTextNode(String(S)),a)}};E(w),m.removeChild(a)},b=document.createTreeWalker(l.content,NodeFilter.SHOW_COMMENT),h=[];for(;b.nextNode();){let a=b.currentNode;a?.nodeValue?.startsWith("pds-val-")&&h.push(a)}return h.forEach(a=>{let w=Number(a.nodeValue.replace("pds-val-",""));g(a,n[w])}),l.content.querySelectorAll("*").forEach(a=>{let w=a.getAttribute("data-pds-prop");if(!w)return;let[m,E]=w.split(":"),S=Number(String(E).replace("pds-val-",""));m&&Number.isInteger(S)&&(a[m]=n[S]),a.removeAttribute("data-pds-prop")}),l.content}function Z(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var ye="pds",ke=/^([a-z][a-z0-9+\-.]*:)?\/\//i,he=/^[a-z]:/i;function U(e=""){return e.endsWith("/")?e:`${e}/`}function Te(e="",t=ye){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function Ue(e){return e.replace(/^\.\/+/,"")}function Ce(e){return he.test(e)?e.replace(he,"").replace(/^\/+/,""):e}function je(e){return e.startsWith("public/")?e.substring(7):e}function N(e,t={}){let n=t.segment||ye,r=t.defaultRoot||`/assets/${n}/`,c=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!c||typeof c!="string")return U(r);let s=c.trim();return s?(s=s.replace(/\\/g,"/"),s=Te(s,n),s=U(s),ke.test(s)?s:(s=Ue(s),s=Ce(s),s.startsWith("/")||(s=je(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,g)=>g===0?l:"/")),U(s))):U(r)}async function $e(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:r,mapper:c=h=>`${h}.js`,onError:s=(h,i)=>console.error(`[defineWebComponents] ${h}:`,i)}=t,l=r?new URL(r,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),g=h=>h.toLowerCase().replace(/(^|-)([a-z])/g,(i,a,w)=>w.toUpperCase()),b=async h=>{try{if(customElements.get(h))return{tag:h,status:"already-defined"};let i=c(h),w=await import(i instanceof URL?i.href:new URL(i,l).href),m=w?.default??w?.[g(h)];if(!m){if(customElements.get(h))return{tag:h,status:"self-defined"};throw new Error(`No export found for ${h}. Expected default export or named export "${g(h)}".`)}return customElements.get(h)?{tag:h,status:"race-already-defined"}:(customElements.define(h,m),{tag:h,status:"defined"})}catch(i){throw s(h,i),i}};return Promise.all(n.map(b))}var z=class{constructor(t={}){let{baseURL:n,mapper:r,onError:c,predicate:s=()=>!0,attributeModule:l="data-module",root:g=document,scanExisting:b=!0,debounceMs:h=16,observeShadows:i=!0,enhancers:a=[],patchAttachShadow:w=!0}=t,m=new Set,E=new Set,S=new Set,L=new Map,R=new WeakMap,_=new WeakMap,p=0,y=!1,A=null,O=u=>{if(!u||!a.length)return;let f=_.get(u);f||(f=new Set,_.set(u,f));for(let d of a)if(!(!d.selector||!d.run)&&!f.has(d.selector))try{u.matches&&u.matches(d.selector)&&(d.run(u),f.add(d.selector))}catch(v){console.warn(`[AutoDefiner] Error applying enhancer for selector "${d.selector}":`,v)}},T=(u,f)=>{if(!y&&!(!u||!u.includes("-"))&&!customElements.get(u)&&!E.has(u)&&!S.has(u)){if(f&&f.getAttribute){let d=f.getAttribute(l);d&&!L.has(u)&&L.set(u,d)}m.add(u),xe()}},xe=()=>{p||(p=setTimeout(ie,h))},D=u=>{if(u){if(u.nodeType===1){let f=u,d=f.tagName?.toLowerCase();d&&d.includes("-")&&!customElements.get(d)&&s(d,f)&&T(d,f),O(f),i&&f.shadowRoot&&X(f.shadowRoot)}u.querySelectorAll&&u.querySelectorAll("*").forEach(f=>{let d=f.tagName?.toLowerCase();d&&d.includes("-")&&!customElements.get(d)&&s(d,f)&&T(d,f),O(f),i&&f.shadowRoot&&X(f.shadowRoot)})}},X=u=>{if(!u||R.has(u))return;D(u);let f=new MutationObserver(d=>{for(let v of d)v.addedNodes?.forEach(P=>{D(P)}),v.type==="attributes"&&v.target&&D(v.target)});f.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...a.map(d=>d.selector).filter(d=>d.startsWith("data-"))]}),R.set(u,f)};async function ie(){if(clearTimeout(p),p=0,!m.size)return;let u=Array.from(m);m.clear(),u.forEach(f=>E.add(f));try{let f=d=>L.get(d)??(r?r(d):`${d}.js`);await $e(...u,{baseURL:n,mapper:f,onError:(d,v)=>{S.add(d),c?.(d,v)}})}catch{}finally{u.forEach(f=>E.delete(f))}}let ce=g===document?document.documentElement:g,le=new MutationObserver(u=>{for(let f of u)f.addedNodes?.forEach(d=>{D(d)}),f.type==="attributes"&&f.target&&D(f.target)});if(le.observe(ce,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...a.map(u=>u.selector).filter(u=>u.startsWith("data-"))]}),i&&w&&Element.prototype.attachShadow){let u=Element.prototype.attachShadow;Element.prototype.attachShadow=function(d){let v=u.call(this,d);if(d&&d.mode==="open"){X(v);let P=this.tagName?.toLowerCase();P&&P.includes("-")&&!customElements.get(P)&&T(P,this)}return v},A=()=>Element.prototype.attachShadow=u}return b&&D(ce),{stop(){y=!0,le.disconnect(),A&&A(),p&&(clearTimeout(p),p=0),R.forEach(u=>u.disconnect())},flush:ie}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let r=t,{baseURL:c,mapper:s=i=>`${i}.js`,onError:l=(i,a)=>console.error(`[defineWebComponents] ${i}:`,a)}=n,g=c?new URL(c,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),b=i=>i.toLowerCase().replace(/(^|-)([a-z])/g,(a,w,m)=>m.toUpperCase()),h=async i=>{try{if(customElements.get(i))return{tag:i,status:"already-defined"};let a=s(i),m=await import(a instanceof URL?a.href:new URL(a,g).href),E=m?.default??m?.[b(i)];if(!E){if(customElements.get(i))return{tag:i,status:"self-defined"};throw new Error(`No export found for ${i}. Expected default export or named export "${b(i)}".`)}return customElements.get(i)?{tag:i,status:"race-already-defined"}:(customElements.define(i,E),{tag:i,status:"defined"})}catch(a){throw l(i,a),a}};return Promise.all(r.map(h))}};var Oe=/^[a-z][a-z0-9+\-.]*:\/\//i,C=(()=>{try{return import.meta.url}catch{return}})(),F=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function W(e,t={}){if(!e||Oe.test(e))return e;let{preferModule:n=!0}=t,r=()=>{if(!C)return null;try{return new URL(e,C).href}catch{return null}},c=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?r()||c():c()||r())||e}var we=(()=>{if(C)try{let e=new URL(C);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",C).href}catch{return}})(),Se=!1;function ge(e){Se||typeof document>"u"||(Se=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function Ee({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:r}){let c="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),r?.(s)}catch{}s?s==="system"?c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c=s:c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:c,storedTheme:s}}function B(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&we&&(r=we),F(W(r))}async function be(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:r=[],autoDefineMapper:c=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:g=!0}=e,b=(()=>{let i=new Map;return(t||[]).forEach(a=>i.set(a.selector,a)),(s||[]).forEach(a=>i.set(a.selector,a)),Array.from(i.values())})(),h=null;if(typeof window<"u"&&typeof document<"u"){let i=z,a=p=>{switch(p){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${p}.js`}},{mapper:w,enhancers:m,...E}=l&&typeof l=="object"?l:{},S=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],L=(()=>{let p=new Map;return(b||[]).forEach(y=>{y?.selector&&p.set(y.selector,y)}),(S||[]).forEach(y=>{if(!y?.selector)return;let A=p.get(y.selector)||null;p.set(y.selector,{...A||{},...y,run:typeof y?.run=="function"?y.run:A?.run})}),Array.from(p.values())})(),_={baseURL:n&&F(W(n,{preferModule:g})),predefine:r,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:L,onError:(p,y)=>{if(typeof p=="string"&&p.startsWith("pds-")){let O=["pds-form","pds-drawer"].includes(p),T=y?.message?.includes("#pds/lit")||y?.message?.includes("Failed to resolve module specifier");O&&T?console.error(`\u274C PDS component <${p}> requires Lit but #pds/lit is not in import map.
|
|
2
|
-
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):console.warn(`\u26A0\uFE0F PDS component <${p}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${p}>:`,y)},...E,mapper:p=>{if(customElements.get(p))return null;if(typeof c=="function")try{let y=c(p);return y===void 0?a(p):y}catch(y){return console.warn("Custom autoDefine.mapper error; falling back to default:",y?.message||y),a(p)}return a(p)}};h=new i(_),r.length>0&&typeof i.define=="function"&&await i.define(...r,{baseURL:n,mapper:_.mapper,onError:_.onError})}return{autoDefiner:h,mergedEnhancers:b}}var te=["light","dark"],ne=new Set(te);function Ie(e){let n=(Array.isArray(e?.themes)?e.themes.map(r=>String(r).toLowerCase()):te).filter(r=>ne.has(r));return n.length?n:te}function re(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(ne.has(n))return n;if(t&&typeof document<"u"){let r=document.documentElement?.getAttribute("data-theme");if(ne.has(r))return r}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Le(e,t){let n=re(t);return Ie(e).includes(n)}var oe=class extends EventTarget{},o=new oe;o.initializing=!1;o.currentPreset=null;o.debug=!1;var q=null,V=null,H=null,K=null;function G(e,t){return t&&typeof t=="string"?t:`${B(o.currentConfig||{},{resolvePublicAssetURL:N})}core/${e}`}async function Ne(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(K||(K=import(G("pds-enhancers.js",o.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return o.defaultEnhancers=n,n}).catch(t=>{throw K=null,t})),K)}async function ze(){return typeof o.ask=="function"&&o.ask!==
|
|
1
|
+
var De=Object.defineProperty;var Pe=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})};var Y=class{constructor(){this._mode="static",this._staticPaths={tokens:"/assets/pds/styles/pds-tokens.css.js",primitives:"/assets/pds/styles/pds-primitives.css.js",components:"/assets/pds/styles/pds-components.css.js",utilities:"/assets/pds/styles/pds-utilities.css.js",styles:"/assets/pds/styles/pds-styles.css.js"}}setLiveMode(){this._mode="live"}setStaticMode(t={}){this._mode="static",this._staticPaths={...this._staticPaths,...t}}async getStylesheet(t){if(this._mode==="live")return null;try{return(await import(this._staticPaths[t]))[t]}catch(n){console.error(`[PDS Registry] Failed to load static ${t}:`,n),console.error(`[PDS Registry] Looking for: ${this._staticPaths[t]}`),console.error("[PDS Registry] Make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let r=new CSSStyleSheet;return r.replaceSync("/* Failed to load "+t+" */"),r}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},M=new Y;async function de(e,t=[],n=null){try{let r=n?.primitivesStylesheet?n.primitivesStylesheet:await M.getStylesheet("primitives");e.adoptedStyleSheets=[r,...t]}catch(r){let c=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${c}> failed to adopt primitives:`,r),e.adoptedStyleSheets=t}}async function ue(e,t=["primitives"],n=[],r=null){let c=Array.isArray(n)?n.filter(Boolean):[];if(c.length){let l=(Array.isArray(e.adoptedStyleSheets)?e.adoptedStyleSheets:[]).filter(w=>!c.includes(w));e.adoptedStyleSheets=[...l,...c]}try{let l=(await Promise.all(t.map(async w=>{if(r)switch(w){case"tokens":return r.tokensStylesheet;case"primitives":return r.primitivesStylesheet;case"components":return r.componentsStylesheet;case"utilities":return r.utilitiesStylesheet;default:break}return M.getStylesheet(w)}))).filter(w=>w!==null);e.adoptedStyleSheets=[...l,...c]}catch(s){let l=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${l}> failed to adopt layers:`,s),e.adoptedStyleSheets=c}}function pe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var fe={FontWeights:{light:300,normal:400,medium:500,semibold:600,bold:700},LineHeights:{tight:1.25,normal:1.5,relaxed:1.75},BorderWidths:{hairline:.5,thin:1,medium:2,thick:3},RadiusSizes:{none:0,small:4,medium:8,large:16,xlarge:24,xxlarge:32},ShadowDepths:{none:"none",light:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",medium:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",deep:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",extreme:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"},TransitionSpeeds:{fast:150,normal:250,slow:350},AnimationEasings:{linear:"linear",ease:"ease","ease-in":"ease-in","ease-out":"ease-out","ease-in-out":"ease-in-out",bounce:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},TouchTargetSizes:{compact:36,standard:44,comfortable:48,spacious:56},LinkStyles:{inline:"inline",block:"block",button:"button"},FocusStyles:{ring:"ring",outline:"outline",border:"border",glow:"glow"},TabSizes:{compact:2,standard:4,wide:8},SelectIcons:{chevron:"chevron",arrow:"arrow",caret:"caret",none:"none"},IconSizes:{xs:16,sm:20,md:24,lg:32,xl:48,"2xl":64,"3xl":96}};var ee={};Pe(ee,{deepMerge:()=>me,fragmentFromTemplateLike:()=>Me,isObject:()=>I,parseHTML:()=>Z});function I(e){return e&&typeof e=="object"&&!Array.isArray(e)}function me(e,t){let n={...e};return I(e)&&I(t)&&Object.keys(t).forEach(r=>{I(t[r])?r in e?n[r]=me(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}function Me(e){let t=Array.isArray(e?.strings)?e.strings:[],n=Array.isArray(e?.values)?e.values:[],r=new Set,c=[],s=/(\s)(\.[\w-]+)=\s*$/;for(let a=0;a<t.length;a+=1){let S=t[a]??"",m=S.match(s);if(m&&a<n.length){let g=m[2].slice(1),L=`pds-val-${a}`;S=S.replace(s,`$1data-pds-prop="${g}:${L}"`),r.add(a)}c.push(S),a<n.length&&!r.has(a)&&c.push(`<!--pds-val-${a}-->`)}let l=document.createElement("template");l.innerHTML=c.join("");let w=(a,S)=>{let m=a.parentNode;if(!m)return;if(S==null){m.removeChild(a);return}let E=g=>{if(g!=null){if(g instanceof Node){m.insertBefore(g,a);return}if(Array.isArray(g)){g.forEach(L=>E(L));return}m.insertBefore(document.createTextNode(String(g)),a)}};E(S),m.removeChild(a)},b=document.createTreeWalker(l.content,NodeFilter.SHOW_COMMENT),h=[];for(;b.nextNode();){let a=b.currentNode;a?.nodeValue?.startsWith("pds-val-")&&h.push(a)}return h.forEach(a=>{let S=Number(a.nodeValue.replace("pds-val-",""));w(a,n[S])}),l.content.querySelectorAll("*").forEach(a=>{let S=a.getAttribute("data-pds-prop");if(!S)return;let[m,E]=S.split(":"),g=Number(String(E).replace("pds-val-",""));m&&Number.isInteger(g)&&(a[m]=n[g]),a.removeAttribute("data-pds-prop")}),l.content}function Z(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var ye="pds",ke=/^([a-z][a-z0-9+\-.]*:)?\/\//i,he=/^[a-z]:/i;function U(e=""){return e.endsWith("/")?e:`${e}/`}function Te(e="",t=ye){let n=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(n)?n:`${n}/${t}`}function Ue(e){return e.replace(/^\.\/+/,"")}function Ce(e){return he.test(e)?e.replace(he,"").replace(/^\/+/,""):e}function je(e){return e.startsWith("public/")?e.substring(7):e}function N(e,t={}){let n=t.segment||ye,r=t.defaultRoot||`/assets/${n}/`,c=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!c||typeof c!="string")return U(r);let s=c.trim();return s?(s=s.replace(/\\/g,"/"),s=Te(s,n),s=U(s),ke.test(s)?s:(s=Ue(s),s=Ce(s),s.startsWith("/")||(s=je(s),s.startsWith("/")||(s=`/${s}`),s=s.replace(/\/+/g,(l,w)=>w===0?l:"/")),U(s))):U(r)}async function $e(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let n=e,{baseURL:r,mapper:c=h=>`${h}.js`,onError:s=(h,i)=>console.error(`[defineWebComponents] ${h}:`,i)}=t,l=r?new URL(r,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),w=h=>h.toLowerCase().replace(/(^|-)([a-z])/g,(i,a,S)=>S.toUpperCase()),b=async h=>{try{if(customElements.get(h))return{tag:h,status:"already-defined"};let i=c(h),S=await import(i instanceof URL?i.href:new URL(i,l).href),m=S?.default??S?.[w(h)];if(!m){if(customElements.get(h))return{tag:h,status:"self-defined"};throw new Error(`No export found for ${h}. Expected default export or named export "${w(h)}".`)}return customElements.get(h)?{tag:h,status:"race-already-defined"}:(customElements.define(h,m),{tag:h,status:"defined"})}catch(i){throw s(h,i),i}};return Promise.all(n.map(b))}var z=class{constructor(t={}){let{baseURL:n,mapper:r,onError:c,predicate:s=()=>!0,attributeModule:l="data-module",root:w=document,scanExisting:b=!0,debounceMs:h=16,observeShadows:i=!0,enhancers:a=[],patchAttachShadow:S=!0}=t,m=new Set,E=new Set,g=new Set,L=new Map,x=new WeakMap,_=new WeakMap,p=0,y=!1,v=null,O=d=>{if(!d||!a.length)return;let f=_.get(d);f||(f=new Set,_.set(d,f));for(let u of a)if(!(!u.selector||!u.run)&&!f.has(u.selector))try{d.matches&&d.matches(u.selector)&&(u.run(d),f.add(u.selector))}catch(A){console.warn(`[AutoDefiner] Error applying enhancer for selector "${u.selector}":`,A)}},T=(d,f)=>{if(!y&&!(!d||!d.includes("-"))&&!customElements.get(d)&&!E.has(d)&&!g.has(d)){if(f&&f.getAttribute){let u=f.getAttribute(l);u&&!L.has(d)&&L.set(d,u)}m.add(d),Re()}},Re=()=>{p||(p=setTimeout(ie,h))},D=d=>{if(d){if(d.nodeType===1){let f=d,u=f.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&s(u,f)&&T(u,f),O(f),i&&f.shadowRoot&&X(f.shadowRoot)}d.querySelectorAll&&d.querySelectorAll("*").forEach(f=>{let u=f.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&s(u,f)&&T(u,f),O(f),i&&f.shadowRoot&&X(f.shadowRoot)})}},X=d=>{if(!d||x.has(d))return;D(d);let f=new MutationObserver(u=>{for(let A of u)A.addedNodes?.forEach(P=>{D(P)}),A.type==="attributes"&&A.target&&D(A.target)});f.observe(d,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...a.map(u=>u.selector).filter(u=>u.startsWith("data-"))]}),x.set(d,f)};async function ie(){if(clearTimeout(p),p=0,!m.size)return;let d=Array.from(m);m.clear(),d.forEach(f=>E.add(f));try{let f=u=>L.get(u)??(r?r(u):`${u}.js`);await $e(...d,{baseURL:n,mapper:f,onError:(u,A)=>{g.add(u),c?.(u,A)}})}catch{}finally{d.forEach(f=>E.delete(f))}}let ce=w===document?document.documentElement:w,le=new MutationObserver(d=>{for(let f of d)f.addedNodes?.forEach(u=>{D(u)}),f.type==="attributes"&&f.target&&D(f.target)});if(le.observe(ce,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[l,...a.map(d=>d.selector).filter(d=>d.startsWith("data-"))]}),i&&S&&Element.prototype.attachShadow){let d=Element.prototype.attachShadow;Element.prototype.attachShadow=function(u){let A=d.call(this,u);if(u&&u.mode==="open"){X(A);let P=this.tagName?.toLowerCase();P&&P.includes("-")&&!customElements.get(P)&&T(P,this)}return A},v=()=>Element.prototype.attachShadow=d}return b&&D(ce),{stop(){y=!0,le.disconnect(),v&&v(),p&&(clearTimeout(p),p=0),x.forEach(d=>d.disconnect())},flush:ie}}static async define(...t){let n={};t.length&&typeof t[t.length-1]=="object"&&(n=t.pop()||{});let r=t,{baseURL:c,mapper:s=i=>`${i}.js`,onError:l=(i,a)=>console.error(`[defineWebComponents] ${i}:`,a)}=n,w=c?new URL(c,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),b=i=>i.toLowerCase().replace(/(^|-)([a-z])/g,(a,S,m)=>m.toUpperCase()),h=async i=>{try{if(customElements.get(i))return{tag:i,status:"already-defined"};let a=s(i),m=await import(a instanceof URL?a.href:new URL(a,w).href),E=m?.default??m?.[b(i)];if(!E){if(customElements.get(i))return{tag:i,status:"self-defined"};throw new Error(`No export found for ${i}. Expected default export or named export "${b(i)}".`)}return customElements.get(i)?{tag:i,status:"race-already-defined"}:(customElements.define(i,E),{tag:i,status:"defined"})}catch(a){throw l(i,a),a}};return Promise.all(r.map(h))}};var Oe=/^[a-z][a-z0-9+\-.]*:\/\//i,C=(()=>{try{return import.meta.url}catch{return}})(),F=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function W(e,t={}){if(!e||Oe.test(e))return e;let{preferModule:n=!0}=t,r=()=>{if(!C)return null;try{return new URL(e,C).href}catch{return null}},c=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(n?r()||c():c()||r())||e}var we=(()=>{if(C)try{let e=new URL(C);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",C).href}catch{return}})(),Se=!1;function ge(e){Se||typeof document>"u"||(Se=!0,e.addEventListener("pds:ready",t=>{let n=t.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function Ee({manageTheme:e,themeStorageKey:t,applyResolvedTheme:n,setupSystemListenerIfNeeded:r}){let c="light",s=null;if(e&&typeof window<"u"){try{s=localStorage.getItem(t)||null}catch{s=null}try{n?.(s),r?.(s)}catch{}s?s==="system"?c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":c=s:c=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:c,storedTheme:s}}function B(e,{resolvePublicAssetURL:t}){let n=!!(e?.public?.root||e?.static?.root),r=t(e);return!n&&we&&(r=we),F(W(r))}async function be(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:r=[],autoDefineMapper:c=null,enhancers:s=[],autoDefineOverrides:l=null,autoDefinePreferModule:w=!0}=e,b=(()=>{let i=new Map;return(t||[]).forEach(a=>i.set(a.selector,a)),(s||[]).forEach(a=>i.set(a.selector,a)),Array.from(i.values())})(),h=null;if(typeof window<"u"&&typeof document<"u"){let i=z,a=p=>{switch(p){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${p}.js`}},{mapper:S,enhancers:m,...E}=l&&typeof l=="object"?l:{},g=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],L=(()=>{let p=new Map;return(b||[]).forEach(y=>{y?.selector&&p.set(y.selector,y)}),(g||[]).forEach(y=>{if(!y?.selector)return;let v=p.get(y.selector)||null;p.set(y.selector,{...v||{},...y,run:typeof y?.run=="function"?y.run:v?.run})}),Array.from(p.values())})(),_={baseURL:n&&F(W(n,{preferModule:w})),predefine:r,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:L,onError:(p,y)=>{if(typeof p=="string"&&p.startsWith("pds-")){let O=["pds-form","pds-drawer"].includes(p),T=y?.message?.includes("#pds/lit")||y?.message?.includes("Failed to resolve module specifier");O&&T?console.error(`\u274C PDS component <${p}> requires Lit but #pds/lit is not in import map.
|
|
2
|
+
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):console.warn(`\u26A0\uFE0F PDS component <${p}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${p}>:`,y)},...E,mapper:p=>{if(customElements.get(p))return null;if(typeof c=="function")try{let y=c(p);return y===void 0?a(p):y}catch(y){return console.warn("Custom autoDefine.mapper error; falling back to default:",y?.message||y),a(p)}return a(p)}};h=new i(_),r.length>0&&typeof i.define=="function"&&await i.define(...r,{baseURL:n,mapper:_.mapper,onError:_.onError})}return{autoDefiner:h,mergedEnhancers:b}}var te=["light","dark"],ne=new Set(te);function Ie(e){let n=(Array.isArray(e?.themes)?e.themes.map(r=>String(r).toLowerCase()):te).filter(r=>ne.has(r));return n.length?n:te}function re(e,{preferDocument:t=!0}={}){let n=String(e||"").toLowerCase();if(ne.has(n))return n;if(t&&typeof document<"u"){let r=document.documentElement?.getAttribute("data-theme");if(ne.has(r))return r}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Le(e,t){let n=re(t);return Ie(e).includes(n)}var oe=class extends EventTarget{},o=new oe;o.initializing=!1;o.currentPreset=null;o.debug=!1;var q=null,V=null,H=null,K=null;function G(e,t){return t&&typeof t=="string"?t:`${B(o.currentConfig||{},{resolvePublicAssetURL:N})}core/${e}`}async function Ne(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(K||(K=import(G("pds-enhancers.js",o.currentConfig?.enhancersURL)).then(t=>{let n=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return o.defaultEnhancers=n,n}).catch(t=>{throw K=null,t})),K)}async function ze(){return typeof o.ask=="function"&&o.ask!==ve?o.ask:(V||(V=import(G("pds-ask.js",o.currentConfig?.askURL)).then(t=>{let n=t?.ask;if(typeof n!="function")throw new Error("Failed to load ask helper");return o.ask=n,n}).catch(t=>{throw V=null,t})),V)}async function $(){return typeof o.toast=="function"&&o.toast!==k?o.toast:(H||(H=import(G("pds-toast.js",o.currentConfig?.toastURL)).then(t=>{let n=t?.toast;if(typeof n!="function")throw new Error("Failed to load toast helper");return o.toast=n,n}).catch(t=>{throw H=null,t})),H)}async function ve(...e){return(await ze())(...e)}async function k(...e){return(await $())(...e)}k.success=async(...e)=>(await $()).success(...e);k.error=async(...e)=>(await $()).error(...e);k.warning=async(...e)=>(await $()).warning(...e);k.info=async(...e)=>(await $()).info(...e);var Ae=function(e="log",t,...n){let r=!!(o.registry&&!o.registry.isLive),c=(this?.debug||this?.design?.debug||o.debug||!1)===!0;if(r){if(!o.debug)return}else if(!c&&e!=="error"&&e!=="warn")return;let s=console[e]||console.log;n.length>0?s(t,...n):s(t)};function ae(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(n=>ae(n)).filter(n=>n!==void 0);let t={};for(let[n,r]of Object.entries(e)){let c=ae(r);c!==void 0&&(t[n]=c)}return t}async function Fe(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let n=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let r=await fetch(n,{cache:"no-store"});return r.ok?await r.json():null}catch{return null}}o.registry=M;o.enums=fe;o.adoptLayers=ue;o.adoptPrimitives=de;o.parse=Z;o.createStylesheet=pe;o.isLiveMode=()=>M.isLive;o.ask=ve;o.toast=k;o.common=ee;o.AutoComplete=null;o.loadAutoComplete=async()=>{if(o.AutoComplete&&typeof o.AutoComplete.connect=="function")return o.AutoComplete;let e=G("pds-autocomplete.js",o.currentConfig?.autoCompleteURL);return q||(q=import(e).then(t=>{let n=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!n)throw new Error("AutoComplete export not found in module");return o.AutoComplete=n,n}).catch(t=>{throw q=null,t})),q};function _e(e){let t=typeof CustomEvent=="function";try{let n=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");o.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",n))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",n))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function xe(e={}){let t=typeof CustomEvent=="function",n={at:Date.now(),...e};try{let r=t?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");o.dispatchEvent(r)}catch{}if(typeof document<"u")if(t){let r={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",r))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var se="pure-ds-theme",R=null,j=null;function Q(e){try{if(typeof document>"u")return;let t="light";e?e==="system"?t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t=e:t=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",t)}catch{}}function J(e){try{if(R&&j){try{typeof R.removeEventListener=="function"?R.removeEventListener("change",j):typeof R.removeListener=="function"&&R.removeListener(j)}catch{}R=null,j=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),n=r=>{let c=r?.matches===void 0?t.matches:r.matches;try{let s=c?"dark":"light";document.documentElement.setAttribute("data-theme",s),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:s,source:"system"}}))}catch{}};R=t,j=n,typeof t.addEventListener=="function"?t.addEventListener("change",n):typeof t.addListener=="function"&&t.addListener(n)}}catch{}}Object.defineProperty(o,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(se)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=o.currentConfig?.design||null,n=re(e);if(t&&!Le(t,n)){let r=t?.name||o.currentPreset?.name||o.currentConfig?.preset||"current preset";console.warn(`PDS theme "${n}" not supported by preset "${r}".`),o.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:n,preset:r}}));return}e==null?localStorage.removeItem(se):localStorage.setItem(se,e),Q(e),J(e),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});o.defaultEnhancers=[];async function We(e){let t=e&&e.mode||"live",{mode:n,...r}=e||{};if(t==="static")return Be(r);let c=B(r,{resolvePublicAssetURL:N}),s=r?.managerURL||r?.public?.managerURL||r?.manager?.url||new URL("core/pds-manager.js",c).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:l}=await import(s);return l(o,r,{emitReady:_e,emitConfigChanged:xe,applyResolvedTheme:Q,setupSystemListenerIfNeeded:J})}o.start=We;async function Be(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,n=e.manageTheme??!0,r=e.themeStorageKey??"pure-ds-theme",c=e.staticPaths??{},s=B(e,{resolvePublicAssetURL:N}),l=e&&e.autoDefine||null,w;l&&l.baseURL?w=F(W(l.baseURL,{preferModule:!1})):w=`${s}components/`;let b=l&&Array.isArray(l.predefine)&&l.predefine||[],h=l&&typeof l.mapper=="function"&&l.mapper||null;try{ge(o);let{resolvedTheme:i}=Ee({manageTheme:n,themeStorageKey:r,applyResolvedTheme:Q,setupSystemListenerIfNeeded:J}),a=await Fe(s,e),S=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],m=a?.config?{...a.config,...e,design:e?.design||a.config.design,preset:e?.preset||a.config.preset}:{...e},E={tokens:`${s}styles/pds-tokens.css.js`,primitives:`${s}styles/pds-primitives.css.js`,components:`${s}styles/pds-components.css.js`,utilities:`${s}styles/pds-utilities.css.js`,styles:`${s}styles/pds-styles.css.js`},g=a?.paths||{};if(c={...E,...g,...c},o.registry.setStaticMode(c),t&&typeof document<"u")try{let p=await o.registry.getStylesheet("styles");if(p){p._pds=!0;let y=(document.adoptedStyleSheets||[]).filter(v=>v._pds!==!0);document.adoptedStyleSheets=[...y,p],xe({mode:"static",source:"static:styles-applied"})}}catch(p){Ae.call(o,"warn","Failed to apply static styles:",p)}let L=null,x=[];try{let p=await Ne(),y=await be({autoDefineBaseURL:w,autoDefinePreload:b,autoDefineMapper:h,enhancers:S,autoDefineOverrides:l||null,autoDefinePreferModule:!(l&&l.baseURL)},{baseEnhancers:p});L=y.autoDefiner,x=y.mergedEnhancers||[]}catch(p){Ae.call(o,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",p)}let _=ae(e);return o.currentConfig=Object.freeze({mode:"static",...structuredClone(_),design:structuredClone(m.design||{}),preset:m.preset,theme:i,enhancers:x}),_e({mode:"static",config:m,theme:i,autoDefiner:L}),{config:m,theme:i,autoDefiner:L}}catch(i){throw o.dispatchEvent(new CustomEvent("pds:error",{detail:{error:i}})),i}}var at=Q,it=J;export{o as PDS,at as applyResolvedTheme,it as setupSystemListenerIfNeeded};
|
package/readme.md
CHANGED
|
@@ -198,6 +198,7 @@ PDS also ships a local MCP server so agents can delegate lookups to actual SSoT
|
|
|
198
198
|
**Tool coverage**
|
|
199
199
|
- `get_tokens` → `public/assets/pds/pds.css-data.json`
|
|
200
200
|
- `find_utility_class` → `src/js/pds-core/pds-ontology.js`
|
|
201
|
+
- `query_design_system` → natural-language query across ontology + token metadata
|
|
201
202
|
- `get_component_api` → `custom-elements.json`
|
|
202
203
|
- `get_enhancer_metadata` → `src/js/pds-core/pds-enhancers-meta.js`
|
|
203
204
|
- `get_config_relations` → `src/js/pds-core/pds-config.js` (`PDS_CONFIG_RELATIONS`)
|
|
@@ -986,70 +987,31 @@ Icons are available as CSS custom properties:
|
|
|
986
987
|
|
|
987
988
|
---
|
|
988
989
|
|
|
989
|
-
##
|
|
990
|
+
## MCP Query Tool
|
|
990
991
|
|
|
991
|
-
Ask questions about your design system
|
|
992
|
+
Ask natural-language questions about your design system through MCP.
|
|
992
993
|
|
|
993
994
|
### Usage
|
|
994
995
|
|
|
995
|
-
|
|
996
|
-
// Programmatic API
|
|
997
|
-
const results = await PDS.query("what is the focus border color on inputs?");
|
|
998
|
-
|
|
999
|
-
results.forEach(result => {
|
|
1000
|
-
console.log(result.text); // "Focus border color: var(--color-primary-500)"
|
|
1001
|
-
console.log(result.category); // "Color Token"
|
|
1002
|
-
console.log(result.cssVar); // "var(--color-primary-500)"
|
|
1003
|
-
console.log(result.code); // Example code
|
|
1004
|
-
});
|
|
1005
|
-
```
|
|
996
|
+
Call `query_design_system` with a `question` string from your MCP client.
|
|
1006
997
|
|
|
1007
|
-
### Example
|
|
1008
|
-
|
|
1009
|
-
**Color Questions:**
|
|
1010
|
-
```javascript
|
|
1011
|
-
await PDS.query("what is the focus border color on inputs?")
|
|
1012
|
-
await PDS.query("what foreground color should I use on this surface?")
|
|
1013
|
-
await PDS.query("button hover color")
|
|
1014
|
-
await PDS.query("primary color scale")
|
|
1015
|
-
```
|
|
1016
|
-
|
|
1017
|
-
**Utility Questions:**
|
|
1018
|
-
```javascript
|
|
1019
|
-
await PDS.query("what are the utility classes for borders?")
|
|
1020
|
-
await PDS.query("border gradient effect")
|
|
1021
|
-
await PDS.query("flex layout utilities")
|
|
1022
|
-
await PDS.query("gap between elements")
|
|
1023
|
-
```
|
|
1024
|
-
|
|
1025
|
-
**Component Questions:**
|
|
1026
|
-
```javascript
|
|
1027
|
-
await PDS.query("how do I create an icon-only button?")
|
|
1028
|
-
await PDS.query("drawer component")
|
|
1029
|
-
await PDS.query("tab strip usage")
|
|
1030
|
-
```
|
|
998
|
+
### Example Questions
|
|
1031
999
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1000
|
+
```text
|
|
1001
|
+
what is the focus border color on inputs?
|
|
1002
|
+
what foreground color should I use on this surface?
|
|
1003
|
+
what are the utility classes for borders?
|
|
1004
|
+
how do I create an icon-only button?
|
|
1037
1005
|
```
|
|
1038
1006
|
|
|
1039
|
-
### AutoComplete Integration
|
|
1040
|
-
|
|
1041
|
-
The query system integrates with `#pds-search` in the configurator. Type queries directly in the search box for instant answers.
|
|
1042
|
-
|
|
1043
1007
|
### How It Works
|
|
1044
1008
|
|
|
1045
1009
|
1. **Intent Detection** - Recognizes what you're asking about (color, spacing, component, utility)
|
|
1046
1010
|
2. **Entity Recognition** - Identifies design elements (button, input, surface)
|
|
1047
1011
|
3. **Context Analysis** - Detects states (hover, focus, active)
|
|
1048
|
-
4. **Data Querying** -
|
|
1012
|
+
4. **Data Querying** - Uses ontology metadata + token metadata from SSoT
|
|
1049
1013
|
5. **Scoring & Ranking** - Returns top 10 most relevant results
|
|
1050
1014
|
|
|
1051
|
-
See [PDS-QUERY-SYSTEM.md](./PDS-QUERY-SYSTEM.md) for detailed documentation.
|
|
1052
|
-
|
|
1053
1015
|
---
|
|
1054
1016
|
|
|
1055
1017
|
## Design Validation
|
|
@@ -1352,15 +1314,6 @@ await PDS.start({
|
|
|
1352
1314
|
});
|
|
1353
1315
|
```
|
|
1354
1316
|
|
|
1355
|
-
### PDS.query(question)
|
|
1356
|
-
|
|
1357
|
-
Smart query interface.
|
|
1358
|
-
|
|
1359
|
-
```typescript
|
|
1360
|
-
const results = await PDS.query(question: string);
|
|
1361
|
-
// Returns array of results with text, value, icon, category, etc.
|
|
1362
|
-
```
|
|
1363
|
-
|
|
1364
1317
|
### validateDesign(config, options)
|
|
1365
1318
|
|
|
1366
1319
|
Validate design for accessibility.
|
|
@@ -2035,7 +1988,7 @@ npm run dev
|
|
|
2035
1988
|
- 🌐 **Homepage:** https://puredesignsystem.z6.web.core.windows.net/
|
|
2036
1989
|
- 📦 **NPM:** https://www.npmjs.com/package/pure-ds
|
|
2037
1990
|
- 🐙 **GitHub:** https://github.com/mvneerven/pure-ds
|
|
2038
|
-
- 📖 **Docs:** [getting-started.md](./getting-started.md)
|
|
1991
|
+
- 📖 **Docs:** [getting-started.md](./getting-started.md)
|
|
2039
1992
|
- 💬 **Discussions:** https://github.com/mvneerven/pure-ds/discussions
|
|
2040
1993
|
- 🐛 **Issues:** https://github.com/mvneerven/pure-ds/issues
|
|
2041
1994
|
|
|
@@ -2741,7 +2741,7 @@ button, .btn, input[type="submit"], input[type="button"], input[type="reset"] {
|
|
|
2741
2741
|
align-items: center;
|
|
2742
2742
|
justify-content: center;
|
|
2743
2743
|
min-height: ${minButtonHeight}px;
|
|
2744
|
-
padding: calc(var(--spacing-1) * ${buttonPaddingValue}) var(--spacing-6);
|
|
2744
|
+
padding: max(calc(var(--spacing-1) * ${buttonPaddingValue}), var(--spacing-2)) var(--spacing-6);
|
|
2745
2745
|
border: var(--border-width-medium) solid transparent;
|
|
2746
2746
|
border-radius: var(--radius-md);
|
|
2747
2747
|
font-family: var(--font-family-body);
|
|
@@ -2851,22 +2851,22 @@ button, .btn, input[type="submit"], input[type="button"], input[type="reset"] {
|
|
|
2851
2851
|
}
|
|
2852
2852
|
|
|
2853
2853
|
.btn-sm {
|
|
2854
|
-
padding: var(--spacing-2) var(--spacing-
|
|
2854
|
+
padding: calc(max(calc(var(--spacing-1) * ${buttonPaddingValue}), var(--spacing-2)) * 0.85) calc(var(--spacing-6) * 0.8);
|
|
2855
2855
|
font-size: var(--font-size-sm);
|
|
2856
|
-
min-height: calc(${minButtonHeight}px * 0.
|
|
2856
|
+
min-height: calc(${minButtonHeight}px * 0.85);
|
|
2857
2857
|
}
|
|
2858
2858
|
|
|
2859
2859
|
.btn-xs {
|
|
2860
|
-
padding: var(--spacing-1) var(--spacing-2);
|
|
2860
|
+
padding: calc(max(calc(var(--spacing-1) * ${buttonPaddingValue}), var(--spacing-2)) * 0.7) calc(var(--spacing-6) * 0.65);
|
|
2861
2861
|
font-size: var(--font-size-xs);
|
|
2862
|
-
min-height: calc(${minButtonHeight}px * 0.
|
|
2862
|
+
min-height: calc(${minButtonHeight}px * 0.7);
|
|
2863
2863
|
}
|
|
2864
2864
|
|
|
2865
2865
|
|
|
2866
2866
|
.btn-lg {
|
|
2867
|
-
padding: var(--spacing-
|
|
2867
|
+
padding: calc(max(calc(var(--spacing-1) * ${buttonPaddingValue}), var(--spacing-2)) * 1.15) calc(var(--spacing-6) * 1.35);
|
|
2868
2868
|
font-size: var(--font-size-lg);
|
|
2869
|
-
min-height: calc(${minButtonHeight}px * 1.
|
|
2869
|
+
min-height: calc(${minButtonHeight}px * 1.15);
|
|
2870
2870
|
}
|
|
2871
2871
|
|
|
2872
2872
|
/* Working/loading state for buttons */
|
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
} from "./pds-theme-utils.js";
|
|
38
38
|
|
|
39
39
|
let __liveApiReady = false;
|
|
40
|
-
let __queryClass = null;
|
|
41
40
|
|
|
42
41
|
const LIVE_EDIT_TOGGLE_ID = "pds-live-edit-toggle";
|
|
43
42
|
const LIVE_EDIT_TOGGLE_STYLE_ID = "pds-live-edit-toggle-style";
|
|
@@ -667,18 +666,16 @@ function buildPresetOmniboxSettings(PDS, options = {}) {
|
|
|
667
666
|
async function __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIfNeeded, emitConfigChanged }) {
|
|
668
667
|
if (__liveApiReady) return;
|
|
669
668
|
|
|
670
|
-
const [ontologyModule, enumsModule,
|
|
669
|
+
const [ontologyModule, enumsModule, commonModule] =
|
|
671
670
|
await Promise.all([
|
|
672
671
|
import("./pds-ontology.js"),
|
|
673
672
|
import("./pds-enums.js"),
|
|
674
|
-
import("./pds-query.js"),
|
|
675
673
|
import("../common/common.js"),
|
|
676
674
|
]);
|
|
677
675
|
|
|
678
676
|
const ontology = ontologyModule?.default || ontologyModule?.ontology;
|
|
679
677
|
const findComponentForElement = ontologyModule?.findComponentForElement;
|
|
680
678
|
const enums = enumsModule?.enums;
|
|
681
|
-
__queryClass = queryModule?.PDSQuery || queryModule?.default || null;
|
|
682
679
|
|
|
683
680
|
// Expose live-only APIs
|
|
684
681
|
PDS.ontology = ontology;
|
|
@@ -717,15 +714,6 @@ async function __attachLiveAPIs(PDS, { applyResolvedTheme, setupSystemListenerIf
|
|
|
717
714
|
PDS.getGenerator = async function() {
|
|
718
715
|
return Generator;
|
|
719
716
|
};
|
|
720
|
-
PDS.query = async function(question) {
|
|
721
|
-
if (!__queryClass) {
|
|
722
|
-
const mod = await import("./pds-query.js");
|
|
723
|
-
__queryClass = mod?.PDSQuery || mod?.default || null;
|
|
724
|
-
}
|
|
725
|
-
if (!__queryClass) return [];
|
|
726
|
-
const queryEngine = new __queryClass(PDS);
|
|
727
|
-
return await queryEngine.search(question);
|
|
728
|
-
};
|
|
729
717
|
PDS.buildPresetOmniboxSettings = function(options = {}) {
|
|
730
718
|
return buildPresetOmniboxSettings(PDS, options);
|
|
731
719
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Pure Design System Ontology (PDS)
|
|
2
2
|
// This file is the single source-of-truth metadata for primitives, components, tokens, themes and enhancements.
|
|
3
|
-
// Used by
|
|
3
|
+
// Used by MCP/query tooling for searching and correlating concepts.
|
|
4
4
|
|
|
5
5
|
export const ontology = {
|
|
6
6
|
meta: {
|
|
@@ -560,7 +560,7 @@ export const ontology = {
|
|
|
560
560
|
|
|
561
561
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
562
562
|
// SEARCH RELATIONS (Cross-concept mappings for intelligent search)
|
|
563
|
-
// Used by
|
|
563
|
+
// Used by MCP tools and Storybook ontology search to expand user queries
|
|
564
564
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
565
565
|
searchRelations: {
|
|
566
566
|
// Typography & Text
|
|
@@ -132,6 +132,22 @@ export async function adoptLayers(
|
|
|
132
132
|
additionalSheets = [],
|
|
133
133
|
generator = null
|
|
134
134
|
) {
|
|
135
|
+
const safeAdditionalSheets = Array.isArray(additionalSheets)
|
|
136
|
+
? additionalSheets.filter(Boolean)
|
|
137
|
+
: [];
|
|
138
|
+
|
|
139
|
+
// Apply component-local sheets immediately so lazy-loaded components avoid
|
|
140
|
+
// transient UA default styling while shared layers are resolving.
|
|
141
|
+
if (safeAdditionalSheets.length) {
|
|
142
|
+
const existing = Array.isArray(shadowRoot.adoptedStyleSheets)
|
|
143
|
+
? shadowRoot.adoptedStyleSheets
|
|
144
|
+
: [];
|
|
145
|
+
const nonAdditional = existing.filter(
|
|
146
|
+
(sheet) => !safeAdditionalSheets.includes(sheet)
|
|
147
|
+
);
|
|
148
|
+
shadowRoot.adoptedStyleSheets = [...nonAdditional, ...safeAdditionalSheets];
|
|
149
|
+
}
|
|
150
|
+
|
|
135
151
|
try {
|
|
136
152
|
// Get all requested stylesheets
|
|
137
153
|
const stylesheets = await Promise.all(
|
|
@@ -158,7 +174,7 @@ export async function adoptLayers(
|
|
|
158
174
|
const validStylesheets = stylesheets.filter((sheet) => sheet !== null);
|
|
159
175
|
|
|
160
176
|
// Adopt all layers + additional sheets
|
|
161
|
-
shadowRoot.adoptedStyleSheets = [...validStylesheets, ...
|
|
177
|
+
shadowRoot.adoptedStyleSheets = [...validStylesheets, ...safeAdditionalSheets];
|
|
162
178
|
} catch (error) {
|
|
163
179
|
const componentName = shadowRoot.host?.tagName?.toLowerCase() || "unknown";
|
|
164
180
|
console.error(
|
|
@@ -166,7 +182,7 @@ export async function adoptLayers(
|
|
|
166
182
|
error
|
|
167
183
|
);
|
|
168
184
|
// Continue with just additional sheets as fallback
|
|
169
|
-
shadowRoot.adoptedStyleSheets =
|
|
185
|
+
shadowRoot.adoptedStyleSheets = safeAdditionalSheets;
|
|
170
186
|
}
|
|
171
187
|
}
|
|
172
188
|
|
package/src/js/pds.d.ts
CHANGED
|
@@ -210,7 +210,6 @@ export class PDS extends EventTarget {
|
|
|
210
210
|
static enums?: Record<string, any>;
|
|
211
211
|
static common?: Record<string, any>;
|
|
212
212
|
static parse?: (html: string) => Element[];
|
|
213
|
-
static query?: (question: string) => Promise<any[]>;
|
|
214
213
|
static AutoComplete?: any;
|
|
215
214
|
static loadAutoComplete?: () => Promise<any>;
|
|
216
215
|
|