@pure-ds/storybook 0.7.1 → 0.7.4
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/dist/pds-reference.json +48 -34
- package/package.json +2 -2
- package/public/assets/js/app.js +4 -4
- package/public/assets/js/pds-auto-definer.js +306 -1
- package/public/assets/js/pds-manager.js +37 -37
- package/public/assets/js/pds.js +2 -2
- package/public/assets/pds/components/pds-scrollrow.js +2 -4
- package/public/assets/pds/core/pds-manager.js +37 -37
- package/public/assets/pds/core.js +2 -2
- package/public/assets/pds/custom-elements.json +77 -46
- package/public/assets/pds/pds-css-complete.json +2 -2
- package/public/assets/pds/pds-runtime-config.json +12 -12
- package/public/assets/pds/pds.css-data.json +1 -1
- package/public/assets/pds/styles/pds-styles.css +4 -65
- package/public/assets/pds/styles/pds-styles.css.js +8 -130
- package/public/assets/pds/styles/pds-tokens.css +3 -3
- package/public/assets/pds/styles/pds-tokens.css.js +6 -6
- package/public/assets/pds/styles/pds-utilities.css +1 -62
- package/public/assets/pds/styles/pds-utilities.css.js +2 -124
- package/public/assets/pds/vscode-custom-data.json +5 -13
- package/src/js/common/pds-core/pds.d.ts +1 -0
- package/src/js/pds-core/pds-live.js +0 -3
- package/src/js/pds-core/pds-start-helpers.js +53 -27
- package/src/js/pds.d.ts +1 -0
- package/src/js/pds.js +0 -4
- package/public/assets/pds/core/pds-auto-definer.js +0 -1
- package/src/js/pds-auto-definer.js +0 -1
package/dist/pds-reference.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-02-
|
|
2
|
+
"generatedAt": "2026-02-24T10:36:00.918Z",
|
|
3
3
|
"sources": {
|
|
4
4
|
"customElements": "custom-elements.json",
|
|
5
5
|
"ontology": "src\\js\\pds-core\\pds-ontology.js",
|
|
@@ -1274,6 +1274,24 @@
|
|
|
1274
1274
|
"attributes": [],
|
|
1275
1275
|
"properties": [],
|
|
1276
1276
|
"methods": [
|
|
1277
|
+
{
|
|
1278
|
+
"name": "createSharedQuickModeMenuItem",
|
|
1279
|
+
"description": null,
|
|
1280
|
+
"parameters": [],
|
|
1281
|
+
"return": null
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
"name": "isInteractiveEditingEnabled",
|
|
1285
|
+
"description": null,
|
|
1286
|
+
"parameters": [],
|
|
1287
|
+
"return": null
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
"name": "openDesignSettings",
|
|
1291
|
+
"description": null,
|
|
1292
|
+
"parameters": [],
|
|
1293
|
+
"return": null
|
|
1294
|
+
},
|
|
1277
1295
|
{
|
|
1278
1296
|
"name": "openImportDetailsFromToast",
|
|
1279
1297
|
"description": null,
|
|
@@ -1285,6 +1303,24 @@
|
|
|
1285
1303
|
}
|
|
1286
1304
|
],
|
|
1287
1305
|
"return": null
|
|
1306
|
+
},
|
|
1307
|
+
{
|
|
1308
|
+
"name": "resetConfig",
|
|
1309
|
+
"description": null,
|
|
1310
|
+
"parameters": [],
|
|
1311
|
+
"return": null
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
"name": "setInteractiveEditingEnabled",
|
|
1315
|
+
"description": null,
|
|
1316
|
+
"parameters": [
|
|
1317
|
+
{
|
|
1318
|
+
"name": "enabled",
|
|
1319
|
+
"type": null,
|
|
1320
|
+
"description": null
|
|
1321
|
+
}
|
|
1322
|
+
],
|
|
1323
|
+
"return": null
|
|
1288
1324
|
}
|
|
1289
1325
|
],
|
|
1290
1326
|
"events": [
|
|
@@ -1834,7 +1870,7 @@
|
|
|
1834
1870
|
"displayName": "Pds Scrollrow",
|
|
1835
1871
|
"storyTitle": "Components/Pds Scrollrow",
|
|
1836
1872
|
"category": "Components",
|
|
1837
|
-
"description":
|
|
1873
|
+
"description": null,
|
|
1838
1874
|
"docsDescription": "Horizontal scrolling container with navigation buttons",
|
|
1839
1875
|
"pdsTags": [
|
|
1840
1876
|
"autodocs",
|
|
@@ -1866,29 +1902,29 @@
|
|
|
1866
1902
|
"attributes": [
|
|
1867
1903
|
{
|
|
1868
1904
|
"name": "label",
|
|
1869
|
-
"description":
|
|
1870
|
-
"type":
|
|
1905
|
+
"description": null,
|
|
1906
|
+
"type": null,
|
|
1871
1907
|
"default": null,
|
|
1872
1908
|
"fieldName": null
|
|
1873
1909
|
},
|
|
1874
1910
|
{
|
|
1875
1911
|
"name": "snap",
|
|
1876
|
-
"description":
|
|
1877
|
-
"type":
|
|
1912
|
+
"description": null,
|
|
1913
|
+
"type": null,
|
|
1878
1914
|
"default": null,
|
|
1879
1915
|
"fieldName": null
|
|
1880
1916
|
},
|
|
1881
1917
|
{
|
|
1882
1918
|
"name": "tile-min",
|
|
1883
|
-
"description":
|
|
1884
|
-
"type":
|
|
1919
|
+
"description": null,
|
|
1920
|
+
"type": null,
|
|
1885
1921
|
"default": null,
|
|
1886
1922
|
"fieldName": null
|
|
1887
1923
|
},
|
|
1888
1924
|
{
|
|
1889
1925
|
"name": "tile-max",
|
|
1890
|
-
"description":
|
|
1891
|
-
"type":
|
|
1926
|
+
"description": null,
|
|
1927
|
+
"type": null,
|
|
1892
1928
|
"default": null,
|
|
1893
1929
|
"fieldName": null
|
|
1894
1930
|
}
|
|
@@ -1946,30 +1982,8 @@
|
|
|
1946
1982
|
}
|
|
1947
1983
|
],
|
|
1948
1984
|
"events": [],
|
|
1949
|
-
"slots": [
|
|
1950
|
-
|
|
1951
|
-
"name": "default",
|
|
1952
|
-
"description": "Scrollable tile content"
|
|
1953
|
-
},
|
|
1954
|
-
{
|
|
1955
|
-
"name": "heading",
|
|
1956
|
-
"description": "Optional heading content rendered in the component header"
|
|
1957
|
-
}
|
|
1958
|
-
],
|
|
1959
|
-
"cssParts": [
|
|
1960
|
-
{
|
|
1961
|
-
"name": "viewport",
|
|
1962
|
-
"description": "The scrollable container element"
|
|
1963
|
-
},
|
|
1964
|
-
{
|
|
1965
|
-
"name": "prev",
|
|
1966
|
-
"description": "The previous/left scroll navigation button"
|
|
1967
|
-
},
|
|
1968
|
-
{
|
|
1969
|
-
"name": "next",
|
|
1970
|
-
"description": "The next/right scroll navigation button"
|
|
1971
|
-
}
|
|
1972
|
-
],
|
|
1985
|
+
"slots": [],
|
|
1986
|
+
"cssParts": [],
|
|
1973
1987
|
"notes": []
|
|
1974
1988
|
},
|
|
1975
1989
|
"pds-splitpanel": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pure-ds/storybook",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Storybook showcase for Pure Design System with live configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"pds:build-icons": "pds-build-icons"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@pure-ds/core": "^0.7.
|
|
41
|
+
"@pure-ds/core": "^0.7.4"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|
package/public/assets/js/app.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var ge=Object.defineProperty;var be=(e,t)=>{for(var s in t)ge(e,s,{get:t[s],enumerable:!0})};var F=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(s){console.error(`[PDS Registry] Failed to load static ${t}:`,s),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 n=new CSSStyleSheet;return n.replaceSync("/* Failed to load "+t+" */"),n}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},_=new F;async function Y(e,t=[],s=null){try{let n=s?.primitivesStylesheet?s.primitivesStylesheet:await _.getStylesheet("primitives");e.adoptedStyleSheets=[n,...t]}catch(n){let a=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${a}> failed to adopt primitives:`,n),e.adoptedStyleSheets=t}}async function Z(e,t=["primitives"],s=[],n=null){try{let o=(await Promise.all(t.map(async c=>{if(n)switch(c){case"tokens":return n.tokensStylesheet;case"primitives":return n.primitivesStylesheet;case"components":return n.componentsStylesheet;case"utilities":return n.utilitiesStylesheet;default:break}return _.getStylesheet(c)}))).filter(c=>c!==null);e.adoptedStyleSheets=[...o,...s]}catch(a){let o=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${o}> failed to adopt layers:`,a),e.adoptedStyleSheets=s}}function ee(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var te={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 B={};be(B,{deepMerge:()=>se,fragmentFromTemplateLike:()=>we,isObject:()=>P,parseHTML:()=>W});function P(e){return e&&typeof e=="object"&&!Array.isArray(e)}function se(e,t){let s={...e};return P(e)&&P(t)&&Object.keys(t).forEach(n=>{P(t[n])?n in e?s[n]=se(e[n],t[n]):Object.assign(s,{[n]:t[n]}):Object.assign(s,{[n]:t[n]})}),s}function we(e){let t=Array.isArray(e?.strings)?e.strings:[],s=Array.isArray(e?.values)?e.values:[],n=new Set,a=[],o=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let l=t[i]??"",p=l.match(o);if(p&&i<s.length){let u=p[2].slice(1),f=`pds-val-${i}`;l=l.replace(o,`$1data-pds-prop="${u}:${f}"`),n.add(i)}a.push(l),i<s.length&&!n.has(i)&&a.push(`<!--pds-val-${i}-->`)}let c=document.createElement("template");c.innerHTML=a.join("");let m=(i,l)=>{let p=i.parentNode;if(!p)return;if(l==null){p.removeChild(i);return}let b=u=>{if(u!=null){if(u instanceof Node){p.insertBefore(u,i);return}if(Array.isArray(u)){u.forEach(f=>b(f));return}p.insertBefore(document.createTextNode(String(u)),i)}};b(l),p.removeChild(i)},v=document.createTreeWalker(c.content,NodeFilter.SHOW_COMMENT),S=[];for(;v.nextNode();){let i=v.currentNode;i?.nodeValue?.startsWith("pds-val-")&&S.push(i)}return S.forEach(i=>{let l=Number(i.nodeValue.replace("pds-val-",""));m(i,s[l])}),c.content.querySelectorAll("*").forEach(i=>{let l=i.getAttribute("data-pds-prop");if(!l)return;let[p,b]=l.split(":"),u=Number(String(b).replace("pds-val-",""));p&&Number.isInteger(u)&&(i[p]=s[u]),i.removeAttribute("data-pds-prop")}),c.content}function W(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var re="pds",Se=/^([a-z][a-z0-9+\-.]*:)?\/\//i,ne=/^[a-z]:/i;function A(e=""){return e.endsWith("/")?e:`${e}/`}function Ee(e="",t=re){let s=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(s)?s:`${s}/${t}`}function ve(e){return e.replace(/^\.\/+/,"")}function Le(e){return ne.test(e)?e.replace(ne,"").replace(/^\/+/,""):e}function _e(e){return e.startsWith("public/")?e.substring(7):e}function M(e,t={}){let s=t.segment||re,n=t.defaultRoot||`/assets/${s}/`,a=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!a||typeof a!="string")return A(n);let o=a.trim();return o?(o=o.replace(/\\/g,"/"),o=Ee(o,s),o=A(o),Se.test(o)?o:(o=ve(o),o=Le(o),o.startsWith("/")||(o=_e(o),o.startsWith("/")||(o=`/${o}`),o=o.replace(/\/+/g,(c,m)=>m===0?c:"/")),A(o))):A(n)}var ke=/^[a-z][a-z0-9+\-.]*:\/\//i,x=(()=>{try{return import.meta.url}catch{return}})(),T=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function U(e,t={}){if(!e||ke.test(e))return e;let{preferModule:s=!0}=t,n=()=>{if(!x)return null;try{return new URL(e,x).href}catch{return null}},a=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(s?n()||a():a()||n())||e}var oe=(()=>{if(x)try{let e=new URL(x);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",x).href}catch{return}})(),ie=!1;function ae(e){ie||typeof document>"u"||(ie=!0,e.addEventListener("pds:ready",t=>{let s=t.detail?.mode;s&&document.documentElement.classList.add(`pds-${s}`,"pds-ready")}))}function ce({manageTheme:e,themeStorageKey:t,applyResolvedTheme:s,setupSystemListenerIfNeeded:n}){let a="light",o=null;if(e&&typeof window<"u"){try{o=localStorage.getItem(t)||null}catch{o=null}try{s?.(o),n?.(o)}catch{}o?o==="system"?a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a=o:a=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:a,storedTheme:o}}function C(e,{resolvePublicAssetURL:t}){let s=!!(e?.public?.root||e?.static?.root),n=t(e);return!s&&oe&&(n=oe),T(U(n))}async function de(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:s="/auto-define/",autoDefinePreload:n=[],autoDefineMapper:a=null,autoDefinerModuleURL:o=null,enhancers:c=[],autoDefineOverrides:m=null,autoDefinePreferModule:v=!0}=e,S=(()=>{let i=new Map;return(t||[]).forEach(l=>i.set(l.selector,l)),(c||[]).forEach(l=>i.set(l.selector,l)),Array.from(i.values())})(),y=null;if(typeof window<"u"&&typeof document<"u"){let i=null;try{if(!o||typeof o!="string")throw new Error("AutoDefiner module URL is not configured");let d=await import(o);i=d?.AutoDefiner||d?.default?.AutoDefiner||d?.default||null}catch(d){console.warn("AutoDefiner not available:",d?.message||d)}let l=d=>{switch(d){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${d}.js`}},{mapper:p,...b}=m&&typeof m=="object"?m:{},f={baseURL:s&&T(U(s,{preferModule:v})),predefine:n,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:S,onError:(d,h)=>{if(typeof d=="string"&&d.startsWith("pds-")){let L=["pds-form","pds-drawer"].includes(d),z=h?.message?.includes("#pds/lit")||h?.message?.includes("Failed to resolve module specifier");L&&z?console.error(`\u274C PDS component <${d}> 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 <${d}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${d}>:`,h)},...b,mapper:d=>{if(customElements.get(d))return null;if(typeof a=="function")try{let h=a(d);return h===void 0?l(d):h}catch(h){return console.warn("Custom autoDefine.mapper error; falling back to default:",h?.message||h),l(d)}return l(d)}};i&&(y=new i(f),n.length>0&&typeof i.define=="function"&&await i.define(...n,{baseURL:s,mapper:f.mapper,onError:f.onError}))}return{autoDefiner:y,mergedEnhancers:S}}var H=["light","dark"],V=new Set(H);function Ae(e){let s=(Array.isArray(e?.themes)?e.themes.map(n=>String(n).toLowerCase()):H).filter(n=>V.has(n));return s.length?s:H}function K(e,{preferDocument:t=!0}={}){let s=String(e||"").toLowerCase();if(V.has(s))return s;if(t&&typeof document<"u"){let n=document.documentElement?.getAttribute("data-theme");if(V.has(n))return n}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function le(e,t){let s=K(t);return Ae(e).includes(s)}var G=class extends EventTarget{},r=new G;r.initializing=!1;r.currentPreset=null;r.debug=!1;var I=null,$=null,N=null,O=null;function j(e,t){return t&&typeof t=="string"?t:`${C(r.currentConfig||{},{resolvePublicAssetURL:M})}core/${e}`}async function xe(){return Array.isArray(r.defaultEnhancers)&&r.defaultEnhancers.length>0?r.defaultEnhancers:(O||(O=import(j("pds-enhancers.js",r.currentConfig?.enhancersURL)).then(t=>{let s=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return r.defaultEnhancers=s,s}).catch(t=>{throw O=null,t})),O)}async function De(){return typeof r.ask=="function"&&r.ask!==ue?r.ask:($||($=import(j("pds-ask.js",r.currentConfig?.askURL)).then(t=>{let s=t?.ask;if(typeof s!="function")throw new Error("Failed to load ask helper");return r.ask=s,s}).catch(t=>{throw $=null,t})),$)}async function R(){return typeof r.toast=="function"&&r.toast!==k?r.toast:(N||(N=import(j("pds-toast.js",r.currentConfig?.toastURL)).then(t=>{let s=t?.toast;if(typeof s!="function")throw new Error("Failed to load toast helper");return r.toast=s,s}).catch(t=>{throw N=null,t})),N)}async function ue(...e){return(await De())(...e)}async function k(...e){return(await R())(...e)}k.success=async(...e)=>(await R()).success(...e);k.error=async(...e)=>(await R()).error(...e);k.warning=async(...e)=>(await R()).warning(...e);k.info=async(...e)=>(await R()).info(...e);var pe=function(e="log",t,...s){let n=!!(r.registry&&!r.registry.isLive),a=(this?.debug||this?.design?.debug||r.debug||!1)===!0;if(n){if(!r.debug)return}else if(!a&&e!=="error"&&e!=="warn")return;let o=console[e]||console.log;s.length>0?o(t,...s):o(t)};function Q(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>Q(s)).filter(s=>s!==void 0);let t={};for(let[s,n]of Object.entries(e)){let a=Q(n);a!==void 0&&(t[s]=a)}return t}async function je(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let s=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let n=await fetch(s,{cache:"no-store"});return n.ok?await n.json():null}catch{return null}}r.registry=_;r.enums=te;r.adoptLayers=Z;r.adoptPrimitives=Y;r.parse=W;r.createStylesheet=ee;r.isLiveMode=()=>_.isLive;r.ask=ue;r.toast=k;r.common=B;r.AutoComplete=null;r.loadAutoComplete=async()=>{if(r.AutoComplete&&typeof r.AutoComplete.connect=="function")return r.AutoComplete;let e=j("pds-autocomplete.js",r.currentConfig?.autoCompleteURL);return I||(I=import(e).then(t=>{let s=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!s)throw new Error("AutoComplete export not found in module");return r.AutoComplete=s,s}).catch(t=>{throw I=null,t})),I};function me(e){let t=typeof CustomEvent=="function";try{let s=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");r.dispatchEvent(s)}catch{}if(typeof document<"u")if(t){let s={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",s))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",s))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function fe(e={}){let t=typeof CustomEvent=="function",s={at:Date.now(),...e};try{let n=t?new CustomEvent("pds:config-changed",{detail:s}):new Event("pds:config-changed");r.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:s,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",n))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var q="pure-ds-theme",E=null,D=null;function J(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 X(e){try{if(E&&D){try{typeof E.removeEventListener=="function"?E.removeEventListener("change",D):typeof E.removeListener=="function"&&E.removeListener(D)}catch{}E=null,D=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),s=n=>{let a=n?.matches===void 0?t.matches:n.matches;try{let o=a?"dark":"light";document.documentElement.setAttribute("data-theme",o),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:o,source:"system"}}))}catch{}};E=t,D=s,typeof t.addEventListener=="function"?t.addEventListener("change",s):typeof t.addListener=="function"&&t.addListener(s)}}catch{}}Object.defineProperty(r,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(q)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=r.currentConfig?.design||null,s=K(e);if(t&&!le(t,s)){let n=t?.name||r.currentPreset?.name||r.currentConfig?.preset||"current preset";console.warn(`PDS theme "${s}" not supported by preset "${n}".`),r.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:s,preset:n}}));return}e==null?localStorage.removeItem(q):localStorage.setItem(q,e),J(e),X(e),r.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});r.defaultEnhancers=[];async function Re(e){let t=e&&e.mode||"live",{mode:s,...n}=e||{};if(t==="static")return Pe(n);let a=C(n,{resolvePublicAssetURL:M}),o=n?.managerURL||n?.public?.managerURL||n?.manager?.url||new URL("core/pds-manager.js",a).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:c}=await import(o);return c(r,n,{emitReady:me,emitConfigChanged:fe,applyResolvedTheme:J,setupSystemListenerIfNeeded:X})}r.start=Re;async function Pe(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,s=e.manageTheme??!0,n=e.themeStorageKey??"pure-ds-theme",a=e.staticPaths??{},o=C(e,{resolvePublicAssetURL:M}),c=e&&e.autoDefine||null,m;c&&c.baseURL?m=T(U(c.baseURL,{preferModule:!1})):m=`${o}components/`;let v=c&&Array.isArray(c.predefine)&&c.predefine||[],S=c&&typeof c.mapper=="function"&&c.mapper||null;try{ae(r);let{resolvedTheme:y}=ce({manageTheme:s,themeStorageKey:n,applyResolvedTheme:J,setupSystemListenerIfNeeded:X}),i=await je(o,e),l=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],p=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},b={tokens:`${o}styles/pds-tokens.css.js`,primitives:`${o}styles/pds-primitives.css.js`,components:`${o}styles/pds-components.css.js`,utilities:`${o}styles/pds-utilities.css.js`,styles:`${o}styles/pds-styles.css.js`},u=i?.paths||{};if(a={...b,...u,...a},r.registry.setStaticMode(a),t&&typeof document<"u")try{let g=await r.registry.getStylesheet("styles");if(g){g._pds=!0;let L=(document.adoptedStyleSheets||[]).filter(z=>z._pds!==!0);document.adoptedStyleSheets=[...L,g],fe({mode:"static",source:"static:styles-applied"})}}catch(g){pe.call(r,"warn","Failed to apply static styles:",g)}let f=null,d=[];try{let g=await xe(),L=await de({autoDefineBaseURL:m,autoDefinePreload:v,autoDefineMapper:S,autoDefinerModuleURL:j("pds-auto-definer.js",c?.moduleURL||r.currentConfig?.autoDefinerURL),enhancers:l,autoDefineOverrides:c||null,autoDefinePreferModule:!(c&&c.baseURL)},{baseEnhancers:g});f=L.autoDefiner,d=L.mergedEnhancers||[]}catch(g){pe.call(r,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",g)}let h=Q(e);return r.currentConfig=Object.freeze({mode:"static",...structuredClone(h),design:structuredClone(p.design||{}),preset:p.preset,theme:y,enhancers:d}),me({mode:"static",config:p,theme:y,autoDefiner:f}),{config:p,theme:y,autoDefiner:f}}catch(y){throw r.dispatchEvent(new CustomEvent("pds:error",{detail:{error:y}})),y}}var he={mode:"live",liveEdit:!0,preset:"default",autoDefine:{predefine:["pds-icon","pds-drawer","pds-toaster","pds-form"]},log(e,t,...s){console[e](t,...s)}};var w={name:"@pure-ds/core",shortname:"pds",version:"0.7.1",description:"Why develop a Design System when you can generate one?",repository:{type:"git",url:"git+https://github.com/Pure-Web-Foundation/pure-ds.git"},bugs:{url:"https://github.com/Pure-Web-Foundation/pure-ds/issues"},homepage:"https://puredesignsystem.z6.web.core.windows.net/",keywords:["design-system","css","web-components","lit","constructable-stylesheets","tokens","utilities","a11y"],type:"module",main:"./public/assets/pds/core.js",module:"./public/assets/pds/core.js",types:"./dist/types/pds.d.ts",bin:{"pds-build":"packages/pds-cli/bin/pds-static.js","pds-sync-assets":"packages/pds-cli/bin/sync-assets.js","pds-build-icons":"packages/pds-cli/bin/pds-build-icons.js","pds-import":"packages/pds-cli/bin/pds-import.js","pds-setup-copilot":"packages/pds-cli/bin/pds-setup-copilot.js","pds-init-config":"packages/pds-cli/bin/pds-init-config.js","pds-bootstrap":"packages/pds-cli/bin/pds-bootstrap.js"},exports:{".":{types:"./src/js/pds.d.ts",import:"./public/assets/pds/core.js"},"./pds-core":"./src/js/pds.js","./auto-define/*":"./public/auto-define/*"},files:[".github/copilot-instructions.md",".cursorrules","dist/types/","public/assets/js/","public/assets/pds/components/","public/assets/pds/templates/","public/assets/pds/core.js","public/assets/pds/core/","public/assets/pds/external/","public/assets/pds/vscode-custom-data.json","public/assets/pds/pds.css-data.json","public/assets/pds/pds-css-complete.json","public/auto-define/","public/pds/components/","public/assets/pds/icons/pds-icons.svg","packages/pds-cli/bin/","packages/pds-cli/lib/","src/js/pds.d.ts","src/js/pds.js","src/js/pds-live-manager/","src/js/pds-core/","custom-elements.json","custom-elements-manifest.config.js","pds.html-data.json","pds.css-data.json","readme.md","INTELLISENSE.md","CSS-INTELLISENSE-LIMITATION.md","CSS-INTELLISENSE-QUICK-REF.md"],scripts:{test:'echo "Error: no test specified" && exit 1',dev:"node esbuild-dev.js",prebuild:"npm run types",build:"node esbuild-build.js",types:"tsc -p tsconfig.json && node scripts/sync-types.mjs",postinstall:"node packages/pds-cli/bin/postinstall.mjs","prepds:build":"npm run types","pds:build":"node packages/pds-cli/bin/pds-static.js","pds:build-icons":"node packages/pds-cli/bin/pds-build-icons.js","pds:bootstrap":"node packages/pds-cli/bin/pds-bootstrap.js","pds:manifest":"node packages/pds-cli/bin/generate-manifest.js","pds:css-data":"node packages/pds-cli/bin/generate-css-data.js","pds:import":"node packages/pds-cli/bin/pds-import.js","pds:dx":"node packages/pds-cli/bin/pds-dx.js","storybook:generate":"cd packages/pds-storybook && npm run generate-stories","storybook:dev":"cd packages/pds-storybook && npm run storybook:dev","storybook:build":"cd packages/pds-storybook && npm run storybook:build"},author:"Marc van Neerven",license:"ISC",engines:{node:">=18"},publishConfig:{access:"public"},devDependencies:{"@custom-elements-manifest/analyzer":"^0.9.9",esbuild:"^0.19.0","fs-extra":"^11.1.1",typescript:"^5.6.3","@types/node":"^22.10.2"},dependencies:{lit:"^3.3.1","pure-web":"1.1.32"},customElements:"custom-elements.json"};await r.start(he);var ye=typeof w.repository=="string"?w.repository:w.repository?.url,Te=ye?ye.replace(/^git\+/,"").replace(/\.git$/,""):"",et=w.homepage||Te,tt=w.bugs?.url||"";document.body.innerHTML=`
|
|
1
|
+
var Pe=Object.defineProperty;var Me=(e,t)=>{for(var s in t)Pe(e,s,{get:t[s],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(s){console.error(`[PDS Registry] Failed to load static ${t}:`,s),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 n=new CSSStyleSheet;return n.replaceSync("/* Failed to load "+t+" */"),n}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},M=new Y;async function pe(e,t=[],s=null){try{let n=s?.primitivesStylesheet?s.primitivesStylesheet:await M.getStylesheet("primitives");e.adoptedStyleSheets=[n,...t]}catch(n){let d=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${d}> failed to adopt primitives:`,n),e.adoptedStyleSheets=t}}async function me(e,t=["primitives"],s=[],n=null){try{let r=(await Promise.all(t.map(async c=>{if(n)switch(c){case"tokens":return n.tokensStylesheet;case"primitives":return n.primitivesStylesheet;case"components":return n.componentsStylesheet;case"utilities":return n.utilitiesStylesheet;default:break}return M.getStylesheet(c)}))).filter(c=>c!==null);e.adoptedStyleSheets=[...r,...s]}catch(d){let r=e.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${r}> failed to adopt layers:`,d),e.adoptedStyleSheets=s}}function fe(e){let t=new CSSStyleSheet;return t.replaceSync(e),t}var he={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={};Me(ee,{deepMerge:()=>ye,fragmentFromTemplateLike:()=>Te,isObject:()=>O,parseHTML:()=>Z});function O(e){return e&&typeof e=="object"&&!Array.isArray(e)}function ye(e,t){let s={...e};return O(e)&&O(t)&&Object.keys(t).forEach(n=>{O(t[n])?n in e?s[n]=ye(e[n],t[n]):Object.assign(s,{[n]:t[n]}):Object.assign(s,{[n]:t[n]})}),s}function Te(e){let t=Array.isArray(e?.strings)?e.strings:[],s=Array.isArray(e?.values)?e.values:[],n=new Set,d=[],r=/(\s)(\.[\w-]+)=\s*$/;for(let i=0;i<t.length;i+=1){let b=t[i]??"",m=b.match(r);if(m&&i<s.length){let g=m[2].slice(1),v=`pds-val-${i}`;b=b.replace(r,`$1data-pds-prop="${g}:${v}"`),n.add(i)}d.push(b),i<s.length&&!n.has(i)&&d.push(`<!--pds-val-${i}-->`)}let c=document.createElement("template");c.innerHTML=d.join("");let E=(i,b)=>{let m=i.parentNode;if(!m)return;if(b==null){m.removeChild(i);return}let S=g=>{if(g!=null){if(g instanceof Node){m.insertBefore(g,i);return}if(Array.isArray(g)){g.forEach(v=>S(v));return}m.insertBefore(document.createTextNode(String(g)),i)}};S(b),m.removeChild(i)},L=document.createTreeWalker(c.content,NodeFilter.SHOW_COMMENT),f=[];for(;L.nextNode();){let i=L.currentNode;i?.nodeValue?.startsWith("pds-val-")&&f.push(i)}return f.forEach(i=>{let b=Number(i.nodeValue.replace("pds-val-",""));E(i,s[b])}),c.content.querySelectorAll("*").forEach(i=>{let b=i.getAttribute("data-pds-prop");if(!b)return;let[m,S]=b.split(":"),g=Number(String(S).replace("pds-val-",""));m&&Number.isInteger(g)&&(i[m]=s[g]),i.removeAttribute("data-pds-prop")}),c.content}function Z(e){return new DOMParser().parseFromString(e,"text/html").body.childNodes}var ge="pds",Ue=/^([a-z][a-z0-9+\-.]*:)?\/\//i,be=/^[a-z]:/i;function C(e=""){return e.endsWith("/")?e:`${e}/`}function Ce(e="",t=ge){let s=e.replace(/\/+$/,"");return new RegExp(`(?:^|/)${t}$`,"i").test(s)?s:`${s}/${t}`}function $e(e){return e.replace(/^\.\/+/,"")}function Ie(e){return be.test(e)?e.replace(be,"").replace(/^\/+/,""):e}function Ne(e){return e.startsWith("public/")?e.substring(7):e}function z(e,t={}){let s=t.segment||ge,n=t.defaultRoot||`/assets/${s}/`,d=e?.public&&e.public?.root||e?.static&&e.static?.root||null;if(!d||typeof d!="string")return C(n);let r=d.trim();return r?(r=r.replace(/\\/g,"/"),r=Ce(r,s),r=C(r),Ue.test(r)?r:(r=$e(r),r=Ie(r),r.startsWith("/")||(r=Ne(r),r.startsWith("/")||(r=`/${r}`),r=r.replace(/\/+/g,(c,E)=>E===0?c:"/")),C(r))):C(n)}async function Oe(...e){let t={};e.length&&typeof e[e.length-1]=="object"&&(t=e.pop()||{});let s=e,{baseURL:n,mapper:d=f=>`${f}.js`,onError:r=(f,a)=>console.error(`[defineWebComponents] ${f}:`,a)}=t,c=n?new URL(n,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),E=f=>f.toLowerCase().replace(/(^|-)([a-z])/g,(a,i,b)=>b.toUpperCase()),L=async f=>{try{if(customElements.get(f))return{tag:f,status:"already-defined"};let a=d(f),b=await import(a instanceof URL?a.href:new URL(a,c).href),m=b?.default??b?.[E(f)];if(!m){if(customElements.get(f))return{tag:f,status:"self-defined"};throw new Error(`No export found for ${f}. Expected default export or named export "${E(f)}".`)}return customElements.get(f)?{tag:f,status:"race-already-defined"}:(customElements.define(f,m),{tag:f,status:"defined"})}catch(a){throw r(f,a),a}};return Promise.all(s.map(L))}var F=class{constructor(t={}){let{baseURL:s,mapper:n,onError:d,predicate:r=()=>!0,attributeModule:c="data-module",root:E=document,scanExisting:L=!0,debounceMs:f=16,observeShadows:a=!0,enhancers:i=[],patchAttachShadow:b=!0}=t,m=new Set,S=new Set,g=new Set,v=new Map,k=new WeakMap,x=new WeakMap,w=0,h=!1,y=null,j=l=>{if(!l||!i.length)return;let p=x.get(l);p||(p=new Set,x.set(l,p));for(let u of i)if(!(!u.selector||!u.run)&&!p.has(u.selector))try{l.matches&&l.matches(u.selector)&&(u.run(l),p.add(u.selector))}catch(_){console.warn(`[AutoDefiner] Error applying enhancer for selector "${u.selector}":`,_)}},U=(l,p)=>{if(!h&&!(!l||!l.includes("-"))&&!customElements.get(l)&&!S.has(l)&&!g.has(l)){if(p&&p.getAttribute){let u=p.getAttribute(c);u&&!v.has(l)&&v.set(l,u)}m.add(l),J()}},J=()=>{w||(w=setTimeout(de,f))},D=l=>{if(l){if(l.nodeType===1){let p=l,u=p.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&r(u,p)&&U(u,p),j(p),a&&p.shadowRoot&&X(p.shadowRoot)}l.querySelectorAll&&l.querySelectorAll("*").forEach(p=>{let u=p.tagName?.toLowerCase();u&&u.includes("-")&&!customElements.get(u)&&r(u,p)&&U(u,p),j(p),a&&p.shadowRoot&&X(p.shadowRoot)})}},X=l=>{if(!l||k.has(l))return;D(l);let p=new MutationObserver(u=>{for(let _ of u)_.addedNodes?.forEach(P=>{D(P)}),_.type==="attributes"&&_.target&&D(_.target)});p.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[c,...i.map(u=>u.selector).filter(u=>u.startsWith("data-"))]}),k.set(l,p)};async function de(){if(clearTimeout(w),w=0,!m.size)return;let l=Array.from(m);m.clear(),l.forEach(p=>S.add(p));try{let p=u=>v.get(u)??(n?n(u):`${u}.js`);await Oe(...l,{baseURL:s,mapper:p,onError:(u,_)=>{g.add(u),d?.(u,_)}})}catch{}finally{l.forEach(p=>S.delete(p))}}let le=E===document?document.documentElement:E,ue=new MutationObserver(l=>{for(let p of l)p.addedNodes?.forEach(u=>{D(u)}),p.type==="attributes"&&p.target&&D(p.target)});if(ue.observe(le,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[c,...i.map(l=>l.selector).filter(l=>l.startsWith("data-"))]}),a&&b&&Element.prototype.attachShadow){let l=Element.prototype.attachShadow;Element.prototype.attachShadow=function(u){let _=l.call(this,u);if(u&&u.mode==="open"){X(_);let P=this.tagName?.toLowerCase();P&&P.includes("-")&&!customElements.get(P)&&U(P,this)}return _},y=()=>Element.prototype.attachShadow=l}return L&&D(le),{stop(){h=!0,ue.disconnect(),y&&y(),w&&(clearTimeout(w),w=0),k.forEach(l=>l.disconnect())},flush:de}}static async define(...t){let s={};t.length&&typeof t[t.length-1]=="object"&&(s=t.pop()||{});let n=t,{baseURL:d,mapper:r=a=>`${a}.js`,onError:c=(a,i)=>console.error(`[defineWebComponents] ${a}:`,i)}=s,E=d?new URL(d,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),L=a=>a.toLowerCase().replace(/(^|-)([a-z])/g,(i,b,m)=>m.toUpperCase()),f=async a=>{try{if(customElements.get(a))return{tag:a,status:"already-defined"};let i=r(a),m=await import(i instanceof URL?i.href:new URL(i,E).href),S=m?.default??m?.[L(a)];if(!S){if(customElements.get(a))return{tag:a,status:"self-defined"};throw new Error(`No export found for ${a}. Expected default export or named export "${L(a)}".`)}return customElements.get(a)?{tag:a,status:"race-already-defined"}:(customElements.define(a,S),{tag:a,status:"defined"})}catch(i){throw c(a,i),i}};return Promise.all(n.map(f))}};var ze=/^[a-z][a-z0-9+\-.]*:\/\//i,$=(()=>{try{return import.meta.url}catch{return}})(),W=e=>typeof e=="string"&&e.length&&!e.endsWith("/")?`${e}/`:e;function B(e,t={}){if(!e||ze.test(e))return e;let{preferModule:s=!0}=t,n=()=>{if(!$)return null;try{return new URL(e,$).href}catch{return null}},d=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(e,window.location.origin).href}catch{return null}};return(s?n()||d():d()||n())||e}var we=(()=>{if($)try{let e=new URL($);if(/\/public\/assets\/js\//.test(e.pathname))return new URL("../pds/",$).href}catch{return}})(),Ee=!1;function Se(e){Ee||typeof document>"u"||(Ee=!0,e.addEventListener("pds:ready",t=>{let s=t.detail?.mode;s&&document.documentElement.classList.add(`pds-${s}`,"pds-ready")}))}function ve({manageTheme:e,themeStorageKey:t,applyResolvedTheme:s,setupSystemListenerIfNeeded:n}){let d="light",r=null;if(e&&typeof window<"u"){try{r=localStorage.getItem(t)||null}catch{r=null}try{s?.(r),n?.(r)}catch{}r?r==="system"?d=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":d=r:d=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:d,storedTheme:r}}function q(e,{resolvePublicAssetURL:t}){let s=!!(e?.public?.root||e?.static?.root),n=t(e);return!s&&we&&(n=we),W(B(n))}async function Le(e,{baseEnhancers:t=[]}={}){let{autoDefineBaseURL:s="/auto-define/",autoDefinePreload:n=[],autoDefineMapper:d=null,enhancers:r=[],autoDefineOverrides:c=null,autoDefinePreferModule:E=!0}=e,L=(()=>{let a=new Map;return(t||[]).forEach(i=>a.set(i.selector,i)),(r||[]).forEach(i=>a.set(i.selector,i)),Array.from(a.values())})(),f=null;if(typeof window<"u"&&typeof document<"u"){let a=F,i=h=>{switch(h){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${h}.js`}},{mapper:b,enhancers:m,...S}=c&&typeof c=="object"?c:{},g=m?Array.isArray(m)?m:typeof m=="object"?Object.values(m):[]:[],v=(()=>{let h=new Map;return(L||[]).forEach(y=>{y?.selector&&h.set(y.selector,y)}),(g||[]).forEach(y=>{if(!y?.selector)return;let j=h.get(y.selector)||null;h.set(y.selector,{...j||{},...y,run:typeof y?.run=="function"?y.run:j?.run})}),Array.from(h.values())})(),x={baseURL:s&&W(B(s,{preferModule:E})),predefine:n,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:v,onError:(h,y)=>{if(typeof h=="string"&&h.startsWith("pds-")){let U=["pds-form","pds-drawer"].includes(h),J=y?.message?.includes("#pds/lit")||y?.message?.includes("Failed to resolve module specifier");U&&J?console.error(`\u274C PDS component <${h}> 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 <${h}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${h}>:`,y)},...S,mapper:h=>{if(customElements.get(h))return null;if(typeof d=="function")try{let y=d(h);return y===void 0?i(h):y}catch(y){return console.warn("Custom autoDefine.mapper error; falling back to default:",y?.message||y),i(h)}return i(h)}};if(!!(typeof window<"u"&&window.__PDS_DEBUG_AUTODEFINE__||c?.debugAutoDefine)){let h=v.filter(y=>typeof y?.run!="function").map(y=>y?.selector).filter(Boolean);console.info("[PDS][AutoDefiner] enhancer summary",{baseEnhancers:(t||[]).length,userEnhancers:(r||[]).length,overrideEnhancers:g.length,resolvedEnhancers:v.length,missingRun:h})}f=new a(x),n.length>0&&typeof a.define=="function"&&await a.define(...n,{baseURL:s,mapper:x.mapper,onError:x.onError})}return{autoDefiner:f,mergedEnhancers:L}}var te=["light","dark"],se=new Set(te);function Fe(e){let s=(Array.isArray(e?.themes)?e.themes.map(n=>String(n).toLowerCase()):te).filter(n=>se.has(n));return s.length?s:te}function ne(e,{preferDocument:t=!0}={}){let s=String(e||"").toLowerCase();if(se.has(s))return s;if(t&&typeof document<"u"){let n=document.documentElement?.getAttribute("data-theme");if(se.has(n))return n}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function _e(e,t){let s=ne(t);return Fe(e).includes(s)}var oe=class extends EventTarget{},o=new oe;o.initializing=!1;o.currentPreset=null;o.debug=!1;var H=null,V=null,K=null,G=null;function Q(e,t){return t&&typeof t=="string"?t:`${q(o.currentConfig||{},{resolvePublicAssetURL:z})}core/${e}`}async function We(){return Array.isArray(o.defaultEnhancers)&&o.defaultEnhancers.length>0?o.defaultEnhancers:(G||(G=import(Q("pds-enhancers.js",o.currentConfig?.enhancersURL)).then(t=>{let s=Array.isArray(t?.defaultPDSEnhancers)?t.defaultPDSEnhancers:[];return o.defaultEnhancers=s,s}).catch(t=>{throw G=null,t})),G)}async function Be(){return typeof o.ask=="function"&&o.ask!==xe?o.ask:(V||(V=import(Q("pds-ask.js",o.currentConfig?.askURL)).then(t=>{let s=t?.ask;if(typeof s!="function")throw new Error("Failed to load ask helper");return o.ask=s,s}).catch(t=>{throw V=null,t})),V)}async function N(){return typeof o.toast=="function"&&o.toast!==T?o.toast:(K||(K=import(Q("pds-toast.js",o.currentConfig?.toastURL)).then(t=>{let s=t?.toast;if(typeof s!="function")throw new Error("Failed to load toast helper");return o.toast=s,s}).catch(t=>{throw K=null,t})),K)}async function xe(...e){return(await Be())(...e)}async function T(...e){return(await N())(...e)}T.success=async(...e)=>(await N()).success(...e);T.error=async(...e)=>(await N()).error(...e);T.warning=async(...e)=>(await N()).warning(...e);T.info=async(...e)=>(await N()).info(...e);var Ae=function(e="log",t,...s){let n=!!(o.registry&&!o.registry.isLive),d=(this?.debug||this?.design?.debug||o.debug||!1)===!0;if(n){if(!o.debug)return}else if(!d&&e!=="error"&&e!=="warn")return;let r=console[e]||console.log;s.length>0?r(t,...s):r(t)};function ie(e){if(e==null)return e;if(typeof e=="function")return;if(typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>ie(s)).filter(s=>s!==void 0);let t={};for(let[s,n]of Object.entries(e)){let d=ie(n);d!==void 0&&(t[s]=d)}return t}async function qe(e,t={}){if(t?.runtimeConfig===!1||typeof fetch!="function")return null;let s=t?.runtimeConfigURL||`${e}pds-runtime-config.json`;try{let n=await fetch(s,{cache:"no-store"});return n.ok?await n.json():null}catch{return null}}o.registry=M;o.enums=he;o.adoptLayers=me;o.adoptPrimitives=pe;o.parse=Z;o.createStylesheet=fe;o.isLiveMode=()=>M.isLive;o.ask=xe;o.toast=T;o.common=ee;o.AutoComplete=null;o.loadAutoComplete=async()=>{if(o.AutoComplete&&typeof o.AutoComplete.connect=="function")return o.AutoComplete;let e=Q("pds-autocomplete.js",o.currentConfig?.autoCompleteURL);return H||(H=import(e).then(t=>{let s=t?.AutoComplete||t?.default?.AutoComplete||t?.default||null;if(!s)throw new Error("AutoComplete export not found in module");return o.AutoComplete=s,s}).catch(t=>{throw H=null,t})),H};function ke(e){let t=typeof CustomEvent=="function";try{let s=t?new CustomEvent("pds:ready",{detail:e}):new Event("pds:ready");o.dispatchEvent(s)}catch{}if(typeof document<"u")if(t){let s={detail:e,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:ready",s))}catch{}try{document.dispatchEvent(new CustomEvent("pds-ready",s))}catch{}}else{try{document.dispatchEvent(new Event("pds:ready"))}catch{}try{document.dispatchEvent(new Event("pds-ready"))}catch{}}}function Re(e={}){let t=typeof CustomEvent=="function",s={at:Date.now(),...e};try{let n=t?new CustomEvent("pds:config-changed",{detail:s}):new Event("pds:config-changed");o.dispatchEvent(n)}catch{}if(typeof document<"u")if(t){let n={detail:s,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",n))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}var re="pure-ds-theme",R=null,I=null;function ae(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 ce(e){try{if(R&&I){try{typeof R.removeEventListener=="function"?R.removeEventListener("change",I):typeof R.removeListener=="function"&&R.removeListener(I)}catch{}R=null,I=null}if(e==="system"&&typeof window<"u"&&window.matchMedia){let t=window.matchMedia("(prefers-color-scheme: dark)"),s=n=>{let d=n?.matches===void 0?t.matches:n.matches;try{let r=d?"dark":"light";document.documentElement.setAttribute("data-theme",r),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:r,source:"system"}}))}catch{}};R=t,I=s,typeof t.addEventListener=="function"?t.addEventListener("change",s):typeof t.addListener=="function"&&t.addListener(s)}}catch{}}Object.defineProperty(o,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(re)||null}catch{return null}},set(e){try{if(typeof window>"u")return;let t=o.currentConfig?.design||null,s=ne(e);if(t&&!_e(t,s)){let n=t?.name||o.currentPreset?.name||o.currentConfig?.preset||"current preset";console.warn(`PDS theme "${s}" not supported by preset "${n}".`),o.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:e,resolvedTheme:s,preset:n}}));return}e==null?localStorage.removeItem(re):localStorage.setItem(re,e),ae(e),ce(e),o.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:e,source:"api"}}))}catch{}}});o.defaultEnhancers=[];async function He(e){let t=e&&e.mode||"live",{mode:s,...n}=e||{};if(t==="static")return Ve(n);let d=q(n,{resolvePublicAssetURL:z}),r=n?.managerURL||n?.public?.managerURL||n?.manager?.url||new URL("core/pds-manager.js",d).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:c}=await import(r);return c(o,n,{emitReady:ke,emitConfigChanged:Re,applyResolvedTheme:ae,setupSystemListenerIfNeeded:ce})}o.start=He;async function Ve(e){if(!e||typeof e!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let t=e.applyGlobalStyles??!0,s=e.manageTheme??!0,n=e.themeStorageKey??"pure-ds-theme",d=e.staticPaths??{},r=q(e,{resolvePublicAssetURL:z}),c=e&&e.autoDefine||null,E;c&&c.baseURL?E=W(B(c.baseURL,{preferModule:!1})):E=`${r}components/`;let L=c&&Array.isArray(c.predefine)&&c.predefine||[],f=c&&typeof c.mapper=="function"&&c.mapper||null;try{Se(o);let{resolvedTheme:a}=ve({manageTheme:s,themeStorageKey:n,applyResolvedTheme:ae,setupSystemListenerIfNeeded:ce}),i=await qe(r,e),b=Array.isArray(e?.enhancers)?e.enhancers:e?.enhancers&&typeof e.enhancers=="object"?Object.values(e.enhancers):[],m=i?.config?{...i.config,...e,design:e?.design||i.config.design,preset:e?.preset||i.config.preset}:{...e},S={tokens:`${r}styles/pds-tokens.css.js`,primitives:`${r}styles/pds-primitives.css.js`,components:`${r}styles/pds-components.css.js`,utilities:`${r}styles/pds-utilities.css.js`,styles:`${r}styles/pds-styles.css.js`},g=i?.paths||{};if(d={...S,...g,...d},o.registry.setStaticMode(d),t&&typeof document<"u")try{let w=await o.registry.getStylesheet("styles");if(w){w._pds=!0;let h=(document.adoptedStyleSheets||[]).filter(y=>y._pds!==!0);document.adoptedStyleSheets=[...h,w],Re({mode:"static",source:"static:styles-applied"})}}catch(w){Ae.call(o,"warn","Failed to apply static styles:",w)}let v=null,k=[];try{let w=await We(),h=await Le({autoDefineBaseURL:E,autoDefinePreload:L,autoDefineMapper:f,enhancers:b,autoDefineOverrides:c||null,autoDefinePreferModule:!(c&&c.baseURL)},{baseEnhancers:w});v=h.autoDefiner,k=h.mergedEnhancers||[]}catch(w){Ae.call(o,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",w)}let x=ie(e);return o.currentConfig=Object.freeze({mode:"static",...structuredClone(x),design:structuredClone(m.design||{}),preset:m.preset,theme:a,enhancers:k}),ke({mode:"static",config:m,theme:a,autoDefiner:v}),{config:m,theme:a,autoDefiner:v}}catch(a){throw o.dispatchEvent(new CustomEvent("pds:error",{detail:{error:a}})),a}}var je={mode:"live",liveEdit:!0,preset:"default",autoDefine:{predefine:["pds-icon","pds-drawer","pds-toaster","pds-form"]},log(e,t,...s){console[e](t,...s)}};var A={name:"@pure-ds/core",shortname:"pds",version:"0.7.4",description:"Why develop a Design System when you can generate one?",repository:{type:"git",url:"git+https://github.com/Pure-Web-Foundation/pure-ds.git"},bugs:{url:"https://github.com/Pure-Web-Foundation/pure-ds/issues"},homepage:"https://puredesignsystem.z6.web.core.windows.net/",keywords:["design-system","css","web-components","lit","constructable-stylesheets","tokens","utilities","a11y"],type:"module",main:"./public/assets/pds/core.js",module:"./public/assets/pds/core.js",types:"./dist/types/pds.d.ts",bin:{"pds-build":"packages/pds-cli/bin/pds-static.js","pds-sync-assets":"packages/pds-cli/bin/sync-assets.js","pds-build-icons":"packages/pds-cli/bin/pds-build-icons.js","pds-import":"packages/pds-cli/bin/pds-import.js","pds-setup-copilot":"packages/pds-cli/bin/pds-setup-copilot.js","pds-init-config":"packages/pds-cli/bin/pds-init-config.js","pds-bootstrap":"packages/pds-cli/bin/pds-bootstrap.js"},exports:{".":{types:"./src/js/pds.d.ts",import:"./public/assets/pds/core.js"},"./pds-core":"./src/js/pds.js","./auto-define/*":"./public/auto-define/*"},files:[".github/copilot-instructions.md",".cursorrules","dist/types/","public/assets/js/","public/assets/pds/components/","public/assets/pds/templates/","public/assets/pds/core.js","public/assets/pds/core/","public/assets/pds/external/","public/assets/pds/vscode-custom-data.json","public/assets/pds/pds.css-data.json","public/assets/pds/pds-css-complete.json","public/auto-define/","public/pds/components/","public/assets/pds/icons/pds-icons.svg","packages/pds-cli/bin/","packages/pds-cli/lib/","src/js/pds.d.ts","src/js/pds.js","src/js/pds-live-manager/","src/js/pds-core/","custom-elements.json","custom-elements-manifest.config.js","pds.html-data.json","pds.css-data.json","readme.md","INTELLISENSE.md","CSS-INTELLISENSE-LIMITATION.md","CSS-INTELLISENSE-QUICK-REF.md"],scripts:{test:'echo "Error: no test specified" && exit 1',dev:"node esbuild-dev.js",prebuild:"npm run types",build:"node esbuild-build.js",types:"tsc -p tsconfig.json && node scripts/sync-types.mjs",postinstall:"node packages/pds-cli/bin/postinstall.mjs","prepds:build":"npm run types","pds:build":"node packages/pds-cli/bin/pds-static.js","pds:build-icons":"node packages/pds-cli/bin/pds-build-icons.js","pds:bootstrap":"node packages/pds-cli/bin/pds-bootstrap.js","pds:manifest":"node packages/pds-cli/bin/generate-manifest.js","pds:css-data":"node packages/pds-cli/bin/generate-css-data.js","pds:import":"node packages/pds-cli/bin/pds-import.js","pds:dx":"node packages/pds-cli/bin/pds-dx.js","storybook:generate":"cd packages/pds-storybook && npm run generate-stories","storybook:dev":"cd packages/pds-storybook && npm run storybook:dev","storybook:build":"cd packages/pds-storybook && npm run storybook:build"},author:"Marc van Neerven",license:"ISC",engines:{node:">=18"},publishConfig:{access:"public"},devDependencies:{"@custom-elements-manifest/analyzer":"^0.9.9",esbuild:"^0.19.0","fs-extra":"^11.1.1",typescript:"^5.6.3","@types/node":"^22.10.2"},dependencies:{lit:"^3.3.1","pure-web":"1.1.32"},customElements:"custom-elements.json"};await o.start(je);var De=typeof A.repository=="string"?A.repository:A.repository?.url,Ge=De?De.replace(/^git\+/,"").replace(/\.git$/,""):"",bt=A.homepage||Ge,gt=A.bugs?.url||"";document.body.innerHTML=`
|
|
3
3
|
<pds-toaster id="global-toaster"></pds-toaster>
|
|
4
4
|
|
|
5
5
|
<div class="container text-center">
|
|
6
6
|
<img src="/assets/img/pds-logo.svg" alt="PDS Logo" width="64" height="64" />
|
|
7
7
|
<header class="container section">
|
|
8
|
-
<h1>${
|
|
9
|
-
<small class="text-muted">${
|
|
8
|
+
<h1>${A.name} ${A.version}</h1>
|
|
9
|
+
<small class="text-muted">${A.description}</small>
|
|
10
10
|
</header>
|
|
11
11
|
</div>
|
|
12
12
|
`;
|
|
@@ -1 +1,306 @@
|
|
|
1
|
-
|
|
1
|
+
// node_modules/pure-web/src/js/auto-definer.js
|
|
2
|
+
async function defineWebComponents(...args) {
|
|
3
|
+
let opts = {};
|
|
4
|
+
if (args.length && typeof args[args.length - 1] === "object") {
|
|
5
|
+
opts = args.pop() || {};
|
|
6
|
+
}
|
|
7
|
+
const tags = args;
|
|
8
|
+
const {
|
|
9
|
+
baseURL,
|
|
10
|
+
mapper = (tag) => `${tag}.js`,
|
|
11
|
+
onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
|
|
12
|
+
} = opts;
|
|
13
|
+
const base = baseURL ? new URL(
|
|
14
|
+
baseURL,
|
|
15
|
+
typeof location !== "undefined" ? location.href : import.meta.url
|
|
16
|
+
) : new URL("./", import.meta.url);
|
|
17
|
+
const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
18
|
+
const loadOne = async (tag) => {
|
|
19
|
+
try {
|
|
20
|
+
if (customElements.get(tag))
|
|
21
|
+
return { tag, status: "already-defined" };
|
|
22
|
+
const spec = mapper(tag);
|
|
23
|
+
const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
|
|
24
|
+
const mod = await import(href);
|
|
25
|
+
const Named = mod?.default ?? mod?.[toPascal(tag)];
|
|
26
|
+
if (!Named) {
|
|
27
|
+
if (customElements.get(tag))
|
|
28
|
+
return { tag, status: "self-defined" };
|
|
29
|
+
throw new Error(
|
|
30
|
+
`No export found for ${tag}. Expected default export or named export "${toPascal(
|
|
31
|
+
tag
|
|
32
|
+
)}".`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (!customElements.get(tag)) {
|
|
36
|
+
customElements.define(tag, Named);
|
|
37
|
+
return { tag, status: "defined" };
|
|
38
|
+
}
|
|
39
|
+
return { tag, status: "race-already-defined" };
|
|
40
|
+
} catch (err) {
|
|
41
|
+
onError(tag, err);
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return Promise.all(tags.map(loadOne));
|
|
46
|
+
}
|
|
47
|
+
var AutoDefiner = class {
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
const {
|
|
50
|
+
baseURL,
|
|
51
|
+
mapper,
|
|
52
|
+
onError,
|
|
53
|
+
predicate = () => true,
|
|
54
|
+
attributeModule = "data-module",
|
|
55
|
+
root = document,
|
|
56
|
+
scanExisting = true,
|
|
57
|
+
debounceMs = 16,
|
|
58
|
+
observeShadows = true,
|
|
59
|
+
enhancers = [],
|
|
60
|
+
// [{String selector, Function run(elem)}]
|
|
61
|
+
patchAttachShadow = true
|
|
62
|
+
} = options;
|
|
63
|
+
const pending = /* @__PURE__ */ new Set();
|
|
64
|
+
const inFlight = /* @__PURE__ */ new Set();
|
|
65
|
+
const knownMissing = /* @__PURE__ */ new Set();
|
|
66
|
+
const perTagModulePath = /* @__PURE__ */ new Map();
|
|
67
|
+
const shadowObservers = /* @__PURE__ */ new WeakMap();
|
|
68
|
+
const enhancerApplied = /* @__PURE__ */ new WeakMap();
|
|
69
|
+
let timer = 0;
|
|
70
|
+
let stopped = false;
|
|
71
|
+
let restoreAttachShadow = null;
|
|
72
|
+
const applyEnhancers = (element) => {
|
|
73
|
+
if (!element || !enhancers.length)
|
|
74
|
+
return;
|
|
75
|
+
let appliedEnhancers = enhancerApplied.get(element);
|
|
76
|
+
if (!appliedEnhancers) {
|
|
77
|
+
appliedEnhancers = /* @__PURE__ */ new Set();
|
|
78
|
+
enhancerApplied.set(element, appliedEnhancers);
|
|
79
|
+
}
|
|
80
|
+
for (const enhancer of enhancers) {
|
|
81
|
+
if (!enhancer.selector || !enhancer.run)
|
|
82
|
+
continue;
|
|
83
|
+
if (appliedEnhancers.has(enhancer.selector))
|
|
84
|
+
continue;
|
|
85
|
+
try {
|
|
86
|
+
if (element.matches && element.matches(enhancer.selector)) {
|
|
87
|
+
enhancer.run(element);
|
|
88
|
+
appliedEnhancers.add(enhancer.selector);
|
|
89
|
+
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
console.warn(
|
|
92
|
+
`[AutoDefiner] Error applying enhancer for selector "${enhancer.selector}":`,
|
|
93
|
+
err
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const queueTag = (tag, el) => {
|
|
99
|
+
if (stopped)
|
|
100
|
+
return;
|
|
101
|
+
if (!tag || !tag.includes("-"))
|
|
102
|
+
return;
|
|
103
|
+
if (customElements.get(tag))
|
|
104
|
+
return;
|
|
105
|
+
if (inFlight.has(tag))
|
|
106
|
+
return;
|
|
107
|
+
if (knownMissing.has(tag))
|
|
108
|
+
return;
|
|
109
|
+
if (el && el.getAttribute) {
|
|
110
|
+
const override = el.getAttribute(attributeModule);
|
|
111
|
+
if (override && !perTagModulePath.has(tag)) {
|
|
112
|
+
perTagModulePath.set(tag, override);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
pending.add(tag);
|
|
116
|
+
schedule();
|
|
117
|
+
};
|
|
118
|
+
const schedule = () => {
|
|
119
|
+
if (timer)
|
|
120
|
+
return;
|
|
121
|
+
timer = setTimeout(flush, debounceMs);
|
|
122
|
+
};
|
|
123
|
+
const crawlTree = (rootNode) => {
|
|
124
|
+
if (!rootNode)
|
|
125
|
+
return;
|
|
126
|
+
if (rootNode.nodeType === 1) {
|
|
127
|
+
const el = (
|
|
128
|
+
/** @type {Element} */
|
|
129
|
+
rootNode
|
|
130
|
+
);
|
|
131
|
+
const tag = el.tagName?.toLowerCase();
|
|
132
|
+
if (tag && tag.includes("-") && !customElements.get(tag) && predicate(tag, el)) {
|
|
133
|
+
queueTag(tag, el);
|
|
134
|
+
}
|
|
135
|
+
applyEnhancers(el);
|
|
136
|
+
if (observeShadows && el.shadowRoot) {
|
|
137
|
+
observeShadowRoot(el.shadowRoot);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (rootNode.querySelectorAll) {
|
|
141
|
+
rootNode.querySelectorAll("*").forEach((e) => {
|
|
142
|
+
const t = e.tagName?.toLowerCase();
|
|
143
|
+
if (t && t.includes("-") && !customElements.get(t) && predicate(t, e)) {
|
|
144
|
+
queueTag(t, e);
|
|
145
|
+
}
|
|
146
|
+
applyEnhancers(e);
|
|
147
|
+
if (observeShadows && e.shadowRoot) {
|
|
148
|
+
observeShadowRoot(e.shadowRoot);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const observeShadowRoot = (sr) => {
|
|
154
|
+
if (!sr || shadowObservers.has(sr))
|
|
155
|
+
return;
|
|
156
|
+
crawlTree(sr);
|
|
157
|
+
const mo = new MutationObserver((mutations) => {
|
|
158
|
+
for (const m of mutations) {
|
|
159
|
+
m.addedNodes?.forEach((n) => {
|
|
160
|
+
crawlTree(n);
|
|
161
|
+
});
|
|
162
|
+
if (m.type === "attributes" && m.target) {
|
|
163
|
+
crawlTree(m.target);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
mo.observe(sr, {
|
|
168
|
+
childList: true,
|
|
169
|
+
subtree: true,
|
|
170
|
+
attributes: true,
|
|
171
|
+
attributeFilter: [
|
|
172
|
+
attributeModule,
|
|
173
|
+
...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
shadowObservers.set(sr, mo);
|
|
177
|
+
};
|
|
178
|
+
async function flush() {
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
timer = 0;
|
|
181
|
+
if (!pending.size)
|
|
182
|
+
return;
|
|
183
|
+
const tags = Array.from(pending);
|
|
184
|
+
pending.clear();
|
|
185
|
+
tags.forEach((t) => inFlight.add(t));
|
|
186
|
+
try {
|
|
187
|
+
const effectiveMapper = (tag) => perTagModulePath.get(tag) ?? (mapper ? mapper(tag) : `${tag}.js`);
|
|
188
|
+
await defineWebComponents(...tags, {
|
|
189
|
+
baseURL,
|
|
190
|
+
mapper: effectiveMapper,
|
|
191
|
+
onError: (tag, err) => {
|
|
192
|
+
knownMissing.add(tag);
|
|
193
|
+
onError?.(tag, err);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
} catch {
|
|
197
|
+
} finally {
|
|
198
|
+
tags.forEach((t) => inFlight.delete(t));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const mountNode = root === document ? document.documentElement : root;
|
|
202
|
+
const obs = new MutationObserver((mutations) => {
|
|
203
|
+
for (const m of mutations) {
|
|
204
|
+
m.addedNodes?.forEach((n) => {
|
|
205
|
+
crawlTree(n);
|
|
206
|
+
});
|
|
207
|
+
if (m.type === "attributes" && m.target) {
|
|
208
|
+
crawlTree(m.target);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
obs.observe(mountNode, {
|
|
213
|
+
childList: true,
|
|
214
|
+
subtree: true,
|
|
215
|
+
attributes: true,
|
|
216
|
+
attributeFilter: [
|
|
217
|
+
attributeModule,
|
|
218
|
+
...enhancers.map((e) => e.selector).filter((s) => s.startsWith("data-"))
|
|
219
|
+
]
|
|
220
|
+
});
|
|
221
|
+
if (observeShadows && patchAttachShadow && Element.prototype.attachShadow) {
|
|
222
|
+
const orig = Element.prototype.attachShadow;
|
|
223
|
+
Element.prototype.attachShadow = function patchedAttachShadow(init) {
|
|
224
|
+
const sr = orig.call(this, init);
|
|
225
|
+
if (init && init.mode === "open") {
|
|
226
|
+
observeShadowRoot(sr);
|
|
227
|
+
const tag = this.tagName?.toLowerCase();
|
|
228
|
+
if (tag && tag.includes("-") && !customElements.get(tag)) {
|
|
229
|
+
queueTag(tag, this);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return sr;
|
|
233
|
+
};
|
|
234
|
+
restoreAttachShadow = () => Element.prototype.attachShadow = orig;
|
|
235
|
+
}
|
|
236
|
+
if (scanExisting) {
|
|
237
|
+
crawlTree(mountNode);
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
stop() {
|
|
241
|
+
stopped = true;
|
|
242
|
+
obs.disconnect();
|
|
243
|
+
if (restoreAttachShadow)
|
|
244
|
+
restoreAttachShadow();
|
|
245
|
+
if (timer) {
|
|
246
|
+
clearTimeout(timer);
|
|
247
|
+
timer = 0;
|
|
248
|
+
}
|
|
249
|
+
shadowObservers.forEach((mo) => mo.disconnect());
|
|
250
|
+
},
|
|
251
|
+
flush
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Dynamically load and (idempotently) define a set of web components by tag name.
|
|
256
|
+
*/
|
|
257
|
+
static async define(...args) {
|
|
258
|
+
let opts = {};
|
|
259
|
+
if (args.length && typeof args[args.length - 1] === "object") {
|
|
260
|
+
opts = args.pop() || {};
|
|
261
|
+
}
|
|
262
|
+
const tags = args;
|
|
263
|
+
const {
|
|
264
|
+
baseURL,
|
|
265
|
+
mapper = (tag) => `${tag}.js`,
|
|
266
|
+
onError = (tag, err) => console.error(`[defineWebComponents] ${tag}:`, err)
|
|
267
|
+
} = opts;
|
|
268
|
+
const base = baseURL ? new URL(
|
|
269
|
+
baseURL,
|
|
270
|
+
typeof location !== "undefined" ? location.href : import.meta.url
|
|
271
|
+
) : new URL("./", import.meta.url);
|
|
272
|
+
const toPascal = (tag) => tag.toLowerCase().replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
273
|
+
const loadOne = async (tag) => {
|
|
274
|
+
try {
|
|
275
|
+
if (customElements.get(tag))
|
|
276
|
+
return { tag, status: "already-defined" };
|
|
277
|
+
const spec = mapper(tag);
|
|
278
|
+
const href = spec instanceof URL ? spec.href : new URL(spec, base).href;
|
|
279
|
+
const mod = await import(href);
|
|
280
|
+
const Named = mod?.default ?? mod?.[toPascal(tag)];
|
|
281
|
+
if (!Named) {
|
|
282
|
+
if (customElements.get(tag))
|
|
283
|
+
return { tag, status: "self-defined" };
|
|
284
|
+
throw new Error(
|
|
285
|
+
`No export found for ${tag}. Expected default export or named export "${toPascal(
|
|
286
|
+
tag
|
|
287
|
+
)}".`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (!customElements.get(tag)) {
|
|
291
|
+
customElements.define(tag, Named);
|
|
292
|
+
return { tag, status: "defined" };
|
|
293
|
+
}
|
|
294
|
+
return { tag, status: "race-already-defined" };
|
|
295
|
+
} catch (err) {
|
|
296
|
+
onError(tag, err);
|
|
297
|
+
throw err;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return Promise.all(tags.map(loadOne));
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
export {
|
|
304
|
+
AutoDefiner
|
|
305
|
+
};
|
|
306
|
+
//# sourceMappingURL=pds-auto-definer.js.map
|