@pure-ds/storybook 0.4.23 → 0.4.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pds-reference.json +3 -3
- package/package.json +2 -2
- package/public/assets/js/app.js +13 -8
- package/public/assets/js/pds.js +14 -9
- package/public/assets/pds/components/pds-form.js +29 -8
- package/src/js/pds-core/pds-config.js +1 -2
- package/src/js/pds.js +21 -4
- package/stories/GettingStarted.md +27 -3
- package/stories/components/PdsForm.stories.js +4902 -4676
- package/stories/components/PdsFormUiSchema.md +1 -1
|
@@ -11,7 +11,7 @@ function getStep(value) {
|
|
|
11
11
|
// Default options for pds-form
|
|
12
12
|
const DEFAULT_OPTIONS = {
|
|
13
13
|
widgets: {
|
|
14
|
-
booleans: "toggle", // 'toggle' | 'checkbox'
|
|
14
|
+
booleans: "toggle", // 'toggle' | 'toggle-with-icons' | 'checkbox'
|
|
15
15
|
numbers: "input", // 'input' | 'range'
|
|
16
16
|
selects: "standard", // 'standard' | 'dropdown'
|
|
17
17
|
},
|
|
@@ -669,10 +669,9 @@ export class SchemaForm extends LitElement {
|
|
|
669
669
|
return useRange ? "input-range" : "input-number";
|
|
670
670
|
}
|
|
671
671
|
if (schema.type === "boolean") {
|
|
672
|
-
//
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
return useToggle ? "toggle" : "checkbox";
|
|
672
|
+
// Return the actual boolean widget type
|
|
673
|
+
const booleanWidget = this.#getOption("widgets.booleans", "toggle");
|
|
674
|
+
return booleanWidget === "checkbox" ? "checkbox" : booleanWidget;
|
|
676
675
|
}
|
|
677
676
|
return "input-text";
|
|
678
677
|
}
|
|
@@ -1489,14 +1488,20 @@ export class SchemaForm extends LitElement {
|
|
|
1489
1488
|
this.#emit("pw:after-render-field", { path, schema: node.schema })
|
|
1490
1489
|
);
|
|
1491
1490
|
|
|
1492
|
-
// Add data-toggle for toggle switches
|
|
1493
|
-
const isToggle = node.widgetKey === "toggle";
|
|
1491
|
+
// Add data-toggle for toggle switches (both toggle and toggle-with-icons)
|
|
1492
|
+
const isToggle = node.widgetKey === "toggle" || node.widgetKey === "toggle-with-icons";
|
|
1493
|
+
const useIconToggle = node.widgetKey === "toggle-with-icons";
|
|
1494
1494
|
|
|
1495
1495
|
// Add range-output class for range inputs if enabled
|
|
1496
1496
|
const isRange = node.widgetKey === "input-range";
|
|
1497
1497
|
const useRangeOutput =
|
|
1498
1498
|
isRange && this.#getOption("enhancements.rangeOutput", true);
|
|
1499
|
-
|
|
1499
|
+
|
|
1500
|
+
// Build class list for label
|
|
1501
|
+
const labelClasses = [];
|
|
1502
|
+
if (useRangeOutput) labelClasses.push("range-output");
|
|
1503
|
+
if (useIconToggle) labelClasses.push("with-icons");
|
|
1504
|
+
const labelClass = labelClasses.length > 0 ? labelClasses.join(" ") : undefined;
|
|
1500
1505
|
|
|
1501
1506
|
const renderControlAndLabel = (isToggle) => {
|
|
1502
1507
|
if (isToggle) return html`${controlTpl} <span data-label>${label}</span>`;
|
|
@@ -1855,6 +1860,22 @@ export class SchemaForm extends LitElement {
|
|
|
1855
1860
|
`
|
|
1856
1861
|
);
|
|
1857
1862
|
|
|
1863
|
+
// Toggle switch with icons (same as toggle, styling comes from .with-icons class on label)
|
|
1864
|
+
this.defineRenderer(
|
|
1865
|
+
"toggle-with-icons",
|
|
1866
|
+
({ id, path, value, attrs, set }) => html`
|
|
1867
|
+
<input
|
|
1868
|
+
id=${id}
|
|
1869
|
+
name=${path}
|
|
1870
|
+
type="checkbox"
|
|
1871
|
+
.checked=${!!value}
|
|
1872
|
+
?disabled=${!!attrs.disabled}
|
|
1873
|
+
?required=${!!attrs.required}
|
|
1874
|
+
@change=${(e) => set(!!e.target.checked)}
|
|
1875
|
+
/>
|
|
1876
|
+
`
|
|
1877
|
+
);
|
|
1878
|
+
|
|
1858
1879
|
this.defineRenderer(
|
|
1859
1880
|
"select",
|
|
1860
1881
|
({ id, path, value, attrs, set, schema, ui, host }) => {
|
|
@@ -737,7 +737,6 @@ export const presets = {
|
|
|
737
737
|
"Data-dense business intelligence app interface with organized hierarchy and professional polish",
|
|
738
738
|
options: {
|
|
739
739
|
liquidGlassEffects: false,
|
|
740
|
-
backgroundMesh: 2,
|
|
741
740
|
},
|
|
742
741
|
colors: {
|
|
743
742
|
primary: "#0066cc", // corporate blue for primary actions
|
|
@@ -815,7 +814,7 @@ presets.default = {
|
|
|
815
814
|
form: {
|
|
816
815
|
options: {
|
|
817
816
|
widgets: {
|
|
818
|
-
booleans: "toggle", // 'toggle' | 'checkbox'
|
|
817
|
+
booleans: "toggle", // 'toggle' | 'toggle-with-icons' | 'checkbox'
|
|
819
818
|
numbers: "input", // 'input' | 'range'
|
|
820
819
|
selects: "standard", // 'standard' | 'dropdown'
|
|
821
820
|
},
|
package/src/js/pds.js
CHANGED
|
@@ -961,10 +961,27 @@ async function __setupAutoDefinerAndEnhancers(options) {
|
|
|
961
961
|
enhancers: mergedEnhancers,
|
|
962
962
|
onError: (tag, err) => {
|
|
963
963
|
if (typeof tag === "string" && tag.startsWith("pds-")) {
|
|
964
|
-
//
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
)
|
|
964
|
+
// Check if this is a Lit-dependent component with missing #pds/lit import map
|
|
965
|
+
const litDependentComponents = ['pds-form', 'pds-drawer'];
|
|
966
|
+
const isLitComponent = litDependentComponents.includes(tag);
|
|
967
|
+
const isMissingLitError = err?.message?.includes('#pds/lit') ||
|
|
968
|
+
err?.message?.includes('Failed to resolve module specifier');
|
|
969
|
+
|
|
970
|
+
if (isLitComponent && isMissingLitError) {
|
|
971
|
+
console.error(
|
|
972
|
+
`❌ PDS component <${tag}> requires Lit but #pds/lit is not in import map.\n` +
|
|
973
|
+
`Add this to your HTML <head>:\n` +
|
|
974
|
+
`<script type="importmap">\n` +
|
|
975
|
+
` { "imports": { "#pds/lit": "./path/to/lit.js" } }\n` +
|
|
976
|
+
`</script>\n` +
|
|
977
|
+
`See: https://github.com/pure-ds/core#lit-components`
|
|
978
|
+
);
|
|
979
|
+
} else {
|
|
980
|
+
// Generic component not found warning
|
|
981
|
+
console.warn(
|
|
982
|
+
`⚠️ PDS component <${tag}> not found. Assets may not be installed.`
|
|
983
|
+
);
|
|
984
|
+
}
|
|
968
985
|
} else {
|
|
969
986
|
console.error(`❌ Auto-define error for <${tag}>:`, err);
|
|
970
987
|
}
|
|
@@ -10,12 +10,26 @@ From zero to hero with PDS.
|
|
|
10
10
|
npm install @pure-ds/core
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
**What happens during install:**
|
|
14
|
+
|
|
15
|
+
PDS automatically sets up your project:
|
|
16
|
+
- ✅ Creates `pds.config.js` with commented examples (if it doesn't exist)
|
|
17
|
+
- ✅ Exports static assets to your web root (components, icons, styles)
|
|
18
|
+
- ✅ Copies AI/Copilot instructions to `.github/copilot-instructions.md`
|
|
19
|
+
- ✅ Adds helper scripts to your `package.json` (`pds:export`, `pds:build-icons`)
|
|
20
|
+
|
|
21
|
+
The generated `pds.config.js` includes:
|
|
14
22
|
|
|
15
23
|
```javascript
|
|
24
|
+
// pds.config.js (auto-generated)
|
|
16
25
|
export const config = {
|
|
17
26
|
mode: "live",
|
|
18
|
-
preset: "default"
|
|
27
|
+
preset: "default",
|
|
28
|
+
|
|
29
|
+
// Uncomment and customize as needed:
|
|
30
|
+
// design: { colors: { primary: '#007acc' } },
|
|
31
|
+
// enhancers: [ /* custom enhancements */ ],
|
|
32
|
+
// autoDefine: { predefine: ['pds-icon'] }
|
|
19
33
|
}
|
|
20
34
|
```
|
|
21
35
|
|
|
@@ -23,11 +37,21 @@ Then initialize in your app:
|
|
|
23
37
|
|
|
24
38
|
```javascript
|
|
25
39
|
import { PDS } from '@pure-ds/core';
|
|
26
|
-
import { config } from "
|
|
40
|
+
import { config } from "./pds.config.js"; // project root
|
|
27
41
|
|
|
28
42
|
await PDS.start(config); // That's it! Start writing semantic HTML.
|
|
29
43
|
```
|
|
30
44
|
|
|
45
|
+
**Manual config generation:**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Create or regenerate config with examples
|
|
49
|
+
npx pds-init-config
|
|
50
|
+
|
|
51
|
+
# Force overwrite existing config
|
|
52
|
+
npx pds-init-config --force
|
|
53
|
+
```
|
|
54
|
+
|
|
31
55
|
### Option B: CDN (Zero Install)
|
|
32
56
|
|
|
33
57
|
Perfect for quick prototypes and learning:
|