@phila/phila-ui-radio 0.0.1

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/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Radio component
2
+
3
+ ## Create a new local build
4
+
5
+ In src/components/COMPONENT_NAME:
6
+
7
+ ```
8
+ npm run build
9
+ npm pack
10
+ ```
11
+
12
+ copy .tgz file to project and run:
13
+
14
+ ```
15
+ npm install COMPONENT_NAME*.tgz
16
+ ```
@@ -0,0 +1,77 @@
1
+ import { InputProps } from "@phila/phila-ui-core";
2
+ import { RadioProps } from "./types";
3
+ import PhilaUICore from "@phila/phila-ui-core";
4
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<InputProps & RadioProps>, {
5
+ id: any;
6
+ errors(): never[];
7
+ label: string;
8
+ desc: string;
9
+ modelValue: () => "";
10
+ valueKey: string;
11
+ textKey: string;
12
+ numOfColumns: number;
13
+ small: boolean;
14
+ options: () => {
15
+ "option-1": string;
16
+ "option-2": string;
17
+ "option-3": string;
18
+ };
19
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
+ "update:modelValue": (...args: any[]) => void;
21
+ change: (...args: any[]) => void;
22
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<InputProps & RadioProps>, {
23
+ id: any;
24
+ errors(): never[];
25
+ label: string;
26
+ desc: string;
27
+ modelValue: () => "";
28
+ valueKey: string;
29
+ textKey: string;
30
+ numOfColumns: number;
31
+ small: boolean;
32
+ options: () => {
33
+ "option-1": string;
34
+ "option-2": string;
35
+ "option-3": string;
36
+ };
37
+ }>>> & {
38
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
39
+ onChange?: ((...args: any[]) => any) | undefined;
40
+ }, {
41
+ id: string;
42
+ errors: PhilaUICore.InputErrors;
43
+ options: (PhilaUICore.HTMLInputValue[] | PhilaUICore.InputOptions | PhilaUICore.InputOptions[] | PhilaUICore.InputOptionsGroup | undefined) & (object | (string | number | object)[]);
44
+ textKey: string;
45
+ valueKey: string;
46
+ label: string;
47
+ desc: string;
48
+ modelValue: "";
49
+ numOfColumns: string | number;
50
+ small: boolean;
51
+ }, {}>, {
52
+ label?(_: {}): any;
53
+ desc?(_: {}): any;
54
+ }>;
55
+ export default _default;
56
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
57
+ type __VLS_TypePropsToRuntimeProps<T> = {
58
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
59
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
60
+ } : {
61
+ type: import('vue').PropType<T[K]>;
62
+ required: true;
63
+ };
64
+ };
65
+ type __VLS_WithDefaults<P, D> = {
66
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
67
+ default: D[K];
68
+ }> : P[K];
69
+ };
70
+ type __VLS_Prettify<T> = {
71
+ [K in keyof T]: T[K];
72
+ } & {};
73
+ type __VLS_WithTemplateSlots<T, S> = T & {
74
+ new (): {
75
+ $slots: S;
76
+ };
77
+ };
package/dist/radio.js ADDED
@@ -0,0 +1,102 @@
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 = {
4
+ key: 0,
5
+ class: "input-error-msg"
6
+ }, F = /* @__PURE__ */ a("span", { class: "icon" }, [
7
+ /* @__PURE__ */ a("i", { class: "fas fa-exclamation-circle" })
8
+ ], -1), H = {
9
+ key: 1,
10
+ class: "is-field-info"
11
+ }, L = {
12
+ key: 0,
13
+ class: "is-field-info"
14
+ }, M = ["id"], j = ["id", "aria-checked", "name", "value"], q = ["for"], { formHelpers: g } = U, { randomID: G } = g, J = {
15
+ inheritAttrs: !1
16
+ }, X = /* @__PURE__ */ O({
17
+ ...J,
18
+ __name: "Radio",
19
+ props: {
20
+ id: { default: G() },
21
+ errors: { default() {
22
+ return [];
23
+ } },
24
+ optgroup: { type: Boolean },
25
+ options: { default: () => ({
26
+ "option-1": "Option 1",
27
+ "option-2": "Option 2",
28
+ "option-3": "Option 3"
29
+ }) },
30
+ textKey: { default: "" },
31
+ valueKey: { default: "" },
32
+ imaskProps: {},
33
+ label: { default: "" },
34
+ desc: { default: "" },
35
+ modelValue: { default: () => "" },
36
+ numOfColumns: { default: 1 },
37
+ small: { type: Boolean, default: !1 }
38
+ },
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,
44
+ (e) => {
45
+ r.value = e;
46
+ }
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])
53
+ }, [
54
+ a("fieldset", null, [
55
+ a("legend", null, [
56
+ e.label ? (o(), l(u, { key: 0 }, [
57
+ R(d(e.label), 1)
58
+ ], 64)) : v(e.$slots, "label", { key: 1 })
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)
68
+ ], 64)),
69
+ a("div", {
70
+ id: `rd-group-${e.id}`,
71
+ style: S(`columns: ${e.numOfColumns} auto`),
72
+ role: "radiogroup"
73
+ }, [
74
+ (o(!0), l(u, null, z(e.options, (i, s) => (o(), l("div", {
75
+ key: s,
76
+ class: "control"
77
+ }, [
78
+ E(a("input", K({
79
+ id: `rd-${s}-${e.id}`,
80
+ "onUpdate:modelValue": h[0] || (h[0] = (I) => r.value = I),
81
+ type: "radio",
82
+ role: "radio",
83
+ "aria-checked": e.modelValue === t(f)(i, s),
84
+ name: `rd-${s}-${e.id}`,
85
+ class: "is-checkradio",
86
+ value: t(f)(i, s),
87
+ ref_for: !0
88
+ }, e.$attrs, { onChange: _ }), null, 16, j), [
89
+ [T, r.value]
90
+ ]),
91
+ a("label", {
92
+ for: `rd-${s}-${e.id}`
93
+ }, d(t(y)(i)), 9, q)
94
+ ]))), 128))
95
+ ], 12, M)
96
+ ])
97
+ ], 2));
98
+ }
99
+ });
100
+ export {
101
+ X as default
102
+ };
@@ -0,0 +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))}})});
@@ -0,0 +1,16 @@
1
+ import Radio from 'Radio.vue';
2
+ declare module '@vue/runtime-core' {
3
+ interface GlobalComponents {
4
+ Radio: typeof Radio;
5
+ }
6
+ }
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;
15
+ options: object | Array<string | number | object>;
16
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@phila/phila-ui-radio",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "./dist/radio.umd.cjs",
10
+ "module": "./dist/radio.js",
11
+ "types": "./dist/types.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": {
15
+ "types": "./dist/types.d.ts",
16
+ "default": "./dist/radio.js"
17
+ },
18
+ "require": "./dist/radio.umd.cjs"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "dev": "vite",
23
+ "prepublish": "npm i && npm run build",
24
+ "build": "vite build && vue-tsc --declaration --emitDeclarationOnly --outdir ./dist",
25
+ "preview": "vite preview"
26
+ },
27
+ "dependencies": {
28
+ "@phila/phila-ui-core": "1.0.12",
29
+ "bulma": "^0.9.4",
30
+ "vue": "^3.3.8"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20.10.3",
34
+ "@vitejs/plugin-vue": "^4.5.0",
35
+ "sass": "^1.69.5",
36
+ "typescript": "^5.2.2",
37
+ "vite": "^5.0.0",
38
+ "vite-plugin-dts": "^3.6.4",
39
+ "vite-plugin-lib-inject-css": "^1.3.0",
40
+ "vue-tsc": "^1.8.22"
41
+ },
42
+ "publishConfig": {
43
+ "registry": "https://registry.npmjs.com/",
44
+ "access": "public"
45
+ },
46
+ "gitHead": "24a55656d994e2c54c353513e478fc74091bafc8"
47
+ }