@histoire/controls 0.8.0 → 0.8.3
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/components/select/CustomSelect.vue.d.ts +2 -2
- package/dist/components/select/HstSelect.vue.d.ts +4 -4
- package/dist/index.d.ts +8 -8
- package/dist/index.es.js +12 -8
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
- package/peeky.config.ts +0 -1
- package/src/components/select/CustomSelect.vue +12 -11
- package/src/components/select/HstSelect.vue +2 -2
- package/src/types.ts +1 -1
- package/tsconfig.json +0 -1
- package/vite.config.ts +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { HstControlOption } from '../../types';
|
|
2
2
|
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
3
3
|
modelValue: string;
|
|
4
|
-
options: Record<string,
|
|
4
|
+
options: Record<string, any> | string[] | HstControlOption[];
|
|
5
5
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
6
|
"update:modelValue": (value: string) => void;
|
|
7
7
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
8
8
|
modelValue: string;
|
|
9
|
-
options: Record<string,
|
|
9
|
+
options: Record<string, any> | string[] | HstControlOption[];
|
|
10
10
|
}>>> & {
|
|
11
11
|
"onUpdate:modelValue"?: (value: string) => any;
|
|
12
12
|
}, {}>;
|
|
@@ -2,15 +2,15 @@ import { HstControlOption } from '../../types';
|
|
|
2
2
|
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
3
3
|
title?: string;
|
|
4
4
|
modelValue: string;
|
|
5
|
-
options: Record<string,
|
|
5
|
+
options: Record<string, any> | string[] | HstControlOption[];
|
|
6
6
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
|
-
"update:modelValue": (value:
|
|
7
|
+
"update:modelValue": (value: any) => void;
|
|
8
8
|
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
9
9
|
title?: string;
|
|
10
10
|
modelValue: string;
|
|
11
|
-
options: Record<string,
|
|
11
|
+
options: Record<string, any> | string[] | HstControlOption[];
|
|
12
12
|
}>>> & {
|
|
13
|
-
"onUpdate:modelValue"?: (value:
|
|
13
|
+
"onUpdate:modelValue"?: (value: any) => any;
|
|
14
14
|
}, {}>;
|
|
15
15
|
export default _default;
|
|
16
16
|
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
package/dist/index.d.ts
CHANGED
|
@@ -128,11 +128,11 @@ export declare const HstSelect: import("vue-demi").DefineComponent<{
|
|
|
128
128
|
required: true;
|
|
129
129
|
};
|
|
130
130
|
options: {
|
|
131
|
-
type: import("vue-demi").PropType<
|
|
131
|
+
type: import("vue-demi").PropType<Record<string, any> | string[] | import("./types").HstControlOption[]>;
|
|
132
132
|
required: true;
|
|
133
133
|
};
|
|
134
134
|
}, {}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {
|
|
135
|
-
"update:modelValue": (value:
|
|
135
|
+
"update:modelValue": (value: any) => void;
|
|
136
136
|
}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
137
137
|
title: {
|
|
138
138
|
type: import("vue-demi").PropType<string>;
|
|
@@ -142,11 +142,11 @@ export declare const HstSelect: import("vue-demi").DefineComponent<{
|
|
|
142
142
|
required: true;
|
|
143
143
|
};
|
|
144
144
|
options: {
|
|
145
|
-
type: import("vue-demi").PropType<
|
|
145
|
+
type: import("vue-demi").PropType<Record<string, any> | string[] | import("./types").HstControlOption[]>;
|
|
146
146
|
required: true;
|
|
147
147
|
};
|
|
148
148
|
}>> & {
|
|
149
|
-
"onUpdate:modelValue"?: (value:
|
|
149
|
+
"onUpdate:modelValue"?: (value: any) => any;
|
|
150
150
|
}, {}>;
|
|
151
151
|
export declare const HstColorShades: import("vue-demi").DefineComponent<{
|
|
152
152
|
shades: {
|
|
@@ -393,11 +393,11 @@ export declare const components: {
|
|
|
393
393
|
required: true;
|
|
394
394
|
};
|
|
395
395
|
options: {
|
|
396
|
-
type: import("vue-demi").PropType<
|
|
396
|
+
type: import("vue-demi").PropType<Record<string, any> | string[] | import("./types").HstControlOption[]>;
|
|
397
397
|
required: true;
|
|
398
398
|
};
|
|
399
399
|
}, {}, unknown, {}, {}, import("vue-demi").ComponentOptionsMixin, import("vue-demi").ComponentOptionsMixin, {
|
|
400
|
-
"update:modelValue": (value:
|
|
400
|
+
"update:modelValue": (value: any) => void;
|
|
401
401
|
}, string, import("vue-demi").VNodeProps & import("vue-demi").AllowedComponentProps & import("vue-demi").ComponentCustomProps, Readonly<import("vue-demi").ExtractPropTypes<{
|
|
402
402
|
title: {
|
|
403
403
|
type: import("vue-demi").PropType<string>;
|
|
@@ -407,11 +407,11 @@ export declare const components: {
|
|
|
407
407
|
required: true;
|
|
408
408
|
};
|
|
409
409
|
options: {
|
|
410
|
-
type: import("vue-demi").PropType<
|
|
410
|
+
type: import("vue-demi").PropType<Record<string, any> | string[] | import("./types").HstControlOption[]>;
|
|
411
411
|
required: true;
|
|
412
412
|
};
|
|
413
413
|
}>> & {
|
|
414
|
-
"onUpdate:modelValue"?: (value:
|
|
414
|
+
"onUpdate:modelValue"?: (value: any) => any;
|
|
415
415
|
}, {}>;
|
|
416
416
|
HstColorShades: import("vue-demi").DefineComponent<{
|
|
417
417
|
shades: {
|
package/dist/index.es.js
CHANGED
|
@@ -401,17 +401,21 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
401
401
|
const props = __props;
|
|
402
402
|
const formattedOptions = computed(() => {
|
|
403
403
|
if (Array.isArray(props.options)) {
|
|
404
|
-
return
|
|
405
|
-
if (typeof
|
|
406
|
-
return [
|
|
404
|
+
return props.options.map((option) => {
|
|
405
|
+
if (typeof option === "string") {
|
|
406
|
+
return [option, option];
|
|
407
407
|
} else {
|
|
408
|
-
return [
|
|
408
|
+
return [option.value, option.label];
|
|
409
409
|
}
|
|
410
|
-
})
|
|
410
|
+
});
|
|
411
|
+
} else {
|
|
412
|
+
return Object.entries(props.options);
|
|
411
413
|
}
|
|
412
|
-
return props.options;
|
|
413
414
|
});
|
|
414
|
-
const selectedLabel = computed(() =>
|
|
415
|
+
const selectedLabel = computed(() => {
|
|
416
|
+
var _a;
|
|
417
|
+
return (_a = formattedOptions.value.find(([value]) => value === props.modelValue)) == null ? void 0 : _a[1];
|
|
418
|
+
});
|
|
415
419
|
function selectValue(value, hide) {
|
|
416
420
|
emits("update:modelValue", value);
|
|
417
421
|
hide();
|
|
@@ -420,7 +424,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
420
424
|
return openBlock(), createBlock(unref(Dropdown), { "auto-size": "" }, {
|
|
421
425
|
popper: withCtx(({ hide }) => [
|
|
422
426
|
createElementVNode("div", _hoisted_3$4, [
|
|
423
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(formattedOptions), (
|
|
427
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(formattedOptions), ([value, label]) => {
|
|
424
428
|
return openBlock(), createElementBlock("div", mergeProps(__spreadProps(__spreadValues({}, _ctx.$attrs), { class: null, style: null }), {
|
|
425
429
|
key: label,
|
|
426
430
|
class: ["htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700", {
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@histoire/controls",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Prebuilt controls components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"*.vue"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@histoire/vendors": "^0.8.
|
|
34
|
+
"@histoire/vendors": "^0.8.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@peeky/test": "^0.13.5",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"autoprefixer": "^10.4.4",
|
|
43
43
|
"concurrently": "^7.1.0",
|
|
44
44
|
"floating-vue": "^2.0.0-beta.16",
|
|
45
|
-
"histoire": "0.8.
|
|
45
|
+
"histoire": "0.8.3",
|
|
46
46
|
"postcss": "^8.4.12",
|
|
47
47
|
"postcss-import": "^14.1.0",
|
|
48
48
|
"tailwindcss": "^3.0.23",
|
package/peeky.config.ts
CHANGED
|
@@ -12,29 +12,30 @@ import { HstControlOption } from '../../types'
|
|
|
12
12
|
|
|
13
13
|
const props = defineProps<{
|
|
14
14
|
modelValue: string
|
|
15
|
-
options: Record<string,
|
|
15
|
+
options: Record<string, any> | string[] | HstControlOption[]
|
|
16
16
|
}>()
|
|
17
17
|
|
|
18
18
|
const emits = defineEmits<{
|
|
19
19
|
(e: 'update:modelValue', value: string): void
|
|
20
20
|
}>()
|
|
21
21
|
|
|
22
|
-
const formattedOptions: ComputedRef<
|
|
22
|
+
const formattedOptions: ComputedRef<[any, string][]> = computed(() => {
|
|
23
23
|
if (Array.isArray(props.options)) {
|
|
24
|
-
return
|
|
25
|
-
if (typeof
|
|
26
|
-
return [
|
|
24
|
+
return props.options.map(option => {
|
|
25
|
+
if (typeof option === 'string') {
|
|
26
|
+
return [option, option] as [string, string]
|
|
27
27
|
} else {
|
|
28
|
-
return [
|
|
28
|
+
return [option.value, option.label] as [any, string]
|
|
29
29
|
}
|
|
30
|
-
})
|
|
30
|
+
})
|
|
31
|
+
} else {
|
|
32
|
+
return Object.entries(props.options)
|
|
31
33
|
}
|
|
32
|
-
return props.options
|
|
33
34
|
})
|
|
34
35
|
|
|
35
|
-
const selectedLabel = computed(() => formattedOptions.value[props.modelValue])
|
|
36
|
+
const selectedLabel = computed(() => formattedOptions.value.find(([value]) => value === props.modelValue)?.[1])
|
|
36
37
|
|
|
37
|
-
function selectValue (value:
|
|
38
|
+
function selectValue (value: any, hide: () => void) {
|
|
38
39
|
emits('update:modelValue', value)
|
|
39
40
|
hide()
|
|
40
41
|
}
|
|
@@ -60,7 +61,7 @@ function selectValue (value: string, hide: () => void) {
|
|
|
60
61
|
<template #popper="{ hide }">
|
|
61
62
|
<div class="htw-flex htw-flex-col htw-bg-gray-50 dark:htw-bg-gray-700">
|
|
62
63
|
<div
|
|
63
|
-
v-for="
|
|
64
|
+
v-for="[value, label] of formattedOptions"
|
|
64
65
|
v-bind="{ ...$attrs, class: null, style: null }"
|
|
65
66
|
:key="label"
|
|
66
67
|
class="htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700"
|
|
@@ -12,11 +12,11 @@ import { HstControlOption } from '../../types'
|
|
|
12
12
|
defineProps<{
|
|
13
13
|
title?: string
|
|
14
14
|
modelValue: string
|
|
15
|
-
options: Record<string,
|
|
15
|
+
options: Record<string, any> | string[] | HstControlOption[]
|
|
16
16
|
}>()
|
|
17
17
|
|
|
18
18
|
const emits = defineEmits<{
|
|
19
|
-
(e: 'update:modelValue', value:
|
|
19
|
+
(e: 'update:modelValue', value: any): void
|
|
20
20
|
}>()
|
|
21
21
|
</script>
|
|
22
22
|
|
package/src/types.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"@iconify/vue": ["./node_modules/@histoire/vendors/dist/client/iconify"],
|
|
36
36
|
"pinia": ["./node_modules/@histoire/vendors/dist/client/pinia"],
|
|
37
37
|
"scroll-into-view-if-needed": ["./node_modules/@histoire/vendors/dist/client/scroll"],
|
|
38
|
-
"shiki": ["./node_modules/@histoire/vendors/dist/client/shiki"],
|
|
39
38
|
"vue-router": ["./node_modules/@histoire/vendors/dist/client/vue-router"],
|
|
40
39
|
"@vueuse/core": ["./node_modules/@histoire/vendors/dist/client/vue-use"],
|
|
41
40
|
"vue": ["./node_modules/@histoire/vendors/dist/client/vue"]
|
package/vite.config.ts
CHANGED
|
@@ -14,7 +14,6 @@ export default defineConfig({
|
|
|
14
14
|
'@iconify/vue': '@histoire/vendors/dist/client/iconify.js',
|
|
15
15
|
pinia: '@histoire/vendors/dist/client/pinia.js',
|
|
16
16
|
'scroll-into-view-if-needed': '@histoire/vendors/dist/client/scroll.js',
|
|
17
|
-
shiki: '@histoire/vendors/dist/client/shiki.js',
|
|
18
17
|
'vue-router': '@histoire/vendors/dist/client/vue-router.js',
|
|
19
18
|
'@vueuse/core': '@histoire/vendors/dist/client/vue-use.js',
|
|
20
19
|
vue: '@histoire/vendors/dist/client/vue.js',
|