@pure-ds/storybook 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/addons/description/preview.js +15 -0
- package/.storybook/addons/description/register.js +60 -0
- package/.storybook/addons/html-preview/Panel.jsx +327 -0
- package/.storybook/addons/html-preview/constants.js +6 -0
- package/.storybook/addons/html-preview/preview.js +178 -0
- package/.storybook/addons/html-preview/register.js +16 -0
- package/.storybook/addons/pds-configurator/SearchTool.js +44 -0
- package/.storybook/addons/pds-configurator/Tool.js +30 -0
- package/.storybook/addons/pds-configurator/constants.js +9 -0
- package/.storybook/addons/pds-configurator/preview.js +159 -0
- package/.storybook/addons/pds-configurator/register.js +24 -0
- package/.storybook/docs.css +35 -0
- package/.storybook/htmlPreview.css +103 -0
- package/.storybook/htmlPreview.js +271 -0
- package/.storybook/main.js +160 -0
- package/.storybook/preview-body.html +48 -0
- package/.storybook/preview-head.html +11 -0
- package/.storybook/preview.js +1563 -0
- package/README.md +266 -0
- package/bin/index.js +40 -0
- package/dist/pds-reference.json +2101 -0
- package/package.json +45 -0
- package/pds.config.js +6 -0
- package/public/assets/css/app.css +1216 -0
- package/public/assets/data/auto-design-advanced.json +704 -0
- package/public/assets/data/auto-design-simple.json +123 -0
- package/public/assets/img/icon-512x512.png +0 -0
- package/public/assets/img/logo-trans.png +0 -0
- package/public/assets/img/logo.png +0 -0
- package/public/assets/js/app.js +15088 -0
- package/public/assets/js/app.js.map +7 -0
- package/public/assets/js/lit.js +1176 -0
- package/public/assets/js/lit.js.map +7 -0
- package/public/assets/js/pds.js +9801 -0
- package/public/assets/js/pds.js.map +7 -0
- package/public/assets/pds/components/pds-calendar.js +837 -0
- package/public/assets/pds/components/pds-drawer.js +857 -0
- package/public/assets/pds/components/pds-icon.js +338 -0
- package/public/assets/pds/components/pds-jsonform.js +1775 -0
- package/public/assets/pds/components/pds-richtext.js +1035 -0
- package/public/assets/pds/components/pds-scrollrow.js +331 -0
- package/public/assets/pds/components/pds-splitpanel.js +401 -0
- package/public/assets/pds/components/pds-tabstrip.js +251 -0
- package/public/assets/pds/components/pds-toaster.js +446 -0
- package/public/assets/pds/components/pds-upload.js +657 -0
- package/public/assets/pds/custom-elements.json +2003 -0
- package/public/assets/pds/icons/pds-icons.svg +498 -0
- package/public/assets/pds/pds-css-complete.json +1861 -0
- package/public/assets/pds/pds-runtime-config.json +11 -0
- package/public/assets/pds/pds.css-data.json +2152 -0
- package/public/assets/pds/styles/pds-components.css +1944 -0
- package/public/assets/pds/styles/pds-components.css.js +3895 -0
- package/public/assets/pds/styles/pds-primitives.css +352 -0
- package/public/assets/pds/styles/pds-primitives.css.js +711 -0
- package/public/assets/pds/styles/pds-styles.css +3761 -0
- package/public/assets/pds/styles/pds-styles.css.js +7529 -0
- package/public/assets/pds/styles/pds-tokens.css +699 -0
- package/public/assets/pds/styles/pds-tokens.css.js +1405 -0
- package/public/assets/pds/styles/pds-utilities.css +763 -0
- package/public/assets/pds/styles/pds-utilities.css.js +1533 -0
- package/public/assets/pds/vscode-custom-data.json +824 -0
- package/scripts/build-pds-reference.mjs +807 -0
- package/scripts/generate-stories.js +542 -0
- package/scripts/package-build.js +86 -0
- package/src/js/app.js +17 -0
- package/src/js/common/ask.js +208 -0
- package/src/js/common/common.js +20 -0
- package/src/js/common/font-loader.js +200 -0
- package/src/js/common/msg.js +90 -0
- package/src/js/lit.js +40 -0
- package/src/js/pds-core/pds-config.js +1162 -0
- package/src/js/pds-core/pds-enhancer-metadata.js +75 -0
- package/src/js/pds-core/pds-enhancers.js +357 -0
- package/src/js/pds-core/pds-enums.js +86 -0
- package/src/js/pds-core/pds-generator.js +5317 -0
- package/src/js/pds-core/pds-ontology.js +256 -0
- package/src/js/pds-core/pds-paths.js +109 -0
- package/src/js/pds-core/pds-query.js +571 -0
- package/src/js/pds-core/pds-registry.js +129 -0
- package/src/js/pds-core/pds.d.ts +129 -0
- package/src/js/pds.d.ts +408 -0
- package/src/js/pds.js +1579 -0
- package/src/pds-core/pds-api.js +105 -0
- package/stories/GettingStarted.md +96 -0
- package/stories/GettingStarted.stories.js +144 -0
- package/stories/WhatIsPDS.md +194 -0
- package/stories/WhatIsPDS.stories.js +144 -0
- package/stories/components/PdsCalendar.stories.js +263 -0
- package/stories/components/PdsDrawer.stories.js +623 -0
- package/stories/components/PdsIcon.stories.js +78 -0
- package/stories/components/PdsJsonform.stories.js +1444 -0
- package/stories/components/PdsRichtext.stories.js +367 -0
- package/stories/components/PdsScrollrow.stories.js +140 -0
- package/stories/components/PdsSplitpanel.stories.js +502 -0
- package/stories/components/PdsTabstrip.stories.js +442 -0
- package/stories/components/PdsToaster.stories.js +186 -0
- package/stories/components/PdsUpload.stories.js +66 -0
- package/stories/enhancements/Dropdowns.stories.js +185 -0
- package/stories/enhancements/InteractiveStates.stories.js +625 -0
- package/stories/enhancements/MeshGradients.stories.js +320 -0
- package/stories/enhancements/OpenGroups.stories.js +227 -0
- package/stories/enhancements/RangeSliders.stories.js +232 -0
- package/stories/enhancements/RequiredFields.stories.js +189 -0
- package/stories/enhancements/Toggles.stories.js +167 -0
- package/stories/foundations/Colors.stories.js +283 -0
- package/stories/foundations/Icons.stories.js +305 -0
- package/stories/foundations/SmartSurfaces.stories.js +367 -0
- package/stories/foundations/Spacing.stories.js +175 -0
- package/stories/foundations/Typography.stories.js +960 -0
- package/stories/foundations/ZIndex.stories.js +325 -0
- package/stories/patterns/BorderEffects.stories.js +72 -0
- package/stories/patterns/Layout.stories.js +99 -0
- package/stories/patterns/Utilities.stories.js +107 -0
- package/stories/primitives/Accordion.stories.js +359 -0
- package/stories/primitives/Alerts.stories.js +64 -0
- package/stories/primitives/Badges.stories.js +183 -0
- package/stories/primitives/Buttons.stories.js +229 -0
- package/stories/primitives/Cards.stories.js +353 -0
- package/stories/primitives/FormGroups.stories.js +569 -0
- package/stories/primitives/Forms.stories.js +131 -0
- package/stories/primitives/Media.stories.js +203 -0
- package/stories/primitives/Tables.stories.js +232 -0
- package/stories/reference/ReferenceCatalog.stories.js +28 -0
- package/stories/reference/reference-catalog.js +413 -0
- package/stories/reference/reference-docs.js +302 -0
- package/stories/reference/reference-helpers.js +310 -0
- package/stories/utilities/GridSystem.stories.js +208 -0
- package/stories/utils/PdsAsk.stories.js +420 -0
- package/stories/utils/toast-utils.js +148 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const enhancerMetadata = [
|
|
2
|
+
{
|
|
3
|
+
selector: "nav[data-dropdown]",
|
|
4
|
+
description:
|
|
5
|
+
"Enhances a nav element with data-dropdown to function as a dropdown menu.",
|
|
6
|
+
demoHtml: `
|
|
7
|
+
<nav data-dropdown>
|
|
8
|
+
<button class="btn-primary">Menu</button>
|
|
9
|
+
<menu>
|
|
10
|
+
<li><a href="#">Item 1</a></li>
|
|
11
|
+
<li><a href="#">Item 2</a></li>
|
|
12
|
+
</menu>
|
|
13
|
+
</nav>
|
|
14
|
+
`.trim(),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
selector: "label[data-toggle]",
|
|
18
|
+
description: "Creates a toggle switch element from a checkbox.",
|
|
19
|
+
demoHtml: `
|
|
20
|
+
<label data-toggle>
|
|
21
|
+
<input type="checkbox">
|
|
22
|
+
<span data-label>Enable notifications</span>
|
|
23
|
+
</label>
|
|
24
|
+
`.trim(),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
selector: 'input[type="range"]',
|
|
28
|
+
description: "Enhances range inputs with an attached <output>.",
|
|
29
|
+
demoHtml: `
|
|
30
|
+
<label class="range-output">
|
|
31
|
+
<span data-label>Volume</span>
|
|
32
|
+
<input type="range" min="0" max="100" value="40">
|
|
33
|
+
</label>
|
|
34
|
+
`.trim(),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
selector: "form [required]",
|
|
38
|
+
description:
|
|
39
|
+
"Enhances required form fields using an asterisk in the label.",
|
|
40
|
+
demoHtml: `
|
|
41
|
+
<form action'#" method="post">
|
|
42
|
+
<label>
|
|
43
|
+
<span>Field Label</span>
|
|
44
|
+
<input type="text" required>
|
|
45
|
+
</label>
|
|
46
|
+
<nav class="form-actions">
|
|
47
|
+
<button type="submit" class="btn-primary">Submit</button>
|
|
48
|
+
</nav>
|
|
49
|
+
</form>
|
|
50
|
+
`.trim(),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
selector: "fieldset[role=group][data-open]",
|
|
54
|
+
description:
|
|
55
|
+
"Enhances a checkbox/radio group to be open (have a way to add and remove items).",
|
|
56
|
+
demoHtml: `
|
|
57
|
+
<fieldset role="group" data-open>
|
|
58
|
+
<label>
|
|
59
|
+
<span data-label>Test</span>
|
|
60
|
+
<input value="lala" name="test1" type="radio" />
|
|
61
|
+
</label>
|
|
62
|
+
</fieldset>
|
|
63
|
+
`.trim(),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
selector: "button, a[class*='btn-']",
|
|
67
|
+
description:
|
|
68
|
+
"Automatically manages spinner icon for buttons with .btn-working class",
|
|
69
|
+
demoHtml: `
|
|
70
|
+
<button class="btn-primary btn-working">
|
|
71
|
+
<span>Saving</span>
|
|
72
|
+
</button>
|
|
73
|
+
`.trim(),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { enhancerMetadata } from "./pds-enhancer-metadata.js";
|
|
2
|
+
|
|
3
|
+
function enhanceDropdown(elem) {
|
|
4
|
+
if (elem.dataset.enhancedDropdown) return;
|
|
5
|
+
elem.dataset.enhancedDropdown = "true";
|
|
6
|
+
const menu = elem.querySelector("menu");
|
|
7
|
+
if (!menu) return;
|
|
8
|
+
|
|
9
|
+
const trigger =
|
|
10
|
+
elem.querySelector("[data-dropdown-toggle]") ||
|
|
11
|
+
elem.querySelector("button");
|
|
12
|
+
|
|
13
|
+
if (trigger && !trigger.hasAttribute("type")) {
|
|
14
|
+
trigger.setAttribute("type", "button");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!menu.id) {
|
|
18
|
+
menu.id = `dropdown-${Math.random().toString(36).slice(2, 9)}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
menu.setAttribute("role", menu.getAttribute("role") || "menu");
|
|
22
|
+
if (!menu.hasAttribute("aria-hidden")) {
|
|
23
|
+
menu.setAttribute("aria-hidden", "true");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (trigger) {
|
|
27
|
+
trigger.setAttribute("aria-haspopup", "true");
|
|
28
|
+
trigger.setAttribute("aria-controls", menu.id);
|
|
29
|
+
trigger.setAttribute("aria-expanded", "false");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const resolveDirection = () => {
|
|
33
|
+
const mode = (elem.getAttribute("data-mode") || "auto").toLowerCase();
|
|
34
|
+
if (mode === "up" || mode === "down") return mode;
|
|
35
|
+
const rect = elem.getBoundingClientRect();
|
|
36
|
+
const spaceBelow = Math.max(0, window.innerHeight - rect.bottom);
|
|
37
|
+
const spaceAbove = Math.max(0, rect.top);
|
|
38
|
+
return spaceAbove > spaceBelow ? "up" : "down";
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const openMenu = () => {
|
|
42
|
+
elem.dataset.dropdownDirection = resolveDirection();
|
|
43
|
+
menu.setAttribute("aria-hidden", "false");
|
|
44
|
+
trigger?.setAttribute("aria-expanded", "true");
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const closeMenu = () => {
|
|
48
|
+
menu.setAttribute("aria-hidden", "true");
|
|
49
|
+
trigger?.setAttribute("aria-expanded", "false");
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const toggleMenu = () => {
|
|
53
|
+
if (menu.getAttribute("aria-hidden") === "false") {
|
|
54
|
+
closeMenu();
|
|
55
|
+
} else {
|
|
56
|
+
openMenu();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
trigger?.addEventListener("click", (event) => {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
event.stopPropagation();
|
|
63
|
+
toggleMenu();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
document.addEventListener("click", (event) => {
|
|
67
|
+
if (!elem.contains(event.target)) {
|
|
68
|
+
closeMenu();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
elem.addEventListener("keydown", (event) => {
|
|
73
|
+
if (event.key === "Escape") {
|
|
74
|
+
closeMenu();
|
|
75
|
+
trigger?.focus();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
elem.addEventListener("focusout", (event) => {
|
|
80
|
+
if (!event.relatedTarget || !elem.contains(event.relatedTarget)) {
|
|
81
|
+
closeMenu();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function enhanceToggle(elem) {
|
|
87
|
+
if (elem.dataset.enhancedToggle) return;
|
|
88
|
+
elem.dataset.enhancedToggle = "true";
|
|
89
|
+
const checkbox = elem.querySelector('input[type="checkbox"]');
|
|
90
|
+
if (!checkbox) return;
|
|
91
|
+
|
|
92
|
+
if (!elem.hasAttribute("tabindex")) {
|
|
93
|
+
elem.setAttribute("tabindex", "0");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
elem.setAttribute("role", "switch");
|
|
97
|
+
elem.setAttribute("aria-checked", checkbox.checked ? "true" : "false");
|
|
98
|
+
|
|
99
|
+
const toggleSwitch = document.createElement("span");
|
|
100
|
+
toggleSwitch.className = "toggle-switch";
|
|
101
|
+
toggleSwitch.setAttribute("role", "presentation");
|
|
102
|
+
toggleSwitch.setAttribute("aria-hidden", "true");
|
|
103
|
+
const knob = document.createElement("span");
|
|
104
|
+
knob.className = "toggle-knob";
|
|
105
|
+
toggleSwitch.appendChild(knob);
|
|
106
|
+
elem.insertBefore(toggleSwitch, checkbox.nextSibling);
|
|
107
|
+
|
|
108
|
+
const updateAria = () => {
|
|
109
|
+
elem.setAttribute("aria-checked", checkbox.checked ? "true" : "false");
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const toggle = () => {
|
|
113
|
+
if (checkbox.disabled) return;
|
|
114
|
+
checkbox.checked = !checkbox.checked;
|
|
115
|
+
updateAria();
|
|
116
|
+
checkbox.dispatchEvent(new Event("change", { bubbles: true }));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
elem.addEventListener("click", (event) => {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
toggle();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
elem.addEventListener("keydown", (event) => {
|
|
125
|
+
if (event.key === " " || event.key === "Enter") {
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
toggle();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
checkbox.addEventListener("change", updateAria);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function enhanceRange(elem) {
|
|
135
|
+
if (elem.dataset.enhancedRange) return;
|
|
136
|
+
|
|
137
|
+
const label = elem.closest("label");
|
|
138
|
+
const hasRangeOutputClass = label?.classList.contains("range-output");
|
|
139
|
+
|
|
140
|
+
const inputId =
|
|
141
|
+
elem.id || `range-${Math.random().toString(36).substring(2, 11)}`;
|
|
142
|
+
const outputId = `${inputId}-output`;
|
|
143
|
+
elem.id = inputId;
|
|
144
|
+
|
|
145
|
+
if (hasRangeOutputClass) {
|
|
146
|
+
const labelSpan = label.querySelector("span");
|
|
147
|
+
if (labelSpan && !labelSpan.classList.contains("range-output-wrapper")) {
|
|
148
|
+
const wrapper = document.createElement("span");
|
|
149
|
+
wrapper.className = "range-output-wrapper";
|
|
150
|
+
wrapper.style.display = "flex";
|
|
151
|
+
wrapper.style.justifyContent = "space-between";
|
|
152
|
+
wrapper.style.alignItems = "center";
|
|
153
|
+
|
|
154
|
+
const textSpan = document.createElement("span");
|
|
155
|
+
textSpan.textContent = labelSpan.textContent;
|
|
156
|
+
wrapper.appendChild(textSpan);
|
|
157
|
+
|
|
158
|
+
const output = document.createElement("output");
|
|
159
|
+
output.id = outputId;
|
|
160
|
+
output.setAttribute("for", inputId);
|
|
161
|
+
output.style.color =
|
|
162
|
+
"var(--surface-text-secondary, var(--color-text-secondary))";
|
|
163
|
+
output.style.fontSize = "0.875rem";
|
|
164
|
+
output.textContent = elem.value;
|
|
165
|
+
wrapper.appendChild(output);
|
|
166
|
+
|
|
167
|
+
labelSpan.textContent = "";
|
|
168
|
+
labelSpan.appendChild(wrapper);
|
|
169
|
+
|
|
170
|
+
const updateOutput = () => {
|
|
171
|
+
output.textContent = elem.value;
|
|
172
|
+
};
|
|
173
|
+
elem.addEventListener("input", updateOutput);
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
let container = elem.closest(".range-container");
|
|
177
|
+
if (!container) {
|
|
178
|
+
container = document.createElement("div");
|
|
179
|
+
container.className = "range-container";
|
|
180
|
+
elem.parentNode?.insertBefore(container, elem);
|
|
181
|
+
container.appendChild(elem);
|
|
182
|
+
}
|
|
183
|
+
container.style.position = "relative";
|
|
184
|
+
|
|
185
|
+
const bubble = document.createElement("output");
|
|
186
|
+
bubble.id = outputId;
|
|
187
|
+
bubble.setAttribute("for", inputId);
|
|
188
|
+
bubble.className = "range-bubble";
|
|
189
|
+
bubble.setAttribute("aria-live", "polite");
|
|
190
|
+
container.appendChild(bubble);
|
|
191
|
+
|
|
192
|
+
const updateBubble = () => {
|
|
193
|
+
const min = parseFloat(elem.min) || 0;
|
|
194
|
+
const max = parseFloat(elem.max) || 100;
|
|
195
|
+
const value = parseFloat(elem.value);
|
|
196
|
+
const pct = (value - min) / (max - min);
|
|
197
|
+
bubble.style.left = `calc(${pct * 100}% )`;
|
|
198
|
+
bubble.textContent = String(value);
|
|
199
|
+
};
|
|
200
|
+
const show = () => bubble.classList.add("visible");
|
|
201
|
+
const hide = () => bubble.classList.remove("visible");
|
|
202
|
+
elem.addEventListener("input", updateBubble);
|
|
203
|
+
elem.addEventListener("pointerdown", show);
|
|
204
|
+
elem.addEventListener("pointerup", hide);
|
|
205
|
+
elem.addEventListener("pointerleave", hide);
|
|
206
|
+
elem.addEventListener("focus", show);
|
|
207
|
+
elem.addEventListener("blur", hide);
|
|
208
|
+
updateBubble();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
elem.dataset.enhancedRange = "1";
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function enhanceRequired(elem) {
|
|
215
|
+
const label = elem.closest("label");
|
|
216
|
+
if (!label) return;
|
|
217
|
+
if (label.querySelector(".required-asterisk")) return;
|
|
218
|
+
|
|
219
|
+
const asterisk = document.createElement("span");
|
|
220
|
+
asterisk.classList.add("required-asterisk");
|
|
221
|
+
asterisk.textContent = "*";
|
|
222
|
+
asterisk.style.marginLeft = "4px";
|
|
223
|
+
label.querySelector("span").appendChild(asterisk);
|
|
224
|
+
|
|
225
|
+
const form = elem.closest("form");
|
|
226
|
+
if (form && !form.querySelector(".required-legend")) {
|
|
227
|
+
const legend = document.createElement("div");
|
|
228
|
+
legend.classList.add("required-legend", "pill", "pill-outline");
|
|
229
|
+
legend.style.fontSize = "0.9em";
|
|
230
|
+
legend.style.marginBottom = "8px";
|
|
231
|
+
legend.textContent = "* Required fields";
|
|
232
|
+
form.insertBefore(
|
|
233
|
+
legend,
|
|
234
|
+
form.querySelector(".form-actions") || form.lastElementChild
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function enhanceOpenGroup(elem) {
|
|
240
|
+
if (elem.dataset.enhancedOpenGroup) return;
|
|
241
|
+
elem.dataset.enhancedOpenGroup = "true";
|
|
242
|
+
|
|
243
|
+
elem.classList.add("flex", "flex-wrap", "buttons");
|
|
244
|
+
|
|
245
|
+
const addInput = document.createElement("input");
|
|
246
|
+
addInput.type = "text";
|
|
247
|
+
addInput.placeholder = "Add item...";
|
|
248
|
+
addInput.classList.add("input-text", "input-sm");
|
|
249
|
+
addInput.style.width = "auto";
|
|
250
|
+
const firstInput = elem.querySelector(
|
|
251
|
+
'input[type="radio"], input[type="checkbox"]'
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
elem.appendChild(addInput);
|
|
255
|
+
addInput.addEventListener("keydown", (event) => {
|
|
256
|
+
if (event.key === "Enter" || event.key === "Tab") {
|
|
257
|
+
const value = addInput.value.trim();
|
|
258
|
+
if (value) {
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
|
|
261
|
+
const type = firstInput.type === "radio" ? "radio" : "checkbox";
|
|
262
|
+
const id = `open-group-${Math.random()
|
|
263
|
+
.toString(36)
|
|
264
|
+
.substring(2, 11)}`;
|
|
265
|
+
const label = document.createElement("label");
|
|
266
|
+
|
|
267
|
+
const span = document.createElement("span");
|
|
268
|
+
span.setAttribute("data-label", "");
|
|
269
|
+
span.textContent = value;
|
|
270
|
+
|
|
271
|
+
const input = document.createElement("input");
|
|
272
|
+
input.type = type;
|
|
273
|
+
input.name =
|
|
274
|
+
firstInput.name || elem.getAttribute("data-name") || "open-group";
|
|
275
|
+
input.value = value;
|
|
276
|
+
input.id = id;
|
|
277
|
+
|
|
278
|
+
label.appendChild(span);
|
|
279
|
+
label.appendChild(input);
|
|
280
|
+
|
|
281
|
+
elem.insertBefore(label, addInput);
|
|
282
|
+
addInput.value = "";
|
|
283
|
+
}
|
|
284
|
+
} else if (event.key === "Backspace" && addInput.value === "") {
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
const labels = elem.querySelectorAll("label");
|
|
287
|
+
if (labels.length > 0) {
|
|
288
|
+
const lastLabel = labels[labels.length - 1];
|
|
289
|
+
lastLabel.remove();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function enhanceButtonWorking(elem) {
|
|
296
|
+
if (elem.dataset.enhancedBtnWorking) return;
|
|
297
|
+
elem.dataset.enhancedBtnWorking = "true";
|
|
298
|
+
|
|
299
|
+
let originalIcon = null;
|
|
300
|
+
let addedIcon = false;
|
|
301
|
+
|
|
302
|
+
const observer = new MutationObserver((mutations) => {
|
|
303
|
+
mutations.forEach((mutation) => {
|
|
304
|
+
if (mutation.attributeName === "class") {
|
|
305
|
+
const hasWorking = elem.classList.contains("btn-working");
|
|
306
|
+
const icon = elem.querySelector("pds-icon");
|
|
307
|
+
|
|
308
|
+
if (hasWorking) {
|
|
309
|
+
if (icon) {
|
|
310
|
+
if (!originalIcon) {
|
|
311
|
+
originalIcon = icon.getAttribute("icon");
|
|
312
|
+
}
|
|
313
|
+
icon.setAttribute("icon", "circle-notch");
|
|
314
|
+
} else {
|
|
315
|
+
const newIcon = document.createElement("pds-icon");
|
|
316
|
+
newIcon.setAttribute("icon", "circle-notch");
|
|
317
|
+
newIcon.setAttribute("size", "sm");
|
|
318
|
+
elem.insertBefore(newIcon, elem.firstChild);
|
|
319
|
+
addedIcon = true;
|
|
320
|
+
}
|
|
321
|
+
} else if (mutation.oldValue?.includes("btn-working")) {
|
|
322
|
+
if (icon) {
|
|
323
|
+
if (addedIcon) {
|
|
324
|
+
icon.remove();
|
|
325
|
+
addedIcon = false;
|
|
326
|
+
} else if (originalIcon) {
|
|
327
|
+
icon.setAttribute("icon", originalIcon);
|
|
328
|
+
originalIcon = null;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
observer.observe(elem, {
|
|
337
|
+
attributes: true,
|
|
338
|
+
attributeFilter: ["class"],
|
|
339
|
+
attributeOldValue: true,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const enhancerRunners = new Map([
|
|
344
|
+
["nav[data-dropdown]", enhanceDropdown],
|
|
345
|
+
["label[data-toggle]", enhanceToggle],
|
|
346
|
+
['input[type="range"]', enhanceRange],
|
|
347
|
+
["form [required]", enhanceRequired],
|
|
348
|
+
["fieldset[role=group][data-open]", enhanceOpenGroup],
|
|
349
|
+
["button, a[class*='btn-']", enhanceButtonWorking],
|
|
350
|
+
]);
|
|
351
|
+
|
|
352
|
+
export const defaultPDSEnhancers = enhancerMetadata.map((meta) => ({
|
|
353
|
+
...meta,
|
|
354
|
+
run: enhancerRunners.get(meta.selector) || (() => {}),
|
|
355
|
+
}));
|
|
356
|
+
|
|
357
|
+
export const defaultPDSEnhancerMetadata = enhancerMetadata;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Static enums for design system values
|
|
2
|
+
export const enums = {
|
|
3
|
+
FontWeights: {
|
|
4
|
+
light: 300,
|
|
5
|
+
normal: 400,
|
|
6
|
+
medium: 500,
|
|
7
|
+
semibold: 600,
|
|
8
|
+
bold: 700,
|
|
9
|
+
},
|
|
10
|
+
LineHeights: {
|
|
11
|
+
tight: 1.25,
|
|
12
|
+
normal: 1.5,
|
|
13
|
+
relaxed: 1.75,
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
BorderWidths: {
|
|
17
|
+
hairline: 0.5,
|
|
18
|
+
thin: 1,
|
|
19
|
+
medium: 2,
|
|
20
|
+
thick: 3,
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
RadiusSizes: {
|
|
24
|
+
none: 0,
|
|
25
|
+
small: 4,
|
|
26
|
+
medium: 8,
|
|
27
|
+
large: 16,
|
|
28
|
+
xlarge: 24,
|
|
29
|
+
xxlarge: 32
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
ShadowDepths: {
|
|
33
|
+
none: "none",
|
|
34
|
+
light: "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
|
|
35
|
+
medium:
|
|
36
|
+
"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
37
|
+
deep: "0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",
|
|
38
|
+
extreme: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
39
|
+
},
|
|
40
|
+
TransitionSpeeds: {
|
|
41
|
+
fast: 150,
|
|
42
|
+
normal: 250,
|
|
43
|
+
slow: 350,
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
AnimationEasings: {
|
|
47
|
+
linear: "linear",
|
|
48
|
+
ease: "ease",
|
|
49
|
+
"ease-in": "ease-in",
|
|
50
|
+
"ease-out": "ease-out",
|
|
51
|
+
"ease-in-out": "ease-in-out",
|
|
52
|
+
bounce: "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
|
|
53
|
+
},
|
|
54
|
+
TouchTargetSizes: {
|
|
55
|
+
compact: 36,
|
|
56
|
+
standard: 44, // iOS/Android accessibility standard
|
|
57
|
+
comfortable: 48,
|
|
58
|
+
spacious: 56,
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
LinkStyles: {
|
|
62
|
+
inline: "inline", // Normal inline text links
|
|
63
|
+
block: "block", // Block-level links
|
|
64
|
+
button: "button", // Button-like links (flex with touch target)
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
FocusStyles: {
|
|
68
|
+
ring: "ring", // Box-shadow ring (default)
|
|
69
|
+
outline: "outline", // Browser outline
|
|
70
|
+
border: "border", // Border change
|
|
71
|
+
glow: "glow", // Subtle glow effect
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
TabSizes: {
|
|
75
|
+
compact: 2,
|
|
76
|
+
standard: 4,
|
|
77
|
+
wide: 8,
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
SelectIcons: {
|
|
81
|
+
chevron: "chevron", // Standard chevron down
|
|
82
|
+
arrow: "arrow", // Simple arrow
|
|
83
|
+
caret: "caret", // Triangle caret
|
|
84
|
+
none: "none", // No icon
|
|
85
|
+
},
|
|
86
|
+
};
|