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.
@@ -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" | "search" | "email" | "tel" | "url" | "password" | "text";
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"),M=t.defineComponent({__name:"OnyxHeadline",props:{is:{},monospace:{type:Boolean,default:!1}},setup(n){const a=n;return(e,r)=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(a.is),{class:t.normalizeClass(["onyx-headline",`onyx-headline--${a.is}`,a.monospace?"onyx-headline--monospace":""])},{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},8,["class"]))}}),V=["h1","h2","h3","h4","h5","h6"],P={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:P},_=Symbol(),x=n=>{const a=t.computed(()=>t.unref(n==null?void 0:n.locale)??"en-US"),e=t.computed(()=>n!=null&&n.messages&&a.value in n.messages?n.messages[a.value]:p),r=t.computed(()=>(s,l={})=>{let d=y(s,e.value)??y(s,p)??"";const i=typeof l.n=="number"?l.n:void 0;return d=L(d,i),O(d,l)});return{locale:a,t:r}},I=n=>{t.provide(_,x(n))},T=()=>t.inject(_,()=>x(),!0),y=(n,a)=>{const e=n.split(".").reduce((r,s)=>!r||typeof r=="string"?r:r[s],a);return e&&typeof e=="string"?e:void 0},L=(n,a)=>{const e=n.split(" | ").map(s=>s.trim());if(e.length<=1)return n;let r=1;return a===0&&(r=0),a&&(a<=0||a>1)&&(r=2),e.length===2?r===1?e[0]:e[1]:e[r]},O=(n,a)=>a?Object.entries(a).reduce((r,[s,l])=>l===void 0?r:r.replace(new RegExp(`{${s}}`,"gi"),l.toString()),n).replace(/\s?{.*}\s?/gi,""):n,b=()=>Object.entries(Object.getOwnPropertyDescriptors(ValidityState.prototype)).filter(([n,a])=>a.enumerable).map(([n])=>n),C=n=>b().reduce((a,e)=>(a[e]=n[e],a),{}),D=n=>{if(n.valueMissing)return"valueMissing";const a=b().filter(e=>e!=="valid").sort();for(const e of a)if(e in n&&n[e])return e},N=(n,a)=>{const e=Object.entries(n).filter(([s,l])=>l!==void 0),r=Object.entries(a).filter(([s,l])=>l!==void 0);return e.length!==r.length?!1:e.every(([s,l])=>l===a[s])},w={key:0,class:"onyx-input__error","aria-live":"polite"},B={class:"onyx-input__info"},k=Object.keys(p.validations.typeMismatch),q=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:a}){var v;const e=n,r=a,{t:s}=T(),{errorMessage:l}=t.toRefs(e),d=t.ref(!1),i=t.ref(null),u=t.ref((v=i.value)==null?void 0:v.validity),m=t.computed({get:()=>e.modelValue,set:o=>r("update:modelValue",o)}),E=t.computed(()=>{if(!u.value||u.value.valid)return"";const o=D(u.value);if(e.errorMessage||o==="customError")return e.errorMessage;if(!o)return"";if(o==="typeMismatch"){const c=k.includes(e.type)?e.type:"generic";return s.value(`validations.typeMismatch.${c}`,{value:m.value})}return s.value(`validations.${o}`,{value:m.value,n:m.value.toString().length,minLength:e.minLength,maxLength:e.maxLength,min:e.min,max:e.max,step:e.step})}),S=o=>{const c=o.target;r("change",c.value)};return t.watch([i,l],()=>{i.value&&i.value.setCustomValidity(e.errorMessage||"")}),t.watch([i,m,l],()=>{if(!i.value)return;const o=C(i.value.validity);(!u.value||!N(o,u.value))&&(u.value=o,r("validityChange",u.value))},{immediate:!0}),(o,c)=>{var g,h;return t.openBlock(),t.createElementBlock("label",{class:t.normalizeClass(["onyx-input",{"onyx-input--touched":d.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]=f=>m.value=f),onChange:S,onBlur:c[1]||(c[1]=f=>d.value=!0)}),null,16),[[t.vModelDynamic,m.value]]),d.value&&!((g=u.value)!=null&&g.valid)?(t.openBlock(),t.createElementBlock("p",w,t.toDisplayString(E.value),1)):t.createCommentVNode("",!0),t.createElementVNode("p",B,'Model value: "'+t.toDisplayString(m.value)+'", is valid: '+t.toDisplayString((h=u.value)==null?void 0:h.valid),1)],2)}}}),U=(n,a)=>{const e=n.__vccOpts||n;for(const[r,s]of a)e[r]=s;return e},j=U(q,[["__scopeId","data-v-6632dbdc"]]);exports.HEADLINE_TYPES=V;exports.OnyxHeadline=M;exports.TestInput=j;exports.provideI18n=I;
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 S, openBlock as g, createBlock as w, resolveDynamicComponent as N, normalizeClass as f, withCtx as U, renderSlot as q, provide as D, inject as $, computed as d, unref as j, toRefs as B, ref as v, watch as E, createElementBlock as V, createElementVNode as h, toDisplayString as p, withDirectives as k, mergeProps as z, vModelDynamic as R, createCommentVNode as A } from "vue";
2
- const ae = /* @__PURE__ */ S({
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, a) => (g(), w(N(n.is), {
11
- class: f([
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: U(() => [
18
- q(e.$slots, "default")
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"], H = {
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
- }, y = {
40
- validations: H
41
- }, L = Symbol(), O = (t) => {
42
- const n = d(() => j(t == null ? void 0 : t.locale) ?? "en-US"), e = d(() => t != null && t.messages && n.value in t.messages ? t.messages[n.value] : y), a = d(() => (r, s = {}) => {
43
- let c = P(r, e.value) ?? P(r, y) ?? "";
44
- const i = typeof s.n == "number" ? s.n : void 0;
45
- return c = F(c, i), J(c, s);
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: a };
48
- }, se = (t) => {
49
- D(L, O(t));
50
- }, Y = () => $(L, () => O(), !0), P = (t, n) => {
51
- const e = t.split(".").reduce((a, r) => !a || typeof a == "string" ? a : a[r], n);
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
- }, F = (t, n) => {
54
- const e = t.split(" | ").map((r) => r.trim());
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 a = 1;
58
- return n === 0 && (a = 0), n && (n <= 0 || n > 1) && (a = 2), e.length === 2 ? a === 1 ? e[0] : e[1] : e[a];
59
- }, J = (t, n) => n ? Object.entries(n).reduce((a, [r, s]) => s === void 0 ? a : a.replace(new RegExp(`{${r}}`, "gi"), s.toString()), t).replace(/\s?{.*}\s?/gi, "") : t, I = () => Object.entries(Object.getOwnPropertyDescriptors(ValidityState.prototype)).filter(([t, n]) => n.enumerable).map(([t]) => t), K = (t) => I().reduce(
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
- ), G = (t) => {
80
+ ), Z = (t) => {
63
81
  if (t.valueMissing)
64
82
  return "valueMissing";
65
- const n = I().filter((e) => e !== "valid").sort();
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
- }, Q = (t, n) => {
70
- const e = Object.entries(t).filter(([r, s]) => s !== void 0), a = Object.entries(n).filter(([r, s]) => s !== void 0);
71
- return e.length !== a.length ? !1 : e.every(([r, s]) => s === n[r]);
72
- }, W = {
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
- }, X = { class: "onyx-input__info" }, Z = Object.keys(
77
- y.validations.typeMismatch
78
- ), ee = /* @__PURE__ */ S({
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, a = n, { t: r } = Y(), { errorMessage: s } = B(e), c = v(!1), i = v(null), o = v((_ = i.value) == null ? void 0 : _.validity), m = d({
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) => a("update:modelValue", l)
116
+ set: (l) => r("update:modelValue", l)
99
117
  }), T = d(() => {
100
- if (!o.value || o.value.valid)
118
+ if (!i.value || i.value.valid)
101
119
  return "";
102
- const l = G(o.value);
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 = Z.includes(e.type) ? e.type : "generic";
109
- return r.value(`validations.typeMismatch.${u}`, { value: m.value });
126
+ const u = ee.includes(e.type) ? e.type : "generic";
127
+ return a.value(`validations.typeMismatch.${u}`, { value: m.value });
110
128
  }
111
- return r.value(`validations.${l}`, {
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
- a("change", u.value);
140
+ r("change", u.value);
123
141
  };
124
- return E([i, s], () => {
125
- i.value && i.value.setCustomValidity(e.errorMessage || "");
126
- }), E(
127
- [i, m, s],
142
+ return S([o, s], () => {
143
+ o.value && o.value.setCustomValidity(e.errorMessage || "");
144
+ }), S(
145
+ [o, m, s],
128
146
  () => {
129
- if (!i.value)
147
+ if (!o.value)
130
148
  return;
131
- const l = K(i.value.validity);
132
- (!o.value || !Q(l, o.value)) && (o.value = l, a("validityChange", o.value));
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 x, b;
137
- return g(), V("label", {
138
- class: f(["onyx-input", { "onyx-input--touched": c.value }])
154
+ var M, O;
155
+ return v(), y("label", {
156
+ class: h(["onyx-input", { "onyx-input--touched": c.value }])
139
157
  }, [
140
- h("span", {
141
- class: f(["onyx-input__label", { "onyx-input__label--required": e.required }])
158
+ f("span", {
159
+ class: h(["onyx-input__label", { "onyx-input__label--required": e.required }])
142
160
  }, p(e.label), 3),
143
- k(h("input", z(e, {
161
+ B(f("input", H(e, {
144
162
  ref_key: "inputElement",
145
- ref: i,
146
- "onUpdate:modelValue": u[0] || (u[0] = (M) => m.value = M),
163
+ ref: o,
164
+ "onUpdate:modelValue": u[0] || (u[0] = (E) => m.value = E),
147
165
  onChange: C,
148
- onBlur: u[1] || (u[1] = (M) => c.value = !0)
166
+ onBlur: u[1] || (u[1] = (E) => c.value = !0)
149
167
  }), null, 16), [
150
168
  [R, m.value]
151
169
  ]),
152
- c.value && !((x = o.value) != null && x.valid) ? (g(), V("p", W, p(T.value), 1)) : A("", !0),
153
- h("p", X, 'Model value: "' + p(m.value) + '", is valid: ' + p((b = o.value) == null ? void 0 : b.valid), 1)
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
- }), te = (t, n) => {
158
- const e = t.__vccOpts || t;
159
- for (const [a, r] of n)
160
- e[a] = r;
161
- return e;
162
- }, le = /* @__PURE__ */ te(ee, [["__scopeId", "data-v-6632dbdc"]]);
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
- ae as OnyxHeadline,
166
- le as TestInput,
167
- se as provideI18n
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
  };