@pure-ds/core 0.6.11 → 0.7.1
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/.github/copilot-instructions.md +6 -1
- package/dist/types/public/assets/js/pds-ask.d.ts +2 -0
- package/dist/types/public/assets/js/pds-ask.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-auto-definer.d.ts +14 -0
- package/dist/types/public/assets/js/pds-auto-definer.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-autocomplete.d.ts +79 -0
- package/dist/types/public/assets/js/pds-autocomplete.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-enhancers.d.ts +7 -0
- package/dist/types/public/assets/js/pds-enhancers.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds-manager.d.ts.map +1 -1
- package/dist/types/public/assets/js/pds-toast.d.ts +8 -0
- package/dist/types/public/assets/js/pds-toast.d.ts.map +1 -0
- package/dist/types/public/assets/js/pds.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-drawer.d.ts +1 -143
- package/dist/types/public/assets/pds/components/pds-drawer.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-icon.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-richtext.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts +1 -83
- package/dist/types/public/assets/pds/components/pds-scrollrow.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts +1 -89
- package/dist/types/public/assets/pds/components/pds-splitpanel.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-theme.d.ts +1 -22
- package/dist/types/public/assets/pds/components/pds-theme.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-toaster.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-treeview.d.ts.map +1 -1
- package/dist/types/public/assets/pds/components/pds-upload.d.ts.map +1 -1
- package/dist/types/src/js/common/ask.d.ts.map +1 -1
- package/dist/types/src/js/pds-ask.d.ts +2 -0
- package/dist/types/src/js/pds-ask.d.ts.map +1 -0
- package/dist/types/src/js/pds-auto-definer.d.ts +2 -0
- package/dist/types/src/js/pds-auto-definer.d.ts.map +1 -0
- package/dist/types/src/js/pds-autocomplete.d.ts +2 -0
- package/dist/types/src/js/pds-autocomplete.d.ts.map +1 -0
- package/dist/types/src/js/pds-core/pds-live.d.ts.map +1 -1
- package/dist/types/src/js/pds-core/pds-start-helpers.d.ts.map +1 -1
- package/dist/types/src/js/pds-enhancers.d.ts +2 -0
- package/dist/types/src/js/pds-enhancers.d.ts.map +1 -0
- package/dist/types/src/js/pds-live-manager/conversion-service.d.ts.map +1 -1
- package/dist/types/src/js/pds-toast.d.ts +2 -0
- package/dist/types/src/js/pds-toast.d.ts.map +1 -0
- package/dist/types/src/js/pds.d.ts.map +1 -1
- package/package.json +6 -4
- package/packages/pds-cli/README.md +9 -0
- package/packages/pds-cli/bin/pds-static.js +12 -1
- package/packages/pds-cli/bin/templates/bootstrap/pds.config.js +1 -5
- package/packages/pds-cli/bin/templates/bootstrap/public/index.html +2 -1
- package/packages/pds-cli/bin/templates/starter-templates.js +1 -3
- package/public/assets/js/app.js +4 -34
- package/public/assets/js/pds-ask.js +25 -0
- package/public/assets/js/pds-auto-definer.js +1 -0
- package/public/assets/js/pds-autocomplete.js +7 -0
- package/public/assets/js/pds-enhancers.js +1 -0
- package/public/assets/js/pds-manager.js +37 -37
- package/public/assets/js/pds-toast.js +1 -0
- package/public/assets/js/pds.js +2 -32
- package/public/assets/pds/components/pds-calendar.js +2 -2
- package/public/assets/pds/components/pds-drawer.js +1 -1
- package/public/assets/pds/components/pds-form.js +7 -6
- package/public/assets/pds/components/pds-icon.js +12 -9
- package/public/assets/pds/components/pds-live-edit.js +5 -8
- package/public/assets/pds/components/pds-live-importer.js +2 -1
- package/public/assets/pds/components/pds-live-template-canvas.js +2 -1
- package/public/assets/pds/components/pds-omnibox.js +11 -1
- package/public/assets/pds/components/pds-richtext.js +2 -0
- package/public/assets/pds/components/pds-scrollrow.js +5 -1
- package/public/assets/pds/components/pds-splitpanel.js +3 -1
- package/public/assets/pds/components/pds-theme.js +2 -0
- package/public/assets/pds/components/pds-toaster.js +2 -0
- package/public/assets/pds/components/pds-treeview.js +2 -0
- package/public/assets/pds/components/pds-upload.js +2 -0
- package/public/assets/pds/core/pds-ask.js +25 -0
- package/public/assets/pds/core/pds-auto-definer.js +1 -0
- package/public/assets/pds/core/pds-autocomplete.js +7 -0
- package/public/assets/pds/core/pds-enhancers.js +1 -0
- package/public/assets/pds/core/pds-manager.js +3646 -0
- package/public/assets/pds/core/pds-toast.js +1 -0
- package/public/assets/pds/core.js +2 -0
- package/readme.md +4 -1
- package/src/js/pds-core/pds-live.js +3 -0
- package/src/js/pds-core/pds-start-helpers.js +5 -1
- package/src/js/pds-live-manager/conversion-service.js +1 -2
- package/src/js/pds.js +159 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pds-enhancers.d.ts","sourceRoot":"","sources":["../../../../src/js/pds-enhancers.js"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-service.d.ts","sourceRoot":"","sources":["../../../../../src/js/pds-live-manager/conversion-service.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conversion-service.d.ts","sourceRoot":"","sources":["../../../../../src/js/pds-live-manager/conversion-service.js"],"names":[],"mappings":"AA6vEA;;;;;EAgBC;AAuhBD;;;;;;;;;;;;EAiKC;AAED;;;;;;;;;;;;EA6CC;AAED;;;;;;;;;;;;EAyBC;AAED;;;;;;;;;;;;EA6CC;;;;;AAtjGC,mCAKO;AAEP,uCAIO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pds-toast.d.ts","sourceRoot":"","sources":["../../../../src/js/pds-toast.js"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pds.d.ts","sourceRoot":"","sources":["../../../../src/js/pds.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pds.d.ts","sourceRoot":"","sources":["../../../../src/js/pds.js"],"names":[],"mappings":"AAmXA,mDAsBC;AAGD,4DAuCC;;;;;;;;;;;;;;;;;;;;;;;;;cA5Za,OAAO,4BAA4B,EAAE,WAAW;;;;iBAChD,CAAC,SAAS,CAAC,EAAE,OAAO,6BAA6B,EAAE,SAAS,KAAK,IAAI;;;;iBACrE,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,gBAAgB,CAAC,EAAE,aAAa,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;;;;qBAChG,CAAC,UAAU,EAAE,UAAU,EAAE,gBAAgB,CAAC,EAAE,aAAa,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC;;;;sBAC7E,CAAC,GAAG,EAAC,MAAM,KAAK,aAAa;;AAW3C,+BAA+B;AAC/B,kBADW,MAAM,GAAG,OAAO,CACD;AArC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;GAIG;AACH;CAAoC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pure-ds/core",
|
|
3
3
|
"shortname": "pds",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.1",
|
|
5
5
|
"description": "Why develop a Design System when you can generate one?",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"a11y"
|
|
23
23
|
],
|
|
24
24
|
"type": "module",
|
|
25
|
-
"main": "./public/assets/
|
|
26
|
-
"module": "./public/assets/
|
|
25
|
+
"main": "./public/assets/pds/core.js",
|
|
26
|
+
"module": "./public/assets/pds/core.js",
|
|
27
27
|
"types": "./dist/types/pds.d.ts",
|
|
28
28
|
"bin": {
|
|
29
29
|
"pds-build": "packages/pds-cli/bin/pds-static.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
|
39
39
|
"types": "./src/js/pds.d.ts",
|
|
40
|
-
"import": "./public/assets/
|
|
40
|
+
"import": "./public/assets/pds/core.js"
|
|
41
41
|
},
|
|
42
42
|
"./pds-core": "./src/js/pds.js",
|
|
43
43
|
"./auto-define/*": "./public/auto-define/*"
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"public/assets/js/",
|
|
50
50
|
"public/assets/pds/components/",
|
|
51
51
|
"public/assets/pds/templates/",
|
|
52
|
+
"public/assets/pds/core.js",
|
|
53
|
+
"public/assets/pds/core/",
|
|
52
54
|
"public/assets/pds/external/",
|
|
53
55
|
"public/assets/pds/vscode-custom-data.json",
|
|
54
56
|
"public/assets/pds/pds.css-data.json",
|
|
@@ -14,6 +14,15 @@ Notes:
|
|
|
14
14
|
|
|
15
15
|
This CLI is intentionally tiny and uses the repository's `pds-api` and `fs-writer` utilities.
|
|
16
16
|
|
|
17
|
+
## pds-bootstrap
|
|
18
|
+
|
|
19
|
+
`pds-bootstrap` scaffolds a browser-ready starter and writes `public/index.html` with an import map that includes:
|
|
20
|
+
|
|
21
|
+
- `"#pds": "/assets/pds/core.js"`
|
|
22
|
+
- `"#pds/lit": "/assets/pds/external/lit.js"`
|
|
23
|
+
|
|
24
|
+
So component modules that import `PDS` from `#pds` and Lit-based modules from `#pds/lit` resolve without extra setup.
|
|
25
|
+
|
|
17
26
|
## pds-import
|
|
18
27
|
|
|
19
28
|
`pds-import` runs the same import pipeline used by live edit and writes a JSON result file.
|
|
@@ -349,7 +349,7 @@ async function loadConsumerConfig() {
|
|
|
349
349
|
if (/PDS is not defined/i.test(msg)) {
|
|
350
350
|
log('❌ Failed to evaluate pds.config.js: PDS is not defined', 'red');
|
|
351
351
|
log(' This usually means your config references the browser global "PDS".', 'yellow');
|
|
352
|
-
log(' The static exporter runs in Node, so please import presets instead of using
|
|
352
|
+
log(' The static exporter runs in Node, so please import presets instead of using a browser global PDS object.', 'yellow');
|
|
353
353
|
log(' Example fix for pds.config.js:', 'yellow');
|
|
354
354
|
log(" import { presets } from 'pure-ds/src/js/pds-core/pds-config.js'", 'blue');
|
|
355
355
|
log(' export const config = { ...presets.default, static: { root: "public/assets/pds/" } }', 'blue');
|
|
@@ -433,6 +433,17 @@ async function main(options = {}) {
|
|
|
433
433
|
|
|
434
434
|
// 4b) Copy live manager bundle into target/core for dynamic import fallback
|
|
435
435
|
try {
|
|
436
|
+
const coreEntrySourceNew = path.join(repoRoot, 'public/assets/pds/core.js');
|
|
437
|
+
const coreEntrySourceLegacy = path.join(repoRoot, 'public/assets/js/pds.js');
|
|
438
|
+
const coreEntrySource = existsSync(coreEntrySourceNew) ? coreEntrySourceNew : coreEntrySourceLegacy;
|
|
439
|
+
if (!existsSync(coreEntrySource)) {
|
|
440
|
+
log('⚠️ core.js not found in package assets; skipping copy', 'yellow');
|
|
441
|
+
} else {
|
|
442
|
+
const coreEntryTarget = path.join(targetDir, 'core.js');
|
|
443
|
+
await copyFile(coreEntrySource, coreEntryTarget);
|
|
444
|
+
log(`✅ Copied core runtime entry → ${path.relative(process.cwd(), coreEntryTarget)}`, 'green');
|
|
445
|
+
}
|
|
446
|
+
|
|
436
447
|
const managerSource = path.join(repoRoot, 'public/assets/js/pds-manager.js');
|
|
437
448
|
if (!existsSync(managerSource)) {
|
|
438
449
|
log('⚠️ pds-manager.js not found in package assets; skipping copy', 'yellow');
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/** @typedef {import("@pure-ds/core").PDSInitConfig} PDSInitConfig */
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const standardPDSEnhancers = Array.isArray(pdsGlobal?.defaultEnhancers)
|
|
8
|
-
? pdsGlobal.defaultEnhancers
|
|
9
|
-
: [];
|
|
5
|
+
const standardPDSEnhancers = [];
|
|
10
6
|
|
|
11
7
|
/** @type {PDSInitConfig} */
|
|
12
8
|
export const config = {
|
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
<!-- PDS Styles -->
|
|
9
9
|
<link rel="stylesheet" href="/assets/css/app.css" />
|
|
10
10
|
|
|
11
|
-
<!-- Import
|
|
11
|
+
<!-- Import map for PDS runtime (#pds) and Lit bridge (#pds/lit) -->
|
|
12
12
|
<script type="importmap">
|
|
13
13
|
{
|
|
14
14
|
"imports": {
|
|
15
|
+
"#pds": "/assets/pds/core.js",
|
|
15
16
|
"#pds/lit": "/assets/pds/external/lit.js"
|
|
16
17
|
}
|
|
17
18
|
}
|
package/public/assets/js/app.js
CHANGED
|
@@ -1,42 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)!==-1||t.indexOf(" ")!==-1||t.startsWith("#/"))return!1;let e=new URL(t,window.location.origin);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function we(t,e,n){let s=window.screen.width/2-e/2,r=window.screen.height/2-n/2;return window.open(t,"",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=${e}, height=${n}, top=${r}, left=${s}`)}var J={result:"ac-suggestion",item:"ac-itm"},B=class t extends EventTarget{constructor(e,n,s){super(),this.settings={emptyResultsText:"",...s},this.container=e,this.input=n,this.input.setAttribute("autocomplete","off"),this.categories=s.categories||{},this.caches=new Map,z(this.attach.bind(this))}static connect(e,n){let s=e.target;if(!s._autoComplete){if(!n?.categories)throw Error("Missing autocomplete settings");s._autoComplete=new t(s.parentNode,s,n),e.type==="focus"&&setTimeout(()=>{s._autoComplete.focusHandler(e)},100)}return s._autoComplete}on(e,n){return this.input.addEventListener(e,n),this}attach(){this.resultsDiv=document.createElement("div"),this.resultsDiv.title="",this.resultsDiv.classList.add(J.result),this.container.offsetWidth>100&&(this.resultsDiv.style.width=this.container.offsetWidth),this.resultsDiv.addEventListener("mousedown",this.resultClick.bind(this)),this.container.classList.add("ac-container"),this.input.classList.add("ac-input");let e=getComputedStyle(this.input);this.container.style.setProperty("--ac-bg-default",e.backgroundColor),this.container.style.setProperty("--ac-color-default",e.color);let n=getComputedStyle(this.input).accentColor;n!=="auto"&&this.container.style.setProperty("--ac-accent-color",n),(this.container?.shadowRoot??this.container).appendChild(this.resultsDiv),this.controller().clear("attach"),this.on("input",ye(this.inputHandler.bind(this),this.settings.throttleInputMs??300)).on("focus",this.focusHandler.bind(this)).on("focusout",this.blurHandler.bind(this)).on("keyup",this.keyUpHandler.bind(this)).on("keydown",this.keyDownHandler.bind(this))}controller(){let e=this.internalController();return typeof this.settings.controller=="function"&&(e=this.settings.controller(this)??e),e}internalController(){return{show:this.show.bind(this),hide:this.hide.bind(this),clear:this.clear.bind(this),empty:()=>{}}}moveResult(e){this.controller().show();let n=this.acItems.length;this.rowIndex=this.rowIndex+e,this.rowIndex<=0?this.rowIndex=0:this.rowIndex>n-1&&(this.rowIndex=0);for(let r of this.acItems)r.classList.remove("selected");let s=this.getSelectedDiv();s?(s.classList.add("selected"),s.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"})):this.focusHandler({target:this.input})}getSelectedDiv(){return this.resultsDiv.querySelector(`div:nth-child(${this.rowIndex+1})`)}selectResult(e){if(e=e||this.getSelectedDiv(),e){let n=parseInt(e.getAttribute("data-index"));this.resultClicked=!0;let s=this.results[n],r=this.categories[s.category]??{};r.action=r.action??this.setText.bind(this),r.newTab&&(this.tabWindow=we("about:blank"));let o={...s,search:this.input.value};e.classList.add("ac-active"),setTimeout(()=>{this.controller().hide("result-selected"),o.action?o.action(o):(r.action(o),r.newTab&&(o.url?this.tabWindow.location.href=o.url:this.tabWindow.close()));var i=new Event("change",{bubbles:!0});this.input.dispatchEvent(i),this.controller().clear("result-selected");let c=new Event("result-selected");c.detail=o,this.input.dispatchEvent(c)},0)}}setText(e){let n=!1;this.input?(this.input.value=e.text,n=!0):this.container?.autoCompleteInput?(this.container.autoCompleteInput.value=e.text,n=!0):"value"in this.container&&(this.container.value=e.text,n=!0),n&&this.input&&this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.controller().hide("settext")}resultClick(e){this.selectResult(e.target.closest(`.${J.item}`))}blurHandler(){setTimeout(()=>{this.resultClicked||this.controller().clear("blurred"),this.resultClicked=!1},100)}clear(){this.settings.debug||this.resultsDiv&&(this.resultsDiv.innerHTML="",this.controller().hide("clear"),this.cacheTmr&&clearTimeout(this.cacheTmr),this.cacheTmr=setTimeout(()=>{this.caches.clear()},60*1e3*5))}show(){if(!this.resultsDiv.classList.contains("ac-active")){let e=this.getViewBounds();this.resultsDiv.style.position="absolute",e.rect.width>100&&(this.resultsDiv.style.width=`${e.rect.width}px`),this.settings.direction=this.settings.direction??e.suggestedDirection,this.resultsDiv.setAttribute("data-direction",this.settings.direction),this.settings.direction==="up"?(this.resultsDiv.style.top="unset",this.resultsDiv.style.bottom=`${e.rect.height+20}px`,this.rowIndex=this.acItems.length):(this.resultsDiv.style.bottom="unset",this.resultsDiv.style.top=`${e.rect.height}px`,this.rowIndex=-1),this.resultsDiv.style.maxWidth="unset",this.resultsDiv.classList.toggle("ac-active",!0)}}getViewBounds(){let e=this.input.getBoundingClientRect();return{rect:e,suggestedDirection:e.top+e.height+500>window.innerHeight?"up":"down"}}hide(){this.resultsDiv.classList.toggle("ac-active",!1)}empty(){this.resultsDiv.innerHTML=`<div class="ac-empty">${this.settings.emptyResultsText}</div>`,this.controller().show()}inputHandler(e){this.cacheTmr&&clearTimeout(this.cacheTmr);let n={search:e.target.value,categories:this.categories};this.container.classList.add("search-running"),this.getItems(n,e).then(s=>{this.controller().clear("new-results"),this.resultsHandler(s,n),this.container.classList.remove("search-running")})}keyDownHandler(e){switch(e.key){case"Enter":e.stopPropagation(),e.preventDefault();break;case"ArrowDown":z(this.moveResult(1));break;case"ArrowUp":z(this.moveResult(-1));break}}keyUpHandler(e){switch(e.key){case"Escape":this.controller().hide("escape");break;case"Enter":this.getSelectedDiv()&&(this.container.preventEnter=!0,e.stopPropagation(),e.preventDefault(),this.selectResult(),setTimeout(()=>{this.container.preventEnter=!1},10));break;default:break}}focusHandler(e){this.controller().clear("focus");let n=e.target.value;this.suggest(n,e)}suggest(e,n){this.input.focus();let s={suggest:!0,search:e||"",categories:this.categories};this.getItems(s,n).then(r=>{this.input.dispatchEvent(new CustomEvent("show-results",{detail:{results:r}})),this.resultsHandler(r,s)})}sort(e,n){return e.sort((s,r)=>{let o=n.categories[s.category],i=n.categories[r.category],c=typeof o.sortIndex=="function"?o.sortIndex(n):o.sortIndex??0;return(typeof i.sortIndex=="function"?i.sortIndex(n):i.sortIndex??0)>c?1:-1})}resultsHandler(e,n){this.results=e,this.rowIndex=-1;let s=0,r=(o,i)=>`
|
|
3
|
-
<div title="${i.tooltip||""}" data-index="${s}" class="${`${J.item} cat-${i.category} ${i.class??""}`.trim()}"${i.style?` style="${i.style}"`:""}>
|
|
4
|
-
${this.handleImageOrIcon(i)}
|
|
5
|
-
<span class="text">${this.formatResultItem(i,n,o)}</span>
|
|
6
|
-
${this.settings.hideCategory?"":`<span class="category">${i.category||""}</span>`}
|
|
7
|
-
</div>`;e.forEach(o=>{let i=n.categories[o.category]||{};o.element?this.resultsDiv.appendChild(o.element):(o=typeof o=="string"?{text:o}:o,this.resultsDiv.appendChild(ge(r(i,o))[0])),s++}),e.length?(this.acItems=this.resultsDiv.querySelectorAll(".ac-itm"),this.controller().show()):n.search.length&&this.controller().empty()}handleImageOrIcon(e){return e.image?`<img src="${e.image}"/>`:typeof this.settings.iconHandler=="function"?this.settings.iconHandler(e):`<svg-icon icon="${e.icon}"></svg-icon>`}formatResultItem(e,n,s){let r=typeof e=="string"?{text:e}:e,o=r.text;return n.search&&(o=o.replace("%search%",n.search),r.description=r.description?.replace("%search%",n.search)),o=this.highlight(o,n.search),r.description&&(o=`<div>${o}</div><small>${r.description}</small>`),s.format&&(o=s.format({item:r,result:o,options:n})),o}highlight(e,n){var s=new RegExp("("+n+")","gi");return e.replace(s,'<span class="txt-hl">$1</span>')}async getItems(e,n){this.aborter&&this.aborter.abort();let s=this.caches.get(e.search);if(s)return s;let r=this.settings.map,o=u=>(typeof u=="string"&&(u={text:u}),u),i=u=>r?u.map(d=>({text:d[r]})):u.map(d=>o(d)),c=u=>(this.settings.max&&this.settings.max>0&&(u.length=this.settings.max),u);return this.aborter=new AbortController,this.aborterSignal=this.aborter.signal,new Promise(u=>{let d=a=>{a=this.sort(a,e),this.settings.cache!==!1&&this.caches.set(e.search,a),u(a)};if(be(this.items)){if(this.settings.minlength>0&&(!e.search||e.search.length<this.settings.minlength)){d([]);return}let a=this.formatSearch(this.items,e);fetch(a).then(l=>{if(l.status===200){l.json().then(h=>{h=i(h),d(c(h.filter(y=>this.isMatch(e,y))))});return}throw Error(`HTTP error ${l.status} - ${a}`)})}else if(Array.isArray(this.items)){let a=!0;this.items=this.items.map(l=>typeof l=="string"?{text:l}:(a=!1,l)),a&&this.container.classList.add("simple"),d(c(i(this.items)))}else if(typeof this.items=="function")e.control=this.container,Promise.resolve(this.items(e,n)).then(l=>{l=l.map(h=>o(h)),l=i(l),d(l)});else return d(Promise.resolve(this.items.apply(this,e)))})}async items(e){let n=[];e.results=[],e.signal=this.aborterSignal;for(var s in e.categories){let r=e.categories[s];if(r.trigger=r.trigger??(()=>!0),e.results=n,r.trigger(e)){let o=[];try{o=await r.getItems(e)}catch(i){console.warn(`Error loading items for omniBox category '${s}'.`,i)}n=n.concat(o.map(i=>(i.category=s,i)))}}return n}formatSearch(e,n){return e.indexOf("%search%")?e.replace("%search%",n.search||""):e+"?"+this.createQueryParam(n)}createQueryParam(e){let n=e.suggest?"&suggest=true":"";return`q=${e.text}${n}`}isMatch(e,n){return n.text?.indexOf("%search%")>=0?!0:e.search?n.text?.toLowerCase().indexOf(e.search.toLowerCase())>=0:e.suggest}static textFilter(e,n){return function(s){if(!e.search)return!0;if(s.hidden)return!1;let o=(n?s[n]:s).match(new RegExp(e.search,"gi"));if(o)return o;if(s.config?.tags)return s.config.tags.some(i=>i.match(new RegExp(e.search,"gi")))}}};var X=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(e={}){this._mode="static",this._staticPaths={...this._staticPaths,...e}}async getStylesheet(e){if(this._mode==="live")return null;try{return(await import(this._staticPaths[e]))[e]}catch(n){console.error(`[PDS Registry] Failed to load static ${e}:`,n),console.error(`[PDS Registry] Looking for: ${this._staticPaths[e]}`),console.error("[PDS Registry] Make sure you've run 'npm run pds:build' and configured PDS.start() with the correct static.root path");let s=new CSSStyleSheet;return s.replaceSync("/* Failed to load "+e+" */"),s}}get mode(){return this._mode}get isLive(){return this._mode==="live"}},U=new X;async function ve(t,e=[],n=null){try{let s=n?.primitivesStylesheet?n.primitivesStylesheet:await U.getStylesheet("primitives");t.adoptedStyleSheets=[s,...e]}catch(s){let r=t.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${r}> failed to adopt primitives:`,s),t.adoptedStyleSheets=e}}async function xe(t,e=["primitives"],n=[],s=null){try{let o=(await Promise.all(e.map(async i=>{if(s)switch(i){case"tokens":return s.tokensStylesheet;case"primitives":return s.primitivesStylesheet;case"components":return s.componentsStylesheet;case"utilities":return s.utilitiesStylesheet;default:break}return U.getStylesheet(i)}))).filter(i=>i!==null);t.adoptedStyleSheets=[...o,...n]}catch(r){let o=t.host?.tagName?.toLowerCase()||"unknown";console.error(`[PDS Adopter] <${o}> failed to adopt layers:`,r),t.adoptedStyleSheets=n}}function Ee(t){let e=new CSSStyleSheet;return e.replaceSync(t),e}var Se={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 V={mode:"live",liveEdit:!0,preset:"default",autoDefine:{predefine:["pds-icon","pds-drawer","pds-toaster","pds-form"]},log(t,e,...n){console[t](e,...n)}};var te={};me(te,{deepMerge:()=>Ae,fragmentFromTemplateLike:()=>Y,isObject:()=>G,parseHTML:()=>ee});function G(t){return t&&typeof t=="object"&&!Array.isArray(t)}function Ae(t,e){let n={...t};return G(t)&&G(e)&&Object.keys(e).forEach(s=>{G(e[s])?s in t?n[s]=Ae(t[s],e[s]):Object.assign(n,{[s]:e[s]}):Object.assign(n,{[s]:e[s]})}),n}function Y(t){let e=Array.isArray(t?.strings)?t.strings:[],n=Array.isArray(t?.values)?t.values:[],s=new Set,r=[],o=/(\s)(\.[\w-]+)=\s*$/;for(let l=0;l<e.length;l+=1){let h=e[l]??"",y=h.match(o);if(y&&l<n.length){let x=y[2].slice(1),w=`pds-val-${l}`;h=h.replace(o,`$1data-pds-prop="${x}:${w}"`),s.add(l)}r.push(h),l<n.length&&!s.has(l)&&r.push(`<!--pds-val-${l}-->`)}let i=document.createElement("template");i.innerHTML=r.join("");let c=(l,h)=>{let y=l.parentNode;if(!y)return;if(h==null){y.removeChild(l);return}let A=x=>{if(x!=null){if(x instanceof Node){y.insertBefore(x,l);return}if(Array.isArray(x)){x.forEach(w=>A(w));return}y.insertBefore(document.createTextNode(String(x)),l)}};A(h),y.removeChild(l)},u=document.createTreeWalker(i.content,NodeFilter.SHOW_COMMENT),d=[];for(;u.nextNode();){let l=u.currentNode;l?.nodeValue?.startsWith("pds-val-")&&d.push(l)}return d.forEach(l=>{let h=Number(l.nodeValue.replace("pds-val-",""));c(l,n[h])}),i.content.querySelectorAll("*").forEach(l=>{let h=l.getAttribute("data-pds-prop");if(!h)return;let[y,A]=h.split(":"),x=Number(String(A).replace("pds-val-",""));y&&Number.isInteger(x)&&(l[y]=n[x]),l.removeAttribute("data-pds-prop")}),i.content}function ee(t){return new DOMParser().parseFromString(t,"text/html").body.childNodes}function ne(t,e){if(e==null)return;if(typeof e=="object"&&Array.isArray(e.strings)&&Array.isArray(e.values)){t.appendChild(Y(e));return}if(e instanceof Node){t.appendChild(e);return}if(Array.isArray(e)){e.forEach(s=>ne(t,s));return}let n=typeof e=="string"?e:String(e);t.appendChild(document.createTextNode(n))}function He(){let t=navigator.userAgent,e=/Safari/i.test(t),n=/(Chrome|Chromium|CriOS|FxiOS|EdgiOS|OPiOS|Opera)/i.test(t);return e&&!n}function We(t){if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let e=window.matchMedia?.("(max-width: 639px)").matches,n=t.classList.contains("dialog-no-scale-animation")?"pds-dialog-fade-enter":e?"pds-dialog-enter-mobile":"pds-dialog-enter";t.style.animation="none",t.offsetWidth,t.style.animation=`${n} var(--transition-normal) ease`,t.addEventListener("animationend",()=>{t.style.animation=""},{once:!0})}async function Le(t,e={}){return e={...{title:"Confirm",type:"confirm",buttons:{ok:{name:"OK",primary:!0},cancel:{name:"Cancel",cancel:!0}}},...e},new Promise(s=>{let r=document.createElement("dialog");He()&&r.classList.add("dialog-no-scale-animation"),V.options?.liquidGlassEffects&&r.classList.add("liquid-glass"),e.size&&r.classList.add(`dialog-${e.size}`),e.type&&r.classList.add(`dialog-${e.type}`),e.class&&(Array.isArray(e.class)?r.classList.add(...e.class):r.classList.add(e.class)),e.maxHeight&&r.style.setProperty("--dialog-max-height",e.maxHeight);let o=Object.entries(e.buttons).map(([c,u])=>{let d=u.primary?"btn-primary btn-sm":"btn-outline btn-sm";return`<button type="${u.cancel?"button":"submit"}" class="${d}" value="${c}">${u.name}</button>`});if(e.useForm){let c=document.createElement("div");ne(c,t);let u=c.querySelector("form");if(u){r.innerHTML=`
|
|
8
|
-
<header>
|
|
9
|
-
<h2>${e.title}</h2>
|
|
10
|
-
</header>
|
|
11
|
-
`;let d=document.createElement("article");for(d.className="dialog-body";u.firstChild;)d.appendChild(u.firstChild);u.appendChild(d);let a=document.createElement("footer");a.innerHTML=o.join(""),u.appendChild(a),r.appendChild(u)}else r.innerHTML=`
|
|
12
|
-
<header>
|
|
13
|
-
<h2>${e.title}</h2>
|
|
14
|
-
</header>
|
|
15
|
-
<article id="msg-container"></article>
|
|
16
|
-
<footer>
|
|
17
|
-
${o.join("")}
|
|
18
|
-
</footer>
|
|
19
|
-
`,r.querySelector("#msg-container").appendChild(c)}else{r.innerHTML=`
|
|
20
|
-
<form method="dialog">
|
|
21
|
-
<header>
|
|
22
|
-
<h2>${e.title}</h2>
|
|
23
|
-
</header>
|
|
24
|
-
|
|
25
|
-
<article id="msg-container"></article>
|
|
26
|
-
|
|
27
|
-
<footer>
|
|
28
|
-
${o.join("")}
|
|
29
|
-
</footer>
|
|
30
|
-
</form>
|
|
31
|
-
`;let c=r.querySelector("#msg-container");ne(c,t)}r.addEventListener("click",c=>{c.target.closest('button[value="cancel"]')&&(r.close(),s(!1))});let i=()=>{let c=r.querySelector("form");c?c.addEventListener("submit",u=>{u.preventDefault();let d;e.useForm&&u.submitter.value==="ok"?(console.log("Found form:",c),console.log("Form elements:",c?Array.from(c.elements):"no form"),d=new FormData(c),console.log("FormData entries:",Array.from(d.entries()))):d=u.submitter.value==="ok",r.close(),s(d)}):requestAnimationFrame(i)};i(),r.addEventListener("close",()=>{setTimeout(()=>r.remove(),200)}),document.body.appendChild(r),typeof e.rendered=="function"&&e.rendered(r),r.showModal(),requestAnimationFrame(()=>We(r))})}async function ze(){let t=document.querySelector("pds-toaster");return t||(t=document.createElement("pds-toaster"),document.body.appendChild(t),await customElements.whenDefined("pds-toaster")),t}async function $(t,e={}){return(await ze()).toast(t,e)}$.success=async function(t,e={}){return $(t,{...e,type:"success"})};$.error=async function(t,e={}){return $(t,{...e,type:"error"})};$.warning=async function(t,e={}){return $(t,{...e,type:"warning"})};$.info=async function(t,e={}){return $(t,{...e,type:"information"})};var Be=[{selector:".accordion"},{selector:"nav[data-dropdown]"},{selector:"label[data-toggle]"},{selector:"label[data-color]"},{selector:'input[type="range"]'},{selector:"form[data-required]"},{selector:"fieldset[role=group][data-open]"},{selector:"[data-clip]"},{selector:"button, a[class*='btn-']"}];function Ve(t){t.dataset.enhancedAccordion||(t.dataset.enhancedAccordion="true",t.addEventListener("toggle",e=>{e.target.open&&e.target.parentElement===t&&t.querySelectorAll(":scope > details[open]").forEach(n=>{n!==e.target&&(n.open=!1)})},!0))}function Ge(t){if(t.dataset.enhancedDropdown)return;t.dataset.enhancedDropdown="true";let e=t.lastElementChild;if(!e)return;let n=t.querySelector("[data-dropdown-toggle]")||t.querySelector("button");n&&!n.hasAttribute("type")&&n.setAttribute("type","button"),e.id||(e.id=`dropdown-${Math.random().toString(36).slice(2,9)}`);let s=e.tagName?.toLowerCase()==="menu",r=8;s&&!e.hasAttribute("role")&&e.setAttribute("role","menu"),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true"),n&&(n.setAttribute("aria-haspopup","true"),n.setAttribute("aria-controls",e.id),n.setAttribute("aria-expanded","false"));let o=()=>{let b=e.getAttribute("style");e.style.visibility="hidden",e.style.display="inline-block",e.style.pointerEvents="none";let S=e.getBoundingClientRect(),C=Math.max(e.offsetWidth||0,e.scrollWidth||0,S.width||0,1),v=Math.max(e.offsetHeight||0,e.scrollHeight||0,S.height||0,1);return b===null?e.removeAttribute("style"):e.setAttribute("style",b),{width:C,height:v}},i=()=>{let b=(t.getAttribute("data-direction")||t.getAttribute("data-dropdown-direction")||t.getAttribute("data-mode")||"auto").toLowerCase();if(b==="up"||b==="down")return b;let S=(n||t).getBoundingClientRect(),{height:C}=o(),v=Math.max(0,window.innerHeight-S.bottom),k=Math.max(0,S.top),M=v>=C,D=k>=C;return M&&!D?"down":D&&!M?"up":M&&D?"down":k>v?"up":"down"},c=()=>{let b=(t.getAttribute("data-align")||t.getAttribute("data-dropdown-align")||"auto").toLowerCase();if(b==="left"||b==="right"||b==="start"||b==="end")return b==="start"?"left":b==="end"?"right":b;let S=(n||t).getBoundingClientRect(),{width:C}=o(),v=Math.max(0,window.innerWidth-S.left),k=Math.max(0,S.right),M=v>=C,D=k>=C;return M&&!D?"left":D&&!M?"right":M&&D?"left":k>v?"right":"left"},u=(b,S=8)=>{let C=getComputedStyle(t).getPropertyValue(b).trim();if(!C)return S;let v=document.createElement("span");v.style.position="fixed",v.style.visibility="hidden",v.style.pointerEvents="none",v.style.height=C,document.body.appendChild(v);let k=Number.parseFloat(getComputedStyle(v).height);return v.remove(),Number.isFinite(k)?k:S},d=()=>{e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("max-width"),e.style.removeProperty("max-inline-size"),e.style.removeProperty("max-height"),e.style.removeProperty("overflow")},a=()=>{e.getAttribute("aria-hidden")==="false"&&(d(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{l()})}))},l=()=>{if(e.getAttribute("aria-hidden")!=="false")return;let b=(n||t).getBoundingClientRect(),S=window.visualViewport,C=S?.width||document.documentElement?.clientWidth||window.innerWidth,v=S?.height||document.documentElement?.clientHeight||window.innerHeight,k=S?.offsetLeft||0,M=S?.offsetTop||0,D=Math.max(1,C-r*2),H=Math.max(1,v-r*2);e.style.maxWidth=`${Math.round(D)}px`,e.style.maxInlineSize=`${Math.round(D)}px`,e.style.maxHeight=`${Math.round(H)}px`,e.style.overflow="auto";let{width:p,height:m}=o(),f=u("--spacing-2",8),T=i(),I=c();t.dataset.dropdownDirection=T,t.dataset.dropdownAlign=I;let W=I==="right"?b.right-p:b.left;p>=D-1?W=k+r:W=Math.max(k+r,Math.min(W,k+C-p-r));let Z=T==="up"?b.top-f-m:b.bottom+f;Z=Math.max(M+r,Math.min(Z,M+v-m-r)),e.style.position="fixed",e.style.left=`${Math.round(W)}px`,e.style.top=`${Math.round(Z)}px`,e.style.right="auto",e.style.bottom="auto",e.style.marginTop="0",e.style.marginBottom="0"},h=null,y=()=>{h||(h=()=>l(),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0))},A=()=>{h&&(window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),h=null)},x=null,w=()=>{x||typeof document>"u"||(x=()=>{e.getAttribute("aria-hidden")==="false"&&(t.dataset.dropdownDirection=i(),t.dataset.dropdownAlign=c(),a(),setTimeout(()=>{e.getAttribute("aria-hidden")==="false"&&a()},50),setTimeout(()=>{e.getAttribute("aria-hidden")==="false"&&a()},150))},document.addEventListener("pds:config-changed",x))},L=()=>{!x||typeof document>"u"||(document.removeEventListener("pds:config-changed",x),x=null)},P=null,E=()=>{t.dataset.dropdownDirection=i(),t.dataset.dropdownAlign=c(),e.setAttribute("aria-hidden","false"),n?.setAttribute("aria-expanded","true"),y(),w(),a(),P||(P=b=>{(b.composedPath?b.composedPath():[b.target]).some(v=>v===t)||R()},setTimeout(()=>{document.addEventListener("click",P)},0))},R=()=>{e.setAttribute("aria-hidden","true"),n?.setAttribute("aria-expanded","false"),A(),L(),d(),P&&(document.removeEventListener("click",P),P=null)},_=()=>{e.getAttribute("aria-hidden")==="false"?R():E()};n?.addEventListener("click",b=>{b.preventDefault(),b.stopPropagation(),_()}),t.addEventListener("keydown",b=>{b.key==="Escape"&&(R(),n?.focus())}),t.addEventListener("focusout",b=>{b.relatedTarget&&((b.composedPath?b.composedPath():[b.relatedTarget]).some(v=>v===t)||R())})}function Ke(t){if(t.dataset.enhancedToggle)return;t.dataset.enhancedToggle="true";let e=t.querySelector('input[type="checkbox"]');if(!e)return;t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.setAttribute("role","switch"),t.setAttribute("aria-checked",e.checked?"true":"false");let n=document.createElement("span");n.className="toggle-switch",n.setAttribute("role","presentation"),n.setAttribute("aria-hidden","true");let s=document.createElement("span");s.className="toggle-knob",n.appendChild(s),t.insertBefore(n,e.nextSibling);let r=()=>{t.setAttribute("aria-checked",e.checked?"true":"false")},o=()=>{e.disabled||(e.checked=!e.checked,r(),e.dispatchEvent(new Event("change",{bubbles:!0})))};t.addEventListener("click",i=>{i.preventDefault(),o()}),t.addEventListener("keydown",i=>{(i.key===" "||i.key==="Enter")&&(i.preventDefault(),o())}),e.addEventListener("change",r)}function Qe(t){if(t.dataset.enhancedColorInput)return;let e=t.querySelector('input[type="color"]');if(!e)return;t.dataset.enhancedColorInput="true";let n=t.querySelector(":scope > .color-control"),s=t.querySelector(":scope > .color-control > .color-swatch"),r=t.querySelector(":scope > .color-control > output");n||(n=document.createElement("span"),n.className="color-control",e.before(n)),s||(s=document.createElement("span"),s.className="color-swatch",n.appendChild(s)),e.parentElement!==s&&s.appendChild(e),r||(r=document.createElement("output"),n.appendChild(r));let o=()=>{if(e.dataset.colorUnset==="1"){r.value="",r.textContent="not set",n.dataset.value="",n.dataset.unset="1",s.dataset.unset="1";return}r.value=e.value,r.textContent=e.value,n.dataset.value=e.value,delete n.dataset.unset,delete s.dataset.unset};o();let i=()=>{e.dataset.colorUnset==="1"&&(e.dataset.colorUnset="0"),o()};e.addEventListener("input",i,{passive:!0}),e.addEventListener("change",i,{passive:!0})}function Ze(t){if(t.dataset.enhancedRange)return;let e=i=>{if(t.dataset.enhancedRangeProgrammatic)return;t.dataset.enhancedRangeProgrammatic="1";let c=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value")||Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");c?.get&&c?.set&&Object.defineProperty(t,"value",{configurable:!0,enumerable:c.enumerable,get(){return c.get.call(this)},set(d){c.set.call(this,d),i()}}),new MutationObserver(d=>{d.some(l=>{let h=l.attributeName;return h==="value"||h==="min"||h==="max"})&&i()}).observe(t,{attributes:!0,attributeFilter:["value","min","max"]})},n=t.closest("label"),s=n?.classList.contains("range-output"),r=t.id||`range-${Math.random().toString(36).substring(2,11)}`,o=`${r}-output`;if(t.id=r,s){let i=n.querySelector("span");if(i&&!i.classList.contains("range-output-wrapper")){let c=document.createElement("span");c.className="range-output-wrapper",c.style.display="flex",c.style.justifyContent="space-between",c.style.alignItems="center";let u=document.createElement("span");u.textContent=i.textContent,c.appendChild(u);let d=document.createElement("output");d.id=o,d.setAttribute("for",r),d.style.color="var(--surface-text-secondary, var(--color-text-secondary))",d.style.fontSize="0.875rem",d.textContent=t.value,c.appendChild(d),i.textContent="",i.appendChild(c);let a=()=>{d.textContent=t.value};t.addEventListener("input",a),t.addEventListener("change",a),e(a),a()}}else{let i=t.closest(".range-container");i||(i=document.createElement("div"),i.className="range-container",t.parentNode?.insertBefore(i,t),i.appendChild(t)),i.style.position="relative";let c=document.createElement("output");c.id=o,c.setAttribute("for",r),c.className="range-bubble",c.setAttribute("aria-live","polite"),i.appendChild(c);let u=()=>{let l=parseFloat(t.min)||0,h=parseFloat(t.max)||100,y=parseFloat(t.value),A=(y-l)/(h-l);c.style.left=`calc(${A*100}% )`,c.textContent=String(y)},d=()=>c.classList.add("visible"),a=()=>c.classList.remove("visible");t.addEventListener("input",u),t.addEventListener("pointerdown",d),t.addEventListener("pointerup",a),t.addEventListener("pointerleave",a),t.addEventListener("focus",d),t.addEventListener("blur",a),t.addEventListener("change",u),e(u),u()}t.dataset.enhancedRange="1"}function Je(t){if(t.dataset.enhancedRequired)return;t.dataset.enhancedRequired="true";let e=n=>{let s;if(n.closest("[role$=group]")?s=n.closest("[role$=group]").querySelector("legend"):s=n.closest("label"),!s||s.querySelector(".required-asterisk"))return;let r=document.createElement("span");r.classList.add("required-asterisk"),r.textContent="*",r.style.marginLeft="4px";let o=s.querySelector("span, [data-label]");if(o)o.appendChild(r);else{let c=s.querySelector("input, select, textarea");c?s.insertBefore(r,c):s.appendChild(r)}let i=n.closest("form");if(i&&!i.querySelector(".required-legend")){let c=document.createElement("small");c.classList.add("required-legend"),c.textContent="* Required fields",i.insertBefore(c,i.querySelector(".form-actions")||i.lastElementChild)}};t.querySelectorAll("[required]").forEach(n=>{e(n)})}function Xe(t){if(t.dataset.enhancedOpenGroup)return;t.dataset.enhancedOpenGroup="true",t.classList.add("flex","flex-wrap","buttons");let e=document.createElement("input");e.type="text",e.placeholder="Add item...",e.classList.add("input-text","input-sm"),e.style.width="auto";let n=()=>t.querySelector('input[type="radio"], input[type="checkbox"]');t.appendChild(e),e.addEventListener("keydown",s=>{if(s.key==="Enter"||s.key==="Tab"){let r=e.value.trim();if(r){s.preventDefault();let o=n(),i=o?.type==="radio"?"radio":"checkbox",c=`open-group-${Math.random().toString(36).substring(2,11)}`,u=document.createElement("label"),d=document.createElement("span");d.setAttribute("data-label",""),d.textContent=r;let a=document.createElement("input");a.type=i,a.name=o?.name||t.getAttribute("data-name")||"open-group",a.value=r,a.id=c,u.appendChild(d),u.appendChild(a),t.insertBefore(u,e),e.value=""}}else if(s.key==="Backspace"&&e.value===""){s.preventDefault();let r=t.querySelectorAll("label");r.length>0&&r[r.length-1].remove()}})}function Ye(t){if(t.dataset.enhancedClip)return;t.dataset.enhancedClip="true",t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.hasAttribute("role")||t.setAttribute("role","button");let e=()=>{let s=t.getAttribute("data-clip-open")==="true";t.setAttribute("aria-expanded",s?"true":"false")},n=()=>{let s=t.getAttribute("data-clip-open")==="true";t.setAttribute("data-clip-open",s?"false":"true"),e()};t.addEventListener("click",s=>{s.defaultPrevented||n()}),t.addEventListener("keydown",s=>{(s.key===" "||s.key==="Enter")&&(s.preventDefault(),n())}),e()}function et(t){if(t.dataset.enhancedBtnWorking)return;t.dataset.enhancedBtnWorking="true";let e=null,n=!1;new MutationObserver(r=>{r.forEach(o=>{if(o.attributeName==="class"){let i=t.classList.contains("btn-working"),c=t.querySelector("pds-icon");if(i)if(c)e||(e=c.getAttribute("icon")),c.setAttribute("icon","circle-notch");else{let u=document.createElement("pds-icon");u.setAttribute("icon","circle-notch"),u.setAttribute("size","sm"),t.insertBefore(u,t.firstChild),n=!0}else o.oldValue?.includes("btn-working")&&c&&(n?(c.remove(),n=!1):e&&(c.setAttribute("icon",e),e=null))}})}).observe(t,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0})}var tt=new Map([[".accordion",Ve],["nav[data-dropdown]",Ge],["label[data-toggle]",Ke],["label[data-color]",Qe],['input[type="range"]',Ze],["form[data-required]",Je],["fieldset[role=group][data-open]",Xe],["[data-clip]",Ye],["button, a[class*='btn-']",et]]),se=Be.map(t=>({...t,run:tt.get(t.selector)||(()=>{})}));var ke="pds",nt=/^([a-z][a-z0-9+\-.]*:)?\/\//i,Ce=/^[a-z]:/i;function N(t=""){return t.endsWith("/")?t:`${t}/`}function st(t="",e=ke){let n=t.replace(/\/+$/,"");return new RegExp(`(?:^|/)${e}$`,"i").test(n)?n:`${n}/${e}`}function rt(t){return t.replace(/^\.\/+/,"")}function ot(t){return Ce.test(t)?t.replace(Ce,"").replace(/^\/+/,""):t}function it(t){return t.startsWith("public/")?t.substring(7):t}function re(t,e={}){let n=e.segment||ke,s=e.defaultRoot||`/assets/${n}/`,r=t?.public&&t.public?.root||t?.static&&t.static?.root||null;if(!r||typeof r!="string")return N(s);let o=r.trim();return o?(o=o.replace(/\\/g,"/"),o=st(o,n),o=N(o),nt.test(o)?o:(o=rt(o),o=ot(o),o.startsWith("/")||(o=it(o),o.startsWith("/")||(o=`/${o}`),o=o.replace(/\/+/g,(i,c)=>c===0?i:"/")),N(o))):N(s)}var ct=/^[a-z][a-z0-9+\-.]*:\/\//i,q=(()=>{try{return import.meta.url}catch{return}})(),K=t=>typeof t=="string"&&t.length&&!t.endsWith("/")?`${t}/`:t;function Q(t,e={}){if(!t||ct.test(t))return t;let{preferModule:n=!0}=e,s=()=>{if(!q)return null;try{return new URL(t,q).href}catch{return null}},r=()=>{if(typeof window>"u"||!window.location?.origin)return null;try{return new URL(t,window.location.origin).href}catch{return null}};return(n?s()||r():r()||s())||t}var Me=(()=>{if(q)try{let t=new URL(q);if(/\/public\/assets\/js\//.test(t.pathname))return new URL("../pds/",q).href}catch{return}})(),Pe=!1;function Re(t){Pe||typeof document>"u"||(Pe=!0,t.addEventListener("pds:ready",e=>{let n=e.detail?.mode;n&&document.documentElement.classList.add(`pds-${n}`,"pds-ready")}))}function $e({manageTheme:t,themeStorageKey:e,applyResolvedTheme:n,setupSystemListenerIfNeeded:s}){let r="light",o=null;if(t&&typeof window<"u"){try{o=localStorage.getItem(e)||null}catch{o=null}try{n?.(o),s?.(o)}catch{}o?o==="system"?r=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":r=o:r=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return{resolvedTheme:r,storedTheme:o}}function ie(t,{resolvePublicAssetURL:e}){let n=!!(t?.public?.root||t?.static?.root),s=e(t);return!n&&Me&&(s=Me),K(Q(s))}async function Ie(t,{baseEnhancers:e=[]}={}){let{autoDefineBaseURL:n="/auto-define/",autoDefinePreload:s=[],autoDefineMapper:r=null,enhancers:o=[],autoDefineOverrides:i=null,autoDefinePreferModule:c=!0}=t,u=(()=>{let a=new Map;return(e||[]).forEach(l=>a.set(l.selector,l)),(o||[]).forEach(l=>a.set(l.selector,l)),Array.from(a.values())})(),d=null;if(typeof window<"u"&&typeof document<"u"){let a=null;try{let w=await Promise.resolve().then(()=>(Te(),De));a=w?.AutoDefiner||w?.default?.AutoDefiner||w?.default||null}catch(w){console.warn("AutoDefiner not available:",w?.message||w)}let l=w=>{switch(w){case"pds-tabpanel":return"pds-tabstrip.js";default:return`${w}.js`}},{mapper:h,...y}=i&&typeof i=="object"?i:{},x={baseURL:n&&K(Q(n,{preferModule:c})),predefine:s,scanExisting:!0,observeShadows:!0,patchAttachShadow:!0,debounceMs:16,enhancers:u,onError:(w,L)=>{if(typeof w=="string"&&w.startsWith("pds-")){let E=["pds-form","pds-drawer"].includes(w),R=L?.message?.includes("#pds/lit")||L?.message?.includes("Failed to resolve module specifier");E&&R?console.error(`\u274C PDS component <${w}> requires Lit but #pds/lit is not in import map.
|
|
32
|
-
See: https://github.com/Pure-Web-Foundation/pure-ds/blob/main/readme.md#lit-components-not-working`):console.warn(`\u26A0\uFE0F PDS component <${w}> not found. Assets may not be installed.`)}else console.error(`\u274C Auto-define error for <${w}>:`,L)},...y,mapper:w=>{if(customElements.get(w))return null;if(typeof r=="function")try{let L=r(w);return L===void 0?l(w):L}catch(L){return console.warn("Custom autoDefine.mapper error; falling back to default:",L?.message||L),l(w)}return l(w)}};a&&(d=new a(x),s.length>0&&typeof a.define=="function"&&await a.define(...s,{baseURL:n,mapper:x.mapper,onError:x.onError}))}return{autoDefiner:d,mergedEnhancers:u}}var ae=["light","dark"],ce=new Set(ae);function lt(t){let n=(Array.isArray(t?.themes)?t.themes.map(s=>String(s).toLowerCase()):ae).filter(s=>ce.has(s));return n.length?n:ae}function le(t,{preferDocument:e=!0}={}){let n=String(t||"").toLowerCase();if(ce.has(n))return n;if(e&&typeof document<"u"){let s=document.documentElement?.getAttribute("data-theme");if(ce.has(s))return s}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function je(t,e){let n=le(e);return lt(t).includes(n)}var ue=class extends EventTarget{},g=new ue;g.initializing=!1;g.currentPreset=null;g.debug=!1;var _e=function(t="log",e,...n){let s=!!(g.registry&&!g.registry.isLive),r=(this?.debug||this?.design?.debug||g.debug||!1)===!0;if(s){if(!g.debug)return}else if(!r&&t!=="error"&&t!=="warn")return;let o=console[t]||console.log;n.length>0?o(e,...n):o(e)};function pe(t){if(t==null)return t;if(typeof t=="function")return;if(typeof t!="object")return t;if(Array.isArray(t))return t.map(n=>pe(n)).filter(n=>n!==void 0);let e={};for(let[n,s]of Object.entries(t)){let r=pe(s);r!==void 0&&(e[n]=r)}return e}async function dt(t,e={}){if(e?.runtimeConfig===!1||typeof fetch!="function")return null;let n=e?.runtimeConfigURL||`${t}pds-runtime-config.json`;try{let s=await fetch(n,{cache:"no-store"});return s.ok?await s.json():null}catch{return null}}g.registry=U;g.enums=Se;g.adoptLayers=xe;g.adoptPrimitives=ve;g.parse=ee;g.createStylesheet=Ee;g.isLiveMode=()=>U.isLive;g.ask=Le;g.toast=$;g.common=te;g.AutoComplete=B;function Oe(t){let e=typeof CustomEvent=="function";try{let n=e?new CustomEvent("pds:ready",{detail:t}):new Event("pds:ready");g.dispatchEvent(n)}catch{}if(typeof document<"u")if(e){let n={detail:t,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 Ue(t={}){let e=typeof CustomEvent=="function",n={at:Date.now(),...t};try{let s=e?new CustomEvent("pds:config-changed",{detail:n}):new Event("pds:config-changed");g.dispatchEvent(s)}catch{}if(typeof document<"u")if(e){let s={detail:n,bubbles:!0,composed:!0};try{document.dispatchEvent(new CustomEvent("pds:config-changed",s))}catch{}}else try{document.dispatchEvent(new Event("pds:config-changed"))}catch{}}typeof window<"u"&&(window.PDS=g);var de="pure-ds-theme",O=null,F=null;function he(t){try{if(typeof document>"u")return;let e="light";t?t==="system"?e=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e=t:e=typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",document.documentElement.setAttribute("data-theme",e)}catch{}}function fe(t){try{if(O&&F){try{typeof O.removeEventListener=="function"?O.removeEventListener("change",F):typeof O.removeListener=="function"&&O.removeListener(F)}catch{}O=null,F=null}if(t==="system"&&typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)"),n=s=>{let r=s?.matches===void 0?e.matches:s.matches;try{let o=r?"dark":"light";document.documentElement.setAttribute("data-theme",o),g.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:o,source:"system"}}))}catch{}};O=e,F=n,typeof e.addEventListener=="function"?e.addEventListener("change",n):typeof e.addListener=="function"&&e.addListener(n)}}catch{}}Object.defineProperty(g,"theme",{get(){try{return typeof window>"u"?null:localStorage.getItem(de)||null}catch{return null}},set(t){try{if(typeof window>"u")return;let e=g.currentConfig?.design||null,n=le(t);if(e&&!je(e,n)){let s=e?.name||g.currentPreset?.name||g.currentConfig?.preset||"current preset";console.warn(`PDS theme "${n}" not supported by preset "${s}".`),g.dispatchEvent(new CustomEvent("pds:theme:blocked",{detail:{theme:t,resolvedTheme:n,preset:s}}));return}t==null?localStorage.removeItem(de):localStorage.setItem(de,t),he(t),fe(t),g.dispatchEvent(new CustomEvent("pds:theme:changed",{detail:{theme:t,source:"api"}}))}catch{}}});g.defaultEnhancers=se;async function ut(t){let e=t&&t.mode||"live",{mode:n,...s}=t||{};if(e==="static")return pt(s);let r=ie(s,{resolvePublicAssetURL:re}),o=s?.managerURL||s?.public?.managerURL||s?.manager?.url||new URL("core/pds-manager.js",r).href||new URL("./pds-manager.js",import.meta.url).href,{startLive:i}=await import(o);return i(g,s,{emitReady:Oe,emitConfigChanged:Ue,applyResolvedTheme:he,setupSystemListenerIfNeeded:fe})}g.start=ut;async function pt(t){if(!t||typeof t!="object")throw new Error("PDS.start({ mode: 'static', ... }) requires a valid configuration object");let e=t.applyGlobalStyles??!0,n=t.manageTheme??!0,s=t.themeStorageKey??"pure-ds-theme",r=t.staticPaths??{},o=ie(t,{resolvePublicAssetURL:re}),i=t&&t.autoDefine||null,c;i&&i.baseURL?c=K(Q(i.baseURL,{preferModule:!1})):c=`${o}components/`;let u=i&&Array.isArray(i.predefine)&&i.predefine||[],d=i&&typeof i.mapper=="function"&&i.mapper||null;try{Re(g);let{resolvedTheme:a}=$e({manageTheme:n,themeStorageKey:s,applyResolvedTheme:he,setupSystemListenerIfNeeded:fe}),l=await dt(o,t),h=Array.isArray(t?.enhancers)?t.enhancers:t?.enhancers&&typeof t.enhancers=="object"?Object.values(t.enhancers):[],y=l?.config?{...l.config,...t,design:t?.design||l.config.design,preset:t?.preset||l.config.preset}:{...t},A={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`},x=l?.paths||{};if(r={...A,...x,...r},g.registry.setStaticMode(r),e&&typeof document<"u")try{let E=await g.registry.getStylesheet("styles");if(E){E._pds=!0;let R=(document.adoptedStyleSheets||[]).filter(_=>_._pds!==!0);document.adoptedStyleSheets=[...R,E],Ue({mode:"static",source:"static:styles-applied"})}}catch(E){_e.call(g,"warn","Failed to apply static styles:",E)}let w=null,L=[];try{let E=await Ie({autoDefineBaseURL:c,autoDefinePreload:u,autoDefineMapper:d,enhancers:h,autoDefineOverrides:i||null,autoDefinePreferModule:!(i&&i.baseURL)},{baseEnhancers:se});w=E.autoDefiner,L=E.mergedEnhancers||[]}catch(E){_e.call(g,"error","\u274C Failed to initialize AutoDefiner/Enhancers (static):",E)}let P=pe(t);return g.currentConfig=Object.freeze({mode:"static",...structuredClone(P),design:structuredClone(y.design||{}),preset:y.preset,theme:a,enhancers:L}),Oe({mode:"static",config:y,theme:a,autoDefiner:w}),{config:y,theme:a,autoDefiner:w}}catch(a){throw g.dispatchEvent(new CustomEvent("pds:error",{detail:{error:a}})),a}}var j={name:"@pure-ds/core",shortname:"pds",version:"0.6.11",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/js/pds.js",module:"./public/assets/js/pds.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/js/pds.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/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 g.start(V);var Ne=typeof j.repository=="string"?j.repository:j.repository?.url,ft=Ne?Ne.replace(/^git\+/,"").replace(/\.git$/,""):"",Gt=j.homepage||ft,Kt=j.bugs?.url||"";document.body.innerHTML=`
|
|
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=`
|
|
33
3
|
<pds-toaster id="global-toaster"></pds-toaster>
|
|
34
4
|
|
|
35
5
|
<div class="container text-center">
|
|
36
6
|
<img src="/assets/img/pds-logo.svg" alt="PDS Logo" width="64" height="64" />
|
|
37
7
|
<header class="container section">
|
|
38
|
-
<h1>${
|
|
39
|
-
<small class="text-muted">${
|
|
8
|
+
<h1>${w.name} ${w.version}</h1>
|
|
9
|
+
<small class="text-muted">${w.description}</small>
|
|
40
10
|
</header>
|
|
41
11
|
</div>
|
|
42
12
|
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function g(n){let e=Array.isArray(n?.strings)?n.strings:[],c=Array.isArray(n?.values)?n.values:[],u=new Set,t=[],f=/(\s)(\.[\w-]+)=\s*$/;for(let r=0;r<e.length;r+=1){let s=e[r]??"",l=s.match(f);if(l&&r<c.length){let d=l[2].slice(1),y=`pds-val-${r}`;s=s.replace(f,`$1data-pds-prop="${d}:${y}"`),u.add(r)}t.push(s),r<c.length&&!u.has(r)&&t.push(`<!--pds-val-${r}-->`)}let m=document.createElement("template");m.innerHTML=t.join("");let a=(r,s)=>{let l=r.parentNode;if(!l)return;if(s==null){l.removeChild(r);return}let p=d=>{if(d!=null){if(d instanceof Node){l.insertBefore(d,r);return}if(Array.isArray(d)){d.forEach(y=>p(y));return}l.insertBefore(document.createTextNode(String(d)),r)}};p(s),l.removeChild(r)},i=document.createTreeWalker(m.content,NodeFilter.SHOW_COMMENT),o=[];for(;i.nextNode();){let r=i.currentNode;r?.nodeValue?.startsWith("pds-val-")&&o.push(r)}return o.forEach(r=>{let s=Number(r.nodeValue.replace("pds-val-",""));a(r,c[s])}),m.content.querySelectorAll("*").forEach(r=>{let s=r.getAttribute("data-pds-prop");if(!s)return;let[l,p]=s.split(":"),d=Number(String(p).replace("pds-val-",""));l&&Number.isInteger(d)&&(r[l]=c[d]),r.removeAttribute("data-pds-prop")}),m.content}function b(n,e){if(e==null)return;if(typeof e=="object"&&Array.isArray(e.strings)&&Array.isArray(e.values)){n.appendChild(g(e));return}if(e instanceof Node){n.appendChild(e);return}if(Array.isArray(e)){e.forEach(u=>b(n,u));return}let c=typeof e=="string"?e:String(e);n.appendChild(document.createTextNode(c))}function A(){let n=navigator.userAgent,e=/Safari/i.test(n),c=/(Chrome|Chromium|CriOS|FxiOS|EdgiOS|OPiOS|Opera)/i.test(n);return e&&!c}function C(n){if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let e=window.matchMedia?.("(max-width: 639px)").matches,c=n.classList.contains("dialog-no-scale-animation")?"pds-dialog-fade-enter":e?"pds-dialog-enter-mobile":"pds-dialog-enter";n.style.animation="none",n.offsetWidth,n.style.animation=`${c} var(--transition-normal) ease`,n.addEventListener("animationend",()=>{n.style.animation=""},{once:!0})}function x(n={}){return n?.liquidGlassEffects===!0}async function E(n,e={}){return e={...{title:"Confirm",type:"confirm",buttons:{ok:{name:"OK",primary:!0},cancel:{name:"Cancel",cancel:!0}}},...e},new Promise(u=>{let t=document.createElement("dialog");A()&&t.classList.add("dialog-no-scale-animation"),x(e)&&t.classList.add("liquid-glass"),e.size&&t.classList.add(`dialog-${e.size}`),e.type&&t.classList.add(`dialog-${e.type}`),e.class&&(Array.isArray(e.class)?t.classList.add(...e.class):t.classList.add(e.class)),e.maxHeight&&t.style.setProperty("--dialog-max-height",e.maxHeight);let f=Object.entries(e.buttons).map(([a,i])=>{let o=i.primary?"btn-primary btn-sm":"btn-outline btn-sm";return`<button type="${i.cancel?"button":"submit"}" class="${o}" value="${a}">${i.name}</button>`});if(e.useForm){let a=document.createElement("div");b(a,n);let i=a.querySelector("form");if(i){t.innerHTML=`
|
|
2
|
+
<header>
|
|
3
|
+
<h2>${e.title}</h2>
|
|
4
|
+
</header>
|
|
5
|
+
`;let o=document.createElement("article");for(o.className="dialog-body";i.firstChild;)o.appendChild(i.firstChild);i.appendChild(o);let h=document.createElement("footer");h.innerHTML=f.join(""),i.appendChild(h),t.appendChild(i)}else t.innerHTML=`
|
|
6
|
+
<header>
|
|
7
|
+
<h2>${e.title}</h2>
|
|
8
|
+
</header>
|
|
9
|
+
<article id="msg-container"></article>
|
|
10
|
+
<footer>
|
|
11
|
+
${f.join("")}
|
|
12
|
+
</footer>
|
|
13
|
+
`,t.querySelector("#msg-container").appendChild(a)}else{t.innerHTML=`
|
|
14
|
+
<form method="dialog">
|
|
15
|
+
<header>
|
|
16
|
+
<h2>${e.title}</h2>
|
|
17
|
+
</header>
|
|
18
|
+
|
|
19
|
+
<article id="msg-container"></article>
|
|
20
|
+
|
|
21
|
+
<footer>
|
|
22
|
+
${f.join("")}
|
|
23
|
+
</footer>
|
|
24
|
+
</form>
|
|
25
|
+
`;let a=t.querySelector("#msg-container");b(a,n)}t.addEventListener("click",a=>{a.target.closest('button[value="cancel"]')&&(t.close(),u(!1))});let m=()=>{let a=t.querySelector("form");a?a.addEventListener("submit",i=>{i.preventDefault();let o;e.useForm&&i.submitter.value==="ok"?(console.log("Found form:",a),console.log("Form elements:",a?Array.from(a.elements):"no form"),o=new FormData(a),console.log("FormData entries:",Array.from(o.entries()))):o=i.submitter.value==="ok",t.close(),u(o)}):requestAnimationFrame(m)};m(),t.addEventListener("close",()=>{setTimeout(()=>t.remove(),200)}),document.body.appendChild(t),typeof e.rendered=="function"&&e.rendered(t),t.showModal(),requestAnimationFrame(()=>C(t))})}export{E as ask};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function P(...h){let i={};h.length&&typeof h[h.length-1]=="object"&&(i=h.pop()||{});let m=h,{baseURL:f,mapper:w=n=>`${n}.js`,onError:E=(n,r)=>console.error(`[defineWebComponents] ${n}:`,r)}=i,d=f?new URL(f,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),l=n=>n.toLowerCase().replace(/(^|-)([a-z])/g,(r,s,u)=>u.toUpperCase()),b=async n=>{try{if(customElements.get(n))return{tag:n,status:"already-defined"};let r=w(n),u=await import(r instanceof URL?r.href:new URL(r,d).href),c=u?.default??u?.[l(n)];if(!c){if(customElements.get(n))return{tag:n,status:"self-defined"};throw new Error(`No export found for ${n}. Expected default export or named export "${l(n)}".`)}return customElements.get(n)?{tag:n,status:"race-already-defined"}:(customElements.define(n,c),{tag:n,status:"defined"})}catch(r){throw E(n,r),r}};return Promise.all(m.map(b))}var M=class{constructor(i={}){let{baseURL:m,mapper:f,onError:w,predicate:E=()=>!0,attributeModule:d="data-module",root:l=document,scanExisting:b=!0,debounceMs:n=16,observeShadows:r=!0,enhancers:s=[],patchAttachShadow:u=!0}=i,c=new Set,y=new Set,$=new Set,S=new Map,U=new WeakMap,v=new WeakMap,p=0,T=!1,x=null,W=e=>{if(!e||!s.length)return;let o=v.get(e);o||(o=new Set,v.set(e,o));for(let t of s)if(!(!t.selector||!t.run)&&!o.has(t.selector))try{e.matches&&e.matches(t.selector)&&(t.run(e),o.add(t.selector))}catch(a){console.warn(`[AutoDefiner] Error applying enhancer for selector "${t.selector}":`,a)}},A=(e,o)=>{if(!T&&!(!e||!e.includes("-"))&&!customElements.get(e)&&!y.has(e)&&!$.has(e)){if(o&&o.getAttribute){let t=o.getAttribute(d);t&&!S.has(e)&&S.set(e,t)}c.add(e),O()}},O=()=>{p||(p=setTimeout(N,n))},L=e=>{if(e){if(e.nodeType===1){let o=e,t=o.tagName?.toLowerCase();t&&t.includes("-")&&!customElements.get(t)&&E(t,o)&&A(t,o),W(o),r&&o.shadowRoot&&C(o.shadowRoot)}e.querySelectorAll&&e.querySelectorAll("*").forEach(o=>{let t=o.tagName?.toLowerCase();t&&t.includes("-")&&!customElements.get(t)&&E(t,o)&&A(t,o),W(o),r&&o.shadowRoot&&C(o.shadowRoot)})}},C=e=>{if(!e||U.has(e))return;L(e);let o=new MutationObserver(t=>{for(let a of t)a.addedNodes?.forEach(R=>{L(R)}),a.type==="attributes"&&a.target&&L(a.target)});o.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[d,...s.map(t=>t.selector).filter(t=>t.startsWith("data-"))]}),U.set(e,o)};async function N(){if(clearTimeout(p),p=0,!c.size)return;let e=Array.from(c);c.clear(),e.forEach(o=>y.add(o));try{let o=t=>S.get(t)??(f?f(t):`${t}.js`);await P(...e,{baseURL:m,mapper:o,onError:(t,a)=>{$.add(t),w?.(t,a)}})}catch{}finally{e.forEach(o=>y.delete(o))}}let _=l===document?document.documentElement:l,j=new MutationObserver(e=>{for(let o of e)o.addedNodes?.forEach(t=>{L(t)}),o.type==="attributes"&&o.target&&L(o.target)});if(j.observe(_,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[d,...s.map(e=>e.selector).filter(e=>e.startsWith("data-"))]}),r&&u&&Element.prototype.attachShadow){let e=Element.prototype.attachShadow;Element.prototype.attachShadow=function(t){let a=e.call(this,t);if(t&&t.mode==="open"){C(a);let R=this.tagName?.toLowerCase();R&&R.includes("-")&&!customElements.get(R)&&A(R,this)}return a},x=()=>Element.prototype.attachShadow=e}return b&&L(_),{stop(){T=!0,j.disconnect(),x&&x(),p&&(clearTimeout(p),p=0),U.forEach(e=>e.disconnect())},flush:N}}static async define(...i){let m={};i.length&&typeof i[i.length-1]=="object"&&(m=i.pop()||{});let f=i,{baseURL:w,mapper:E=r=>`${r}.js`,onError:d=(r,s)=>console.error(`[defineWebComponents] ${r}:`,s)}=m,l=w?new URL(w,typeof location<"u"?location.href:import.meta.url):new URL("./",import.meta.url),b=r=>r.toLowerCase().replace(/(^|-)([a-z])/g,(s,u,c)=>c.toUpperCase()),n=async r=>{try{if(customElements.get(r))return{tag:r,status:"already-defined"};let s=E(r),c=await import(s instanceof URL?s.href:new URL(s,l).href),y=c?.default??c?.[b(r)];if(!y){if(customElements.get(r))return{tag:r,status:"self-defined"};throw new Error(`No export found for ${r}. Expected default export or named export "${b(r)}".`)}return customElements.get(r)?{tag:r,status:"race-already-defined"}:(customElements.define(r,y),{tag:r,status:"defined"})}catch(s){throw d(r,s),s}};return Promise.all(f.map(n))}};export{M as AutoDefiner};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function m(o){return new DOMParser().parseFromString(o,"text/html").body.childNodes}function y(o,t=100){let e;return function(...i){let r=()=>{clearTimeout(e),o(...i)};clearTimeout(e),e=setTimeout(r,t)}}function p(o){setTimeout(o,0)}function b(o){try{if(typeof o!="string"||o.indexOf(`
|
|
2
|
+
`)!==-1||o.indexOf(" ")!==-1||o.startsWith("#/"))return!1;let t=new URL(o,window.location.origin);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function x(o,t,e){let s=window.screen.width/2-t/2,i=window.screen.height/2-e/2;return window.open(o,"",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=${t}, height=${e}, top=${i}, left=${s}`)}var g={result:"ac-suggestion",item:"ac-itm"},f=class o extends EventTarget{constructor(t,e,s){super(),this.settings={emptyResultsText:"",...s},this.container=t,this.input=e,this.input.setAttribute("autocomplete","off"),this.categories=s.categories||{},this.caches=new Map,p(this.attach.bind(this))}static connect(t,e){let s=t.target;if(!s._autoComplete){if(!e?.categories)throw Error("Missing autocomplete settings");s._autoComplete=new o(s.parentNode,s,e),t.type==="focus"&&setTimeout(()=>{s._autoComplete.focusHandler(t)},100)}return s._autoComplete}on(t,e){return this.input.addEventListener(t,e),this}attach(){this.resultsDiv=document.createElement("div"),this.resultsDiv.title="",this.resultsDiv.classList.add(g.result),this.container.offsetWidth>100&&(this.resultsDiv.style.width=this.container.offsetWidth),this.resultsDiv.addEventListener("mousedown",this.resultClick.bind(this)),this.container.classList.add("ac-container"),this.input.classList.add("ac-input");let t=getComputedStyle(this.input);this.container.style.setProperty("--ac-bg-default",t.backgroundColor),this.container.style.setProperty("--ac-color-default",t.color);let e=getComputedStyle(this.input).accentColor;e!=="auto"&&this.container.style.setProperty("--ac-accent-color",e),(this.container?.shadowRoot??this.container).appendChild(this.resultsDiv),this.controller().clear("attach"),this.on("input",y(this.inputHandler.bind(this),this.settings.throttleInputMs??300)).on("focus",this.focusHandler.bind(this)).on("focusout",this.blurHandler.bind(this)).on("keyup",this.keyUpHandler.bind(this)).on("keydown",this.keyDownHandler.bind(this))}controller(){let t=this.internalController();return typeof this.settings.controller=="function"&&(t=this.settings.controller(this)??t),t}internalController(){return{show:this.show.bind(this),hide:this.hide.bind(this),clear:this.clear.bind(this),empty:()=>{}}}moveResult(t){this.controller().show();let e=this.acItems.length;this.rowIndex=this.rowIndex+t,this.rowIndex<=0?this.rowIndex=0:this.rowIndex>e-1&&(this.rowIndex=0);for(let i of this.acItems)i.classList.remove("selected");let s=this.getSelectedDiv();s?(s.classList.add("selected"),s.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"})):this.focusHandler({target:this.input})}getSelectedDiv(){return this.resultsDiv.querySelector(`div:nth-child(${this.rowIndex+1})`)}selectResult(t){if(t=t||this.getSelectedDiv(),t){let e=parseInt(t.getAttribute("data-index"));this.resultClicked=!0;let s=this.results[e],i=this.categories[s.category]??{};i.action=i.action??this.setText.bind(this),i.newTab&&(this.tabWindow=x("about:blank"));let r={...s,search:this.input.value};t.classList.add("ac-active"),setTimeout(()=>{this.controller().hide("result-selected"),r.action?r.action(r):(i.action(r),i.newTab&&(r.url?this.tabWindow.location.href=r.url:this.tabWindow.close()));var n=new Event("change",{bubbles:!0});this.input.dispatchEvent(n),this.controller().clear("result-selected");let u=new Event("result-selected");u.detail=r,this.input.dispatchEvent(u)},0)}}setText(t){let e=!1;this.input?(this.input.value=t.text,e=!0):this.container?.autoCompleteInput?(this.container.autoCompleteInput.value=t.text,e=!0):"value"in this.container&&(this.container.value=t.text,e=!0),e&&this.input&&this.input.dispatchEvent(new Event("input",{bubbles:!0})),this.controller().hide("settext")}resultClick(t){this.selectResult(t.target.closest(`.${g.item}`))}blurHandler(){setTimeout(()=>{this.resultClicked||this.controller().clear("blurred"),this.resultClicked=!1},100)}clear(){this.settings.debug||this.resultsDiv&&(this.resultsDiv.innerHTML="",this.controller().hide("clear"),this.cacheTmr&&clearTimeout(this.cacheTmr),this.cacheTmr=setTimeout(()=>{this.caches.clear()},60*1e3*5))}show(){if(!this.resultsDiv.classList.contains("ac-active")){let t=this.getViewBounds();this.resultsDiv.style.position="absolute",t.rect.width>100&&(this.resultsDiv.style.width=`${t.rect.width}px`),this.settings.direction=this.settings.direction??t.suggestedDirection,this.resultsDiv.setAttribute("data-direction",this.settings.direction),this.settings.direction==="up"?(this.resultsDiv.style.top="unset",this.resultsDiv.style.bottom=`${t.rect.height+20}px`,this.rowIndex=this.acItems.length):(this.resultsDiv.style.bottom="unset",this.resultsDiv.style.top=`${t.rect.height}px`,this.rowIndex=-1),this.resultsDiv.style.maxWidth="unset",this.resultsDiv.classList.toggle("ac-active",!0)}}getViewBounds(){let t=this.input.getBoundingClientRect();return{rect:t,suggestedDirection:t.top+t.height+500>window.innerHeight?"up":"down"}}hide(){this.resultsDiv.classList.toggle("ac-active",!1)}empty(){this.resultsDiv.innerHTML=`<div class="ac-empty">${this.settings.emptyResultsText}</div>`,this.controller().show()}inputHandler(t){this.cacheTmr&&clearTimeout(this.cacheTmr);let e={search:t.target.value,categories:this.categories};this.container.classList.add("search-running"),this.getItems(e,t).then(s=>{this.controller().clear("new-results"),this.resultsHandler(s,e),this.container.classList.remove("search-running")})}keyDownHandler(t){switch(t.key){case"Enter":t.stopPropagation(),t.preventDefault();break;case"ArrowDown":p(this.moveResult(1));break;case"ArrowUp":p(this.moveResult(-1));break}}keyUpHandler(t){switch(t.key){case"Escape":this.controller().hide("escape");break;case"Enter":this.getSelectedDiv()&&(this.container.preventEnter=!0,t.stopPropagation(),t.preventDefault(),this.selectResult(),setTimeout(()=>{this.container.preventEnter=!1},10));break;default:break}}focusHandler(t){this.controller().clear("focus");let e=t.target.value;this.suggest(e,t)}suggest(t,e){this.input.focus();let s={suggest:!0,search:t||"",categories:this.categories};this.getItems(s,e).then(i=>{this.input.dispatchEvent(new CustomEvent("show-results",{detail:{results:i}})),this.resultsHandler(i,s)})}sort(t,e){return t.sort((s,i)=>{let r=e.categories[s.category],n=e.categories[i.category],u=typeof r.sortIndex=="function"?r.sortIndex(e):r.sortIndex??0;return(typeof n.sortIndex=="function"?n.sortIndex(e):n.sortIndex??0)>u?1:-1})}resultsHandler(t,e){this.results=t,this.rowIndex=-1;let s=0,i=(r,n)=>`
|
|
3
|
+
<div title="${n.tooltip||""}" data-index="${s}" class="${`${g.item} cat-${n.category} ${n.class??""}`.trim()}"${n.style?` style="${n.style}"`:""}>
|
|
4
|
+
${this.handleImageOrIcon(n)}
|
|
5
|
+
<span class="text">${this.formatResultItem(n,e,r)}</span>
|
|
6
|
+
${this.settings.hideCategory?"":`<span class="category">${n.category||""}</span>`}
|
|
7
|
+
</div>`;t.forEach(r=>{let n=e.categories[r.category]||{};r.element?this.resultsDiv.appendChild(r.element):(r=typeof r=="string"?{text:r}:r,this.resultsDiv.appendChild(m(i(n,r))[0])),s++}),t.length?(this.acItems=this.resultsDiv.querySelectorAll(".ac-itm"),this.controller().show()):e.search.length&&this.controller().empty()}handleImageOrIcon(t){return t.image?`<img src="${t.image}"/>`:typeof this.settings.iconHandler=="function"?this.settings.iconHandler(t):`<svg-icon icon="${t.icon}"></svg-icon>`}formatResultItem(t,e,s){let i=typeof t=="string"?{text:t}:t,r=i.text;return e.search&&(r=r.replace("%search%",e.search),i.description=i.description?.replace("%search%",e.search)),r=this.highlight(r,e.search),i.description&&(r=`<div>${r}</div><small>${i.description}</small>`),s.format&&(r=s.format({item:i,result:r,options:e})),r}highlight(t,e){var s=new RegExp("("+e+")","gi");return t.replace(s,'<span class="txt-hl">$1</span>')}async getItems(t,e){this.aborter&&this.aborter.abort();let s=this.caches.get(t.search);if(s)return s;let i=this.settings.map,r=a=>(typeof a=="string"&&(a={text:a}),a),n=a=>i?a.map(h=>({text:h[i]})):a.map(h=>r(h)),u=a=>(this.settings.max&&this.settings.max>0&&(a.length=this.settings.max),a);return this.aborter=new AbortController,this.aborterSignal=this.aborter.signal,new Promise(a=>{let h=l=>{l=this.sort(l,t),this.settings.cache!==!1&&this.caches.set(t.search,l),a(l)};if(b(this.items)){if(this.settings.minlength>0&&(!t.search||t.search.length<this.settings.minlength)){h([]);return}let l=this.formatSearch(this.items,t);fetch(l).then(c=>{if(c.status===200){c.json().then(d=>{d=n(d),h(u(d.filter(w=>this.isMatch(t,w))))});return}throw Error(`HTTP error ${c.status} - ${l}`)})}else if(Array.isArray(this.items)){let l=!0;this.items=this.items.map(c=>typeof c=="string"?{text:c}:(l=!1,c)),l&&this.container.classList.add("simple"),h(u(n(this.items)))}else if(typeof this.items=="function")t.control=this.container,Promise.resolve(this.items(t,e)).then(c=>{c=c.map(d=>r(d)),c=n(c),h(c)});else return h(Promise.resolve(this.items.apply(this,t)))})}async items(t){let e=[];t.results=[],t.signal=this.aborterSignal;for(var s in t.categories){let i=t.categories[s];if(i.trigger=i.trigger??(()=>!0),t.results=e,i.trigger(t)){let r=[];try{r=await i.getItems(t)}catch(n){console.warn(`Error loading items for omniBox category '${s}'.`,n)}e=e.concat(r.map(n=>(n.category=s,n)))}}return e}formatSearch(t,e){return t.indexOf("%search%")?t.replace("%search%",e.search||""):t+"?"+this.createQueryParam(e)}createQueryParam(t){let e=t.suggest?"&suggest=true":"";return`q=${t.text}${e}`}isMatch(t,e){return e.text?.indexOf("%search%")>=0?!0:t.search?e.text?.toLowerCase().indexOf(t.search.toLowerCase())>=0:t.suggest}static textFilter(t,e){return function(s){if(!t.search)return!0;if(s.hidden)return!1;let r=(e?s[e]:s).match(new RegExp(t.search,"gi"));if(r)return r;if(s.config?.tags)return s.config.tags.some(n=>n.match(new RegExp(t.search,"gi")))}}};export{f as AutoComplete};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var F=[{selector:".accordion"},{selector:"nav[data-dropdown]"},{selector:"label[data-toggle]"},{selector:"label[data-color]"},{selector:'input[type="range"]'},{selector:"form[data-required]"},{selector:"fieldset[role=group][data-open]"},{selector:"[data-clip]"},{selector:"button, a[class*='btn-']"}];function W(t){t.dataset.enhancedAccordion||(t.dataset.enhancedAccordion="true",t.addEventListener("toggle",e=>{e.target.open&&e.target.parentElement===t&&t.querySelectorAll(":scope > details[open]").forEach(n=>{n!==e.target&&(n.open=!1)})},!0))}function H(t){if(t.dataset.enhancedDropdown)return;t.dataset.enhancedDropdown="true";let e=t.lastElementChild;if(!e)return;let n=t.querySelector("[data-dropdown-toggle]")||t.querySelector("button");n&&!n.hasAttribute("type")&&n.setAttribute("type","button"),e.id||(e.id=`dropdown-${Math.random().toString(36).slice(2,9)}`);let o=e.tagName?.toLowerCase()==="menu",a=8;o&&!e.hasAttribute("role")&&e.setAttribute("role","menu"),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true"),n&&(n.setAttribute("aria-haspopup","true"),n.setAttribute("aria-controls",e.id),n.setAttribute("aria-expanded","false"));let c=()=>{let s=e.getAttribute("style");e.style.visibility="hidden",e.style.display="inline-block",e.style.pointerEvents="none";let h=e.getBoundingClientRect(),f=Math.max(e.offsetWidth||0,e.scrollWidth||0,h.width||0,1),d=Math.max(e.offsetHeight||0,e.scrollHeight||0,h.height||0,1);return s===null?e.removeAttribute("style"):e.setAttribute("style",s),{width:f,height:d}},i=()=>{let s=(t.getAttribute("data-direction")||t.getAttribute("data-dropdown-direction")||t.getAttribute("data-mode")||"auto").toLowerCase();if(s==="up"||s==="down")return s;let h=(n||t).getBoundingClientRect(),{height:f}=c(),d=Math.max(0,window.innerHeight-h.bottom),b=Math.max(0,h.top),v=d>=f,y=b>=f;return v&&!y?"down":y&&!v?"up":v&&y?"down":b>d?"up":"down"},r=()=>{let s=(t.getAttribute("data-align")||t.getAttribute("data-dropdown-align")||"auto").toLowerCase();if(s==="left"||s==="right"||s==="start"||s==="end")return s==="start"?"left":s==="end"?"right":s;let h=(n||t).getBoundingClientRect(),{width:f}=c(),d=Math.max(0,window.innerWidth-h.left),b=Math.max(0,h.right),v=d>=f,y=b>=f;return v&&!y?"left":y&&!v?"right":v&&y?"left":b>d?"right":"left"},p=(s,h=8)=>{let f=getComputedStyle(t).getPropertyValue(s).trim();if(!f)return h;let d=document.createElement("span");d.style.position="fixed",d.style.visibility="hidden",d.style.pointerEvents="none",d.style.height=f,document.body.appendChild(d);let b=Number.parseFloat(getComputedStyle(d).height);return d.remove(),Number.isFinite(b)?b:h},u=()=>{e.style.removeProperty("position"),e.style.removeProperty("left"),e.style.removeProperty("top"),e.style.removeProperty("right"),e.style.removeProperty("bottom"),e.style.removeProperty("margin-top"),e.style.removeProperty("margin-bottom"),e.style.removeProperty("max-width"),e.style.removeProperty("max-inline-size"),e.style.removeProperty("max-height"),e.style.removeProperty("overflow")},l=()=>{e.getAttribute("aria-hidden")==="false"&&(u(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{w()})}))},w=()=>{if(e.getAttribute("aria-hidden")!=="false")return;let s=(n||t).getBoundingClientRect(),h=window.visualViewport,f=h?.width||document.documentElement?.clientWidth||window.innerWidth,d=h?.height||document.documentElement?.clientHeight||window.innerHeight,b=h?.offsetLeft||0,v=h?.offsetTop||0,y=Math.max(1,f-a*2),T=Math.max(1,d-a*2);e.style.maxWidth=`${Math.round(y)}px`,e.style.maxInlineSize=`${Math.round(y)}px`,e.style.maxHeight=`${Math.round(T)}px`,e.style.overflow="auto";let{width:k,height:M}=c(),q=p("--spacing-2",8),P=i(),R=r();t.dataset.dropdownDirection=P,t.dataset.dropdownAlign=R;let C=R==="right"?s.right-k:s.left;k>=y-1?C=b+a:C=Math.max(b+a,Math.min(C,b+f-k-a));let S=P==="up"?s.top-q-M:s.bottom+q;S=Math.max(v+a,Math.min(S,v+d-M-a)),e.style.position="fixed",e.style.left=`${Math.round(C)}px`,e.style.top=`${Math.round(S)}px`,e.style.right="auto",e.style.bottom="auto",e.style.marginTop="0",e.style.marginBottom="0"},g=null,E=()=>{g||(g=()=>w(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0))},L=()=>{g&&(window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),g=null)},m=null,O=()=>{m||typeof document>"u"||(m=()=>{e.getAttribute("aria-hidden")==="false"&&(t.dataset.dropdownDirection=i(),t.dataset.dropdownAlign=r(),l(),setTimeout(()=>{e.getAttribute("aria-hidden")==="false"&&l()},50),setTimeout(()=>{e.getAttribute("aria-hidden")==="false"&&l()},150))},document.addEventListener("pds:config-changed",m))},D=()=>{!m||typeof document>"u"||(document.removeEventListener("pds:config-changed",m),m=null)},A=null,I=()=>{t.dataset.dropdownDirection=i(),t.dataset.dropdownAlign=r(),e.setAttribute("aria-hidden","false"),n?.setAttribute("aria-expanded","true"),E(),O(),l(),A||(A=s=>{(s.composedPath?s.composedPath():[s.target]).some(d=>d===t)||x()},setTimeout(()=>{document.addEventListener("click",A)},0))},x=()=>{e.setAttribute("aria-hidden","true"),n?.setAttribute("aria-expanded","false"),L(),D(),u(),A&&(document.removeEventListener("click",A),A=null)},B=()=>{e.getAttribute("aria-hidden")==="false"?x():I()};n?.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),B()}),t.addEventListener("keydown",s=>{s.key==="Escape"&&(x(),n?.focus())}),t.addEventListener("focusout",s=>{s.relatedTarget&&((s.composedPath?s.composedPath():[s.relatedTarget]).some(d=>d===t)||x())})}function N(t){if(t.dataset.enhancedToggle)return;t.dataset.enhancedToggle="true";let e=t.querySelector('input[type="checkbox"]');if(!e)return;t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.setAttribute("role","switch"),t.setAttribute("aria-checked",e.checked?"true":"false");let n=document.createElement("span");n.className="toggle-switch",n.setAttribute("role","presentation"),n.setAttribute("aria-hidden","true");let o=document.createElement("span");o.className="toggle-knob",n.appendChild(o),t.insertBefore(n,e.nextSibling);let a=()=>{t.setAttribute("aria-checked",e.checked?"true":"false")},c=()=>{e.disabled||(e.checked=!e.checked,a(),e.dispatchEvent(new Event("change",{bubbles:!0})))};t.addEventListener("click",i=>{i.preventDefault(),c()}),t.addEventListener("keydown",i=>{(i.key===" "||i.key==="Enter")&&(i.preventDefault(),c())}),e.addEventListener("change",a)}function $(t){if(t.dataset.enhancedColorInput)return;let e=t.querySelector('input[type="color"]');if(!e)return;t.dataset.enhancedColorInput="true";let n=t.querySelector(":scope > .color-control"),o=t.querySelector(":scope > .color-control > .color-swatch"),a=t.querySelector(":scope > .color-control > output");n||(n=document.createElement("span"),n.className="color-control",e.before(n)),o||(o=document.createElement("span"),o.className="color-swatch",n.appendChild(o)),e.parentElement!==o&&o.appendChild(e),a||(a=document.createElement("output"),n.appendChild(a));let c=()=>{if(e.dataset.colorUnset==="1"){a.value="",a.textContent="not set",n.dataset.value="",n.dataset.unset="1",o.dataset.unset="1";return}a.value=e.value,a.textContent=e.value,n.dataset.value=e.value,delete n.dataset.unset,delete o.dataset.unset};c();let i=()=>{e.dataset.colorUnset==="1"&&(e.dataset.colorUnset="0"),c()};e.addEventListener("input",i,{passive:!0}),e.addEventListener("change",i,{passive:!0})}function U(t){if(t.dataset.enhancedRange)return;let e=i=>{if(t.dataset.enhancedRangeProgrammatic)return;t.dataset.enhancedRangeProgrammatic="1";let r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"value")||Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value");r?.get&&r?.set&&Object.defineProperty(t,"value",{configurable:!0,enumerable:r.enumerable,get(){return r.get.call(this)},set(u){r.set.call(this,u),i()}}),new MutationObserver(u=>{u.some(w=>{let g=w.attributeName;return g==="value"||g==="min"||g==="max"})&&i()}).observe(t,{attributes:!0,attributeFilter:["value","min","max"]})},n=t.closest("label"),o=n?.classList.contains("range-output"),a=t.id||`range-${Math.random().toString(36).substring(2,11)}`,c=`${a}-output`;if(t.id=a,o){let i=n.querySelector("span");if(i&&!i.classList.contains("range-output-wrapper")){let r=document.createElement("span");r.className="range-output-wrapper",r.style.display="flex",r.style.justifyContent="space-between",r.style.alignItems="center";let p=document.createElement("span");p.textContent=i.textContent,r.appendChild(p);let u=document.createElement("output");u.id=c,u.setAttribute("for",a),u.style.color="var(--surface-text-secondary, var(--color-text-secondary))",u.style.fontSize="0.875rem",u.textContent=t.value,r.appendChild(u),i.textContent="",i.appendChild(r);let l=()=>{u.textContent=t.value};t.addEventListener("input",l),t.addEventListener("change",l),e(l),l()}}else{let i=t.closest(".range-container");i||(i=document.createElement("div"),i.className="range-container",t.parentNode?.insertBefore(i,t),i.appendChild(t)),i.style.position="relative";let r=document.createElement("output");r.id=c,r.setAttribute("for",a),r.className="range-bubble",r.setAttribute("aria-live","polite"),i.appendChild(r);let p=()=>{let w=parseFloat(t.min)||0,g=parseFloat(t.max)||100,E=parseFloat(t.value),L=(E-w)/(g-w);r.style.left=`calc(${L*100}% )`,r.textContent=String(E)},u=()=>r.classList.add("visible"),l=()=>r.classList.remove("visible");t.addEventListener("input",p),t.addEventListener("pointerdown",u),t.addEventListener("pointerup",l),t.addEventListener("pointerleave",l),t.addEventListener("focus",u),t.addEventListener("blur",l),t.addEventListener("change",p),e(p),p()}t.dataset.enhancedRange="1"}function z(t){if(t.dataset.enhancedRequired)return;t.dataset.enhancedRequired="true";let e=n=>{let o;if(n.closest("[role$=group]")?o=n.closest("[role$=group]").querySelector("legend"):o=n.closest("label"),!o||o.querySelector(".required-asterisk"))return;let a=document.createElement("span");a.classList.add("required-asterisk"),a.textContent="*",a.style.marginLeft="4px";let c=o.querySelector("span, [data-label]");if(c)c.appendChild(a);else{let r=o.querySelector("input, select, textarea");r?o.insertBefore(a,r):o.appendChild(a)}let i=n.closest("form");if(i&&!i.querySelector(".required-legend")){let r=document.createElement("small");r.classList.add("required-legend"),r.textContent="* Required fields",i.insertBefore(r,i.querySelector(".form-actions")||i.lastElementChild)}};t.querySelectorAll("[required]").forEach(n=>{e(n)})}function j(t){if(t.dataset.enhancedOpenGroup)return;t.dataset.enhancedOpenGroup="true",t.classList.add("flex","flex-wrap","buttons");let e=document.createElement("input");e.type="text",e.placeholder="Add item...",e.classList.add("input-text","input-sm"),e.style.width="auto";let n=()=>t.querySelector('input[type="radio"], input[type="checkbox"]');t.appendChild(e),e.addEventListener("keydown",o=>{if(o.key==="Enter"||o.key==="Tab"){let a=e.value.trim();if(a){o.preventDefault();let c=n(),i=c?.type==="radio"?"radio":"checkbox",r=`open-group-${Math.random().toString(36).substring(2,11)}`,p=document.createElement("label"),u=document.createElement("span");u.setAttribute("data-label",""),u.textContent=a;let l=document.createElement("input");l.type=i,l.name=c?.name||t.getAttribute("data-name")||"open-group",l.value=a,l.id=r,p.appendChild(u),p.appendChild(l),t.insertBefore(p,e),e.value=""}}else if(o.key==="Backspace"&&e.value===""){o.preventDefault();let a=t.querySelectorAll("label");a.length>0&&a[a.length-1].remove()}})}function V(t){if(t.dataset.enhancedClip)return;t.dataset.enhancedClip="true",t.hasAttribute("tabindex")||t.setAttribute("tabindex","0"),t.hasAttribute("role")||t.setAttribute("role","button");let e=()=>{let o=t.getAttribute("data-clip-open")==="true";t.setAttribute("aria-expanded",o?"true":"false")},n=()=>{let o=t.getAttribute("data-clip-open")==="true";t.setAttribute("data-clip-open",o?"false":"true"),e()};t.addEventListener("click",o=>{o.defaultPrevented||n()}),t.addEventListener("keydown",o=>{(o.key===" "||o.key==="Enter")&&(o.preventDefault(),n())}),e()}function G(t){if(t.dataset.enhancedBtnWorking)return;t.dataset.enhancedBtnWorking="true";let e=null,n=!1;new MutationObserver(a=>{a.forEach(c=>{if(c.attributeName==="class"){let i=t.classList.contains("btn-working"),r=t.querySelector("pds-icon");if(i)if(r)e||(e=r.getAttribute("icon")),r.setAttribute("icon","circle-notch");else{let p=document.createElement("pds-icon");p.setAttribute("icon","circle-notch"),p.setAttribute("size","sm"),t.insertBefore(p,t.firstChild),n=!0}else c.oldValue?.includes("btn-working")&&r&&(n?(r.remove(),n=!1):e&&(r.setAttribute("icon",e),e=null))}})}).observe(t,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0})}var _=new Map([[".accordion",W],["nav[data-dropdown]",H],["label[data-toggle]",N],["label[data-color]",$],['input[type="range"]',U],["form[data-required]",z],["fieldset[role=group][data-open]",j],["[data-clip]",V],["button, a[class*='btn-']",G]]),J=F.map(t=>({...t,run:_.get(t.selector)||(()=>{})}));export{J as defaultPDSEnhancers};
|