sit-onyx 1.0.0-alpha.13 → 1.0.0-alpha.15
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/OnyxButton/OnyxButton.stories.d.ts +9 -0
- package/dist/components/OnyxButton/types.d.ts +4 -0
- package/dist/components/OnyxCheckbox/OnyxCheckbox.vue.d.ts +42 -0
- package/dist/components/OnyxCheckboxGroup/OnyxCheckboxGroup.stories.d.ts +111 -0
- package/dist/components/OnyxCheckboxGroup/OnyxCheckboxGroup.vue.d.ts +52 -0
- package/dist/components/OnyxCheckboxGroup/types.d.ts +38 -0
- package/dist/i18n/index.d.ts +2 -2
- package/dist/i18n/locales/en-US.json.d.ts +3 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +221 -113
- package/dist/style.css +1 -1
- package/dist/utils/plugin.d.ts +11 -0
- package/dist/utils/storybook.d.ts +20 -0
- package/package.json +7 -7
- package/src/i18n/locales/de-DE.json +3 -1
- package/src/i18n/locales/en-US.json +3 -1
- package/src/styles/index.scss +1 -0
- package/src/styles/required.scss +24 -0
|
@@ -19,6 +19,10 @@ export type ButtonProps = {
|
|
|
19
19
|
* The style of the button.
|
|
20
20
|
*/
|
|
21
21
|
mode?: ButtonMode;
|
|
22
|
+
/**
|
|
23
|
+
* An icon which will be displayed on the left side of the label.
|
|
24
|
+
*/
|
|
25
|
+
icon?: string;
|
|
22
26
|
};
|
|
23
27
|
export declare const BUTTON_TYPES: readonly ["button", "submit", "reset"];
|
|
24
28
|
export type ButtonType = (typeof BUTTON_TYPES)[number];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { OnyxCheckboxProps } from "./types";
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<OnyxCheckboxProps>, {
|
|
3
|
+
modelValue: boolean;
|
|
4
|
+
label: string;
|
|
5
|
+
indeterminate: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
required: boolean;
|
|
8
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
"update:modelValue": (value: boolean) => void;
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<OnyxCheckboxProps>, {
|
|
11
|
+
modelValue: boolean;
|
|
12
|
+
label: string;
|
|
13
|
+
indeterminate: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
required: boolean;
|
|
16
|
+
}>>> & {
|
|
17
|
+
"onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
required: boolean;
|
|
20
|
+
label: string;
|
|
21
|
+
modelValue: boolean;
|
|
22
|
+
indeterminate: boolean;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
}, {}>;
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
27
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
28
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
29
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
30
|
+
} : {
|
|
31
|
+
type: import('vue').PropType<T[K]>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
type __VLS_WithDefaults<P, D> = {
|
|
36
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
37
|
+
default: D[K];
|
|
38
|
+
}> : P[K];
|
|
39
|
+
};
|
|
40
|
+
type __VLS_Prettify<T> = {
|
|
41
|
+
[K in keyof T]: T[K];
|
|
42
|
+
} & {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/vue3";
|
|
2
|
+
import OnyxCheckboxGroup from "./OnyxCheckboxGroup.vue";
|
|
3
|
+
/**
|
|
4
|
+
* Checkboxes are a fundamental UI element, that allows users to make a binary selection.
|
|
5
|
+
* They are commonly used for tasks such as selecting multiple items, opting into services or confirming and agreeing.
|
|
6
|
+
*/
|
|
7
|
+
declare const meta: Meta<typeof OnyxCheckboxGroup>;
|
|
8
|
+
export default meta;
|
|
9
|
+
/**
|
|
10
|
+
* A checkbox group that contains a list of checkboxes.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Default: {
|
|
13
|
+
args: {
|
|
14
|
+
headline: string;
|
|
15
|
+
modelValue: string[];
|
|
16
|
+
options: ({
|
|
17
|
+
label: string;
|
|
18
|
+
id: string;
|
|
19
|
+
required?: undefined;
|
|
20
|
+
disabled?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
label: string;
|
|
23
|
+
id: string;
|
|
24
|
+
required: true;
|
|
25
|
+
disabled?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
label: string;
|
|
28
|
+
id: string;
|
|
29
|
+
disabled: true;
|
|
30
|
+
required?: undefined;
|
|
31
|
+
})[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A horizontal checkbox group.
|
|
36
|
+
*/
|
|
37
|
+
export declare const Horizontal: {
|
|
38
|
+
args: {
|
|
39
|
+
direction: "horizontal";
|
|
40
|
+
headline: string;
|
|
41
|
+
modelValue: string[];
|
|
42
|
+
options: ({
|
|
43
|
+
label: string;
|
|
44
|
+
id: string;
|
|
45
|
+
required?: undefined;
|
|
46
|
+
disabled?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
label: string;
|
|
49
|
+
id: string;
|
|
50
|
+
required: true;
|
|
51
|
+
disabled?: undefined;
|
|
52
|
+
} | {
|
|
53
|
+
label: string;
|
|
54
|
+
id: string;
|
|
55
|
+
disabled: true;
|
|
56
|
+
required?: undefined;
|
|
57
|
+
})[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* A checkbox group with the check all option to check/uncheck all options.
|
|
62
|
+
*/
|
|
63
|
+
export declare const WithCheckAll: {
|
|
64
|
+
args: {
|
|
65
|
+
withCheckAll: true;
|
|
66
|
+
headline: string;
|
|
67
|
+
modelValue: string[];
|
|
68
|
+
options: ({
|
|
69
|
+
label: string;
|
|
70
|
+
id: string;
|
|
71
|
+
required?: undefined;
|
|
72
|
+
disabled?: undefined;
|
|
73
|
+
} | {
|
|
74
|
+
label: string;
|
|
75
|
+
id: string;
|
|
76
|
+
required: true;
|
|
77
|
+
disabled?: undefined;
|
|
78
|
+
} | {
|
|
79
|
+
label: string;
|
|
80
|
+
id: string;
|
|
81
|
+
disabled: true;
|
|
82
|
+
required?: undefined;
|
|
83
|
+
})[];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* A disabled checkbox group where all checkboxes are disabled.
|
|
88
|
+
*/
|
|
89
|
+
export declare const Disabled: {
|
|
90
|
+
args: {
|
|
91
|
+
disabled: true;
|
|
92
|
+
headline: string;
|
|
93
|
+
modelValue: string[];
|
|
94
|
+
options: ({
|
|
95
|
+
label: string;
|
|
96
|
+
id: string;
|
|
97
|
+
required?: undefined;
|
|
98
|
+
disabled?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
label: string;
|
|
101
|
+
id: string;
|
|
102
|
+
required: true;
|
|
103
|
+
disabled?: undefined;
|
|
104
|
+
} | {
|
|
105
|
+
label: string;
|
|
106
|
+
id: string;
|
|
107
|
+
disabled: true;
|
|
108
|
+
required?: undefined;
|
|
109
|
+
})[];
|
|
110
|
+
};
|
|
111
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
declare const _default: <TValue extends string | number | boolean>(__VLS_props: {
|
|
2
|
+
modelValue?: TValue[] | undefined;
|
|
3
|
+
disabled?: boolean | undefined;
|
|
4
|
+
"onUpdate:modelValue"?: ((value: TValue[]) => any) | undefined;
|
|
5
|
+
options: import('../../index').CheckboxGroupOption<TValue>[];
|
|
6
|
+
headline?: string | undefined;
|
|
7
|
+
direction?: "horizontal" | "vertical" | undefined;
|
|
8
|
+
withCheckAll?: boolean | undefined;
|
|
9
|
+
checkAllLabel?: string | undefined;
|
|
10
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, __VLS_ctx?: {
|
|
11
|
+
attrs: any;
|
|
12
|
+
slots: {};
|
|
13
|
+
emit: (evt: "update:modelValue", value: TValue[]) => void;
|
|
14
|
+
} | undefined, __VLS_expose?: ((exposed: import('vue').ShallowUnwrapRef<{}>) => void) | undefined, __VLS_setup?: Promise<{
|
|
15
|
+
props: {
|
|
16
|
+
modelValue?: TValue[] | undefined;
|
|
17
|
+
disabled?: boolean | undefined;
|
|
18
|
+
"onUpdate:modelValue"?: ((value: TValue[]) => any) | undefined;
|
|
19
|
+
options: import('../../index').CheckboxGroupOption<TValue>[];
|
|
20
|
+
headline?: string | undefined;
|
|
21
|
+
direction?: "horizontal" | "vertical" | undefined;
|
|
22
|
+
withCheckAll?: boolean | undefined;
|
|
23
|
+
checkAllLabel?: string | undefined;
|
|
24
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
25
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
26
|
+
attrs: any;
|
|
27
|
+
slots: {};
|
|
28
|
+
emit: (evt: "update:modelValue", value: TValue[]) => void;
|
|
29
|
+
}>) => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}> & {
|
|
32
|
+
__ctx?: {
|
|
33
|
+
props: {
|
|
34
|
+
modelValue?: TValue[] | undefined;
|
|
35
|
+
disabled?: boolean | undefined;
|
|
36
|
+
"onUpdate:modelValue"?: ((value: TValue[]) => any) | undefined;
|
|
37
|
+
options: import('../../index').CheckboxGroupOption<TValue>[];
|
|
38
|
+
headline?: string | undefined;
|
|
39
|
+
direction?: "horizontal" | "vertical" | undefined;
|
|
40
|
+
withCheckAll?: boolean | undefined;
|
|
41
|
+
checkAllLabel?: string | undefined;
|
|
42
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
|
|
43
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
44
|
+
attrs: any;
|
|
45
|
+
slots: {};
|
|
46
|
+
emit: (evt: "update:modelValue", value: TValue[]) => void;
|
|
47
|
+
} | undefined;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
50
|
+
type __VLS_Prettify<T> = {
|
|
51
|
+
[K in keyof T]: T[K];
|
|
52
|
+
} & {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { OnyxCheckboxProps } from "../OnyxCheckbox/types";
|
|
2
|
+
export type OnyxCheckboxGroupProps<TValue extends string | number | boolean = string | number | boolean> = {
|
|
3
|
+
/**
|
|
4
|
+
* Checkbox options.
|
|
5
|
+
*/
|
|
6
|
+
options: CheckboxGroupOption<TValue>[];
|
|
7
|
+
/**
|
|
8
|
+
* Currently checked checkboxes.
|
|
9
|
+
*/
|
|
10
|
+
modelValue?: TValue[];
|
|
11
|
+
/**
|
|
12
|
+
* Headline to show above all checkboxes which is also the fieldset legend.
|
|
13
|
+
*/
|
|
14
|
+
headline?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Direction of the checkboxes.
|
|
17
|
+
*/
|
|
18
|
+
direction?: CheckboxGroupDirection;
|
|
19
|
+
/**
|
|
20
|
+
* If true, an additional checkbox will be displayed to check/uncheck all options.
|
|
21
|
+
* Disabled checkboxes will be excluded from the check/uncheck behavior.
|
|
22
|
+
*/
|
|
23
|
+
withCheckAll?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Checkbox label if property `withCheckAll` is enabled.
|
|
26
|
+
* If unset, a default label will be shown depending on the current locale/language.
|
|
27
|
+
*/
|
|
28
|
+
checkAllLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether all checkboxes should be disabled.
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export type CheckboxGroupOption<T extends string | number | boolean> = Omit<OnyxCheckboxProps, "modelValue" | "indeterminate"> & {
|
|
35
|
+
id: T;
|
|
36
|
+
};
|
|
37
|
+
export declare const CHECKBOX_GROUP_DIRECTIONS: readonly ["horizontal", "vertical"];
|
|
38
|
+
export type CheckboxGroupDirection = (typeof CHECKBOX_GROUP_DIRECTIONS)[number];
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ObjectToDottedStrings } from '../types/i18n';
|
|
2
2
|
import type { DeepPartial } from '../types/utils';
|
|
3
|
-
import { type MaybeRef } from "vue";
|
|
3
|
+
import { type MaybeRef, type App } from "vue";
|
|
4
4
|
import enUS from "./locales/en-US.json";
|
|
5
5
|
/**
|
|
6
6
|
* The type of the imported `enUS` above is a concrete type so the value type of each message
|
|
@@ -44,7 +44,7 @@ export type ProvideI18nOptions = {
|
|
|
44
44
|
* Provides a global i18n instance that is used by onyx.
|
|
45
45
|
* Must only be called once in the `App.vue` file of a project that consumes onyx.
|
|
46
46
|
*/
|
|
47
|
-
export declare const provideI18n: (
|
|
47
|
+
export declare const provideI18n: (app: App, options?: ProvideI18nOptions) => App<any>;
|
|
48
48
|
/**
|
|
49
49
|
* Injects the onyx i18n instance.
|
|
50
50
|
* Creates a fallback if provide was never called.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
"optional": "(optional)",
|
|
2
3
|
"validations": {
|
|
3
4
|
"tooShort": "Please lengthen this text to {minLength} characters or more (you are currently using 1 character) | Please lengthen this text to {minLength} characters or more (you are currently using {n} characters)",
|
|
4
5
|
"tooLong": "Please shorten this text to {maxLength} characters or less (you are currently using 1 character) | Please shorten this text to {maxLength} characters or less (you are currently using {n} characters)",
|
|
@@ -15,7 +16,8 @@ declare const _default: {
|
|
|
15
16
|
"tel": "\"{value}\" must be a valid phone number.",
|
|
16
17
|
"url": "\"{value}\" must a valid URL."
|
|
17
18
|
}
|
|
18
|
-
}
|
|
19
|
+
},
|
|
20
|
+
"selectAll": "Select all"
|
|
19
21
|
}
|
|
20
22
|
;
|
|
21
23
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),S="(optional)",T={tooShort:"Please lengthen this text to {minLength} characters or more (you are currently using 1 character) | Please lengthen this text to {minLength} characters or more (you are currently using {n} characters)",tooLong:"Please shorten this text to {maxLength} characters or less (you are currently using 1 character) | Please shorten this text to {maxLength} characters or less (you are currently using {n} characters)",rangeUnderflow:"Value must be greater than or equal to {min}",rangeOverflow:"Value must be less than or equal to {max}",patternMismatch:"Please match the format requested.",valueMissing:"Please fill in this field.",stepMismatch:"Please enter a value that is a multiple of {step}.",badInput:'"{value}" does not match the expected type.',typeMismatch:{generic:'"{value}" does not match the expected type.',email:'"{value}" must be a valid email address.',number:'"{value}" must be a number.',tel:'"{value}" must be a valid phone number.',url:'"{value}" must a valid URL.'}},N="Select all",f={optional:S,validations:T,selectAll:N},V=Symbol(),C=l=>{const n=e.computed(()=>e.unref(l==null?void 0:l.locale)??"en-US"),t=e.computed(()=>l!=null&&l.messages&&n.value in l.messages?l.messages[n.value]:f),a=e.computed(()=>(o,r={})=>{let d=b(o,t.value)??b(o,f)??"";const i=typeof r.n=="number"?r.n:void 0;return d=M(d,i),P(d,r)});return{locale:n,t:a}},I=(l,n)=>l.provide(V,C(n)),_=()=>e.inject(V,()=>C(),!0),b=(l,n)=>{const t=l.split(".").reduce((a,o)=>!a||typeof a=="string"?a:a[o],n);return t&&typeof t=="string"?t:void 0},M=(l,n)=>{const t=l.split(" | ").map(o=>o.trim());if(t.length<=1)return l;let a=1;return n===0&&(a=0),n&&(n<=0||n>1)&&(a=2),t.length===2?a===1?t[0]:t[1]:t[a]},P=(l,n)=>n?Object.entries(n).reduce((a,[o,r])=>r===void 0?a:a.replace(new RegExp(`{${o}}`,"gi"),r.toString()),l).replace(/\s?{.*}\s?/gi,""):l,$={class:"onyx-checkbox__container"},L=["indeterminate","disabled","required"],U={key:0,class:"onyx-checkbox__label"},k=e.defineComponent({__name:"OnyxCheckbox",props:{modelValue:{type:Boolean,default:!1},label:{default:""},indeterminate:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(l,{emit:n}){const t=l,a=n,o=e.computed({get:()=>t.modelValue,set:d=>a("update:modelValue",d)}),r=e.ref(!1);return(d,i)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["onyx-checkbox",{"onyx-required-marker":t.required,"onyx-optional-marker":!t.required}])},[e.createElementVNode("div",$,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":i[0]||(i[0]=c=>o.value=c),class:e.normalizeClass(["onyx-checkbox__input",{"onyx-checkbox__input--touched":r.value}]),type:"checkbox",indeterminate:t.indeterminate,disabled:t.disabled,required:t.required,onBlur:i[1]||(i[1]=c=>r.value=!0)},null,42,L),[[e.vModelCheckbox,o.value]])]),t.label?(e.openBlock(),e.createElementBlock("p",U,e.toDisplayString(t.label),1)):e.createCommentVNode("",!0)],2))}}),D=["disabled"],z={key:0,class:"onyx-checkbox-group__label"},w=e.defineComponent({__name:"OnyxCheckboxGroup",props:{options:{},modelValue:{default:()=>[]},headline:{},direction:{default:"vertical"},withCheckAll:{type:Boolean,default:!1},checkAllLabel:{},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(l,{emit:n}){const t=l,a=n,{t:o}=_(),r=(s,p)=>{const u=p?[...t.modelValue,s]:t.modelValue.filter(y=>y!==s);a("update:modelValue",u)},d=e.computed(()=>t.options.filter(s=>!s.disabled)),i=s=>{const p=s?d.value.map(({id:u})=>u):[];a("update:modelValue",p)},c=e.computed(()=>{const s=d.value.map(({id:u})=>u),p=t.modelValue.filter(u=>s.includes(u));return!s.length||!p.length?{modelValue:!1}:p.length===s.length?{modelValue:!0}:{indeterminate:!0,modelValue:!1}});return(s,p)=>(e.openBlock(),e.createElementBlock("fieldset",{class:"onyx-checkbox-group",disabled:t.disabled},[t.headline?(e.openBlock(),e.createElementBlock("legend",z,[e.createVNode(e.unref(O),{is:"h3"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.headline),1)]),_:1})])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["onyx-checkbox-group__content",{"onyx-checkbox-group__content--horizontal":t.direction==="horizontal"}])},[t.withCheckAll?(e.openBlock(),e.createBlock(k,e.mergeProps({key:0},c.value,{label:t.checkAllLabel||e.unref(o)("selectAll"),"onUpdate:modelValue":i}),null,16,["label"])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,u=>(e.openBlock(),e.createBlock(k,e.mergeProps({key:u.id.toString()},u,{"model-value":t.modelValue.includes(u.id),"onUpdate:modelValue":y=>r(u.id,y)}),null,16,["model-value","onUpdate:modelValue"]))),128))],2)],8,D))}}),q=["horizontal","vertical"],O=e.defineComponent({__name:"OnyxHeadline",props:{is:{},monospace:{type:Boolean,default:!1}},setup(l){const n=l;return(t,a)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.is),{class:e.normalizeClass(["onyx-headline",`onyx-headline--${n.is}`,n.monospace?"onyx-headline--monospace":""])},{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},8,["class"]))}}),A=["disabled"],R={class:"onyx-button__label"},H=e.defineComponent({__name:"OnyxButton",props:{label:{default:""},disabled:{type:Boolean,default:!1},type:{default:"button"},variation:{default:"primary"},mode:{default:"default"},icon:{}},setup(l){const n=l;return(t,a)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["onyx-button",[`onyx-button--${n.variation}`,`onyx-button--${n.mode}`]]),disabled:n.disabled},[n.icon?(e.openBlock(),e.createBlock(e.unref(B),{key:0,icon:n.icon,size:"24px"},null,8,["icon"])):e.createCommentVNode("",!0),e.createElementVNode("span",R,e.toDisplayString(n.label),1)],10,A))}}),Y=["h1","h2","h3","h4","h5","h6"],j=["button","submit","reset"],G=["primary","secondary","danger"],X=["default","outline","plain"],F=["innerHTML"],B=e.defineComponent({__name:"OnyxIcon",props:{icon:{},size:{default:"24px"},color:{default:"currentColor"}},setup(l){const n=l;return(t,a)=>(e.openBlock(),e.createElementBlock("figure",{class:e.normalizeClass(["onyx-icon",[n.size!=="24px"?`onyx-icon--${n.size}`:"",n.color!=="currentColor"?`onyx-icon--${n.color}`:""]]),"aria-hidden":"true",innerHTML:n.icon},null,10,F))}}),K=["12px","16px","24px","32px","48px","64px","96px"],E=()=>Object.entries(Object.getOwnPropertyDescriptors(ValidityState.prototype)).filter(([l,n])=>n.enumerable).map(([l])=>l),Z=l=>E().reduce((n,t)=>(n[t]=l[t],n),{}),J=l=>{if(l.valueMissing)return"valueMissing";const n=E().filter(t=>t!=="valid").sort();for(const t of n)if(t in l&&l[t])return t},W=(l,n)=>{const t=Object.entries(l).filter(([o,r])=>r!==void 0),a=Object.entries(n).filter(([o,r])=>r!==void 0);return t.length!==a.length?!1:t.every(([o,r])=>r===n[o])},Q={key:0,class:"onyx-input__error","aria-live":"polite"},ee={class:"onyx-input__info"},te=Object.keys(f.validations.typeMismatch),ne=e.defineComponent({__name:"TestInput",props:{modelValue:{default:""},label:{default:""},errorMessage:{},required:{type:Boolean},pattern:{},type:{default:"text"},max:{},maxLength:{},min:{},step:{},minLength:{}},emits:["update:modelValue","change","validityChange"],setup(l,{emit:n}){var y;const t=l,a=n,{t:o}=_(),{errorMessage:r}=e.toRefs(t),d=e.ref(!1),i=e.ref(null),c=e.ref((y=i.value)==null?void 0:y.validity),s=e.computed({get:()=>t.modelValue,set:m=>a("update:modelValue",m)}),p=e.computed(()=>{if(!c.value||c.value.valid)return"";const m=J(c.value);if(t.errorMessage||m==="customError")return t.errorMessage;if(!m)return"";if(m==="typeMismatch"){const h=te.includes(t.type)?t.type:"generic";return o.value(`validations.typeMismatch.${h}`,{value:s.value})}return o.value(`validations.${m}`,{value:s.value,n:s.value.toString().length,minLength:t.minLength,maxLength:t.maxLength,min:t.min,max:t.max,step:t.step})}),u=m=>{const h=m.target;a("change",h.value)};return e.watch([i,r],()=>{i.value&&i.value.setCustomValidity(t.errorMessage||"")}),e.watch([i,s,r],()=>{if(!i.value)return;const m=Z(i.value.validity);(!c.value||!W(m,c.value))&&(c.value=m,a("validityChange",c.value))},{immediate:!0}),(m,h)=>{var v,x;return e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["onyx-input",{"onyx-input--touched":d.value}])},[e.createElementVNode("span",{class:e.normalizeClass(["onyx-input__label",{"onyx-input__label--required":t.required}])},e.toDisplayString(t.label),3),e.withDirectives(e.createElementVNode("input",e.mergeProps(t,{ref_key:"inputElement",ref:i,"onUpdate:modelValue":h[0]||(h[0]=g=>s.value=g),onChange:u,onBlur:h[1]||(h[1]=g=>d.value=!0)}),null,16),[[e.vModelDynamic,s.value]]),d.value&&!((v=c.value)!=null&&v.valid)?(e.openBlock(),e.createElementBlock("p",Q,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0),e.createElementVNode("p",ee,'Model value: "'+e.toDisplayString(s.value)+'", is valid: '+e.toDisplayString((x=c.value)==null?void 0:x.valid),1)],2)}}}),le=["primary","secondary","neutral","danger","warning","success","info"],ae=l=>({install:n=>{I(n,l.i18n);const t=n.runWithContext(()=>_());e.watchEffect(()=>oe(t.t.value("optional")))}}),oe=l=>globalThis.document.body.style.setProperty("--onyx-global-optional-text",l);exports.BUTTON_MODES=X;exports.BUTTON_TYPES=j;exports.BUTTON_VARIATIONS=G;exports.CHECKBOX_GROUP_DIRECTIONS=q;exports.HEADLINE_TYPES=Y;exports.ICON_SIZES=K;exports.ONYX_COLORS=le;exports.OnyxButton=H;exports.OnyxCheckboxGroup=w;exports.OnyxHeadline=O;exports.OnyxIcon=B;exports.TestInput=ne;exports.createOnyx=ae;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from './components/OnyxCheckbox/types';
|
|
2
|
+
export { default as OnyxCheckboxGroup } from './components/OnyxCheckboxGroup/OnyxCheckboxGroup.vue';
|
|
3
|
+
export * from './components/OnyxCheckboxGroup/types';
|
|
2
4
|
export { default as OnyxHeadline } from './components/OnyxHeadline/OnyxHeadline.vue';
|
|
3
5
|
export { default as OnyxButton } from './components/OnyxButton/OnyxButton.vue';
|
|
4
6
|
export * from './components/OnyxHeadline/types';
|
|
@@ -9,4 +11,5 @@ export { default as TestInput } from './components/TestInput/TestInput.vue';
|
|
|
9
11
|
export * from './types/colors';
|
|
10
12
|
export * from './types/i18n';
|
|
11
13
|
export * from './types/utils';
|
|
12
|
-
export {
|
|
14
|
+
export { type OnyxTranslations } from './i18n';
|
|
15
|
+
export { createOnyx } from './utils/plugin';
|