@phila/phila-ui-radio 0.0.2 → 0.0.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.
@@ -6,7 +6,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
6
6
  errors(): never[];
7
7
  label: string;
8
8
  desc: string;
9
- modelValue: () => "";
9
+ modelValue: string;
10
10
  valueKey: string;
11
11
  textKey: string;
12
12
  numOfColumns: number;
@@ -24,7 +24,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
24
24
  errors(): never[];
25
25
  label: string;
26
26
  desc: string;
27
- modelValue: () => "";
27
+ modelValue: string;
28
28
  valueKey: string;
29
29
  textKey: string;
30
30
  numOfColumns: number;
@@ -45,7 +45,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
45
45
  valueKey: string;
46
46
  label: string;
47
47
  desc: string;
48
- modelValue: "";
48
+ modelValue: string | number | boolean;
49
49
  numOfColumns: string | number;
50
50
  small: boolean;
51
51
  }, {}>, {
package/dist/radio.js CHANGED
@@ -1,23 +1,23 @@
1
- import { defineComponent as O, getCurrentInstance as B, ref as w, watch as D, computed as N, openBlock as o, createElementBlock as l, normalizeClass as P, createElementVNode as a, Fragment as u, createTextVNode as R, toDisplayString as d, renderSlot as v, unref as t, createCommentVNode as $, normalizeStyle as S, renderList as z, withDirectives as E, mergeProps as K, vModelRadio as T } from "vue";
2
- import U from "@phila/phila-ui-core";
3
- const A = {
1
+ import { defineComponent as B, getCurrentInstance as I, ref as O, watch as N, openBlock as o, createElementBlock as l, normalizeClass as S, unref as s, createElementVNode as a, Fragment as u, createTextVNode as w, toDisplayString as n, renderSlot as h, createCommentVNode as v, normalizeStyle as D, renderList as P, withDirectives as z, mergeProps as E, vModelRadio as K } from "vue";
2
+ import R from "@phila/phila-ui-core";
3
+ const T = {
4
4
  key: 0,
5
5
  class: "input-error-msg"
6
- }, F = /* @__PURE__ */ a("span", { class: "icon" }, [
6
+ }, U = /* @__PURE__ */ a("span", { class: "icon" }, [
7
7
  /* @__PURE__ */ a("i", { class: "fas fa-exclamation-circle" })
8
- ], -1), H = {
8
+ ], -1), q = {
9
9
  key: 1,
10
10
  class: "is-field-info"
11
- }, L = {
11
+ }, A = {
12
12
  key: 0,
13
13
  class: "is-field-info"
14
- }, M = ["id"], j = ["id", "aria-checked", "name", "value"], q = ["for"], { formHelpers: g } = U, { randomID: G } = g, J = {
14
+ }, F = ["id"], H = ["id", "aria-checked", "name", "value"], L = ["for"], { formHelpers: g } = R, { randomID: M } = g, j = {
15
15
  inheritAttrs: !1
16
- }, X = /* @__PURE__ */ O({
17
- ...J,
16
+ }, Q = /* @__PURE__ */ B({
17
+ ...j,
18
18
  __name: "Radio",
19
19
  props: {
20
- id: { default: G() },
20
+ id: { default: M() },
21
21
  errors: { default() {
22
22
  return [];
23
23
  } },
@@ -32,71 +32,71 @@ const A = {
32
32
  imaskProps: {},
33
33
  label: { default: "" },
34
34
  desc: { default: "" },
35
- modelValue: { default: () => "" },
35
+ modelValue: { type: [String, Number, Boolean], default: "" },
36
36
  numOfColumns: { default: 1 },
37
37
  small: { type: Boolean, default: !1 }
38
38
  },
39
39
  emits: ["update:modelValue", "change"],
40
- setup(V, { emit: C }) {
41
- const n = V, c = C, k = B(), { error: p, classes: m, optionText: y, optionValue: f } = g.useInput.useInputComposable(k, n), r = w(n.modelValue);
42
- D(
43
- () => n.modelValue,
40
+ setup($, { emit: V }) {
41
+ const r = $, p = V, y = I(), { error: c, classes: C, optionText: k, optionValue: m } = g.useInput.useInputComposable(y, r), i = O(r.modelValue);
42
+ N(
43
+ () => r.modelValue,
44
44
  (e) => {
45
- r.value = e;
45
+ i.value = e;
46
46
  }
47
47
  );
48
- const _ = (e) => {
49
- c("change", e), c("update:modelValue", r.value);
50
- }, b = N(() => n.small ? `${m} small-checkradio` : m);
51
- return (e, h) => (o(), l("div", {
52
- class: P(["input-wrap input-radio", b.value])
48
+ const b = (e) => {
49
+ p("change", e), p("update:modelValue", i.value);
50
+ };
51
+ return (e, f) => (o(), l("div", {
52
+ class: S(["input-wrap input-radio", [s(C), r.small && "small-checkradio"]])
53
53
  }, [
54
54
  a("fieldset", null, [
55
55
  a("legend", null, [
56
56
  e.label ? (o(), l(u, { key: 0 }, [
57
- R(d(e.label), 1)
58
- ], 64)) : v(e.$slots, "label", { key: 1 })
57
+ w(n(e.label) + " " + n(e.$attrs.required !== void 0 ? "*" : ""), 1)
58
+ ], 64)) : h(e.$slots, "label", { key: 1 })
59
59
  ]),
60
- t(p) ? (o(), l("div", A, [
61
- F,
62
- a("span", null, d(t(p)), 1)
63
- ])) : $("", !0),
64
- e.desc ? (o(), l("div", H, d(e.desc), 1)) : (o(), l(u, { key: 2 }, [
65
- e.$slots.desc ? (o(), l("div", L, [
66
- v(e.$slots, "desc")
67
- ])) : $("", !0)
60
+ s(c) ? (o(), l("div", T, [
61
+ U,
62
+ a("span", null, n(s(c)), 1)
63
+ ])) : v("", !0),
64
+ e.desc ? (o(), l("div", q, n(e.desc), 1)) : (o(), l(u, { key: 2 }, [
65
+ e.$slots.desc ? (o(), l("div", A, [
66
+ h(e.$slots, "desc")
67
+ ])) : v("", !0)
68
68
  ], 64)),
69
69
  a("div", {
70
70
  id: `rd-group-${e.id}`,
71
- style: S(`columns: ${e.numOfColumns} auto`),
71
+ style: D(`columns: ${e.numOfColumns} auto`),
72
72
  role: "radiogroup"
73
73
  }, [
74
- (o(!0), l(u, null, z(e.options, (i, s) => (o(), l("div", {
75
- key: s,
74
+ (o(!0), l(u, null, P(e.options, (d, t) => (o(), l("div", {
75
+ key: t,
76
76
  class: "control"
77
77
  }, [
78
- E(a("input", K({
79
- id: `rd-${s}-${e.id}`,
80
- "onUpdate:modelValue": h[0] || (h[0] = (I) => r.value = I),
78
+ z(a("input", E({
79
+ id: `rd-${t}-${e.id}`,
80
+ "onUpdate:modelValue": f[0] || (f[0] = (_) => i.value = _),
81
81
  type: "radio",
82
82
  role: "radio",
83
- "aria-checked": e.modelValue === t(f)(i, s),
84
- name: `rd-${s}-${e.id}`,
83
+ "aria-checked": e.modelValue === s(m)(d, t),
84
+ name: `rd-${t}-${e.id}`,
85
85
  class: "is-checkradio",
86
- value: t(f)(i, s),
86
+ value: s(m)(d, t),
87
87
  ref_for: !0
88
- }, e.$attrs, { onChange: _ }), null, 16, j), [
89
- [T, r.value]
88
+ }, e.$attrs, { onChange: b }), null, 16, H), [
89
+ [K, i.value]
90
90
  ]),
91
91
  a("label", {
92
- for: `rd-${s}-${e.id}`
93
- }, d(t(y)(i)), 9, q)
92
+ for: `rd-${t}-${e.id}`
93
+ }, n(s(k)(d)), 9, L)
94
94
  ]))), 128))
95
- ], 12, M)
95
+ ], 12, F)
96
96
  ])
97
97
  ], 2));
98
98
  }
99
99
  });
100
100
  export {
101
- X as default
101
+ Q as default
102
102
  };
@@ -1 +1 @@
1
- (function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l(require("vue"),require("@phila/phila-ui-core")):typeof define=="function"&&define.amd?define(["vue","@phila/phila-ui-core"],l):(e=typeof globalThis<"u"?globalThis:e||self,e.Radio=l(e.Vue,e.PhilaUICore))})(this,function(e,l){"use strict";const f={key:0,class:"input-error-msg"},u=e.createElementVNode("span",{class:"icon"},[e.createElementVNode("i",{class:"fas fa-exclamation-circle"})],-1),h={key:1,class:"is-field-info"},k={key:0,class:"is-field-info"},V=["id"],B=["id","aria-checked","name","value"],E=["for"],{formHelpers:s}=l,{randomID:g}=s,y={inheritAttrs:!1};return e.defineComponent({...y,__name:"Radio",props:{id:{default:g()},errors:{default(){return[]}},optgroup:{type:Boolean},options:{default:()=>({"option-1":"Option 1","option-2":"Option 2","option-3":"Option 3"})},textKey:{default:""},valueKey:{default:""},imaskProps:{},label:{default:""},desc:{default:""},modelValue:{default:()=>""},numOfColumns:{default:1},small:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup($,{emit:C}){const n=$,i=C,N=e.getCurrentInstance(),{error:d,classes:c,optionText:_,optionValue:m}=s.useInput.useInputComposable(N,n),a=e.ref(n.modelValue);e.watch(()=>n.modelValue,o=>{a.value=o});const S=o=>{i("change",o),i("update:modelValue",a.value)},D=e.computed(()=>n.small?`${c} small-checkradio`:c);return(o,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["input-wrap input-radio",D.value])},[e.createElementVNode("fieldset",null,[e.createElementVNode("legend",null,[o.label?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(o.label),1)],64)):e.renderSlot(o.$slots,"label",{key:1})]),e.unref(d)?(e.openBlock(),e.createElementBlock("div",f,[u,e.createElementVNode("span",null,e.toDisplayString(e.unref(d)),1)])):e.createCommentVNode("",!0),o.desc?(e.openBlock(),e.createElementBlock("div",h,e.toDisplayString(o.desc),1)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[o.$slots.desc?(e.openBlock(),e.createElementBlock("div",k,[e.renderSlot(o.$slots,"desc")])):e.createCommentVNode("",!0)],64)),e.createElementVNode("div",{id:`rd-group-${o.id}`,style:e.normalizeStyle(`columns: ${o.numOfColumns} auto`),role:"radiogroup"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,(r,t)=>(e.openBlock(),e.createElementBlock("div",{key:t,class:"control"},[e.withDirectives(e.createElementVNode("input",e.mergeProps({id:`rd-${t}-${o.id}`,"onUpdate:modelValue":p[0]||(p[0]=b=>a.value=b),type:"radio",role:"radio","aria-checked":o.modelValue===e.unref(m)(r,t),name:`rd-${t}-${o.id}`,class:"is-checkradio",value:e.unref(m)(r,t),ref_for:!0},o.$attrs,{onChange:S}),null,16,B),[[e.vModelRadio,a.value]]),e.createElementVNode("label",{for:`rd-${t}-${o.id}`},e.toDisplayString(e.unref(_)(r)),9,E)]))),128))],12,V)])],2))}})});
1
+ (function(e,l){typeof exports=="object"&&typeof module<"u"?module.exports=l(require("vue"),require("@phila/phila-ui-core")):typeof define=="function"&&define.amd?define(["vue","@phila/phila-ui-core"],l):(e=typeof globalThis<"u"?globalThis:e||self,e.Radio=l(e.Vue,e.PhilaUICore))})(this,function(e,l){"use strict";const m={key:0,class:"input-error-msg"},f=e.createElementVNode("span",{class:"icon"},[e.createElementVNode("i",{class:"fas fa-exclamation-circle"})],-1),u={key:1,class:"is-field-info"},h={key:0,class:"is-field-info"},k=["id"],V=["id","aria-checked","name","value"],B=["for"],{formHelpers:s}=l,{randomID:g}=s,y={inheritAttrs:!1};return e.defineComponent({...y,__name:"Radio",props:{id:{default:g()},errors:{default(){return[]}},optgroup:{type:Boolean},options:{default:()=>({"option-1":"Option 1","option-2":"Option 2","option-3":"Option 3"})},textKey:{default:""},valueKey:{default:""},imaskProps:{},label:{default:""},desc:{default:""},modelValue:{type:[String,Number,Boolean],default:""},numOfColumns:{default:1},small:{type:Boolean,default:!1}},emits:["update:modelValue","change"],setup(E,{emit:$}){const n=E,i=$,N=e.getCurrentInstance(),{error:d,classes:C,optionText:S,optionValue:c}=s.useInput.useInputComposable(N,n),a=e.ref(n.modelValue);e.watch(()=>n.modelValue,o=>{a.value=o});const _=o=>{i("change",o),i("update:modelValue",a.value)};return(o,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["input-wrap input-radio",[e.unref(C),n.small&&"small-checkradio"]])},[e.createElementVNode("fieldset",null,[e.createElementVNode("legend",null,[o.label?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(o.label)+" "+e.toDisplayString(o.$attrs.required!==void 0?"*":""),1)],64)):e.renderSlot(o.$slots,"label",{key:1})]),e.unref(d)?(e.openBlock(),e.createElementBlock("div",m,[f,e.createElementVNode("span",null,e.toDisplayString(e.unref(d)),1)])):e.createCommentVNode("",!0),o.desc?(e.openBlock(),e.createElementBlock("div",u,e.toDisplayString(o.desc),1)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[o.$slots.desc?(e.openBlock(),e.createElementBlock("div",h,[e.renderSlot(o.$slots,"desc")])):e.createCommentVNode("",!0)],64)),e.createElementVNode("div",{id:`rd-group-${o.id}`,style:e.normalizeStyle(`columns: ${o.numOfColumns} auto`),role:"radiogroup"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.options,(r,t)=>(e.openBlock(),e.createElementBlock("div",{key:t,class:"control"},[e.withDirectives(e.createElementVNode("input",e.mergeProps({id:`rd-${t}-${o.id}`,"onUpdate:modelValue":p[0]||(p[0]=D=>a.value=D),type:"radio",role:"radio","aria-checked":o.modelValue===e.unref(c)(r,t),name:`rd-${t}-${o.id}`,class:"is-checkradio",value:e.unref(c)(r,t),ref_for:!0},o.$attrs,{onChange:_}),null,16,V),[[e.vModelRadio,a.value]]),e.createElementVNode("label",{for:`rd-${t}-${o.id}`},e.toDisplayString(e.unref(S)(r)),9,B)]))),128))],12,k)])],2))}})});
package/dist/types.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import Radio from 'Radio.vue';
1
+ import Radio from './Radio.vue';
2
2
  declare module '@vue/runtime-core' {
3
3
  interface GlobalComponents {
4
4
  Radio: typeof Radio;
5
5
  }
6
6
  }
7
7
  export interface RadioProps {
8
- label: string;
9
- desc: string;
10
- modelValue: unknown;
11
- valueKey: string;
12
- textKey: string;
13
- numOfColumns: string | number;
14
- small: boolean;
8
+ label?: string;
9
+ desc?: string;
10
+ modelValue: string | number | boolean;
11
+ valueKey?: string;
12
+ textKey?: string;
13
+ numOfColumns?: string | number;
14
+ small?: boolean;
15
15
  options: object | Array<string | number | object>;
16
16
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@phila/phila-ui-radio",
3
3
  "private": false,
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"
@@ -43,5 +43,5 @@
43
43
  "registry": "https://registry.npmjs.com/",
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "fdbb95c5dead04026c297ab8c38462de7456a374"
46
+ "gitHead": "41f3602a8182b747db366652993576f74555dd20"
47
47
  }