@happeouikit/form-elements 2.3.37 → 2.3.39
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/dist/Checkbox.types.d.ts +3 -3
- package/dist/RadioButton.d.ts +1 -1
- package/dist/RadioButton.types.d.ts +1 -0
- package/dist/Switch.types.d.ts +2 -1
- package/dist/index.cjs.js +21 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +251 -182
- package/dist/index.es.js.map +1 -1
- package/package.json +2 -2
package/dist/Checkbox.types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSProperties } from "react";
|
|
1
|
+
import { ChangeEvent, CSSProperties } from "react";
|
|
2
2
|
interface BaseCheckboxProps {
|
|
3
3
|
label?: string;
|
|
4
4
|
subtitle?: string;
|
|
@@ -6,7 +6,7 @@ interface BaseCheckboxProps {
|
|
|
6
6
|
indeterminate?: boolean;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
background?: string;
|
|
9
|
-
onChange:
|
|
9
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>, newVal: boolean) => void | any;
|
|
10
10
|
checked: boolean;
|
|
11
11
|
style?: CSSProperties;
|
|
12
12
|
id?: string;
|
|
@@ -29,7 +29,7 @@ export interface CheckboxGroupOption {
|
|
|
29
29
|
value: string;
|
|
30
30
|
background?: string;
|
|
31
31
|
disabled?: boolean;
|
|
32
|
-
onChange?: (newVal: boolean) => void;
|
|
32
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>, newVal: boolean) => void;
|
|
33
33
|
}
|
|
34
34
|
export interface CheckboxGroupProps {
|
|
35
35
|
value?: string[];
|
package/dist/RadioButton.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PropTypes from "prop-types";
|
|
2
2
|
import { RadioButtonProps } from "./RadioButton.types";
|
|
3
3
|
declare const RadioButton: {
|
|
4
|
-
({ label, subtitle, description, background, id, ...props }: RadioButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
({ label, subtitle, description, background, id, onChange, ...props }: RadioButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
propTypes: {
|
|
6
6
|
label: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
7
7
|
subtitle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
package/dist/Switch.types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export interface BaseSwitchProps {
|
|
2
3
|
tabIndex?: number;
|
|
3
4
|
id?: string;
|
|
@@ -10,7 +11,7 @@ export interface BaseSwitchProps {
|
|
|
10
11
|
"data-tracker"?: string;
|
|
11
12
|
"data-testid"?: string;
|
|
12
13
|
required?: boolean;
|
|
13
|
-
onChange?: (
|
|
14
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>, newVal: boolean) => void | any;
|
|
14
15
|
"aria-label"?: string;
|
|
15
16
|
"aria-expanded"?: boolean;
|
|
16
17
|
"aria-controls"?: string;
|
package/dist/index.cjs.js
CHANGED
|
@@ -212,7 +212,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
212
212
|
color: ${({hoverColor:e})=>e||N.active};
|
|
213
213
|
text-decoration: underline;
|
|
214
214
|
}
|
|
215
|
-
`;_a.propTypes={color:P.string,hoverColor:P.string,underline:P.bool,children:P.node};_a.defaultProps={color:N.active,hoverColor:N.active,underline:!1};const Ff=({label:e,subtitle:t,description:r,tabIndex:n,id:a,disabled:i,checked:o,defaultChecked:s,required:u,onChange:l,background:c,"data-tip":d,"data-tip-disable":m,"data-testid":p,...h})=>{const g=f.useRef(null),v=f.useCallback(C=>{if(!i&&(C.preventDefault(),g.current)){const k=!g.current.checked;C.currentTarget.setAttribute("aria-checked",k.toString()),g.current.checked=k,l==
|
|
215
|
+
`;_a.propTypes={color:P.string,hoverColor:P.string,underline:P.bool,children:P.node};_a.defaultProps={color:N.active,hoverColor:N.active,underline:!1};const Ff=({label:e,subtitle:t,description:r,tabIndex:n,id:a,disabled:i,checked:o,defaultChecked:s,required:u,onChange:l,background:c,"data-tip":d,"data-tip-disable":m,"data-testid":p,...h})=>{const g=f.useRef(null),v=f.useCallback(C=>{if(!i&&(C.preventDefault(),g.current)){const k=!g.current.checked;C.currentTarget.setAttribute("aria-checked",k.toString()),g.current.checked=k;const y={...C,target:{...g.current,checked:k,id:I}};typeof l=="function"&&l(y,k)}},[l]),b=f.useCallback(C=>{C.key.match(/enter|spacebar|\W{1}/i)&&v(C)},[v]),I=f.useMemo(()=>a||Ot(),[a]);return W.jsxs(Lf,{background:c,children:[W.jsx(Rf,{"aria-hidden":"true",ref:g,type:"checkbox",tabIndex:-1,disabled:i,checked:o,required:u,id:I,"data-testid":p,"aria-describedby":r?`${I}_description`:void 0}),W.jsx(Ln,{type:"button",role:"switch","aria-checked":o||s||!1,onKeyDown:b,onClick:v,disabled:i,background:c,...h}),e&&W.jsxs(Gf,{children:[W.jsxs(Bf,{children:[e&&W.jsx(Vf,{bold:!0,htmlFor:I,"data-tip":d,"data-tip-disable":m,onClick:v,children:e}),t&&W.jsx(Wf,{children:t})]}),r&&W.jsx(Yf,{id:`${I}_description`,children:r})]})]})},Rf=S.input`
|
|
216
216
|
position: absolute;
|
|
217
217
|
opacity: 0;
|
|
218
218
|
height: 0;
|
|
@@ -228,6 +228,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
228
228
|
background-color: ${({background:e})=>e||"var(--color-stroke)"};
|
|
229
229
|
border: 2px solid ${({background:e})=>e||"var(--color-stroke)"};
|
|
230
230
|
border-radius: var(--radius-pill);
|
|
231
|
+
flex-shrink: 0;
|
|
232
|
+
|
|
233
|
+
:active {
|
|
234
|
+
transform: none;
|
|
235
|
+
box-shadow: none;
|
|
236
|
+
}
|
|
231
237
|
|
|
232
238
|
:before {
|
|
233
239
|
position: absolute;
|
|
@@ -305,10 +311,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
305
311
|
|
|
306
312
|
input:disabled + ${Ln} {
|
|
307
313
|
cursor: not-allowed;
|
|
308
|
-
border-color:
|
|
314
|
+
border-color: transparent;
|
|
309
315
|
background-color: var(--color-disabled-text-on-light);
|
|
310
316
|
}
|
|
311
|
-
`,fs=({label:e,subtitle:t,description:r,indeterminate:n,onChange:a,style:i,disabled:o,checked:s,id:u,background:l,"data-tip":c,"data-tip-disable":d,...m})=>{const p=f.useRef(null);f.useEffect(()=>{p.current&&(p.current.indeterminate=n||!1)},[n]);const
|
|
317
|
+
`,fs=({label:e,subtitle:t,description:r,indeterminate:n,onChange:a,style:i,disabled:o,checked:s,id:u,background:l,"data-tip":c,"data-tip-disable":d,...m})=>{const p=f.useRef(null),h=f.useMemo(()=>u||Ot(),[u]);f.useEffect(()=>{p.current&&(p.current.indeterminate=n||!1)},[n]);const g=f.useCallback(b=>{if(!p.current||o)return;b.preventDefault();const I=!p.current.checked;if(p.current.checked=I,typeof a=="function"){const C={...b,target:{...p.current,checked:I,id:h}};a(C,I)}},[o,h,a]),v=f.useCallback(b=>{!b.key.match(/enter|spacebar|\W{1}/i)||!p.current||(b.preventDefault(),g(b))},[a]);return W.jsxs(Jf,{style:i,background:l,children:[W.jsx("input",{ref:p,type:"checkbox",tabIndex:-1,disabled:o,checked:s,"aria-checked":n?"mixed":s,"aria-disabled":o,"aria-describedby":r?`${h}_description`:void 0,id:h,...m}),n?W.jsx(kt,{onClick:g,onKeyDown:v,tabIndex:0,"aria-checked":"mixed","aria-disabled":o,background:l,...m,children:W.jsx(Zf,{})}):W.jsx(vt,{onClick:g,onKeyDown:v,tabIndex:0,"aria-checked":s,"aria-disabled":o,background:l,...m,children:W.jsx(Hf,{})}),e&&W.jsxs(Xf,{children:[W.jsxs(jf,{children:[e&&W.jsx($f,{onClick:g,bold:!0,htmlFor:h,"data-tip":c,"data-tip-disable":d,children:e}),t&&W.jsx(zf,{children:t})]}),r&&W.jsx(Uf,{id:`${h}_description`,children:r})]})]})},vt=S.span`
|
|
318
|
+
box-sizing: content-box;
|
|
312
319
|
cursor: pointer;
|
|
313
320
|
height: 16px;
|
|
314
321
|
width: 16px;
|
|
@@ -316,6 +323,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
316
323
|
background-color: transparent;
|
|
317
324
|
border: 2px solid ${({background:e})=>e||"var(--color-stroke)"};
|
|
318
325
|
position: relative;
|
|
326
|
+
flex-shrink: 0;
|
|
319
327
|
|
|
320
328
|
&:focus-visible {
|
|
321
329
|
outline: 0;
|
|
@@ -392,9 +400,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
392
400
|
background: var(--color-disabled-text-on-light);
|
|
393
401
|
}
|
|
394
402
|
|
|
395
|
-
input:disabled ~ div
|
|
396
|
-
|
|
397
|
-
|
|
403
|
+
input:disabled ~ div {
|
|
404
|
+
p,
|
|
405
|
+
label {
|
|
406
|
+
cursor: default;
|
|
407
|
+
color: var(--color-disabled-text-on-light);
|
|
408
|
+
}
|
|
398
409
|
}
|
|
399
410
|
|
|
400
411
|
:hover {
|
|
@@ -410,7 +421,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
410
421
|
${({background:e})=>e||"var(--color-active-darken10)"};
|
|
411
422
|
}
|
|
412
423
|
}
|
|
413
|
-
`,Qf=e=>e.map(t=>go(t)?{label:t,value:t}:t),Kf=e=>(t,r)=>{const n=e.findIndex(i=>i.value===t),a=e.findIndex(i=>i.value===r);return n-a},qf=e=>vo(e).map(({props:t})=>t),eh=e=>e.filter(({defaultChecked:t})=>t).map(({value:t})=>t),th="[CheckboxGroup] Both the `children` and `options` props have been used.\n The `options` prop will be ignored. To get rid of this warning, remove one of these props.",nh="[CheckboxGroup] Both the `defaultChecked` and `defaultValue` props have been used.\n The `defaultValue` prop will be ignored. To get rid of this warning, remove one of these props.",rh=({value:e,disabled:t,name:r,children:n,className:a,options:i,onChange:o,defaultValue:s})=>{ca(n&&i,th);const u=f.useMemo(()=>n?qf(n):Qf(i||[]),[n,i]),l=f.useMemo(()=>{const h=eh(u),g=!!h.length;return g&&s&&la(nh),g?h:s},[u,s]),[c,d]=f.useState(e||l||[]);f.useEffect(()=>{e&&d(e)},[e]);const m=h=>c.includes(h),p=(h,g)=>{h.onChange&&h.onChange(g);const
|
|
424
|
+
`,Qf=e=>e.map(t=>go(t)?{label:t,value:t}:t),Kf=e=>(t,r)=>{const n=e.findIndex(i=>i.value===t),a=e.findIndex(i=>i.value===r);return n-a},qf=e=>vo(e).map(({props:t})=>t),eh=e=>e.filter(({defaultChecked:t})=>t).map(({value:t})=>t),th="[CheckboxGroup] Both the `children` and `options` props have been used.\n The `options` prop will be ignored. To get rid of this warning, remove one of these props.",nh="[CheckboxGroup] Both the `defaultChecked` and `defaultValue` props have been used.\n The `defaultValue` prop will be ignored. To get rid of this warning, remove one of these props.",rh=({value:e,disabled:t,name:r,children:n,className:a,options:i,onChange:o,defaultValue:s})=>{ca(n&&i,th);const u=f.useMemo(()=>n?qf(n):Qf(i||[]),[n,i]),l=f.useMemo(()=>{const h=eh(u),g=!!h.length;return g&&s&&la(nh),g?h:s},[u,s]),[c,d]=f.useState(e||l||[]);f.useEffect(()=>{e&&d(e)},[e]);const m=h=>c.includes(h),p=(h,g,v)=>{h.onChange&&h.onChange(g,v);const I=(v?[...c,h.value]:c.filter(C=>C!==h.value)).sort(Kf(u));d(I),o&&o(I)};return W.jsx(ah,{className:a,children:u.map(h=>W.jsx("li",{children:W.jsx(fs,{label:h.label,background:h.background,name:r,disabled:h.disabled||t||!1,checked:m(h.value),onChange:(g,v)=>p(h,g,v)})},h.value))})},ah=S.ul`
|
|
414
425
|
list-style: none;
|
|
415
426
|
display: flex;
|
|
416
427
|
flex-direction: column;
|
|
@@ -419,7 +430,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
419
430
|
padding-inline-start: 0;
|
|
420
431
|
padding-inline-end: 0;
|
|
421
432
|
padding-block-start: 0;
|
|
422
|
-
`,Oa=({label:e,subtitle:t,description:r,background:n,id:a,...
|
|
433
|
+
`,Oa=({label:e,subtitle:t,description:r,background:n,id:a,onChange:i,...o})=>{const[s]=f.useState(()=>a||`radio_${Ot()}`),u=f.useCallback(c=>{if(o.disabled)return;c.preventDefault();const d={...c,target:{...c.target,checked:!0,id:s}};typeof i=="function"&&i(d,!0)},[s,i,o.disabled]),l=f.useCallback(c=>{c.key.match(/enter|spacebar|\W{1}/i)&&(c.preventDefault(),u(c))},[u]);return W.jsxs(ch,{background:n,children:[W.jsx("input",{type:"radio","aria-describedby":r?`${s}_description`:void 0,...o,id:s,onKeyDown:l}),W.jsx(on,{onClick:u,onKeyDown:l,background:n}),e&&W.jsxs(ih,{children:[W.jsxs(oh,{children:[e&&W.jsx(lh,{bold:!0,htmlFor:s,"data-tip":o["data-tip"],"data-tip-disable":o["data-tip-disable"],onClick:u,children:e}),t&&W.jsx(sh,{children:t})]}),r&&W.jsx(uh,{id:`${s}_description`,children:r})]})]})};Oa.propTypes={label:P.node,subtitle:P.node,description:P.node};Oa.defaultProps={label:null};const on=S.span`
|
|
434
|
+
box-sizing: content-box;
|
|
423
435
|
position: relative;
|
|
424
436
|
height: 16px;
|
|
425
437
|
width: 16px;
|
|
@@ -427,6 +439,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
427
439
|
border: 2px solid ${({background:e})=>e||"var(--color-stroke)"};
|
|
428
440
|
border-radius: var(--radius-circle);
|
|
429
441
|
flex-shrink: 0;
|
|
442
|
+
cursor: pointer;
|
|
430
443
|
input:focus + & {
|
|
431
444
|
:before {
|
|
432
445
|
content: "";
|