@purr-react-tailwindcss/components.radio-group 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purr-react-tailwindcss/components.radio-group",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -24,9 +24,9 @@
24
24
  "typescript": "*",
25
25
  "react": "*",
26
26
  "clsx": "*",
27
- "@purr-core/utils.helpers": "0.0.9",
28
- "@purr-core/utils.definitions": "0.0.9",
29
- "@purr-core/hooks.sync-state-with-props": "0.0.7"
27
+ "@purr-core/hooks.sync-state-with-props": "0.0.8",
28
+ "@purr-core/utils.helpers": "0.0.11",
29
+ "@purr-core/utils.definitions": "0.0.11"
30
30
  },
31
31
  "author": "@DinhThienPhuc",
32
32
  "license": "ISC",
@@ -35,6 +35,8 @@
35
35
  "scripts": {
36
36
  "dev": "vite build --watch",
37
37
  "build": "tsc && vite build",
38
+ "build:vite": "tsc && vite build",
39
+ "build:tsup": "tsup",
38
40
  "lint": "eslint . --ext ts,tsx --max-warnings 0"
39
41
  }
40
42
  }
@@ -1,4 +0,0 @@
1
- import { default as React } from 'react';
2
- import { IRadioGroupLabelProps } from '../_types';
3
-
4
- export declare const RadioGroupLabel: React.MemoExoticComponent<({ label, hasValue, htmlAttributes }: IRadioGroupLabelProps) => React.JSX.Element>;
@@ -1,4 +0,0 @@
1
- import { default as React } from 'react';
2
- import { IRadioGroupOptionProps } from '../_types';
3
-
4
- export declare const RadioGroupOption: React.MemoExoticComponent<({ label, value, name, htmlAttributes, textHTMLAttributes, checkBoxHTMLAttributes, checkBoxTickHTMLAttributes, isStandalone, currentValue, setCurrentValue, onChange, }: IRadioGroupOptionProps) => React.JSX.Element>;
@@ -1,4 +0,0 @@
1
- import { default as React } from 'react';
2
- import { IRadioGroupProps } from '../_types';
3
-
4
- export declare const RadioGroup: React.ForwardRefExoticComponent<IRadioGroupProps & React.RefAttributes<HTMLElement>>;
@@ -1,21 +0,0 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import a from "clsx";
3
- import { memo as i } from "react";
4
- const s = i(
5
- ({ label: o = "", hasValue: e, htmlAttributes: r }) => /* @__PURE__ */ t(
6
- "span",
7
- {
8
- className: a(
9
- "text-base transition-colors duration-200 ease-in-out",
10
- e ? "text-blue-300" : "text-white",
11
- "radio-group-label"
12
- ),
13
- ...r,
14
- children: o
15
- }
16
- )
17
- );
18
- s.displayName = "RadioGroupLabel";
19
- export {
20
- s as RadioGroupLabel
21
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),i=require("clsx"),s=require("react"),e=s.memo(({label:t="",hasValue:o,htmlAttributes:r})=>a.jsx("span",{className:i("text-base transition-colors duration-200 ease-in-out",o?"text-blue-300":"text-white","radio-group-label"),...r,children:t}));e.displayName="RadioGroupLabel";exports.RadioGroupLabel=e;
package/dist/_types.d.ts DELETED
@@ -1,38 +0,0 @@
1
- import { ChangeEvent, HTMLAttributes, LabelHTMLAttributes } from 'react';
2
- import { IExtendable } from '@purr-core/utils.definitions';
3
-
4
- export type TRadioGroupDirection = "column" | "row";
5
- export interface IRadioGroupOption {
6
- key: string;
7
- value: string;
8
- label?: string;
9
- htmlAttributes?: LabelHTMLAttributes<HTMLLabelElement> & IExtendable;
10
- textHTMLAttributes?: LabelHTMLAttributes<HTMLSpanElement> & IExtendable;
11
- checkBoxHTMLAttributes?: LabelHTMLAttributes<HTMLInputElement> & IExtendable;
12
- checkBoxTickHTMLAttributes?: LabelHTMLAttributes<HTMLInputElement> & IExtendable;
13
- }
14
- export interface IRadioGroupOptionProps extends IRadioGroupOption {
15
- name: string;
16
- currentValue?: string;
17
- isStandalone?: boolean;
18
- setCurrentValue?: (value: string) => void;
19
- onChange?: (value: string, e: ChangeEvent<HTMLInputElement>) => void;
20
- }
21
- export interface IRadioGroupLabelProps {
22
- label?: string;
23
- hasValue?: boolean;
24
- htmlAttributes?: LabelHTMLAttributes<HTMLLabelElement> & IExtendable;
25
- }
26
- export interface IRadioGroupProps {
27
- options: IRadioGroupOption[];
28
- name: string;
29
- value?: string;
30
- label?: string;
31
- isStandalone?: boolean;
32
- direction?: TRadioGroupDirection;
33
- htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
34
- labelHtmlAttributes?: HTMLAttributes<HTMLSpanElement> & IExtendable;
35
- optionHtmlAttributes?: LabelHTMLAttributes<HTMLLabelElement> & IExtendable;
36
- optionGroupHtmlAttributes?: LabelHTMLAttributes<HTMLDivElement> & IExtendable;
37
- onChange?: (value: string, e: ChangeEvent<HTMLInputElement>) => void;
38
- }
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("react"),b=require("clsx"),g=require("@purr-core/hooks.sync-state-with-props"),k=require("@purr-core/utils.helpers"),j=t.memo(({label:r,value:e,name:o,htmlAttributes:c,textHTMLAttributes:n,checkBoxHTMLAttributes:d,checkBoxTickHTMLAttributes:f,isStandalone:p,currentValue:m,setCurrentValue:a,onChange:l})=>{var R;const h=t.useRef(null),i=p?(R=h.current)==null?void 0:R.checked:m===e,x=p?void 0:m===e,u=t.useCallback(y=>{l==null||l(e,y),a==null||a(e)},[l,a,e]),w=t.useMemo(()=>s.jsx("span",{className:"radio-group-option-label text-base text-white",...n,children:r}),[r,n]);return s.jsxs("label",{className:"radio-group-option flex cursor-pointer items-center gap-3",...c,children:[s.jsxs("span",{className:"relative flex",children:[s.jsx("input",{className:b("h-4 w-4 appearance-none rounded-full border-2 border-blue-300","radio-group-option-input",i?"radio-group-option-input--checked":""),name:o,type:"radio",value:e,checked:x,onChange:u,ref:h,...d}),s.jsx("span",{className:b("absolute left-1 top-1 h-2 w-2 rounded-full bg-blue-300 transition-transform duration-200 ease-in-out",i?"scale-100 transform":"scale-0 transform"),...f})]}),w]})},k.arePropsShallowEqual(["currentValue"],(r,e,o)=>{switch(r){case"currentValue":return o.currentValue===o.value==(e.currentValue===e.value);default:return}}));j.displayName="RadioGroupOption";const q=t.lazy(()=>Promise.resolve().then(()=>require("./_label-VT0fJVvQ.cjs")).then(r=>({default:r.RadioGroupLabel}))),N=t.forwardRef(({options:r,name:e,value:o="",label:c="",onChange:n,isStandalone:d=!1,direction:f="column",htmlAttributes:p,labelHtmlAttributes:m,optionHtmlAttributes:a,optionGroupHtmlAttributes:l},h)=>{const{currentValue:i,setCurrentValue:x}=g(o,d);return s.jsxs("div",{className:"radio-group flex flex-col gap-4",...p,children:[s.jsx(t.Suspense,{children:!!c&&s.jsx(q,{hasValue:!!i,label:c,htmlAttributes:m})}),s.jsx("div",{className:b("flex gap-4",f==="column"?"flex-col items-start":"flex-row"),...l,children:r==null?void 0:r.map(u=>t.createElement(j,{...u,key:u.key,name:e,htmlAttributes:a??u.htmlAttributes,isStandalone:d,currentValue:i,setCurrentValue:x,onChange:n}))})]})});N.displayName="RadioGroup";exports.RadioGroup=N;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './_components';
2
- export * from './_types';
package/dist/index.js DELETED
@@ -1,144 +0,0 @@
1
- import { jsx as l, jsxs as b } from "react/jsx-runtime";
2
- import { memo as y, useRef as g, useCallback as G, useMemo as O, lazy as j, forwardRef as A, Suspense as E, createElement as L } from "react";
3
- import R from "clsx";
4
- import S from "@purr-core/hooks.sync-state-with-props";
5
- import { arePropsShallowEqual as q } from "@purr-core/utils.helpers";
6
- const N = y(
7
- ({
8
- label: r,
9
- value: e,
10
- name: o,
11
- htmlAttributes: c,
12
- textHTMLAttributes: u,
13
- checkBoxHTMLAttributes: n,
14
- checkBoxTickHTMLAttributes: m,
15
- isStandalone: d,
16
- currentValue: p,
17
- setCurrentValue: t,
18
- onChange: a
19
- }) => {
20
- var x;
21
- const f = g(null), s = d ? (x = f.current) == null ? void 0 : x.checked : p === e, h = d ? void 0 : p === e, i = G(
22
- (k) => {
23
- a == null || a(e, k), t == null || t(e);
24
- },
25
- [a, t, e]
26
- ), w = O(
27
- () => /* @__PURE__ */ l(
28
- "span",
29
- {
30
- className: "radio-group-option-label text-base text-white",
31
- ...u,
32
- children: r
33
- }
34
- ),
35
- [r, u]
36
- );
37
- return /* @__PURE__ */ b(
38
- "label",
39
- {
40
- className: "radio-group-option flex cursor-pointer items-center gap-3",
41
- ...c,
42
- children: [
43
- /* @__PURE__ */ b("span", { className: "relative flex", children: [
44
- /* @__PURE__ */ l(
45
- "input",
46
- {
47
- className: R(
48
- "h-4 w-4 appearance-none rounded-full border-2 border-blue-300",
49
- "radio-group-option-input",
50
- s ? "radio-group-option-input--checked" : ""
51
- ),
52
- name: o,
53
- type: "radio",
54
- value: e,
55
- checked: h,
56
- onChange: i,
57
- ref: f,
58
- ...n
59
- }
60
- ),
61
- /* @__PURE__ */ l(
62
- "span",
63
- {
64
- className: R(
65
- "absolute left-1 top-1 h-2 w-2 rounded-full bg-blue-300 transition-transform duration-200 ease-in-out",
66
- s ? "scale-100 transform" : "scale-0 transform"
67
- ),
68
- ...m
69
- }
70
- )
71
- ] }),
72
- w
73
- ]
74
- }
75
- );
76
- },
77
- q(["currentValue"], (r, e, o) => {
78
- switch (r) {
79
- case "currentValue":
80
- return o.currentValue === o.value == (e.currentValue === e.value);
81
- default:
82
- return;
83
- }
84
- })
85
- );
86
- N.displayName = "RadioGroupOption";
87
- const z = j(
88
- () => import("./_label-Bwrjrv60.js").then((r) => ({
89
- default: r.RadioGroupLabel
90
- }))
91
- ), I = A(
92
- ({
93
- options: r,
94
- name: e,
95
- value: o = "",
96
- label: c = "",
97
- onChange: u,
98
- isStandalone: n = !1,
99
- direction: m = "column",
100
- htmlAttributes: d,
101
- labelHtmlAttributes: p,
102
- optionHtmlAttributes: t,
103
- optionGroupHtmlAttributes: a
104
- }, f) => {
105
- const { currentValue: s, setCurrentValue: h } = S(o, n);
106
- return /* @__PURE__ */ b("div", { className: "radio-group flex flex-col gap-4", ...d, children: [
107
- /* @__PURE__ */ l(E, { children: !!c && /* @__PURE__ */ l(
108
- z,
109
- {
110
- hasValue: !!s,
111
- label: c,
112
- htmlAttributes: p
113
- }
114
- ) }),
115
- /* @__PURE__ */ l(
116
- "div",
117
- {
118
- className: R(
119
- "flex gap-4",
120
- m === "column" ? "flex-col items-start" : "flex-row"
121
- ),
122
- ...a,
123
- children: r == null ? void 0 : r.map((i) => /* @__PURE__ */ L(
124
- N,
125
- {
126
- ...i,
127
- key: i.key,
128
- name: e,
129
- htmlAttributes: t ?? i.htmlAttributes,
130
- isStandalone: n,
131
- currentValue: s,
132
- setCurrentValue: h,
133
- onChange: u
134
- }
135
- ))
136
- }
137
- )
138
- ] });
139
- }
140
- );
141
- I.displayName = "RadioGroup";
142
- export {
143
- I as RadioGroup
144
- };