@purr-react-styled-components/components.radio-group 0.0.8 → 0.0.9
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 +7 -5
- package/dist/_components/_option.d.ts +0 -4
- package/dist/_components/index.d.ts +0 -4
- package/dist/_style.d.ts +0 -9
- package/dist/_types.d.ts +0 -34
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -76
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purr-react-styled-components/components.radio-group",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"react": "*",
|
|
26
26
|
"styled-components": "*",
|
|
27
27
|
"clsx": "*",
|
|
28
|
-
"@purr-core/utils.definitions": "0.0.
|
|
29
|
-
"@purr-core/utils.helpers": "0.0.
|
|
30
|
-
"@purr-core/hooks.sync-state-with-props": "0.0.
|
|
28
|
+
"@purr-core/utils.definitions": "0.0.11",
|
|
29
|
+
"@purr-core/utils.helpers": "0.0.11",
|
|
30
|
+
"@purr-core/hooks.sync-state-with-props": "0.0.8"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@purr-react-styled-components/components.form-field": "0.0.
|
|
33
|
+
"@purr-react-styled-components/components.form-field": "0.0.2"
|
|
34
34
|
},
|
|
35
35
|
"author": "@DinhThienPhuc",
|
|
36
36
|
"license": "ISC",
|
|
@@ -39,6 +39,8 @@
|
|
|
39
39
|
"scripts": {
|
|
40
40
|
"dev": "vite build --watch",
|
|
41
41
|
"build": "tsc && vite build",
|
|
42
|
+
"build:vite": "tsc && vite build",
|
|
43
|
+
"build:tsup": "tsup",
|
|
42
44
|
"lint": "eslint . --ext ts,tsx --max-warnings 0"
|
|
43
45
|
}
|
|
44
46
|
}
|
|
@@ -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, disabled, htmlAttributes, isStandalone, currentValue, setCurrentValue, onChange, }: IRadioGroupOptionProps) => React.JSX.Element>;
|
package/dist/_style.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const Styled: {
|
|
2
|
-
Container: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
|
-
$direction: "row" | "column";
|
|
4
|
-
}>> & string;
|
|
5
|
-
OptionLabel: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, {
|
|
6
|
-
$disabled?: boolean;
|
|
7
|
-
}>> & string;
|
|
8
|
-
OptionInput: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
|
|
9
|
-
};
|
package/dist/_types.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ChangeEvent, HTMLAttributes, LabelHTMLAttributes, ReactNode } 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?: ReactNode;
|
|
9
|
-
htmlAttributes?: LabelHTMLAttributes<HTMLLabelElement> & IExtendable;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface IRadioGroupOptionProps extends IRadioGroupOption {
|
|
13
|
-
name: string;
|
|
14
|
-
currentValue?: string;
|
|
15
|
-
isStandalone?: boolean;
|
|
16
|
-
setCurrentValue?: (value: string) => void;
|
|
17
|
-
onChange?: (value: string, e: ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
-
}
|
|
19
|
-
export interface IRadioGroupLabelProps {
|
|
20
|
-
label?: ReactNode;
|
|
21
|
-
htmlAttributes?: LabelHTMLAttributes<HTMLLabelElement> & IExtendable;
|
|
22
|
-
}
|
|
23
|
-
export interface IRadioGroupProps {
|
|
24
|
-
className?: string;
|
|
25
|
-
options: IRadioGroupOption[];
|
|
26
|
-
name: string;
|
|
27
|
-
value?: string;
|
|
28
|
-
isStandalone?: boolean;
|
|
29
|
-
direction?: TRadioGroupDirection;
|
|
30
|
-
disabled?: boolean;
|
|
31
|
-
htmlAttributes?: HTMLAttributes<HTMLDivElement> & IExtendable;
|
|
32
|
-
optionHtmlAttributes?: LabelHTMLAttributes<HTMLLabelElement> & IExtendable;
|
|
33
|
-
onChange?: (value: string, e: ChangeEvent<HTMLInputElement>) => void;
|
|
34
|
-
}
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),y=require("clsx"),m=require("react"),_=require("@purr-core/hooks.sync-state-with-props"),f=require("styled-components"),k=require("@purr-core/utils.helpers"),b={Container:f.div.withConfig({displayName:"_style__Container",componentId:"sc-192tru7-0"})(["display:flex;flex-direction:",";align-items:",";gap:16px;position:relative;"],({$direction:e})=>e,({$direction:e})=>e==="column"?"flex-start":"inherit"),OptionLabel:f.label.withConfig({displayName:"_style__OptionLabel",componentId:"sc-192tru7-1"})(["display:flex;align-items:center;gap:12px;cursor:",";opacity:",";"],({$disabled:e})=>e?"not-allowed":"pointer",({$disabled:e})=>e?.4:1),OptionInput:f.input.withConfig({displayName:"_style__OptionInput",componentId:"sc-192tru7-2"})(['appearance:none;width:16px;height:16px;border:1px solid #d9d9d9;border-radius:50%;background-color:#ffffff;cursor:pointer;transition:all 300ms ease-in-out;&::before{content:"";display:block;margin-top:4px;margin-left:4px;width:6px;height:6px;border-radius:50%;background-color:#ffffff;transform:scale(0);}&:checked::before{transform:scale(1);}&:checked{background-color:#44403c;border-color:#44403c;}&[type="radio" i]{margin:0;}&:hover:not(:disabled){border-color:#44403c;}'])},g=m.memo(({label:e,value:r,name:o,disabled:a,htmlAttributes:s,isStandalone:n,currentValue:p,setCurrentValue:t,onChange:i})=>{const c=n?void 0:p===r,h=m.useCallback(u=>{i==null||i(r,u),t==null||t(r)},[i,t,r]);return d.jsxs(b.OptionLabel,{$disabled:a,...s,className:"radio-group-option",children:[d.jsx(b.OptionInput,{className:y("radio-group-option-input",c?"radio-group-option-input--checked":""),name:o,type:"radio",value:r,checked:c,onChange:h,disabled:a}),e]})},k.arePropsShallowEqual(["currentValue"],(e,r,o)=>{switch(e){case"currentValue":return o.currentValue===o.value==(r.currentValue===r.value);default:return}}));g.displayName="RadioGroupOption";const x=m.forwardRef(({options:e,className:r,name:o,value:a="",onChange:s,isStandalone:n=!1,direction:p="column",disabled:t=!1,htmlAttributes:i,optionHtmlAttributes:c},h)=>{const{currentValue:u,setCurrentValue:w}=_(a,n);return d.jsx(b.Container,{...i,$direction:p,className:y("radio-group",r),children:e==null?void 0:e.map(l=>d.jsx(g,{label:l.label,value:l.value,name:o,htmlAttributes:c??l.htmlAttributes,isStandalone:n,currentValue:u,setCurrentValue:w,onChange:s,disabled:l.disabled??t},l.key))})});x.displayName="RadioGroup";exports.RadioGroup=x;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { jsxs as x, jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import h from "clsx";
|
|
3
|
-
import { memo as w, useCallback as k, forwardRef as N } from "react";
|
|
4
|
-
import _ from "@purr-core/hooks.sync-state-with-props";
|
|
5
|
-
import u from "styled-components";
|
|
6
|
-
import { arePropsShallowEqual as O } from "@purr-core/utils.helpers";
|
|
7
|
-
const f = {
|
|
8
|
-
Container: u.div.withConfig({
|
|
9
|
-
displayName: "_style__Container",
|
|
10
|
-
componentId: "sc-192tru7-0"
|
|
11
|
-
})(["display:flex;flex-direction:", ";align-items:", ";gap:16px;position:relative;"], ({
|
|
12
|
-
$direction: r
|
|
13
|
-
}) => r, ({
|
|
14
|
-
$direction: r
|
|
15
|
-
}) => r === "column" ? "flex-start" : "inherit"),
|
|
16
|
-
OptionLabel: u.label.withConfig({
|
|
17
|
-
displayName: "_style__OptionLabel",
|
|
18
|
-
componentId: "sc-192tru7-1"
|
|
19
|
-
})(["display:flex;align-items:center;gap:12px;cursor:", ";opacity:", ";"], ({
|
|
20
|
-
$disabled: r
|
|
21
|
-
}) => r ? "not-allowed" : "pointer", ({
|
|
22
|
-
$disabled: r
|
|
23
|
-
}) => r ? 0.4 : 1),
|
|
24
|
-
OptionInput: u.input.withConfig({
|
|
25
|
-
displayName: "_style__OptionInput",
|
|
26
|
-
componentId: "sc-192tru7-2"
|
|
27
|
-
})(['appearance:none;width:16px;height:16px;border:1px solid #d9d9d9;border-radius:50%;background-color:#ffffff;cursor:pointer;transition:all 300ms ease-in-out;&::before{content:"";display:block;margin-top:4px;margin-left:4px;width:6px;height:6px;border-radius:50%;background-color:#ffffff;transform:scale(0);}&:checked::before{transform:scale(1);}&:checked{background-color:#44403c;border-color:#44403c;}&[type="radio" i]{margin:0;}&:hover:not(:disabled){border-color:#44403c;}'])
|
|
28
|
-
}, y = w(({
|
|
29
|
-
label: r,
|
|
30
|
-
value: e,
|
|
31
|
-
name: o,
|
|
32
|
-
disabled: a,
|
|
33
|
-
htmlAttributes: d,
|
|
34
|
-
isStandalone: n,
|
|
35
|
-
currentValue: p,
|
|
36
|
-
setCurrentValue: t,
|
|
37
|
-
onChange: i
|
|
38
|
-
}) => {
|
|
39
|
-
const c = n ? void 0 : p === e, b = k((s) => {
|
|
40
|
-
i == null || i(e, s), t == null || t(e);
|
|
41
|
-
}, [i, t, e]);
|
|
42
|
-
return /* @__PURE__ */ x(f.OptionLabel, { $disabled: a, ...d, className: "radio-group-option", children: [
|
|
43
|
-
/* @__PURE__ */ m(f.OptionInput, { className: h("radio-group-option-input", c ? "radio-group-option-input--checked" : ""), name: o, type: "radio", value: e, checked: c, onChange: b, disabled: a }),
|
|
44
|
-
r
|
|
45
|
-
] });
|
|
46
|
-
}, O(["currentValue"], (r, e, o) => {
|
|
47
|
-
switch (r) {
|
|
48
|
-
case "currentValue":
|
|
49
|
-
return o.currentValue === o.value == (e.currentValue === e.value);
|
|
50
|
-
default:
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}));
|
|
54
|
-
y.displayName = "RadioGroupOption";
|
|
55
|
-
const R = N(({
|
|
56
|
-
options: r,
|
|
57
|
-
className: e,
|
|
58
|
-
name: o,
|
|
59
|
-
value: a = "",
|
|
60
|
-
onChange: d,
|
|
61
|
-
isStandalone: n = !1,
|
|
62
|
-
direction: p = "column",
|
|
63
|
-
disabled: t = !1,
|
|
64
|
-
htmlAttributes: i,
|
|
65
|
-
optionHtmlAttributes: c
|
|
66
|
-
}, b) => {
|
|
67
|
-
const {
|
|
68
|
-
currentValue: s,
|
|
69
|
-
setCurrentValue: g
|
|
70
|
-
} = _(a, n);
|
|
71
|
-
return /* @__PURE__ */ m(f.Container, { ...i, $direction: p, className: h("radio-group", e), children: r == null ? void 0 : r.map((l) => /* @__PURE__ */ m(y, { label: l.label, value: l.value, name: o, htmlAttributes: c ?? l.htmlAttributes, isStandalone: n, currentValue: s, setCurrentValue: g, onChange: d, disabled: l.disabled ?? t }, l.key)) });
|
|
72
|
-
});
|
|
73
|
-
R.displayName = "RadioGroup";
|
|
74
|
-
export {
|
|
75
|
-
R as RadioGroup
|
|
76
|
-
};
|