sit-onyx 0.1.0-alpha.5 → 0.1.0-alpha.7
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/GridPlayground/GridPlayground.stories.d.ts +13 -0
- package/dist/components/OnyxIcon/OnyxIcon.stories.d.ts +37 -0
- package/dist/components/OnyxIcon/OnyxIcon.vue.d.ts +29 -0
- package/dist/components/OnyxIcon/types.d.ts +14 -0
- package/dist/components/OnyxRadioButton/OnyxRadioButton.stories.d.ts +18 -0
- package/dist/components/OnyxRadioButton/types.d.ts +18 -0
- package/dist/components/OnyxRadioButtonGroup/OnyxRadioButtonGroup.stories.d.ts +27 -0
- package/dist/components/TestInput/TestInput.vue.d.ts +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +93 -69
- package/dist/style.css +1 -1
- package/dist/types/colors.d.ts +2 -0
- package/dist/types/dom.d.ts +10 -0
- package/package.json +10 -8
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/vue3";
|
|
2
|
+
import Grid from "./GridPlayground.vue";
|
|
3
|
+
/**
|
|
4
|
+
* The GridPlayground allows to test and play around with the Onyx grid system
|
|
5
|
+
*/
|
|
6
|
+
declare const meta: Meta<typeof Grid>;
|
|
7
|
+
export default meta;
|
|
8
|
+
/**
|
|
9
|
+
* Please open in Fullscreen mode for playground to behave correctly!
|
|
10
|
+
*/
|
|
11
|
+
export declare const Default: {
|
|
12
|
+
args: {};
|
|
13
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/vue3";
|
|
2
|
+
import OnyxIcon from "./OnyxIcon.vue";
|
|
3
|
+
/**
|
|
4
|
+
* Component to display icons. Supports all inline SVG icon libraries.
|
|
5
|
+
* We recommend using the official icons from `@sit-onyx/icons`.
|
|
6
|
+
*
|
|
7
|
+
* When importing SVG icon files, make sure to add `?raw` after the file name as shown in the examples to import the SVG content
|
|
8
|
+
* instead of the file system path to the file.
|
|
9
|
+
*/
|
|
10
|
+
declare const meta: Meta<typeof OnyxIcon>;
|
|
11
|
+
export default meta;
|
|
12
|
+
/**
|
|
13
|
+
* This example shows a default icon.
|
|
14
|
+
*/
|
|
15
|
+
export declare const Default: {
|
|
16
|
+
args: {
|
|
17
|
+
icon: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* This example shows an icon with a different size.
|
|
22
|
+
*/
|
|
23
|
+
export declare const WithSize: {
|
|
24
|
+
args: {
|
|
25
|
+
size: "2xl";
|
|
26
|
+
icon: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* This example shows an icon with a different color.
|
|
31
|
+
*/
|
|
32
|
+
export declare const WithColor: {
|
|
33
|
+
args: {
|
|
34
|
+
color: "success";
|
|
35
|
+
icon: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OnyxIconProps } from "./types";
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<OnyxIconProps>, {
|
|
3
|
+
size: string;
|
|
4
|
+
color: string;
|
|
5
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<OnyxIconProps>, {
|
|
6
|
+
size: string;
|
|
7
|
+
color: string;
|
|
8
|
+
}>>>, {
|
|
9
|
+
color: "primary" | "secondary" | "neutral" | "danger" | "warning" | "success" | "info" | "currentColor";
|
|
10
|
+
size: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
11
|
+
}, {}>;
|
|
12
|
+
export default _default;
|
|
13
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
14
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
15
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
16
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
17
|
+
} : {
|
|
18
|
+
type: import('vue').PropType<T[K]>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type __VLS_WithDefaults<P, D> = {
|
|
23
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
24
|
+
default: D[K];
|
|
25
|
+
}> : P[K];
|
|
26
|
+
};
|
|
27
|
+
type __VLS_Prettify<T> = {
|
|
28
|
+
[K in keyof T]: T[K];
|
|
29
|
+
} & {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { OnyxColor } from '../../index';
|
|
2
|
+
export type OnyxIconProps = {
|
|
3
|
+
/**
|
|
4
|
+
* SVG source of the icon. **Important**: Only provide trustworthy content, the SVG content will
|
|
5
|
+
* not be sanitized.
|
|
6
|
+
*/
|
|
7
|
+
icon: string;
|
|
8
|
+
/** Icon size. */
|
|
9
|
+
size?: IconSize;
|
|
10
|
+
/** Icon color. */
|
|
11
|
+
color?: OnyxColor | "currentColor";
|
|
12
|
+
};
|
|
13
|
+
export declare const ICON_SIZES: readonly ["2xs", "xs", "sm", "md", "lg", "xl", "2xl"];
|
|
14
|
+
export type IconSize = (typeof ICON_SIZES)[number];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/vue3";
|
|
2
|
+
import OnyxRadioButton from "./OnyxRadioButton.vue";
|
|
3
|
+
/**
|
|
4
|
+
* The input component can be used to...
|
|
5
|
+
*/
|
|
6
|
+
declare const meta: Meta<typeof OnyxRadioButton>;
|
|
7
|
+
export default meta;
|
|
8
|
+
/**
|
|
9
|
+
* This example shows a standalone radio button.
|
|
10
|
+
*/
|
|
11
|
+
export declare const Default: {
|
|
12
|
+
args: {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TODO: move to dedicated file
|
|
3
|
+
*/
|
|
4
|
+
export type SelectionOption<T> = {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* An optional value.
|
|
9
|
+
* It's not actually used by the selection controls, but can be used to associate data with this option.
|
|
10
|
+
*/
|
|
11
|
+
value?: T;
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
isReadonly?: boolean;
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type SelectionProps<T> = SelectionOption<T> & {
|
|
17
|
+
selected?: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Meta } from "@storybook/vue3";
|
|
2
|
+
import OnyxRadioButtonGroup from "./OnyxRadioButtonGroup.vue";
|
|
3
|
+
import type { SelectionOption } from "../OnyxRadioButton/types";
|
|
4
|
+
/**
|
|
5
|
+
* The input component can be used to...
|
|
6
|
+
*/
|
|
7
|
+
declare const meta: Meta<typeof OnyxRadioButtonGroup>;
|
|
8
|
+
export default meta;
|
|
9
|
+
/**
|
|
10
|
+
* This example shows a radio button group.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Default: {
|
|
13
|
+
args: {
|
|
14
|
+
name: string;
|
|
15
|
+
options: SelectionOption<string>[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* This example shows a preselected radio button.
|
|
20
|
+
*/
|
|
21
|
+
export declare const Preselected: {
|
|
22
|
+
args: {
|
|
23
|
+
name: string;
|
|
24
|
+
options: SelectionOption<string>[];
|
|
25
|
+
modelValue: SelectionOption<string>;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -52,13 +52,13 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
52
52
|
label: string;
|
|
53
53
|
type: string;
|
|
54
54
|
}>>> & {
|
|
55
|
-
"onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
|
|
56
55
|
onChange?: ((value: string) => any) | undefined;
|
|
56
|
+
"onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
|
|
57
57
|
onValidityChange?: ((state: ValidityState) => any) | undefined;
|
|
58
58
|
}, {
|
|
59
|
-
type: "number" | "
|
|
60
|
-
modelValue: string | number;
|
|
59
|
+
type: "number" | "text" | "email" | "password" | "search" | "tel" | "url";
|
|
61
60
|
label: string;
|
|
61
|
+
modelValue: string | number;
|
|
62
62
|
}, {}>;
|
|
63
63
|
export default _default;
|
|
64
64
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),O=t.defineComponent({__name:"OnyxHeadline",props:{is:{},monospace:{type:Boolean,default:!1}},setup(n){const r=n;return(e,a)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(r.is),{class:t.normalizeClass(["onyx-headline",`onyx-headline--${r.is}`,r.monospace?"onyx-headline--monospace":""])},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},8,["class"]))}}),M=["h1","h2","h3","h4","h5","h6"],C=["innerHTML"],I=t.defineComponent({__name:"OnyxIcon",props:{icon:{},size:{default:"sm"},color:{default:"currentColor"}},setup(n){const r=n;return(e,a)=>(t.openBlock(),t.createElementBlock("figure",{class:t.normalizeClass(["onyx-icon",[r.size!=="sm"?`onyx-icon--${r.size}`:"",r.color!=="currentColor"?`onyx-icon--${r.color}`:""]]),"aria-hidden":"true",innerHTML:r.icon},null,10,C))}}),L=["2xs","xs","sm","md","lg","xl","2xl"],V={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.'}},p={validations:V},_=Symbol(),x=n=>{const r=t.computed(()=>t.unref(n==null?void 0:n.locale)??"en-US"),e=t.computed(()=>n!=null&&n.messages&&r.value in n.messages?n.messages[r.value]:p),a=t.computed(()=>(s,l={})=>{let m=f(s,e.value)??f(s,p)??"";const i=typeof l.n=="number"?l.n:void 0;return m=N(m,i),B(m,l)});return{locale:r,t:a}},P=n=>{t.provide(_,x(n))},T=()=>t.inject(_,()=>x(),!0),f=(n,r)=>{const e=n.split(".").reduce((a,s)=>!a||typeof a=="string"?a:a[s],r);return e&&typeof e=="string"?e:void 0},N=(n,r)=>{const e=n.split(" | ").map(s=>s.trim());if(e.length<=1)return n;let a=1;return r===0&&(a=0),r&&(r<=0||r>1)&&(a=2),e.length===2?a===1?e[0]:e[1]:e[a]},B=(n,r)=>r?Object.entries(r).reduce((a,[s,l])=>l===void 0?a:a.replace(new RegExp(`{${s}}`,"gi"),l.toString()),n).replace(/\s?{.*}\s?/gi,""):n,S=()=>Object.entries(Object.getOwnPropertyDescriptors(ValidityState.prototype)).filter(([n,r])=>r.enumerable).map(([n])=>n),D=n=>S().reduce((r,e)=>(r[e]=n[e],r),{}),$=n=>{if(n.valueMissing)return"valueMissing";const r=S().filter(e=>e!=="valid").sort();for(const e of r)if(e in n&&n[e])return e},w=(n,r)=>{const e=Object.entries(n).filter(([s,l])=>l!==void 0),a=Object.entries(r).filter(([s,l])=>l!==void 0);return e.length!==a.length?!1:e.every(([s,l])=>l===r[s])},z={key:0,class:"onyx-input__error","aria-live":"polite"},k={class:"onyx-input__info"},q=Object.keys(p.validations.typeMismatch),U=t.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(n,{emit:r}){var v;const e=n,a=r,{t:s}=T(),{errorMessage:l}=t.toRefs(e),m=t.ref(!1),i=t.ref(null),u=t.ref((v=i.value)==null?void 0:v.validity),d=t.computed({get:()=>e.modelValue,set:o=>a("update:modelValue",o)}),E=t.computed(()=>{if(!u.value||u.value.valid)return"";const o=$(u.value);if(e.errorMessage||o==="customError")return e.errorMessage;if(!o)return"";if(o==="typeMismatch"){const c=q.includes(e.type)?e.type:"generic";return s.value(`validations.typeMismatch.${c}`,{value:d.value})}return s.value(`validations.${o}`,{value:d.value,n:d.value.toString().length,minLength:e.minLength,maxLength:e.maxLength,min:e.min,max:e.max,step:e.step})}),b=o=>{const c=o.target;a("change",c.value)};return t.watch([i,l],()=>{i.value&&i.value.setCustomValidity(e.errorMessage||"")}),t.watch([i,d,l],()=>{if(!i.value)return;const o=D(i.value.validity);(!u.value||!w(o,u.value))&&(u.value=o,a("validityChange",u.value))},{immediate:!0}),(o,c)=>{var g,h;return t.openBlock(),t.createElementBlock("label",{class:t.normalizeClass(["onyx-input",{"onyx-input--touched":m.value}])},[t.createElementVNode("span",{class:t.normalizeClass(["onyx-input__label",{"onyx-input__label--required":e.required}])},t.toDisplayString(e.label),3),t.withDirectives(t.createElementVNode("input",t.mergeProps(e,{ref_key:"inputElement",ref:i,"onUpdate:modelValue":c[0]||(c[0]=y=>d.value=y),onChange:b,onBlur:c[1]||(c[1]=y=>m.value=!0)}),null,16),[[t.vModelDynamic,d.value]]),m.value&&!((g=u.value)!=null&&g.valid)?(t.openBlock(),t.createElementBlock("p",z,t.toDisplayString(E.value),1)):t.createCommentVNode("",!0),t.createElementVNode("p",k,'Model value: "'+t.toDisplayString(d.value)+'", is valid: '+t.toDisplayString((h=u.value)==null?void 0:h.valid),1)],2)}}}),j=["primary","secondary","neutral","danger","warning","success","info"];exports.HEADLINE_TYPES=M;exports.ICON_SIZES=L;exports.ONYX_COLORS=j;exports.OnyxHeadline=O;exports.OnyxIcon=I;exports.TestInput=U;exports.provideI18n=P;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { default as OnyxHeadline } from './components/OnyxHeadline/OnyxHeadline.vue';
|
|
2
2
|
export * from './components/OnyxHeadline/types';
|
|
3
|
+
export { default as OnyxIcon } from './components/OnyxIcon/OnyxIcon.vue';
|
|
4
|
+
export * from './components/OnyxIcon/types';
|
|
3
5
|
export { default as TestInput } from './components/TestInput/TestInput.vue';
|
|
6
|
+
export * from './types/colors';
|
|
4
7
|
export * from './types/i18n';
|
|
5
8
|
export * from './types/utils';
|
|
6
9
|
export { provideI18n, type OnyxTranslations, type ProvideI18nOptions } from './i18n';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as _, openBlock as v, createBlock as $, resolveDynamicComponent as N, normalizeClass as h, withCtx as w, renderSlot as U, createElementBlock as y, provide as q, inject as z, computed as d, unref as D, toRefs as j, ref as g, watch as S, createElementVNode as f, toDisplayString as p, withDirectives as B, mergeProps as H, vModelDynamic as R, createCommentVNode as k } from "vue";
|
|
2
|
+
const ne = /* @__PURE__ */ _({
|
|
3
3
|
__name: "OnyxHeadline",
|
|
4
4
|
props: {
|
|
5
5
|
is: {},
|
|
@@ -7,20 +7,38 @@ const ae = /* @__PURE__ */ S({
|
|
|
7
7
|
},
|
|
8
8
|
setup(t) {
|
|
9
9
|
const n = t;
|
|
10
|
-
return (e,
|
|
11
|
-
class:
|
|
10
|
+
return (e, r) => (v(), $(N(n.is), {
|
|
11
|
+
class: h([
|
|
12
12
|
"onyx-headline",
|
|
13
13
|
`onyx-headline--${n.is}`,
|
|
14
14
|
n.monospace ? "onyx-headline--monospace" : ""
|
|
15
15
|
])
|
|
16
16
|
}, {
|
|
17
|
-
default:
|
|
18
|
-
|
|
17
|
+
default: w(() => [
|
|
18
|
+
U(e.$slots, "default")
|
|
19
19
|
]),
|
|
20
20
|
_: 3
|
|
21
21
|
}, 8, ["class"]));
|
|
22
22
|
}
|
|
23
|
-
}), re = ["h1", "h2", "h3", "h4", "h5", "h6"],
|
|
23
|
+
}), re = ["h1", "h2", "h3", "h4", "h5", "h6"], Y = ["innerHTML"], ae = /* @__PURE__ */ _({
|
|
24
|
+
__name: "OnyxIcon",
|
|
25
|
+
props: {
|
|
26
|
+
icon: {},
|
|
27
|
+
size: { default: "sm" },
|
|
28
|
+
color: { default: "currentColor" }
|
|
29
|
+
},
|
|
30
|
+
setup(t) {
|
|
31
|
+
const n = t;
|
|
32
|
+
return (e, r) => (v(), y("figure", {
|
|
33
|
+
class: h(["onyx-icon", [
|
|
34
|
+
n.size !== "sm" ? `onyx-icon--${n.size}` : "",
|
|
35
|
+
n.color !== "currentColor" ? `onyx-icon--${n.color}` : ""
|
|
36
|
+
]]),
|
|
37
|
+
"aria-hidden": "true",
|
|
38
|
+
innerHTML: n.icon
|
|
39
|
+
}, null, 10, Y));
|
|
40
|
+
}
|
|
41
|
+
}), se = ["2xs", "xs", "sm", "md", "lg", "xl", "2xl"], A = {
|
|
24
42
|
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)",
|
|
25
43
|
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)",
|
|
26
44
|
rangeUnderflow: "Value must be greater than or equal to {min}",
|
|
@@ -36,46 +54,46 @@ const ae = /* @__PURE__ */ S({
|
|
|
36
54
|
tel: '"{value}" must be a valid phone number.',
|
|
37
55
|
url: '"{value}" must a valid URL.'
|
|
38
56
|
}
|
|
39
|
-
},
|
|
40
|
-
validations:
|
|
41
|
-
},
|
|
42
|
-
const n = d(() =>
|
|
43
|
-
let c =
|
|
44
|
-
const
|
|
45
|
-
return c =
|
|
57
|
+
}, x = {
|
|
58
|
+
validations: A
|
|
59
|
+
}, I = Symbol(), V = (t) => {
|
|
60
|
+
const n = d(() => D(t == null ? void 0 : t.locale) ?? "en-US"), e = d(() => t != null && t.messages && n.value in t.messages ? t.messages[n.value] : x), r = d(() => (a, s = {}) => {
|
|
61
|
+
let c = L(a, e.value) ?? L(a, x) ?? "";
|
|
62
|
+
const o = typeof s.n == "number" ? s.n : void 0;
|
|
63
|
+
return c = J(c, o), K(c, s);
|
|
46
64
|
});
|
|
47
|
-
return { locale: n, t:
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
const e = t.split(".").reduce((
|
|
65
|
+
return { locale: n, t: r };
|
|
66
|
+
}, le = (t) => {
|
|
67
|
+
q(I, V(t));
|
|
68
|
+
}, F = () => z(I, () => V(), !0), L = (t, n) => {
|
|
69
|
+
const e = t.split(".").reduce((r, a) => !r || typeof r == "string" ? r : r[a], n);
|
|
52
70
|
return e && typeof e == "string" ? e : void 0;
|
|
53
|
-
},
|
|
54
|
-
const e = t.split(" | ").map((
|
|
71
|
+
}, J = (t, n) => {
|
|
72
|
+
const e = t.split(" | ").map((a) => a.trim());
|
|
55
73
|
if (e.length <= 1)
|
|
56
74
|
return t;
|
|
57
|
-
let
|
|
58
|
-
return n === 0 && (
|
|
59
|
-
},
|
|
75
|
+
let r = 1;
|
|
76
|
+
return n === 0 && (r = 0), n && (n <= 0 || n > 1) && (r = 2), e.length === 2 ? r === 1 ? e[0] : e[1] : e[r];
|
|
77
|
+
}, K = (t, n) => n ? Object.entries(n).reduce((r, [a, s]) => s === void 0 ? r : r.replace(new RegExp(`{${a}}`, "gi"), s.toString()), t).replace(/\s?{.*}\s?/gi, "") : t, P = () => Object.entries(Object.getOwnPropertyDescriptors(ValidityState.prototype)).filter(([t, n]) => n.enumerable).map(([t]) => t), X = (t) => P().reduce(
|
|
60
78
|
(n, e) => (n[e] = t[e], n),
|
|
61
79
|
{}
|
|
62
|
-
),
|
|
80
|
+
), Z = (t) => {
|
|
63
81
|
if (t.valueMissing)
|
|
64
82
|
return "valueMissing";
|
|
65
|
-
const n =
|
|
83
|
+
const n = P().filter((e) => e !== "valid").sort();
|
|
66
84
|
for (const e of n)
|
|
67
85
|
if (e in t && t[e])
|
|
68
86
|
return e;
|
|
69
|
-
},
|
|
70
|
-
const e = Object.entries(t).filter(([
|
|
71
|
-
return e.length !==
|
|
72
|
-
},
|
|
87
|
+
}, G = (t, n) => {
|
|
88
|
+
const e = Object.entries(t).filter(([a, s]) => s !== void 0), r = Object.entries(n).filter(([a, s]) => s !== void 0);
|
|
89
|
+
return e.length !== r.length ? !1 : e.every(([a, s]) => s === n[a]);
|
|
90
|
+
}, Q = {
|
|
73
91
|
key: 0,
|
|
74
92
|
class: "onyx-input__error",
|
|
75
93
|
"aria-live": "polite"
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
),
|
|
94
|
+
}, W = { class: "onyx-input__info" }, ee = Object.keys(
|
|
95
|
+
x.validations.typeMismatch
|
|
96
|
+
), oe = /* @__PURE__ */ _({
|
|
79
97
|
__name: "TestInput",
|
|
80
98
|
props: {
|
|
81
99
|
modelValue: { default: "" },
|
|
@@ -92,23 +110,23 @@ const ae = /* @__PURE__ */ S({
|
|
|
92
110
|
},
|
|
93
111
|
emits: ["update:modelValue", "change", "validityChange"],
|
|
94
112
|
setup(t, { emit: n }) {
|
|
95
|
-
var
|
|
96
|
-
const e = t,
|
|
113
|
+
var b;
|
|
114
|
+
const e = t, r = n, { t: a } = F(), { errorMessage: s } = j(e), c = g(!1), o = g(null), i = g((b = o.value) == null ? void 0 : b.validity), m = d({
|
|
97
115
|
get: () => e.modelValue,
|
|
98
|
-
set: (l) =>
|
|
116
|
+
set: (l) => r("update:modelValue", l)
|
|
99
117
|
}), T = d(() => {
|
|
100
|
-
if (!
|
|
118
|
+
if (!i.value || i.value.valid)
|
|
101
119
|
return "";
|
|
102
|
-
const l =
|
|
120
|
+
const l = Z(i.value);
|
|
103
121
|
if (e.errorMessage || l === "customError")
|
|
104
122
|
return e.errorMessage;
|
|
105
123
|
if (!l)
|
|
106
124
|
return "";
|
|
107
125
|
if (l === "typeMismatch") {
|
|
108
|
-
const u =
|
|
109
|
-
return
|
|
126
|
+
const u = ee.includes(e.type) ? e.type : "generic";
|
|
127
|
+
return a.value(`validations.typeMismatch.${u}`, { value: m.value });
|
|
110
128
|
}
|
|
111
|
-
return
|
|
129
|
+
return a.value(`validations.${l}`, {
|
|
112
130
|
value: m.value,
|
|
113
131
|
n: m.value.toString().length,
|
|
114
132
|
minLength: e.minLength,
|
|
@@ -119,50 +137,56 @@ const ae = /* @__PURE__ */ S({
|
|
|
119
137
|
});
|
|
120
138
|
}), C = (l) => {
|
|
121
139
|
const u = l.target;
|
|
122
|
-
|
|
140
|
+
r("change", u.value);
|
|
123
141
|
};
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
}),
|
|
127
|
-
[
|
|
142
|
+
return S([o, s], () => {
|
|
143
|
+
o.value && o.value.setCustomValidity(e.errorMessage || "");
|
|
144
|
+
}), S(
|
|
145
|
+
[o, m, s],
|
|
128
146
|
() => {
|
|
129
|
-
if (!
|
|
147
|
+
if (!o.value)
|
|
130
148
|
return;
|
|
131
|
-
const l =
|
|
132
|
-
(!
|
|
149
|
+
const l = X(o.value.validity);
|
|
150
|
+
(!i.value || !G(l, i.value)) && (i.value = l, r("validityChange", i.value));
|
|
133
151
|
},
|
|
134
152
|
{ immediate: !0 }
|
|
135
153
|
), (l, u) => {
|
|
136
|
-
var
|
|
137
|
-
return
|
|
138
|
-
class:
|
|
154
|
+
var M, O;
|
|
155
|
+
return v(), y("label", {
|
|
156
|
+
class: h(["onyx-input", { "onyx-input--touched": c.value }])
|
|
139
157
|
}, [
|
|
140
|
-
|
|
141
|
-
class:
|
|
158
|
+
f("span", {
|
|
159
|
+
class: h(["onyx-input__label", { "onyx-input__label--required": e.required }])
|
|
142
160
|
}, p(e.label), 3),
|
|
143
|
-
|
|
161
|
+
B(f("input", H(e, {
|
|
144
162
|
ref_key: "inputElement",
|
|
145
|
-
ref:
|
|
146
|
-
"onUpdate:modelValue": u[0] || (u[0] = (
|
|
163
|
+
ref: o,
|
|
164
|
+
"onUpdate:modelValue": u[0] || (u[0] = (E) => m.value = E),
|
|
147
165
|
onChange: C,
|
|
148
|
-
onBlur: u[1] || (u[1] = (
|
|
166
|
+
onBlur: u[1] || (u[1] = (E) => c.value = !0)
|
|
149
167
|
}), null, 16), [
|
|
150
168
|
[R, m.value]
|
|
151
169
|
]),
|
|
152
|
-
c.value && !((
|
|
153
|
-
|
|
170
|
+
c.value && !((M = i.value) != null && M.valid) ? (v(), y("p", Q, p(T.value), 1)) : k("", !0),
|
|
171
|
+
f("p", W, 'Model value: "' + p(m.value) + '", is valid: ' + p((O = i.value) == null ? void 0 : O.valid), 1)
|
|
154
172
|
], 2);
|
|
155
173
|
};
|
|
156
174
|
}
|
|
157
|
-
}),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
175
|
+
}), ie = [
|
|
176
|
+
"primary",
|
|
177
|
+
"secondary",
|
|
178
|
+
"neutral",
|
|
179
|
+
"danger",
|
|
180
|
+
"warning",
|
|
181
|
+
"success",
|
|
182
|
+
"info"
|
|
183
|
+
];
|
|
163
184
|
export {
|
|
164
185
|
re as HEADLINE_TYPES,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
186
|
+
se as ICON_SIZES,
|
|
187
|
+
ie as ONYX_COLORS,
|
|
188
|
+
ne as OnyxHeadline,
|
|
189
|
+
ae as OnyxIcon,
|
|
190
|
+
oe as TestInput,
|
|
191
|
+
le as provideI18n
|
|
168
192
|
};
|