@brightlocal/ui-components 2.27.0 → 3.0.0
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 +6 -1
- package/component-meta.json +480 -126
- package/deprecations.json +189 -2
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +2 -2
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.js +18 -18
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +11 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +31 -28
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +4 -4
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +15 -11
- package/dist/blocks/empty-state.cjs +1 -0
- package/dist/blocks/empty-state.d.ts +172 -0
- package/dist/blocks/empty-state.d.ts.map +1 -0
- package/dist/blocks/empty-state.js +155 -0
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +124 -108
- package/dist/blocks/progress-state.cjs +1 -0
- package/dist/blocks/{progress-screen.d.ts → progress-state.d.ts} +30 -18
- package/dist/blocks/progress-state.d.ts.map +1 -0
- package/dist/blocks/{progress-screen.js → progress-state.js} +100 -71
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +160 -161
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +11 -11
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +37 -38
- package/dist/callout.cjs +1 -1
- package/dist/callout.d.ts +24 -2
- package/dist/callout.d.ts.map +1 -1
- package/dist/callout.js +57 -55
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +23 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +94 -91
- package/dist/chart-empty.cjs +1 -0
- package/dist/chart-empty.d.ts +59 -0
- package/dist/chart-empty.d.ts.map +1 -0
- package/dist/chart-empty.js +29 -0
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -1
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +183 -183
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +5 -3
- package/dist/combobox.cjs +2 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +81 -79
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +74 -77
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +26 -29
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +44 -10
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +13 -11
- package/dist/description.cjs +1 -1
- package/dist/description.js +5 -5
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +20 -20
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +8 -11
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +17 -20
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +29 -25
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +27 -1
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +18 -16
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +56 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +32 -0
- package/dist/header.d.ts +13 -0
- package/dist/header.d.ts.map +1 -1
- package/dist/hooks/use-delayed-pending.cjs +1 -0
- package/dist/hooks/use-delayed-pending.d.ts +34 -0
- package/dist/hooks/use-delayed-pending.d.ts.map +1 -0
- package/dist/hooks/use-delayed-pending.js +17 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +13 -13
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +512 -494
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +25 -25
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +9 -9
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +9 -9
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +51 -51
- package/dist/input.cjs +1 -1
- package/dist/input.js +9 -9
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +25 -28
- package/dist/lib/block-illustration.cjs +1 -0
- package/dist/lib/block-illustration.d.ts +28 -0
- package/dist/lib/block-illustration.d.ts.map +1 -0
- package/dist/lib/block-illustration.js +21 -0
- package/dist/lib/empty-canvas.cjs +1 -0
- package/dist/lib/empty-canvas.d.ts +27 -0
- package/dist/lib/empty-canvas.d.ts.map +1 -0
- package/dist/lib/empty-canvas.js +62 -0
- package/dist/lib/optical-center.cjs +1 -0
- package/dist/lib/optical-center.d.ts +12 -0
- package/dist/lib/optical-center.d.ts.map +1 -0
- package/dist/lib/optical-center.js +11 -0
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +28 -5
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +62 -58
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +60 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +187 -164
- package/dist/media-empty.cjs +1 -0
- package/dist/media-empty.d.ts +72 -0
- package/dist/media-empty.d.ts.map +1 -0
- package/dist/media-empty.js +45 -0
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +17 -20
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +7 -7
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +127 -1
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +189 -98
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +2 -26
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +79 -118
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +19 -18
- package/dist/separator.cjs +1 -1
- package/dist/separator.js +8 -8
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +2 -2
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +38 -3
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +43 -20
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.js +26 -26
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +40 -40
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +31 -28
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-reveal-motion.d.ts +10 -0
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +11 -11
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +8 -8
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +8 -8
- package/dist/typography-heading.cjs +1 -0
- package/dist/typography-heading.d.ts +116 -0
- package/dist/typography-heading.d.ts.map +1 -0
- package/dist/typography-heading.js +84 -0
- package/dist/typography-text.cjs +1 -0
- package/dist/typography-text.d.ts +113 -0
- package/dist/typography-text.d.ts.map +1 -0
- package/dist/typography-text.js +81 -0
- package/dist/typography.d.ts +13 -0
- package/dist/typography.d.ts.map +1 -1
- package/package.json +35 -7
- package/src/blocks/empty-state.tsx +424 -0
- package/src/blocks/input-list.tsx +66 -36
- package/src/blocks/{progress-screen.tsx → progress-state.tsx} +154 -93
- package/src/blocks/sidebar.tsx +25 -26
- package/src/components/accordion.tsx +2 -2
- package/src/components/alert-dialog.tsx +2 -2
- package/src/components/alert.tsx +27 -13
- package/src/components/avatar.tsx +1 -1
- package/src/components/badge.tsx +8 -4
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +3 -3
- package/src/components/calendar.tsx +5 -6
- package/src/components/callout.tsx +48 -15
- package/src/components/card.tsx +52 -17
- package/src/components/chart-empty.tsx +116 -0
- package/src/components/chart.tsx +43 -17
- package/src/components/chip.tsx +5 -3
- package/src/components/combobox.tsx +12 -10
- package/src/components/command.tsx +9 -10
- package/src/components/context-menu.tsx +6 -9
- package/src/components/data-table.tsx +72 -17
- package/src/components/description.tsx +1 -1
- package/src/components/dialog.tsx +2 -2
- package/src/components/drawer.tsx +2 -5
- package/src/components/dropdown-menu.tsx +8 -11
- package/src/components/field.tsx +8 -4
- package/src/components/global-layout.tsx +36 -3
- package/src/components/grid.tsx +130 -0
- package/src/components/header.tsx +13 -0
- package/src/components/hover-card.tsx +1 -1
- package/src/components/input-chip.tsx +1 -1
- package/src/components/input-group.tsx +1 -1
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input-password.tsx +1 -1
- package/src/components/input.tsx +1 -1
- package/src/components/label.tsx +10 -13
- package/src/components/list.tsx +13 -9
- package/src/components/map.tsx +101 -5
- package/src/components/media-empty.tsx +156 -0
- package/src/components/menubar.tsx +7 -10
- package/src/components/navigation-menu.tsx +1 -1
- package/src/components/pagination.tsx +279 -1
- package/src/components/progress.tsx +35 -113
- package/src/components/select.tsx +5 -4
- package/src/components/separator.tsx +1 -1
- package/src/components/sheet.tsx +2 -2
- package/src/components/skeleton.tsx +78 -7
- package/src/components/sonner.tsx +2 -2
- package/src/components/stepper.tsx +3 -3
- package/src/components/table.tsx +6 -3
- package/src/components/tabs.tsx +1 -1
- package/src/components/text-reveal-motion.tsx +10 -0
- package/src/components/textarea.tsx +1 -1
- package/src/components/toggle.tsx +1 -1
- package/src/components/tooltip.tsx +1 -1
- package/src/components/typography-heading.tsx +229 -0
- package/src/components/typography-text.tsx +225 -0
- package/src/components/typography.tsx +13 -0
- package/src/hooks/use-delayed-pending.ts +60 -0
- package/src/index.ts +10 -1
- package/src/lib/block-illustration.tsx +88 -0
- package/src/lib/empty-canvas.tsx +128 -0
- package/src/lib/optical-center.tsx +45 -0
- package/src/lib/utils.ts +26 -0
- package/dist/blocks/progress-screen.cjs +0 -1
- package/dist/blocks/progress-screen.d.ts.map +0 -1
package/dist/input-chip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),$=require("react"),B=require("class-variance-authority"),j=require("@brightlocal/ui-components/lib/utils"),K=require("@brightlocal/ui-components/chip");function T(r){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(f,o,s.get?s:{enumerable:!0,get:()=>r[o]})}}return f.default=r,Object.freeze(f)}const n=T($),F=n.createContext(null),O=n.createContext(null),P=n.createContext(null);function E(){const r=n.useContext(F);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function S(){const r=n.useContext(O);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function q(){const r=n.useContext(P);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function _(){const r=E(),{value:f,disabled:o}=S(),{inputValue:s,focusedChipIndex:l}=q();return{...r,value:f,disabled:o,inputValue:s,focusedChipIndex:l}}function L({value:r,defaultValue:f=[],onValueChange:o,disabled:s=!1,allowDuplicates:l=!1,children:c}){const[h,a]=n.useState(f),[g,i]=n.useState(""),[b,w]=n.useState(-1),y=n.useRef(null),t=n.useRef([]),e=r!==void 0,u=e?r:h,d=n.useRef(u),I=n.useRef(o),R=n.useRef(s);n.useLayoutEffect(()=>{d.current=u,I.current=o,R.current=s}),n.useEffect(()=>{t.current.length>u.length&&(t.current.length=u.length),b>=u.length&&w(-1)},[u.length,b]);const p=n.useCallback(x=>{e||a(x),I.current?.(x)},[e]),k=n.useCallback(x=>{if(R.current)return;const V=x.trim();V&&(l||!d.current.includes(V))&&(p([...d.current,V]),i(""))},[l,p]),D=n.useCallback(x=>{R.current||p(d.current.filter((V,N)=>N!==x))},[p]),C=n.useMemo(()=>({onValueChange:p,setInputValue:i,addItem:k,removeItem:D,inputRef:y,setFocusedChipIndex:w,chipRefs:t}),[p,k,D]),v=n.useMemo(()=>({value:u,disabled:s}),[u,s]),M=n.useMemo(()=>({inputValue:g,focusedChipIndex:b}),[g,b]);return m.jsx(F.Provider,{value:C,children:m.jsx(O.Provider,{value:v,children:m.jsx(P.Provider,{value:M,children:c})})})}const H=B.cva(["relative flex w-full flex-wrap items-center gap-1","min-h-9 rounded-sm border border-input bg-background","px-3 py-2","has-[:focus-visible]:border-ring has-[:focus-visible]:bg-background","has-[:focus-visible]:shadow-default","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50","transition-[color,box-shadow,border-color]","duration-fast","ease-out"],{variants:{error:{true:["border-destructive-40","has-[:focus-visible]:border-destructive-40 has-[:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{error:!1}}),W=["flex-1 min-w-20","bg-transparent","border-0 outline-none","text-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),$=require("react"),B=require("class-variance-authority"),j=require("@brightlocal/ui-components/lib/utils"),K=require("@brightlocal/ui-components/chip");function T(r){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(f,o,s.get?s:{enumerable:!0,get:()=>r[o]})}}return f.default=r,Object.freeze(f)}const n=T($),F=n.createContext(null),O=n.createContext(null),P=n.createContext(null);function E(){const r=n.useContext(F);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function S(){const r=n.useContext(O);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function q(){const r=n.useContext(P);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function _(){const r=E(),{value:f,disabled:o}=S(),{inputValue:s,focusedChipIndex:l}=q();return{...r,value:f,disabled:o,inputValue:s,focusedChipIndex:l}}function L({value:r,defaultValue:f=[],onValueChange:o,disabled:s=!1,allowDuplicates:l=!1,children:c}){const[h,a]=n.useState(f),[g,i]=n.useState(""),[b,w]=n.useState(-1),y=n.useRef(null),t=n.useRef([]),e=r!==void 0,u=e?r:h,d=n.useRef(u),I=n.useRef(o),R=n.useRef(s);n.useLayoutEffect(()=>{d.current=u,I.current=o,R.current=s}),n.useEffect(()=>{t.current.length>u.length&&(t.current.length=u.length),b>=u.length&&w(-1)},[u.length,b]);const p=n.useCallback(x=>{e||a(x),I.current?.(x)},[e]),k=n.useCallback(x=>{if(R.current)return;const V=x.trim();V&&(l||!d.current.includes(V))&&(p([...d.current,V]),i(""))},[l,p]),D=n.useCallback(x=>{R.current||p(d.current.filter((V,N)=>N!==x))},[p]),C=n.useMemo(()=>({onValueChange:p,setInputValue:i,addItem:k,removeItem:D,inputRef:y,setFocusedChipIndex:w,chipRefs:t}),[p,k,D]),v=n.useMemo(()=>({value:u,disabled:s}),[u,s]),M=n.useMemo(()=>({inputValue:g,focusedChipIndex:b}),[g,b]);return m.jsx(F.Provider,{value:C,children:m.jsx(O.Provider,{value:v,children:m.jsx(P.Provider,{value:M,children:c})})})}const H=B.cva(["relative flex w-full flex-wrap items-center gap-1","min-h-9 rounded-sm border border-input bg-background","px-3 py-2","has-[:focus-visible]:border-ring has-[:focus-visible]:bg-background","has-[:focus-visible]:shadow-default","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50","transition-[color,box-shadow,border-color]","duration-fast","ease-out"],{variants:{error:{true:["border-destructive-40","has-[:focus-visible]:border-destructive-40 has-[:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{error:!1}}),W=["flex-1 min-w-20","bg-transparent","border-0 outline-none","text-body","text-foreground","placeholder:text-muted-foreground","focus:outline-none focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50"],A=n.forwardRef(({className:r,error:f=!1,dataHook:o,trackingEl:s,trackingLabel:l,placeholder:c,inputId:h,"aria-label":a,"aria-labelledby":g,children:i,...b},w)=>{const{setInputValue:y,addItem:t,inputRef:e,setFocusedChipIndex:u,chipRefs:d}=E(),{value:I,disabled:R}=S(),{inputValue:p}=q(),k=C=>{y(C.target.value)},D=C=>{if(C.key==="Enter"&&p.trim()&&(C.preventDefault(),t(p)),C.key==="ArrowLeft"&&!p&&I.length>0){C.preventDefault();const v=I.length-1;u(v),d.current[v]?.focus()}if(C.key==="Backspace"&&!p&&I.length>0){C.preventDefault();const v=I.length-1;u(v),d.current[v]?.focus()}};return m.jsxs("div",{ref:w,className:j.cn(H({error:f}),r),"data-hook":o,"data-slot":"input-chip","data-tracking-el":s,"data-tracking-label":l,...b,children:[i,m.jsx("input",{ref:e,"aria-label":a,"aria-labelledby":g,className:j.cn(W),"data-slot":"input-chip-input",disabled:R,id:h,placeholder:c,type:"text",value:p,onChange:k,onKeyDown:D})]})});A.displayName="InputChipInput";function z({className:r,dataHookPrefix:f="chip",itemAriaLabel:o}){const{removeItem:s,inputRef:l,setFocusedChipIndex:c,chipRefs:h}=E(),{value:a,disabled:g}=S(),i=n.useRef(null);n.useEffect(()=>{if(i.current!==null){if(i.current==="input")l.current?.focus();else{const t=i.current;t>=0&&t<a.length?h.current[t]?.focus():a.length>0?h.current[a.length-1]?.focus():l.current?.focus()}i.current=null}},[a.length,l,h]);const b=(t,e)=>{if(!g)switch(t.key){case"ArrowLeft":t.preventDefault(),e>0&&(c(e-1),h.current[e-1]?.focus());break;case"ArrowRight":t.preventDefault(),e<a.length-1?(c(e+1),h.current[e+1]?.focus()):(c(-1),l.current?.focus());break;case"Backspace":case"Delete":{t.preventDefault();const u=a.length-1;if(u===0)c(-1),i.current="input",s(e);else if(e>=u){const d=u-1;c(d),i.current=d,s(e)}else c(e),i.current=e,s(e);break}case"Home":t.preventDefault(),a.length>0&&(c(0),h.current[0]?.focus());break;case"End":t.preventDefault(),c(-1),l.current?.focus();break}},w=t=>{c(t)},y=t=>{const e=t.relatedTarget;e&&(e.closest('[data-slot="chip"]')!==null||e.dataset.slot==="input-chip-input")||c(-1)};return a.length===0?null:m.jsx("div",{className:j.cn("contents",r),"data-slot":"input-chip-items",children:a.map((t,e)=>m.jsx(K.Chip,{ref:u=>{h.current[e]=u},"aria-label":o?o.replace("{item}",t):`${t}, press Delete to remove`,dataHook:`${f}-${e}`,disabled:g,role:"group",tabIndex:-1,onBlur:y,onFocus:()=>w(e),onKeyDown:u=>b(u,e),onRemove:()=>s(e),children:t},`${t}-${e}`))})}exports.InputChip=L;exports.InputChipInput=A;exports.InputChipItems=z;exports.useInputChipContext=_;
|
package/dist/input-chip.js
CHANGED
|
@@ -23,12 +23,12 @@ function N() {
|
|
|
23
23
|
return u;
|
|
24
24
|
}
|
|
25
25
|
function G() {
|
|
26
|
-
const u = F(), { value: b, disabled: d } = $(), { inputValue:
|
|
26
|
+
const u = F(), { value: b, disabled: d } = $(), { inputValue: s, focusedChipIndex: c } = N();
|
|
27
27
|
return {
|
|
28
28
|
...u,
|
|
29
29
|
value: b,
|
|
30
30
|
disabled: d,
|
|
31
|
-
inputValue:
|
|
31
|
+
inputValue: s,
|
|
32
32
|
focusedChipIndex: c
|
|
33
33
|
};
|
|
34
34
|
}
|
|
@@ -36,13 +36,13 @@ function J({
|
|
|
36
36
|
value: u,
|
|
37
37
|
defaultValue: b = [],
|
|
38
38
|
onValueChange: d,
|
|
39
|
-
disabled:
|
|
39
|
+
disabled: s = !1,
|
|
40
40
|
allowDuplicates: c = !1,
|
|
41
|
-
children:
|
|
41
|
+
children: o
|
|
42
42
|
}) {
|
|
43
|
-
const [p, a] = n.useState(b), [v, l] = n.useState(""), [C, I] = n.useState(-1), k = n.useRef(null), t = n.useRef([]), e = u !== void 0, r = e ? u : p, f = n.useRef(r), g = n.useRef(d), R = n.useRef(
|
|
43
|
+
const [p, a] = n.useState(b), [v, l] = n.useState(""), [C, I] = n.useState(-1), k = n.useRef(null), t = n.useRef([]), e = u !== void 0, r = e ? u : p, f = n.useRef(r), g = n.useRef(d), R = n.useRef(s);
|
|
44
44
|
n.useLayoutEffect(() => {
|
|
45
|
-
f.current = r, g.current = d, R.current =
|
|
45
|
+
f.current = r, g.current = d, R.current = s;
|
|
46
46
|
}), n.useEffect(() => {
|
|
47
47
|
t.current.length > r.length && (t.current.length = r.length), C >= r.length && I(-1);
|
|
48
48
|
}, [r.length, C]);
|
|
@@ -75,13 +75,13 @@ function J({
|
|
|
75
75
|
}),
|
|
76
76
|
[i, y, D]
|
|
77
77
|
), m = n.useMemo(
|
|
78
|
-
() => ({ value: r, disabled:
|
|
79
|
-
[r,
|
|
78
|
+
() => ({ value: r, disabled: s }),
|
|
79
|
+
[r, s]
|
|
80
80
|
), S = n.useMemo(
|
|
81
81
|
() => ({ inputValue: v, focusedChipIndex: C }),
|
|
82
82
|
[v, C]
|
|
83
83
|
);
|
|
84
|
-
return /* @__PURE__ */ x(A.Provider, { value: h, children: /* @__PURE__ */ x(B.Provider, { value: m, children: /* @__PURE__ */ x(K.Provider, { value: S, children:
|
|
84
|
+
return /* @__PURE__ */ x(A.Provider, { value: h, children: /* @__PURE__ */ x(B.Provider, { value: m, children: /* @__PURE__ */ x(K.Provider, { value: S, children: o }) }) });
|
|
85
85
|
}
|
|
86
86
|
const H = P(
|
|
87
87
|
[
|
|
@@ -120,7 +120,7 @@ const H = P(
|
|
|
120
120
|
"bg-transparent",
|
|
121
121
|
"border-0 outline-none",
|
|
122
122
|
// Typography
|
|
123
|
-
"text-
|
|
123
|
+
"text-body",
|
|
124
124
|
"text-foreground",
|
|
125
125
|
// Placeholder
|
|
126
126
|
"placeholder:text-muted-foreground",
|
|
@@ -133,9 +133,9 @@ const H = P(
|
|
|
133
133
|
className: u,
|
|
134
134
|
error: b = !1,
|
|
135
135
|
dataHook: d,
|
|
136
|
-
trackingEl:
|
|
136
|
+
trackingEl: s,
|
|
137
137
|
trackingLabel: c,
|
|
138
|
-
placeholder:
|
|
138
|
+
placeholder: o,
|
|
139
139
|
inputId: p,
|
|
140
140
|
"aria-label": a,
|
|
141
141
|
"aria-labelledby": v,
|
|
@@ -163,7 +163,7 @@ const H = P(
|
|
|
163
163
|
className: E(H({ error: b }), u),
|
|
164
164
|
"data-hook": d,
|
|
165
165
|
"data-slot": "input-chip",
|
|
166
|
-
"data-tracking-el":
|
|
166
|
+
"data-tracking-el": s,
|
|
167
167
|
"data-tracking-label": c,
|
|
168
168
|
...C,
|
|
169
169
|
children: [
|
|
@@ -178,7 +178,7 @@ const H = P(
|
|
|
178
178
|
"data-slot": "input-chip-input",
|
|
179
179
|
disabled: R,
|
|
180
180
|
id: p,
|
|
181
|
-
placeholder:
|
|
181
|
+
placeholder: o,
|
|
182
182
|
type: "text",
|
|
183
183
|
value: i,
|
|
184
184
|
onChange: y,
|
|
@@ -196,7 +196,7 @@ function O({
|
|
|
196
196
|
dataHookPrefix: b = "chip",
|
|
197
197
|
itemAriaLabel: d
|
|
198
198
|
}) {
|
|
199
|
-
const { removeItem:
|
|
199
|
+
const { removeItem: s, inputRef: c, setFocusedChipIndex: o, chipRefs: p } = F(), { value: a, disabled: v } = $(), l = n.useRef(null);
|
|
200
200
|
n.useEffect(() => {
|
|
201
201
|
if (l.current !== null) {
|
|
202
202
|
if (l.current === "input")
|
|
@@ -212,36 +212,36 @@ function O({
|
|
|
212
212
|
if (!v)
|
|
213
213
|
switch (t.key) {
|
|
214
214
|
case "ArrowLeft":
|
|
215
|
-
t.preventDefault(), e > 0 && (
|
|
215
|
+
t.preventDefault(), e > 0 && (o(e - 1), p.current[e - 1]?.focus());
|
|
216
216
|
break;
|
|
217
217
|
case "ArrowRight":
|
|
218
|
-
t.preventDefault(), e < a.length - 1 ? (
|
|
218
|
+
t.preventDefault(), e < a.length - 1 ? (o(e + 1), p.current[e + 1]?.focus()) : (o(-1), c.current?.focus());
|
|
219
219
|
break;
|
|
220
220
|
case "Backspace":
|
|
221
221
|
case "Delete": {
|
|
222
222
|
t.preventDefault();
|
|
223
223
|
const r = a.length - 1;
|
|
224
224
|
if (r === 0)
|
|
225
|
-
|
|
225
|
+
o(-1), l.current = "input", s(e);
|
|
226
226
|
else if (e >= r) {
|
|
227
227
|
const f = r - 1;
|
|
228
|
-
|
|
228
|
+
o(f), l.current = f, s(e);
|
|
229
229
|
} else
|
|
230
|
-
|
|
230
|
+
o(e), l.current = e, s(e);
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
233
|
case "Home":
|
|
234
|
-
t.preventDefault(), a.length > 0 && (
|
|
234
|
+
t.preventDefault(), a.length > 0 && (o(0), p.current[0]?.focus());
|
|
235
235
|
break;
|
|
236
236
|
case "End":
|
|
237
|
-
t.preventDefault(),
|
|
237
|
+
t.preventDefault(), o(-1), c.current?.focus();
|
|
238
238
|
break;
|
|
239
239
|
}
|
|
240
240
|
}, I = (t) => {
|
|
241
|
-
|
|
241
|
+
o(t);
|
|
242
242
|
}, k = (t) => {
|
|
243
243
|
const e = t.relatedTarget;
|
|
244
|
-
e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") ||
|
|
244
|
+
e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") || o(-1);
|
|
245
245
|
};
|
|
246
246
|
return a.length === 0 ? null : /* @__PURE__ */ x("div", { className: E("contents", u), "data-slot": "input-chip-items", children: a.map((t, e) => /* @__PURE__ */ x(
|
|
247
247
|
j,
|
|
@@ -257,7 +257,7 @@ function O({
|
|
|
257
257
|
onBlur: k,
|
|
258
258
|
onFocus: () => I(e),
|
|
259
259
|
onKeyDown: (r) => C(r, e),
|
|
260
|
-
onRemove: () =>
|
|
260
|
+
onRemove: () => s(e),
|
|
261
261
|
children: t
|
|
262
262
|
},
|
|
263
263
|
`${t}-${e}`
|
package/dist/input-group.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),m=require("react"),x=require("@radix-ui/react-slot"),l=require("class-variance-authority"),a=require("@brightlocal/ui-components/lib/utils"),G=require("./input.cjs");function I(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const u=I(m),c=l.cva("relative flex w-full items-center rounded-sm border border-input bg-background transition-[color,background-color,border-color,box-shadow] duration-fast ease-out has-[input:focus-visible]:border-ring has-[input:focus-visible]:shadow-default has-[:disabled]:opacity-50",{variants:{size:{default:"h-9",sm:"h-8",lg:"h-10"},error:{true:["border-destructive-40","has-[input:focus-visible]:border-destructive-40 has-[input:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{size:"default",error:!1}}),p=u.forwardRef(({className:t,size:n,error:e,dataHook:o,trackingEl:s,trackingLabel:i,...d},h)=>r.jsx("div",{ref:h,className:a.cn(c({size:n,error:e}),t),"data-hook":o,"data-slot":"input-group","data-tracking-el":s,"data-tracking-label":i,...d}));p.displayName="InputGroup";const f=u.forwardRef(({className:t,...n},e)=>r.jsx(G.Input,{ref:e,className:a.cn("border-0 focus-visible:border-0 focus-visible:shadow-[none]","h-full",t),dataHook:"input-group-input",...n}));f.displayName="InputGroupInput";const w=l.cva("flex shrink-0 items-center text-muted-foreground",{variants:{align:{"inline-start":"","inline-end":"ml-auto","block-start":"self-start","block-end":"self-end"}},defaultVariants:{align:"inline-start"}}),b=u.forwardRef(({className:t,align:n,...e},o)=>r.jsx("div",{ref:o,className:a.cn(w({align:n}),t),"data-slot":"input-group-addon",...e}));b.displayName="InputGroupAddon";const g=l.cva(["inline-flex items-center justify-center gap-2","text-label transition-colors duration-fast ease-out","outline-none focus-visible:shadow-default rounded-sm","disabled:pointer-events-none disabled:opacity-50","text-muted-foreground hover:text-foreground","[&_svg]:pointer-events-none [&_svg]:shrink-0"],{variants:{variant:{default:"hover:bg-accent",ghost:""},size:{default:"h-9 px-3",sm:"h-8 px-2",lg:"h-10 px-4",icon:"h-9 w-9","icon-xs":"h-6 w-6","icon-sm":"h-8 w-8","icon-lg":"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),v=u.forwardRef(({className:t,variant:n,size:e,asChild:o=!1,...s},i)=>{const d=o?x.Slot:"button";return r.jsx(d,{ref:i,className:a.cn(g({variant:n,size:e,className:t})),"data-slot":"input-group-button",type:o?void 0:"button",...s})});v.displayName="InputGroupButton";exports.InputGroup=p;exports.InputGroupAddon=b;exports.InputGroupButton=v;exports.InputGroupInput=f;exports.inputGroupButtonVariants=g;exports.inputGroupVariants=c;
|
package/dist/input-group.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import * as n from "react";
|
|
3
3
|
import { Slot as f } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva as d } from "class-variance-authority";
|
|
5
5
|
import { cn as s } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -26,8 +26,8 @@ const m = d(
|
|
|
26
26
|
error: !1
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
), b =
|
|
30
|
-
({ className: t, size: o, error: e, dataHook: r, trackingEl: i, trackingLabel: u, ...l }, p) => /* @__PURE__ */
|
|
29
|
+
), b = n.forwardRef(
|
|
30
|
+
({ className: t, size: o, error: e, dataHook: r, trackingEl: i, trackingLabel: u, ...l }, p) => /* @__PURE__ */ a(
|
|
31
31
|
"div",
|
|
32
32
|
{
|
|
33
33
|
ref: p,
|
|
@@ -41,7 +41,7 @@ const m = d(
|
|
|
41
41
|
)
|
|
42
42
|
);
|
|
43
43
|
b.displayName = "InputGroup";
|
|
44
|
-
const h =
|
|
44
|
+
const h = n.forwardRef(({ className: t, ...o }, e) => /* @__PURE__ */ a(
|
|
45
45
|
c,
|
|
46
46
|
{
|
|
47
47
|
ref: e,
|
|
@@ -71,8 +71,8 @@ const v = d(
|
|
|
71
71
|
align: "inline-start"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
), g =
|
|
75
|
-
({ className: t, align: o, ...e }, r) => /* @__PURE__ */
|
|
74
|
+
), g = n.forwardRef(
|
|
75
|
+
({ className: t, align: o, ...e }, r) => /* @__PURE__ */ a(
|
|
76
76
|
"div",
|
|
77
77
|
{
|
|
78
78
|
ref: r,
|
|
@@ -86,7 +86,7 @@ g.displayName = "InputGroupAddon";
|
|
|
86
86
|
const w = d(
|
|
87
87
|
[
|
|
88
88
|
"inline-flex items-center justify-center gap-2",
|
|
89
|
-
"text-
|
|
89
|
+
"text-label transition-colors duration-fast ease-out",
|
|
90
90
|
"outline-none focus-visible:shadow-default rounded-sm",
|
|
91
91
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
92
92
|
"text-muted-foreground hover:text-foreground",
|
|
@@ -113,7 +113,7 @@ const w = d(
|
|
|
113
113
|
size: "default"
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
), x =
|
|
116
|
+
), x = n.forwardRef(({ className: t, variant: o, size: e, asChild: r = !1, ...i }, u) => /* @__PURE__ */ a(
|
|
117
117
|
r ? f : "button",
|
|
118
118
|
{
|
|
119
119
|
ref: u,
|
package/dist/input-otp.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),S=require("react"),l=require("input-otp"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),S=require("react"),l=require("input-otp"),y=require("@brightlocal/icons"),x=require("@brightlocal/ui-components/lib/utils");function _(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:()=>t[o]})}}return n.default=t,Object.freeze(n)}const i=_(S),g=i.createContext(null);function v(){const t=i.useContext(g);if(!t)throw new Error("InputOTP components must be used within an <InputOTP>");return t}const p=i.forwardRef(({dataHook:t,trackingEl:n,trackingLabel:o,containerClassName:r,error:a,disabled:u,children:s,...c},m)=>{const O=i.useMemo(()=>({error:a,disabled:u}),[a,u]);return e.jsx(g.Provider,{value:O,children:e.jsx(l.OTPInput,{ref:m,"aria-invalid":a?"true":void 0,className:"disabled:cursor-not-allowed",containerClassName:x.cn("group flex items-center gap-2 has-disabled:opacity-50 w-fit",r),"data-hook":t,"data-slot":"input-otp","data-tracking-el":n,"data-tracking-label":o,disabled:u,...c,children:s})})});p.displayName="InputOTP";function f({className:t,...n}){return e.jsx("div",{className:x.cn("flex items-center rounded-md shadow-xs",t),"data-slot":"input-otp-group",...n})}function d({index:t,className:n,...o}){const{error:r}=v(),a=i.useContext(l.OTPInputContext),{char:u,hasFakeCaret:s,isActive:c}=a?.slots[t]??{};return e.jsxs("div",{className:x.cn("relative flex h-9 w-9 items-center justify-center","border-input bg-background border-y border-r","text-foreground duration-fast text-body transition-[border-color,box-shadow] ease-out outline-none","first:rounded-l-md first:border-l last:rounded-r-md","data-[active=true]:border-ring data-[active=true]:z-10","data-[active=true]:shadow-default",r&&"border-destructive-40",r&&"data-[active=true]:border-destructive-40 data-[active=true]:shadow-destructive","dark:bg-input/30",n),"data-active":c,"data-error":r,"data-slot":"input-otp-slot",...o,children:[u,s&&e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function P({...t}){return e.jsx("div",{"data-slot":"input-otp-separator",role:"separator",...t,children:e.jsx(y.Minus,{})})}const h=i.forwardRef(({maxLength:t=6,...n},o)=>e.jsx(p,{ref:o,inputMode:"numeric",maxLength:t,pasteTransformer:r=>r.replace(/\D+/g,"").slice(0,t),pattern:l.REGEXP_ONLY_DIGITS,...n,children:e.jsx(f,{children:Array.from({length:t},(r,a)=>e.jsx(d,{index:a},a))})}));h.displayName="InputOTPDigitsOnly";const T=i.forwardRef(({maxLength:t=4,...n},o)=>e.jsx(p,{ref:o,containerClassName:"gap-2",maxLength:t,...n,children:Array.from({length:t},(r,a)=>e.jsx(d,{className:"rounded-md border-l shadow-xs",index:a},a))}));T.displayName="InputOTPWithSpacing";const j=i.forwardRef(({maxLength:t=6,...n},o)=>{const r=Math.ceil(t/2),a=t-r;return e.jsxs(p,{ref:o,maxLength:t,...n,children:[e.jsx(f,{children:Array.from({length:r},(u,s)=>e.jsx(d,{index:s},s))}),e.jsx(P,{}),e.jsx(f,{children:Array.from({length:a},(u,s)=>e.jsx(d,{index:s+r},s+r))})]})});j.displayName="InputOTPSimple";const b=i.forwardRef(({maxLength:t=6,...n},o)=>{const a=Math.ceil(t/2);return e.jsx(p,{ref:o,maxLength:t,...n,children:Array.from({length:a},(u,s)=>{const c=s*2,O=Math.min(c+2,t)-c;return e.jsxs(i.Fragment,{children:[s>0&&e.jsx(P,{}),e.jsx(f,{children:Array.from({length:O},(N,I)=>e.jsx(d,{index:c+I},c+I))})]},s)})})});b.displayName="InputOTPWithSeparator";Object.defineProperty(exports,"REGEXP_ONLY_CHARS",{enumerable:!0,get:()=>l.REGEXP_ONLY_CHARS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS",{enumerable:!0,get:()=>l.REGEXP_ONLY_DIGITS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS_AND_CHARS",{enumerable:!0,get:()=>l.REGEXP_ONLY_DIGITS_AND_CHARS});exports.InputOTP=p;exports.InputOTPDigitsOnly=h;exports.InputOTPGroup=f;exports.InputOTPSeparator=P;exports.InputOTPSimple=j;exports.InputOTPSlot=d;exports.InputOTPWithSeparator=b;exports.InputOTPWithSpacing=T;
|
package/dist/input-otp.js
CHANGED
|
@@ -5,7 +5,7 @@ import { REGEXP_ONLY_CHARS as M, REGEXP_ONLY_DIGITS as z, REGEXP_ONLY_DIGITS_AND
|
|
|
5
5
|
import { Minus as b } from "@brightlocal/icons";
|
|
6
6
|
import { cn as h } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
const g = s.createContext(null);
|
|
8
|
-
function
|
|
8
|
+
function y() {
|
|
9
9
|
const t = s.useContext(g);
|
|
10
10
|
if (!t)
|
|
11
11
|
throw new Error("InputOTP components must be used within an <InputOTP>");
|
|
@@ -59,7 +59,7 @@ function p({ className: t, ...o }) {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
function c({ index: t, className: o, ...i }) {
|
|
62
|
-
const { error: r } =
|
|
62
|
+
const { error: r } = y(), n = s.useContext(
|
|
63
63
|
v
|
|
64
64
|
), { char: d, hasFakeCaret: a, isActive: u } = n?.slots[t] ?? {};
|
|
65
65
|
return /* @__PURE__ */ m(
|
|
@@ -69,7 +69,7 @@ function c({ index: t, className: o, ...i }) {
|
|
|
69
69
|
// Base styles
|
|
70
70
|
"relative flex h-9 w-9 items-center justify-center",
|
|
71
71
|
"border-input bg-background border-y border-r",
|
|
72
|
-
"text-foreground duration-fast text-
|
|
72
|
+
"text-foreground duration-fast text-body transition-[border-color,box-shadow] ease-out outline-none",
|
|
73
73
|
"first:rounded-l-md first:border-l last:rounded-r-md",
|
|
74
74
|
// Focus state
|
|
75
75
|
"data-[active=true]:border-ring data-[active=true]:z-10",
|
|
@@ -95,7 +95,7 @@ function c({ index: t, className: o, ...i }) {
|
|
|
95
95
|
function P({ ...t }) {
|
|
96
96
|
return /* @__PURE__ */ e("div", { "data-slot": "input-otp-separator", role: "separator", ...t, children: /* @__PURE__ */ e(b, {}) });
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const N = s.forwardRef(({ maxLength: t = 6, ...o }, i) => /* @__PURE__ */ e(
|
|
99
99
|
l,
|
|
100
100
|
{
|
|
101
101
|
ref: i,
|
|
@@ -107,8 +107,8 @@ const w = s.forwardRef(({ maxLength: t = 6, ...o }, i) => /* @__PURE__ */ e(
|
|
|
107
107
|
children: /* @__PURE__ */ e(p, { children: Array.from({ length: t }, (r, n) => /* @__PURE__ */ e(c, { index: n }, n)) })
|
|
108
108
|
}
|
|
109
109
|
));
|
|
110
|
-
|
|
111
|
-
const
|
|
110
|
+
N.displayName = "InputOTPDigitsOnly";
|
|
111
|
+
const w = s.forwardRef(({ maxLength: t = 4, ...o }, i) => /* @__PURE__ */ e(
|
|
112
112
|
l,
|
|
113
113
|
{
|
|
114
114
|
ref: i,
|
|
@@ -125,7 +125,7 @@ const y = s.forwardRef(({ maxLength: t = 4, ...o }, i) => /* @__PURE__ */ e(
|
|
|
125
125
|
))
|
|
126
126
|
}
|
|
127
127
|
));
|
|
128
|
-
|
|
128
|
+
w.displayName = "InputOTPWithSpacing";
|
|
129
129
|
const S = s.forwardRef(
|
|
130
130
|
({ maxLength: t = 6, ...o }, i) => {
|
|
131
131
|
const r = Math.ceil(t / 2), n = t - r;
|
|
@@ -156,13 +156,13 @@ const _ = s.forwardRef(({ maxLength: t = 6, ...o }, i) => {
|
|
|
156
156
|
_.displayName = "InputOTPWithSeparator";
|
|
157
157
|
export {
|
|
158
158
|
l as InputOTP,
|
|
159
|
-
|
|
159
|
+
N as InputOTPDigitsOnly,
|
|
160
160
|
p as InputOTPGroup,
|
|
161
161
|
P as InputOTPSeparator,
|
|
162
162
|
S as InputOTPSimple,
|
|
163
163
|
c as InputOTPSlot,
|
|
164
164
|
_ as InputOTPWithSeparator,
|
|
165
|
-
|
|
165
|
+
w as InputOTPWithSpacing,
|
|
166
166
|
M as REGEXP_ONLY_CHARS,
|
|
167
167
|
z as REGEXP_ONLY_DIGITS,
|
|
168
168
|
j as REGEXP_ONLY_DIGITS_AND_CHARS
|
package/dist/input-password.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),D=require("react"),j=require("@brightlocal/icons"),M=require("@brightlocal/ui-components/progress"),y=require("@brightlocal/ui-components/lib/utils"),w=require("@brightlocal/ui-components/input-group");function $(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const n=$(D),O={meter:{label:"Meter",value:0,color:"bg-green-500"},weak:{label:"Weak",value:25,color:"bg-green-500"},ok:{label:"Ok",value:50,color:"bg-green-500"},good:{label:"Good",value:75,color:"bg-green-500"},great:{label:"Great",value:100,color:"bg-green-500"}};function L(e){if(!e||e.length===0)return"meter";if(e.length<12)return"weak";let t=0;return e.length>=16&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[^a-zA-Z0-9]/.test(e)&&(t+=1),t<=1?"ok":t<=3?"good":"great"}const _=n.createContext(null);function k(){const e=n.useContext(_);if(!e)throw new Error("InputPassword compound components must be used within InputPasswordRoot");return e}function q({children:e,dataHook:t,trackingEl:o,trackingLabel:r,disabled:u,value:a,onChange:l,onStrengthChange:i,strengthLevels:g,calculateStrength:p,error:c,id:h,className:f}){const[m
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),D=require("react"),j=require("@brightlocal/icons"),M=require("@brightlocal/ui-components/progress"),y=require("@brightlocal/ui-components/lib/utils"),w=require("@brightlocal/ui-components/input-group");function $(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const n=$(D),O={meter:{label:"Meter",value:0,color:"bg-green-500"},weak:{label:"Weak",value:25,color:"bg-green-500"},ok:{label:"Ok",value:50,color:"bg-green-500"},good:{label:"Good",value:75,color:"bg-green-500"},great:{label:"Great",value:100,color:"bg-green-500"}};function L(e){if(!e||e.length===0)return"meter";if(e.length<12)return"weak";let t=0;return e.length>=16&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[^a-zA-Z0-9]/.test(e)&&(t+=1),t<=1?"ok":t<=3?"good":"great"}const _=n.createContext(null);function k(){const e=n.useContext(_);if(!e)throw new Error("InputPassword compound components must be used within InputPasswordRoot");return e}function q({children:e,dataHook:t,trackingEl:o,trackingLabel:r,disabled:u,value:a,onChange:l,onStrengthChange:i,strengthLevels:g,calculateStrength:p,error:c,id:h,className:f}){const[b,m]=n.useState(!1),[S,v]=n.useState(""),[P,x]=n.useState("meter"),F=n.useId(),E=h||F,I=a!==void 0?a:S,N=g??O,T=p??L,R=n.useCallback(d=>{a===void 0&&v(d),l?.(d)},[a,l]),G=n.useCallback(()=>{m(d=>!d)},[]);n.useEffect(()=>{const d=setTimeout(()=>{const C=T(I);x(C),i?.(C)},180);return()=>clearTimeout(d)},[I,T,i]);const z=n.useMemo(()=>({showPassword:b,setShowPassword:m,toggleVisibility:G,password:I,setPassword:R,strength:P,strengthLevels:N,disabled:u,dataHook:t,trackingEl:o,trackingLabel:r,inputId:E,error:c}),[b,G,I,R,P,N,u,t,o,r,E,c]);return s.jsx(_.Provider,{value:z,children:s.jsx("div",{className:y.cn("w-full",f),"data-hook":t,"data-slot":"input-password",children:e})})}q.displayName="InputPasswordRoot";const H=n.forwardRef(({className:e,groupClassName:t,onChange:o,showLabel:r,hideLabel:u,...a},l)=>{const{showPassword:i,toggleVisibility:g,password:p,setPassword:c,disabled:h,dataHook:f,trackingEl:b,trackingLabel:m,inputId:S,error:v}=k(),P=x=>{c(x.target.value),o?.(x)};return s.jsxs(w.InputGroup,{className:t,dataHook:f,error:v,children:[s.jsx(w.InputGroupInput,{ref:l,className:e,disabled:h,id:S,trackingEl:b,trackingLabel:m,type:i?"text":"password",value:p,onChange:P,...a}),s.jsx(w.InputGroupAddon,{align:"inline-end",children:s.jsx(w.InputGroupButton,{"aria-label":i?u??"Hide password":r??"Show password","data-hook":`${f}-toggle`,disabled:h,size:"icon-sm",variant:"ghost",onClick:g,children:i?s.jsx(j.EyeOff,{}):s.jsx(j.Eye,{})})})]})});H.displayName="InputPasswordField";const V=n.forwardRef(({className:e,showLabel:t,hideLabel:o,size:r="icon",variant:u="ghost",...a},l)=>{const{showPassword:i,toggleVisibility:g,disabled:p,dataHook:c}=k();return s.jsx(w.InputGroupButton,{ref:l,"aria-label":i?o??"Hide password":t??"Show password",className:e,"data-hook":`${c}-toggle`,disabled:p,size:r,variant:u,onClick:g,...a,children:i?s.jsx(j.EyeOff,{}):s.jsx(j.Eye,{})})});V.displayName="InputPasswordToggle";function A({className:e,showLabel:t=!0}){const{strength:o,strengthLevels:r,dataHook:u,disabled:a}=k(),l=r[o]??{label:o,value:0,color:"bg-muted"};return s.jsx("div",{className:y.cn("mt-1 space-y-2",e),children:s.jsxs("div",{className:y.cn("flex items-center gap-2",a&&"opacity-50"),children:[s.jsx(M.Progress,{className:"h-2 flex-1",dataHook:`${u}-strength-progress`,indicatorClassName:l.color,value:l.value}),t&&s.jsx("span",{className:"text-foreground text-label w-10 shrink-0 text-right whitespace-nowrap","data-hook":`${u}-strength-label`,children:l.label})]})})}A.displayName="InputPasswordStrength";exports.DEFAULT_STRENGTH_LEVELS=O;exports.InputPasswordField=H;exports.InputPasswordRoot=q;exports.InputPasswordStrength=A;exports.InputPasswordToggle=V;exports.calculatePasswordStrength=L;
|
package/dist/input-password.js
CHANGED
|
@@ -11,43 +11,43 @@ const Z = {
|
|
|
11
11
|
good: { label: "Good", value: 75, color: "bg-green-500" },
|
|
12
12
|
great: { label: "Great", value: 100, color: "bg-green-500" }
|
|
13
13
|
};
|
|
14
|
-
function _(
|
|
15
|
-
if (!
|
|
14
|
+
function _(e) {
|
|
15
|
+
if (!e || e.length === 0)
|
|
16
16
|
return "meter";
|
|
17
|
-
if (
|
|
17
|
+
if (e.length < 12)
|
|
18
18
|
return "weak";
|
|
19
|
-
let
|
|
20
|
-
return
|
|
19
|
+
let t = 0;
|
|
20
|
+
return e.length >= 16 && (t += 1), /[a-z]/.test(e) && (t += 1), /[A-Z]/.test(e) && (t += 1), /[0-9]/.test(e) && (t += 1), /[^a-zA-Z0-9]/.test(e) && (t += 1), t <= 1 ? "ok" : t <= 3 ? "good" : "great";
|
|
21
21
|
}
|
|
22
22
|
const A = s.createContext(null);
|
|
23
23
|
function S() {
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
24
|
+
const e = s.useContext(A);
|
|
25
|
+
if (!e)
|
|
26
26
|
throw new Error(
|
|
27
27
|
"InputPassword compound components must be used within InputPasswordRoot"
|
|
28
28
|
);
|
|
29
|
-
return
|
|
29
|
+
return e;
|
|
30
30
|
}
|
|
31
31
|
function B({
|
|
32
|
-
children:
|
|
33
|
-
dataHook:
|
|
34
|
-
trackingEl:
|
|
32
|
+
children: e,
|
|
33
|
+
dataHook: t,
|
|
34
|
+
trackingEl: n,
|
|
35
35
|
trackingLabel: d,
|
|
36
36
|
disabled: l,
|
|
37
37
|
value: r,
|
|
38
|
-
onChange:
|
|
38
|
+
onChange: a,
|
|
39
39
|
onStrengthChange: i,
|
|
40
40
|
strengthLevels: g,
|
|
41
41
|
calculateStrength: p,
|
|
42
42
|
error: c,
|
|
43
43
|
id: h,
|
|
44
|
-
className:
|
|
44
|
+
className: w
|
|
45
45
|
}) {
|
|
46
|
-
const [
|
|
46
|
+
const [m, f] = s.useState(!1), [P, v] = s.useState(""), [k, b] = s.useState("meter"), $ = s.useId(), y = h || $, I = r !== void 0 ? r : P, N = g ?? Z, C = p ?? _, E = s.useCallback(
|
|
47
47
|
(u) => {
|
|
48
|
-
r === void 0 && v(u),
|
|
48
|
+
r === void 0 && v(u), a?.(u);
|
|
49
49
|
},
|
|
50
|
-
[r,
|
|
50
|
+
[r, a]
|
|
51
51
|
), G = s.useCallback(() => {
|
|
52
52
|
f((u) => !u);
|
|
53
53
|
}, []);
|
|
@@ -60,7 +60,7 @@ function B({
|
|
|
60
60
|
}, [I, C, i]);
|
|
61
61
|
const z = s.useMemo(
|
|
62
62
|
() => ({
|
|
63
|
-
showPassword:
|
|
63
|
+
showPassword: m,
|
|
64
64
|
setShowPassword: f,
|
|
65
65
|
toggleVisibility: G,
|
|
66
66
|
password: I,
|
|
@@ -68,22 +68,22 @@ function B({
|
|
|
68
68
|
strength: k,
|
|
69
69
|
strengthLevels: N,
|
|
70
70
|
disabled: l,
|
|
71
|
-
dataHook:
|
|
72
|
-
trackingEl:
|
|
71
|
+
dataHook: t,
|
|
72
|
+
trackingEl: n,
|
|
73
73
|
trackingLabel: d,
|
|
74
74
|
inputId: y,
|
|
75
75
|
error: c
|
|
76
76
|
}),
|
|
77
77
|
[
|
|
78
|
-
|
|
78
|
+
m,
|
|
79
79
|
G,
|
|
80
80
|
I,
|
|
81
81
|
E,
|
|
82
82
|
k,
|
|
83
83
|
N,
|
|
84
84
|
l,
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
t,
|
|
86
|
+
n,
|
|
87
87
|
d,
|
|
88
88
|
y,
|
|
89
89
|
c
|
|
@@ -92,42 +92,42 @@ function B({
|
|
|
92
92
|
return /* @__PURE__ */ o(A.Provider, { value: z, children: /* @__PURE__ */ o(
|
|
93
93
|
"div",
|
|
94
94
|
{
|
|
95
|
-
className: x("w-full",
|
|
96
|
-
"data-hook":
|
|
95
|
+
className: x("w-full", w),
|
|
96
|
+
"data-hook": t,
|
|
97
97
|
"data-slot": "input-password",
|
|
98
|
-
children:
|
|
98
|
+
children: e
|
|
99
99
|
}
|
|
100
100
|
) });
|
|
101
101
|
}
|
|
102
102
|
B.displayName = "InputPasswordRoot";
|
|
103
103
|
const D = s.forwardRef(
|
|
104
|
-
({ className:
|
|
104
|
+
({ className: e, groupClassName: t, onChange: n, showLabel: d, hideLabel: l, ...r }, a) => {
|
|
105
105
|
const {
|
|
106
106
|
showPassword: i,
|
|
107
107
|
toggleVisibility: g,
|
|
108
108
|
password: p,
|
|
109
109
|
setPassword: c,
|
|
110
110
|
disabled: h,
|
|
111
|
-
dataHook:
|
|
112
|
-
trackingEl:
|
|
111
|
+
dataHook: w,
|
|
112
|
+
trackingEl: m,
|
|
113
113
|
trackingLabel: f,
|
|
114
114
|
inputId: P,
|
|
115
115
|
error: v
|
|
116
116
|
} = S();
|
|
117
|
-
return /* @__PURE__ */ T(j, { className:
|
|
117
|
+
return /* @__PURE__ */ T(j, { className: t, dataHook: w, error: v, children: [
|
|
118
118
|
/* @__PURE__ */ o(
|
|
119
119
|
M,
|
|
120
120
|
{
|
|
121
|
-
ref:
|
|
122
|
-
className:
|
|
121
|
+
ref: a,
|
|
122
|
+
className: e,
|
|
123
123
|
disabled: h,
|
|
124
124
|
id: P,
|
|
125
|
-
trackingEl:
|
|
125
|
+
trackingEl: m,
|
|
126
126
|
trackingLabel: f,
|
|
127
127
|
type: i ? "text" : "password",
|
|
128
128
|
value: p,
|
|
129
129
|
onChange: (b) => {
|
|
130
|
-
c(b.target.value),
|
|
130
|
+
c(b.target.value), n?.(b);
|
|
131
131
|
},
|
|
132
132
|
...r
|
|
133
133
|
}
|
|
@@ -136,7 +136,7 @@ const D = s.forwardRef(
|
|
|
136
136
|
V,
|
|
137
137
|
{
|
|
138
138
|
"aria-label": i ? l ?? "Hide password" : d ?? "Show password",
|
|
139
|
-
"data-hook": `${
|
|
139
|
+
"data-hook": `${w}-toggle`,
|
|
140
140
|
disabled: h,
|
|
141
141
|
size: "icon-sm",
|
|
142
142
|
variant: "ghost",
|
|
@@ -150,20 +150,20 @@ const D = s.forwardRef(
|
|
|
150
150
|
D.displayName = "InputPasswordField";
|
|
151
151
|
const U = s.forwardRef(
|
|
152
152
|
({
|
|
153
|
-
className:
|
|
154
|
-
showLabel:
|
|
155
|
-
hideLabel:
|
|
153
|
+
className: e,
|
|
154
|
+
showLabel: t,
|
|
155
|
+
hideLabel: n,
|
|
156
156
|
size: d = "icon",
|
|
157
157
|
variant: l = "ghost",
|
|
158
158
|
...r
|
|
159
|
-
},
|
|
159
|
+
}, a) => {
|
|
160
160
|
const { showPassword: i, toggleVisibility: g, disabled: p, dataHook: c } = S();
|
|
161
161
|
return /* @__PURE__ */ o(
|
|
162
162
|
V,
|
|
163
163
|
{
|
|
164
|
-
ref:
|
|
165
|
-
"aria-label": i ?
|
|
166
|
-
className:
|
|
164
|
+
ref: a,
|
|
165
|
+
"aria-label": i ? n ?? "Hide password" : t ?? "Show password",
|
|
166
|
+
className: e,
|
|
167
167
|
"data-hook": `${c}-toggle`,
|
|
168
168
|
disabled: p,
|
|
169
169
|
size: d,
|
|
@@ -177,30 +177,30 @@ const U = s.forwardRef(
|
|
|
177
177
|
);
|
|
178
178
|
U.displayName = "InputPasswordToggle";
|
|
179
179
|
function W({
|
|
180
|
-
className:
|
|
181
|
-
showLabel:
|
|
180
|
+
className: e,
|
|
181
|
+
showLabel: t = !0
|
|
182
182
|
}) {
|
|
183
|
-
const { strength:
|
|
184
|
-
label:
|
|
183
|
+
const { strength: n, strengthLevels: d, dataHook: l, disabled: r } = S(), a = d[n] ?? {
|
|
184
|
+
label: n,
|
|
185
185
|
value: 0,
|
|
186
186
|
color: "bg-muted"
|
|
187
187
|
};
|
|
188
|
-
return /* @__PURE__ */ o("div", { className: x("mt-1 space-y-2",
|
|
188
|
+
return /* @__PURE__ */ o("div", { className: x("mt-1 space-y-2", e), children: /* @__PURE__ */ T("div", { className: x("flex items-center gap-2", r && "opacity-50"), children: [
|
|
189
189
|
/* @__PURE__ */ o(
|
|
190
190
|
F,
|
|
191
191
|
{
|
|
192
192
|
className: "h-2 flex-1",
|
|
193
193
|
dataHook: `${l}-strength-progress`,
|
|
194
|
-
indicatorClassName:
|
|
195
|
-
value:
|
|
194
|
+
indicatorClassName: a.color,
|
|
195
|
+
value: a.value
|
|
196
196
|
}
|
|
197
197
|
),
|
|
198
|
-
|
|
198
|
+
t && /* @__PURE__ */ o(
|
|
199
199
|
"span",
|
|
200
200
|
{
|
|
201
|
-
className: "text-foreground w-10 shrink-0 text-right
|
|
201
|
+
className: "text-foreground text-label w-10 shrink-0 text-right whitespace-nowrap",
|
|
202
202
|
"data-hook": `${l}-strength-label`,
|
|
203
|
-
children:
|
|
203
|
+
children: a.label
|
|
204
204
|
}
|
|
205
205
|
)
|
|
206
206
|
] }) });
|
package/dist/input.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),b=require("react"),p=require("class-variance-authority"),v=require("@brightlocal/ui-components/lib/utils");function g(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const h=g(b),n=p.cva(["flex w-full min-w-0 h-9","border border-input bg-background rounded-sm","outline-none transition-[border-color,box-shadow,background-color] duration-fast ease-out","text-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),b=require("react"),p=require("class-variance-authority"),v=require("@brightlocal/ui-components/lib/utils");function g(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const h=g(b),n=p.cva(["flex w-full min-w-0 h-9","border border-input bg-background rounded-sm","outline-none transition-[border-color,box-shadow,background-color] duration-fast ease-out","text-body","text-foreground","overflow-hidden text-ellipsis","focus-visible:outline-none focus-visible:border-ring focus-visible:bg-background","focus-visible:shadow-default","disabled:cursor-not-allowed disabled:opacity-50","placeholder:text-muted-foreground","placeholder:overflow-hidden placeholder:text-ellipsis","items-center px-3","[&::-webkit-calendar-picker-indicator]:hidden"],{variants:{hasIcon:{true:"pl-9",false:""},hasSecondaryIcon:{true:"pr-9",false:""}},defaultVariants:{hasIcon:!1,hasSecondaryIcon:!1}}),s=h.forwardRef(({className:e,hasIcon:r=!1,hasSecondaryIcon:t=!1,dataHook:a,error:l,trackingEl:c,trackingLabel:d,...o},u)=>{const i=l||o["aria-invalid"]===!0||o["aria-invalid"]==="true";return f.jsx("input",{ref:u,"aria-invalid":i?"true":void 0,className:v.cn(n({hasIcon:r,hasSecondaryIcon:t}),i&&"border-destructive-40 focus-visible:border-destructive-40 focus-visible:shadow-destructive",e),"data-hook":a,"data-slot":"input","data-tracking-el":c,"data-tracking-label":d,...o})});s.displayName="Input";exports.Input=s;exports.inputVariants=n;
|