feather-k-demo-utils 0.1.0 → 0.1.2
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/DEMO-UTILS.md +11 -3
- package/README.md +7 -0
- package/lib/{DemoSelection.vue_vue_type_script_setup_true_lang-DaLhEeza.js → DemoSelection.vue_vue_type_script_setup_true_lang-DIdktGNu.js} +558 -494
- package/lib/components/DemoSelection.vue.d.ts +7 -5
- package/lib/components/demoSelectionQueryParam.d.ts +6 -0
- package/lib/components/index.es.js +1 -1
- package/lib/index.es.js +1 -1
- package/lib/utils/index.es.js +1 -1
- package/package.json +1 -1
package/DEMO-UTILS.md
CHANGED
|
@@ -227,7 +227,9 @@ This ensures demo-utils styles and features work as intended and matches the fea
|
|
|
227
227
|
|
|
228
228
|
# Multi-Demo Navigation with DemoSelection
|
|
229
229
|
|
|
230
|
-
For projects with multiple demos, use the `DemoSelection` component
|
|
230
|
+
For projects with multiple demos, use the `DemoSelection` component from `feather-k-demo-utils` to provide a consistent, accessible demo picker and slot-based rendering for your demo components.
|
|
231
|
+
|
|
232
|
+
**Important:** Always import `DemoSelection` from `feather-k-demo-utils`. Do not use a local `DemoSelection.vue` file. The package provides the official, up-to-date version.
|
|
231
233
|
|
|
232
234
|
## DemoSelection Component
|
|
233
235
|
|
|
@@ -236,6 +238,8 @@ For projects with multiple demos, use the `DemoSelection` component (available l
|
|
|
236
238
|
### Props
|
|
237
239
|
- `options: Array<{ text: string; value: string }>` — List of demo options to display in the DropDownList.
|
|
238
240
|
- `modelValue: string` — The currently selected demo value (for v-model binding).
|
|
241
|
+
- `syncQueryParam?: boolean` — Optional. Defaults to `true`. Syncs the selected demo to a query parameter and initializes from it.
|
|
242
|
+
- `queryParamName?: string` — Optional. Defaults to `"demo"`. Query parameter key used when `syncQueryParam` is enabled.
|
|
239
243
|
|
|
240
244
|
### Emits
|
|
241
245
|
- `update:modelValue` — Emitted when the user selects a new demo.
|
|
@@ -246,10 +250,11 @@ For projects with multiple demos, use the `DemoSelection` component (available l
|
|
|
246
250
|
|
|
247
251
|
### Example Usage
|
|
248
252
|
|
|
253
|
+
|
|
249
254
|
```vue
|
|
250
255
|
<script setup lang="ts">
|
|
251
256
|
import { ref } from "vue";
|
|
252
|
-
import DemoSelection from "
|
|
257
|
+
import { DemoSelection } from "feather-k-demo-utils";
|
|
253
258
|
import BasicGrid from "./basic/BasicGrid.vue";
|
|
254
259
|
import DetailsGrid from "./details/DetailsGrid.vue";
|
|
255
260
|
// ...other imports
|
|
@@ -277,11 +282,14 @@ const selectedDemo = ref("Basic");
|
|
|
277
282
|
- The DropDownList is only rendered if slot content is provided.
|
|
278
283
|
- The selected value is always kept in sync with the parent via v-model.
|
|
279
284
|
- The slot prop `selected` is the current value, so you can use it for conditional rendering.
|
|
285
|
+
- By default, the component reads `?demo=<value>` on load and uses it when the value exists in `options`.
|
|
286
|
+
- Query matching is case-insensitive, so values like `?demo=basic`, `?demo=Basic`, and `?demo=BASIC` resolve to the same option.
|
|
287
|
+
- When the selection changes, the component updates the query parameter with `history.replaceState` (no page reload).
|
|
280
288
|
|
|
281
289
|
### Benefits
|
|
282
290
|
- Consistent demo navigation UI across projects.
|
|
283
291
|
- Keeps demo selection logic and rendering decoupled and reusable.
|
|
284
|
-
-
|
|
292
|
+
- No need to maintain a local DemoSelection.vue; always use the package version for updates and bugfixes.
|
|
285
293
|
|
|
286
294
|
# Multi-Demo Navigation with DropDownList
|
|
287
295
|
|
package/README.md
CHANGED
|
@@ -77,6 +77,13 @@ const demoOptions = [
|
|
|
77
77
|
];
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
By default, `DemoSelection` also keeps the selected demo in the URL query string using `demo` (for example, `?demo=demo2`), and initializes selection from that query value when valid. Query matching is case-insensitive, so `?demo=DEMO2` and `?demo=demo2` both resolve.
|
|
81
|
+
|
|
82
|
+
Optional props:
|
|
83
|
+
|
|
84
|
+
- `syncQueryParam?: boolean` (default `true`) - Enable/disable URL query synchronization.
|
|
85
|
+
- `queryParamName?: string` (default `"demo"`) - Change the query key used for sync.
|
|
86
|
+
|
|
80
87
|
### DemoDebug
|
|
81
88
|
|
|
82
89
|
Collapsible debug panel. Slot content is only shown if provided.
|