@brightlocal/ui-components 3.3.0 → 3.5.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/AI_USAGE.md +22 -3
- package/README.md +177 -109
- package/component-meta.json +1307 -113
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +13 -2
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +4 -3
- package/dist/banner.cjs +1 -1
- package/dist/banner.d.ts +47 -11
- package/dist/banner.d.ts.map +1 -1
- package/dist/banner.js +156 -79
- package/dist/blocks/empty-state.cjs +1 -1
- package/dist/blocks/empty-state.d.ts +40 -5
- package/dist/blocks/empty-state.d.ts.map +1 -1
- package/dist/blocks/empty-state.js +59 -52
- package/dist/blocks/input-list.cjs +1 -1
- package/dist/blocks/input-list.d.ts +1 -0
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +39 -39
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +12 -6
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +64 -63
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +47 -43
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +12 -0
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +115 -97
- package/dist/chart.cjs +6 -6
- package/dist/chart.d.ts +6 -10
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +281 -296
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +430 -343
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +23 -2
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +212 -207
- package/dist/count-indicator.cjs +1 -0
- package/dist/count-indicator.d.ts +85 -0
- package/dist/count-indicator.d.ts.map +1 -0
- package/dist/count-indicator.js +72 -0
- package/dist/data-table.cjs +1 -1
- package/dist/data-table.d.ts +101 -11
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +593 -523
- package/dist/description-list.cjs +1 -0
- package/dist/description-list.d.ts +142 -0
- package/dist/description-list.d.ts.map +1 -0
- package/dist/description-list.js +173 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +26 -3
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +62 -47
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +8 -4
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +37 -38
- package/dist/file-upload.cjs +1 -0
- package/dist/file-upload.d.ts +546 -0
- package/dist/file-upload.d.ts.map +1 -0
- package/dist/file-upload.js +1103 -0
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +7 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +52 -52
- package/dist/hooks/use-file-dropzone.cjs +1 -0
- package/dist/hooks/use-file-dropzone.d.ts +75 -0
- package/dist/hooks/use-file-dropzone.d.ts.map +1 -0
- package/dist/hooks/use-file-dropzone.js +133 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +29 -16
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +153 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +681 -623
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +30 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -115
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +37 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +131 -114
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.js +6 -6
- package/dist/lib/empty-canvas.cjs +1 -1
- package/dist/lib/empty-canvas.d.ts +27 -1
- package/dist/lib/empty-canvas.d.ts.map +1 -1
- package/dist/lib/empty-canvas.js +27 -23
- package/dist/lib/empty-chip.cjs +1 -1
- package/dist/lib/empty-chip.d.ts +19 -2
- package/dist/lib/empty-chip.d.ts.map +1 -1
- package/dist/lib/empty-chip.js +14 -9
- package/dist/lib/field-aria.cjs +1 -1
- package/dist/lib/field-aria.d.ts +4 -4
- package/dist/lib/field-aria.d.ts.map +1 -1
- package/dist/lib/field-aria.js +7 -5
- package/dist/lib/media-viewer-content.cjs +1 -1
- package/dist/lib/media-viewer-content.js +1 -1
- package/dist/lib/motion.cjs +1 -1
- package/dist/lib/motion.js +15 -10
- package/dist/lib/table-internal.cjs +1 -1
- package/dist/lib/table-internal.d.ts +19 -0
- package/dist/lib/table-internal.d.ts.map +1 -1
- package/dist/lib/table-internal.js +22 -7
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +230 -40
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +301 -66
- package/dist/logo-mark.cjs +1 -1
- package/dist/logo-mark.d.ts +18 -2
- package/dist/logo-mark.d.ts.map +1 -1
- package/dist/logo-mark.js +159 -79
- package/dist/media-empty.cjs +1 -1
- package/dist/media-empty.d.ts +50 -7
- package/dist/media-empty.d.ts.map +1 -1
- package/dist/media-empty.js +14 -13
- package/dist/media-viewer.cjs +1 -1
- package/dist/media-viewer.js +6 -6
- package/dist/multi-select-filter.cjs +1 -1
- package/dist/multi-select-filter.d.ts.map +1 -1
- package/dist/multi-select-filter.js +92 -101
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +11 -0
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +17 -17
- package/dist/relative-date.d.ts +6 -0
- package/dist/relative-date.d.ts.map +1 -1
- package/dist/resizable.d.ts +1 -1
- package/dist/result-count.cjs +1 -1
- package/dist/result-count.d.ts +13 -16
- package/dist/result-count.d.ts.map +1 -1
- package/dist/result-count.js +24 -33
- package/dist/route-progress.cjs +1 -1
- package/dist/route-progress.js +24 -23
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +22 -3
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +152 -125
- package/dist/single-select-filter.cjs +1 -1
- package/dist/single-select-filter.d.ts.map +1 -1
- package/dist/single-select-filter.js +67 -76
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +77 -76
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +39 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +127 -76
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +34 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +115 -19
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +137 -131
- package/dist/typography-text.cjs +1 -1
- package/dist/typography-text.d.ts +6 -2
- package/dist/typography-text.d.ts.map +1 -1
- package/dist/typography-text.js +14 -13
- package/package.json +2 -3
- package/src/blocks/empty-state.tsx +108 -48
- package/src/blocks/input-list.tsx +15 -9
- package/src/blocks/sidebar.tsx +39 -16
- package/src/components/alert-dialog.tsx +18 -2
- package/src/components/banner.tsx +247 -68
- package/src/components/button.tsx +27 -10
- package/src/components/card.tsx +89 -7
- package/src/components/chart.tsx +47 -67
- package/src/components/combobox.tsx +221 -12
- package/src/components/command.tsx +83 -37
- package/src/components/count-indicator.tsx +188 -0
- package/src/components/data-table.tsx +506 -159
- package/src/components/description-list.tsx +445 -0
- package/src/components/dialog.tsx +74 -5
- package/src/components/drawer.tsx +52 -32
- package/src/components/file-upload.tsx +2574 -0
- package/src/components/global-layout.tsx +18 -5
- package/src/components/hover-card.tsx +395 -65
- package/src/components/input-chip.tsx +67 -2
- package/src/components/input-group.tsx +89 -6
- package/src/components/list.tsx +720 -72
- package/src/components/logo-mark.tsx +109 -25
- package/src/components/media-empty.tsx +62 -7
- package/src/components/multi-select-filter.tsx +9 -16
- package/src/components/pagination.tsx +15 -2
- package/src/components/relative-date.tsx +6 -0
- package/src/components/result-count.tsx +27 -54
- package/src/components/sheet.tsx +86 -8
- package/src/components/single-select-filter.tsx +9 -16
- package/src/components/table.tsx +16 -1
- package/src/components/tabs.tsx +223 -41
- package/src/components/textarea.tsx +271 -4
- package/src/components/tooltip.tsx +29 -2
- package/src/components/typography-text.tsx +7 -2
- package/src/hooks/use-file-dropzone.ts +325 -0
- package/src/index.ts +4 -0
- package/src/lib/empty-canvas.tsx +47 -20
- package/src/lib/empty-chip.tsx +38 -3
- package/src/lib/field-aria.tsx +11 -6
- package/src/lib/table-internal.ts +38 -0
package/dist/input-chip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const
|
|
1
|
+
"use client";const P=require("./_virtual/_rolldown/runtime.cjs"),A=require("./lib/field-aria.cjs"),T=require("./count-indicator.cjs");let e=require("react");e=P.__toESM(e,1);let q=require("@brightlocal/ui-components/lib/utils"),w=require("react/jsx-runtime"),U=require("class-variance-authority"),z=require("@brightlocal/ui-components/chip");var N=e.createContext(null),S=e.createContext(null),$=e.createContext(null);function B(){const r=e.useContext(N);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function E(){const r=e.useContext(S);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function K(){const r=e.useContext($);if(!r)throw new Error("InputChip components must be used within an <InputChip>");return r}function G(){const r=B(),{value:v,disabled:d}=E(),{inputValue:o,focusedChipIndex:u}=K();return{...r,value:v,disabled:d,inputValue:o,focusedChipIndex:u}}function J({value:r,defaultValue:v=[],onValueChange:d,onBeforeAdd:o,disabled:u=!1,allowDuplicates:s=!1,children:f}){const[c,y]=e.useState(v),[p,x]=e.useState(""),[C,R]=e.useState(-1),n=e.useRef(null),t=e.useRef([]),i=r!==void 0,l=i?r:c,b=e.useRef(l),_=e.useRef(d),k=e.useRef(o),I=e.useRef(u);e.useLayoutEffect(()=>{b.current=l,_.current=d,k.current=o,I.current=u}),e.useEffect(()=>{t.current.length>l.length&&(t.current.length=l.length),C>=l.length&&R(-1)},[l.length,C]);const g=e.useCallback(a=>{i||y(a),_.current?.(a)},[i]),m=e.useCallback(a=>{if(I.current)return;const h=a.trim();h&&k.current?.(h)!==!1&&(!s&&b.current.includes(h)||(g([...b.current,h]),x("")))},[s,g]),D=e.useCallback(a=>{I.current||g(b.current.filter((h,L)=>L!==a))},[g]),V=e.useMemo(()=>({onValueChange:g,setInputValue:x,addItem:m,removeItem:D,inputRef:n,setFocusedChipIndex:R,chipRefs:t}),[g,m,D]),j=e.useMemo(()=>({value:l,disabled:u}),[l,u]),F=e.useMemo(()=>({inputValue:p,focusedChipIndex:C}),[p,C]);return(0,w.jsx)(N.Provider,{value:V,children:(0,w.jsx)(S.Provider,{value:j,children:(0,w.jsx)($.Provider,{value:F,children:f})})})}var O=(0,U.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-[[data-slot=count-indicator][data-state=over]]:border-destructive-40","has-[[data-slot=count-indicator][data-state=over]]:has-[:focus-visible]:border-destructive-40","has-[[data-slot=count-indicator][data-state=over]]:has-[:focus-visible]:shadow-destructive","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}}),Q=["flex-1 min-w-20","bg-transparent","border-0 outline-none","text-field","text-foreground","placeholder:text-muted-foreground","focus:outline-none focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50"],M=e.forwardRef(({className:r,error:v=!1,dataHook:d,trackingEl:o,trackingLabel:u,placeholder:s,inputId:f,"aria-label":c,"aria-labelledby":y,"aria-describedby":p,"aria-invalid":x,wrapperRef:C,children:R,...n},t)=>{const{setInputValue:i,addItem:l,inputRef:b,setFocusedChipIndex:_,chipRefs:k}=B(),{value:I,disabled:g}=E(),{inputValue:m}=K(),D=A.useFieldDescribedBy(p);e.useImperativeHandle(t,()=>b.current,[b]);const V=v||x===!0||x==="true",j=a=>{i(a.target.value)},F=a=>{if(a.key==="Enter"&&m.trim()&&(a.preventDefault(),l(m)),a.key==="ArrowLeft"&&!m&&I.length>0){a.preventDefault();const h=I.length-1;_(h),k.current[h]?.focus()}if(a.key==="Backspace"&&!m&&I.length>0){a.preventDefault();const h=I.length-1;_(h),k.current[h]?.focus()}};return(0,w.jsxs)("div",{ref:C,className:(0,q.cn)(O({error:V}),r),"data-hook":d,"data-slot":"input-chip","data-tracking-el":o,"data-tracking-label":u,...n,children:[R,(0,w.jsx)("input",{ref:b,"aria-describedby":D||void 0,"aria-invalid":V?"true":void 0,"aria-label":c,"aria-labelledby":y,className:(0,q.cn)(Q),"data-slot":"input-chip-input",disabled:g,id:f,placeholder:s,type:"text",value:m,onChange:j,onKeyDown:F})]})});M.displayName="InputChipInput";function W({className:r,dataHookPrefix:v="chip",itemAriaLabel:d}){const{removeItem:o,inputRef:u,setFocusedChipIndex:s,chipRefs:f}=B(),{value:c,disabled:y}=E(),p=e.useRef(null);e.useEffect(()=>{if(p.current!==null){if(p.current==="input")u.current?.focus();else{const n=p.current;n>=0&&n<c.length?f.current[n]?.focus():c.length>0?f.current[c.length-1]?.focus():u.current?.focus()}p.current=null}},[c.length,u,f]);const x=(n,t)=>{if(!y)switch(n.key){case"ArrowLeft":n.preventDefault(),t>0&&(s(t-1),f.current[t-1]?.focus());break;case"ArrowRight":n.preventDefault(),t<c.length-1?(s(t+1),f.current[t+1]?.focus()):(s(-1),u.current?.focus());break;case"Backspace":case"Delete":{n.preventDefault();const i=c.length-1;if(i===0)s(-1),p.current="input",o(t);else if(t>=i){const l=i-1;s(l),p.current=l,o(t)}else s(t),p.current=t,o(t);break}case"Home":n.preventDefault(),c.length>0&&(s(0),f.current[0]?.focus());break;case"End":n.preventDefault(),s(-1),u.current?.focus()}},C=n=>{s(n)},R=n=>{const t=n.relatedTarget;t&&(t.closest('[data-slot="chip"]')!==null||t.dataset.slot==="input-chip-input")||s(-1)};return c.length===0?null:(0,w.jsx)("div",{className:(0,q.cn)("contents",r),"data-slot":"input-chip-items",children:c.map((n,t)=>(0,w.jsx)(z.Chip,{ref:i=>{f.current[t]=i},"aria-label":d?d.replace("{item}",n):`${n}, press Delete to remove`,dataHook:`${v}-${t}`,disabled:y,role:"group",tabIndex:-1,onBlur:R,onFocus:()=>C(t),onKeyDown:i=>x(i,t),onRemove:()=>o(t),children:n},`${n}-${t}`))})}var H=e.forwardRef(({className:r,count:v,...d},o)=>{const{value:u}=E();return(0,w.jsx)(T.CountIndicator,{ref:o,className:(0,q.cn)("order-last ml-auto pl-3",r),count:v??u.length,...d})});H.displayName="InputChipCount";exports.InputChip=J;exports.InputChipCount=H;exports.InputChipInput=M;exports.InputChipItems=W;exports.useInputChipContext=G;
|
package/dist/input-chip.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { CountIndicatorProps } from './count-indicator';
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
interface InputChipContextValue {
|
|
4
5
|
value: string[];
|
|
@@ -17,6 +18,7 @@ interface InputChipContextValue {
|
|
|
17
18
|
/** Refs for chip elements for programmatic focus */
|
|
18
19
|
chipRefs: React.RefObject<(HTMLDivElement | null)[]>;
|
|
19
20
|
}
|
|
21
|
+
/** Returns the combined InputChip context (value, dispatch, and input state). */
|
|
20
22
|
declare function useInputChipContext(): InputChipContextValue;
|
|
21
23
|
export interface InputChipProps {
|
|
22
24
|
/** Controlled value - array of chip values */
|
|
@@ -145,5 +147,32 @@ export interface InputChipItemsProps {
|
|
|
145
147
|
* Must be used within an InputChip component.
|
|
146
148
|
*/
|
|
147
149
|
declare function InputChipItems({ className, dataHookPrefix, itemAriaLabel, }: InputChipItemsProps): React.JSX.Element | null;
|
|
148
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Props for InputChipCount. `count` is optional: by default the chip field
|
|
152
|
+
* counts its items.
|
|
153
|
+
*/
|
|
154
|
+
export interface InputChipCountProps extends Omit<CountIndicatorProps, "count"> {
|
|
155
|
+
/**
|
|
156
|
+
* Count to show. Omit it to count the items in the chip field.
|
|
157
|
+
*/
|
|
158
|
+
count?: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Count of items against a limit at the end of the last row of the chip field,
|
|
162
|
+
* such as `3 / 5`. Place it inside `InputChipInput`, next to `InputChipItems`.
|
|
163
|
+
*
|
|
164
|
+
* It never blocks adding. Over the limit the count turns red and the field
|
|
165
|
+
* takes the error border; show the error message and reject the save yourself
|
|
166
|
+
* (`onBeforeAdd` on `InputChip` can stop the add itself).
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* <InputChipInput dataHook="emails-input">
|
|
171
|
+
* <InputChipItems />
|
|
172
|
+
* <InputChipCount dataHook="emails-count" limit={5} />
|
|
173
|
+
* </InputChipInput>
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
declare const InputChipCount: React.ForwardRefExoticComponent<InputChipCountProps & React.RefAttributes<HTMLSpanElement>>;
|
|
177
|
+
export { InputChip, InputChipCount, InputChipInput, InputChipItems, useInputChipContext, };
|
|
149
178
|
//# sourceMappingURL=input-chip.d.ts.map
|
package/dist/input-chip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-chip.d.ts","sourceRoot":"","sources":["../../src/components/input-chip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"input-chip.d.ts","sourceRoot":"","sources":["../../src/components/input-chip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BA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c,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,iBAAS,cAAc,CAAC,EACtB,SAAS,EACT,cAAuB,EACvB,aAAa,GACd,EAAE,mBAAmB,4BAoJrB;AAUD;;;GAGG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAC/C,mBAAmB,EACnB,OAAO,CACR;IACC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,cAAc,6FAYnB,CAAC;AAGF,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,cAAc,EACd,mBAAmB,GACpB,CAAC"}
|
package/dist/input-chip.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useFieldDescribedBy as j } from "./lib/field-aria.js";
|
|
3
|
+
import { CountIndicator as A } from "./count-indicator.js";
|
|
2
4
|
import * as t from "react";
|
|
3
|
-
import { cn as
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { cva as
|
|
6
|
-
import { Chip as
|
|
5
|
+
import { cn as F } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
import { jsx as R, jsxs as T } from "react/jsx-runtime";
|
|
7
|
+
import { cva as U } from "class-variance-authority";
|
|
8
|
+
import { Chip as _ } from "@brightlocal/ui-components/chip";
|
|
7
9
|
var S = t.createContext(null), H = t.createContext(null), L = t.createContext(null);
|
|
8
10
|
function K() {
|
|
9
11
|
const r = t.useContext(S);
|
|
10
12
|
if (!r) throw new Error("InputChip components must be used within an <InputChip>");
|
|
11
13
|
return r;
|
|
12
14
|
}
|
|
13
|
-
function
|
|
15
|
+
function B() {
|
|
14
16
|
const r = t.useContext(H);
|
|
15
17
|
if (!r) throw new Error("InputChip components must be used within an <InputChip>");
|
|
16
18
|
return r;
|
|
@@ -20,67 +22,70 @@ function M() {
|
|
|
20
22
|
if (!r) throw new Error("InputChip components must be used within an <InputChip>");
|
|
21
23
|
return r;
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
const r = K(), { value:
|
|
25
|
+
function ee() {
|
|
26
|
+
const r = K(), { value: v, disabled: f } = B(), { inputValue: a, focusedChipIndex: u } = M();
|
|
25
27
|
return {
|
|
26
28
|
...r,
|
|
27
|
-
value:
|
|
28
|
-
disabled:
|
|
29
|
-
inputValue:
|
|
30
|
-
focusedChipIndex:
|
|
29
|
+
value: v,
|
|
30
|
+
disabled: f,
|
|
31
|
+
inputValue: a,
|
|
32
|
+
focusedChipIndex: u
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
|
-
function
|
|
34
|
-
const [
|
|
35
|
+
function te({ value: r, defaultValue: v = [], onValueChange: f, onBeforeAdd: a, disabled: u = !1, allowDuplicates: o = !1, children: d }) {
|
|
36
|
+
const [c, y] = t.useState(v), [p, w] = t.useState(""), [b, x] = t.useState(-1), n = t.useRef(null), e = t.useRef([]), i = r !== void 0, l = i ? r : c, C = t.useRef(l), k = t.useRef(f), D = t.useRef(a), m = t.useRef(u);
|
|
35
37
|
t.useLayoutEffect(() => {
|
|
36
|
-
C.current =
|
|
38
|
+
C.current = l, k.current = f, D.current = a, m.current = u;
|
|
37
39
|
}), t.useEffect(() => {
|
|
38
|
-
e.current.length >
|
|
39
|
-
}, [
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
}, [
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
|
|
48
|
-
}, [
|
|
49
|
-
onValueChange:
|
|
40
|
+
e.current.length > l.length && (e.current.length = l.length), b >= l.length && x(-1);
|
|
41
|
+
}, [l.length, b]);
|
|
42
|
+
const g = t.useCallback((s) => {
|
|
43
|
+
i || y(s), k.current?.(s);
|
|
44
|
+
}, [i]), I = t.useCallback((s) => {
|
|
45
|
+
if (m.current) return;
|
|
46
|
+
const h = s.trim();
|
|
47
|
+
h && D.current?.(h) !== !1 && (!o && C.current.includes(h) || (g([...C.current, h]), w("")));
|
|
48
|
+
}, [o, g]), V = t.useCallback((s) => {
|
|
49
|
+
m.current || g(C.current.filter((h, P) => P !== s));
|
|
50
|
+
}, [g]), E = t.useMemo(() => ({
|
|
51
|
+
onValueChange: g,
|
|
50
52
|
setInputValue: w,
|
|
51
|
-
addItem:
|
|
53
|
+
addItem: I,
|
|
52
54
|
removeItem: V,
|
|
53
55
|
inputRef: n,
|
|
54
56
|
setFocusedChipIndex: x,
|
|
55
57
|
chipRefs: e
|
|
56
58
|
}), [
|
|
57
|
-
m,
|
|
58
59
|
g,
|
|
60
|
+
I,
|
|
59
61
|
V
|
|
60
|
-
]),
|
|
61
|
-
value:
|
|
62
|
-
disabled:
|
|
63
|
-
}), [
|
|
64
|
-
inputValue:
|
|
65
|
-
focusedChipIndex:
|
|
66
|
-
}), [
|
|
67
|
-
return /* @__PURE__ */
|
|
68
|
-
value:
|
|
69
|
-
children: /* @__PURE__ */
|
|
70
|
-
value:
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
value:
|
|
73
|
-
children:
|
|
62
|
+
]), N = t.useMemo(() => ({
|
|
63
|
+
value: l,
|
|
64
|
+
disabled: u
|
|
65
|
+
}), [l, u]), $ = t.useMemo(() => ({
|
|
66
|
+
inputValue: p,
|
|
67
|
+
focusedChipIndex: b
|
|
68
|
+
}), [p, b]);
|
|
69
|
+
return /* @__PURE__ */ R(S.Provider, {
|
|
70
|
+
value: E,
|
|
71
|
+
children: /* @__PURE__ */ R(H.Provider, {
|
|
72
|
+
value: N,
|
|
73
|
+
children: /* @__PURE__ */ R(L.Provider, {
|
|
74
|
+
value: $,
|
|
75
|
+
children: d
|
|
74
76
|
})
|
|
75
77
|
})
|
|
76
78
|
});
|
|
77
79
|
}
|
|
78
|
-
var
|
|
80
|
+
var q = U([
|
|
79
81
|
"relative flex w-full flex-wrap items-center gap-1",
|
|
80
82
|
"min-h-9 rounded-sm border border-input bg-background",
|
|
81
83
|
"px-3 py-2",
|
|
82
84
|
"has-[:focus-visible]:border-ring has-[:focus-visible]:bg-background",
|
|
83
85
|
"has-[:focus-visible]:shadow-default",
|
|
86
|
+
"has-[[data-slot=count-indicator][data-state=over]]:border-destructive-40",
|
|
87
|
+
"has-[[data-slot=count-indicator][data-state=over]]:has-[:focus-visible]:border-destructive-40",
|
|
88
|
+
"has-[[data-slot=count-indicator][data-state=over]]:has-[:focus-visible]:shadow-destructive",
|
|
84
89
|
"has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
|
|
85
90
|
"transition-[color,box-shadow,border-color]",
|
|
86
91
|
"duration-fast",
|
|
@@ -91,7 +96,7 @@ var U = A([
|
|
|
91
96
|
false: ""
|
|
92
97
|
} },
|
|
93
98
|
defaultVariants: { error: !1 }
|
|
94
|
-
}),
|
|
99
|
+
}), z = [
|
|
95
100
|
"flex-1 min-w-20",
|
|
96
101
|
"bg-transparent",
|
|
97
102
|
"border-0 outline-none",
|
|
@@ -100,123 +105,134 @@ var U = A([
|
|
|
100
105
|
"placeholder:text-muted-foreground",
|
|
101
106
|
"focus:outline-none focus-visible:outline-none",
|
|
102
107
|
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
103
|
-
],
|
|
104
|
-
const { setInputValue:
|
|
108
|
+
], G = t.forwardRef(({ className: r, error: v = !1, dataHook: f, trackingEl: a, trackingLabel: u, placeholder: o, inputId: d, "aria-label": c, "aria-labelledby": y, "aria-describedby": p, "aria-invalid": w, wrapperRef: b, children: x, ...n }, e) => {
|
|
109
|
+
const { setInputValue: i, addItem: l, inputRef: C, setFocusedChipIndex: k, chipRefs: D } = K(), { value: m, disabled: g } = B(), { inputValue: I } = M(), V = j(p);
|
|
105
110
|
t.useImperativeHandle(e, () => C.current, [C]);
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
}, $ = (
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
111
|
+
const E = v || w === !0 || w === "true", N = (s) => {
|
|
112
|
+
i(s.target.value);
|
|
113
|
+
}, $ = (s) => {
|
|
114
|
+
if (s.key === "Enter" && I.trim() && (s.preventDefault(), l(I)), s.key === "ArrowLeft" && !I && m.length > 0) {
|
|
115
|
+
s.preventDefault();
|
|
116
|
+
const h = m.length - 1;
|
|
117
|
+
k(h), D.current[h]?.focus();
|
|
113
118
|
}
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
119
|
+
if (s.key === "Backspace" && !I && m.length > 0) {
|
|
120
|
+
s.preventDefault();
|
|
121
|
+
const h = m.length - 1;
|
|
122
|
+
k(h), D.current[h]?.focus();
|
|
118
123
|
}
|
|
119
124
|
};
|
|
120
|
-
return /* @__PURE__ */
|
|
121
|
-
ref:
|
|
122
|
-
className:
|
|
123
|
-
"data-hook":
|
|
125
|
+
return /* @__PURE__ */ T("div", {
|
|
126
|
+
ref: b,
|
|
127
|
+
className: F(q({ error: E }), r),
|
|
128
|
+
"data-hook": f,
|
|
124
129
|
"data-slot": "input-chip",
|
|
125
|
-
"data-tracking-el":
|
|
126
|
-
"data-tracking-label":
|
|
130
|
+
"data-tracking-el": a,
|
|
131
|
+
"data-tracking-label": u,
|
|
127
132
|
...n,
|
|
128
|
-
children: [x, /* @__PURE__ */
|
|
133
|
+
children: [x, /* @__PURE__ */ R("input", {
|
|
129
134
|
ref: C,
|
|
130
|
-
"aria-describedby":
|
|
131
|
-
"aria-invalid":
|
|
132
|
-
"aria-label":
|
|
133
|
-
"aria-labelledby":
|
|
134
|
-
className:
|
|
135
|
+
"aria-describedby": V || void 0,
|
|
136
|
+
"aria-invalid": E ? "true" : void 0,
|
|
137
|
+
"aria-label": c,
|
|
138
|
+
"aria-labelledby": y,
|
|
139
|
+
className: F(z),
|
|
135
140
|
"data-slot": "input-chip-input",
|
|
136
|
-
disabled:
|
|
137
|
-
id:
|
|
138
|
-
placeholder:
|
|
141
|
+
disabled: g,
|
|
142
|
+
id: d,
|
|
143
|
+
placeholder: o,
|
|
139
144
|
type: "text",
|
|
140
|
-
value:
|
|
141
|
-
onChange:
|
|
145
|
+
value: I,
|
|
146
|
+
onChange: N,
|
|
142
147
|
onKeyDown: $
|
|
143
148
|
})]
|
|
144
149
|
});
|
|
145
150
|
});
|
|
146
|
-
|
|
147
|
-
function
|
|
148
|
-
const { removeItem:
|
|
151
|
+
G.displayName = "InputChipInput";
|
|
152
|
+
function ne({ className: r, dataHookPrefix: v = "chip", itemAriaLabel: f }) {
|
|
153
|
+
const { removeItem: a, inputRef: u, setFocusedChipIndex: o, chipRefs: d } = K(), { value: c, disabled: y } = B(), p = t.useRef(null);
|
|
149
154
|
t.useEffect(() => {
|
|
150
|
-
if (
|
|
151
|
-
if (
|
|
155
|
+
if (p.current !== null) {
|
|
156
|
+
if (p.current === "input") u.current?.focus();
|
|
152
157
|
else {
|
|
153
|
-
const n =
|
|
154
|
-
n >= 0 && n <
|
|
158
|
+
const n = p.current;
|
|
159
|
+
n >= 0 && n < c.length ? d.current[n]?.focus() : c.length > 0 ? d.current[c.length - 1]?.focus() : u.current?.focus();
|
|
155
160
|
}
|
|
156
|
-
|
|
161
|
+
p.current = null;
|
|
157
162
|
}
|
|
158
163
|
}, [
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
c.length,
|
|
165
|
+
u,
|
|
166
|
+
d
|
|
162
167
|
]);
|
|
163
168
|
const w = (n, e) => {
|
|
164
|
-
if (!
|
|
169
|
+
if (!y)
|
|
165
170
|
switch (n.key) {
|
|
166
171
|
case "ArrowLeft":
|
|
167
|
-
n.preventDefault(), e > 0 && (
|
|
172
|
+
n.preventDefault(), e > 0 && (o(e - 1), d.current[e - 1]?.focus());
|
|
168
173
|
break;
|
|
169
174
|
case "ArrowRight":
|
|
170
|
-
n.preventDefault(), e <
|
|
175
|
+
n.preventDefault(), e < c.length - 1 ? (o(e + 1), d.current[e + 1]?.focus()) : (o(-1), u.current?.focus());
|
|
171
176
|
break;
|
|
172
177
|
case "Backspace":
|
|
173
178
|
case "Delete": {
|
|
174
179
|
n.preventDefault();
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
else if (e >=
|
|
179
|
-
const
|
|
180
|
-
|
|
180
|
+
const i = c.length - 1;
|
|
181
|
+
if (i === 0)
|
|
182
|
+
o(-1), p.current = "input", a(e);
|
|
183
|
+
else if (e >= i) {
|
|
184
|
+
const l = i - 1;
|
|
185
|
+
o(l), p.current = l, a(e);
|
|
181
186
|
} else
|
|
182
|
-
|
|
187
|
+
o(e), p.current = e, a(e);
|
|
183
188
|
break;
|
|
184
189
|
}
|
|
185
190
|
case "Home":
|
|
186
|
-
n.preventDefault(),
|
|
191
|
+
n.preventDefault(), c.length > 0 && (o(0), d.current[0]?.focus());
|
|
187
192
|
break;
|
|
188
193
|
case "End":
|
|
189
|
-
n.preventDefault(),
|
|
194
|
+
n.preventDefault(), o(-1), u.current?.focus();
|
|
190
195
|
}
|
|
191
|
-
},
|
|
192
|
-
|
|
196
|
+
}, b = (n) => {
|
|
197
|
+
o(n);
|
|
193
198
|
}, x = (n) => {
|
|
194
199
|
const e = n.relatedTarget;
|
|
195
|
-
e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") ||
|
|
200
|
+
e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") || o(-1);
|
|
196
201
|
};
|
|
197
|
-
return
|
|
198
|
-
className:
|
|
202
|
+
return c.length === 0 ? null : /* @__PURE__ */ R("div", {
|
|
203
|
+
className: F("contents", r),
|
|
199
204
|
"data-slot": "input-chip-items",
|
|
200
|
-
children:
|
|
201
|
-
ref: (
|
|
202
|
-
|
|
205
|
+
children: c.map((n, e) => /* @__PURE__ */ R(_, {
|
|
206
|
+
ref: (i) => {
|
|
207
|
+
d.current[e] = i;
|
|
203
208
|
},
|
|
204
|
-
"aria-label":
|
|
205
|
-
dataHook: `${
|
|
206
|
-
disabled:
|
|
209
|
+
"aria-label": f ? f.replace("{item}", n) : `${n}, press Delete to remove`,
|
|
210
|
+
dataHook: `${v}-${e}`,
|
|
211
|
+
disabled: y,
|
|
207
212
|
role: "group",
|
|
208
213
|
tabIndex: -1,
|
|
209
214
|
onBlur: x,
|
|
210
|
-
onFocus: () =>
|
|
211
|
-
onKeyDown: (
|
|
212
|
-
onRemove: () =>
|
|
215
|
+
onFocus: () => b(e),
|
|
216
|
+
onKeyDown: (i) => w(i, e),
|
|
217
|
+
onRemove: () => a(e),
|
|
213
218
|
children: n
|
|
214
219
|
}, `${n}-${e}`))
|
|
215
220
|
});
|
|
216
221
|
}
|
|
222
|
+
var J = t.forwardRef(({ className: r, count: v, ...f }, a) => {
|
|
223
|
+
const { value: u } = B();
|
|
224
|
+
return /* @__PURE__ */ R(A, {
|
|
225
|
+
ref: a,
|
|
226
|
+
className: F("order-last ml-auto pl-3", r),
|
|
227
|
+
count: v ?? u.length,
|
|
228
|
+
...f
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
J.displayName = "InputChipCount";
|
|
217
232
|
export {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
233
|
+
te as InputChip,
|
|
234
|
+
J as InputChipCount,
|
|
235
|
+
G as InputChipInput,
|
|
236
|
+
ne as InputChipItems,
|
|
237
|
+
ee as useInputChipContext
|
|
222
238
|
};
|
package/dist/input-group.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const E=require("./_virtual/_rolldown/runtime.cjs"),
|
|
1
|
+
"use client";const E=require("./_virtual/_rolldown/runtime.cjs"),z=require("./count-indicator.cjs"),B=require("./input.cjs");let t=require("react");t=E.__toESM(t,1);let H=require("@brightlocal/icons"),b=require("@brightlocal/ui-components/lib/utils"),p=require("react/jsx-runtime"),A=require("@radix-ui/react-slot"),G=require("class-variance-authority");var x=t.createContext(null),y=(0,G.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 has-[[data-slot=count-indicator][data-state=over]]:border-destructive-40 has-[[data-slot=count-indicator][data-state=over]]:has-[input:focus-visible]:border-destructive-40 has-[[data-slot=count-indicator][data-state=over]]:has-[input:focus-visible]:shadow-destructive",{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}}),w=t.forwardRef(({className:i,size:r,error:l,dataHook:n,trackingEl:s,trackingLabel:c,...h},g)=>{const[o,d]=t.useState({hasValue:!1,length:0,disabled:!1,ready:!1}),f=t.useRef(null),e=t.useCallback(()=>{const u=f.current,v={hasValue:!!u&&u.value.length>0,length:u?u.value.length:0,disabled:!!u&&(u.disabled||u.readOnly),ready:!0};d(m=>m.hasValue===v.hasValue&&m.length===v.length&&m.disabled===v.disabled&&m.ready===v.ready?m:v)},[]),a=t.useCallback(u=>{f.current=u},[]),I=t.useRef(null),_=t.useCallback(u=>{I.current=u},[]),k=t.useCallback(u=>{I.current?.(u)},[]),S=t.useMemo(()=>({inputState:o,syncInputState:e,registerInput:a,registerClearHandler:_,clearInput:k,inputRef:f}),[o,e,a,_,k]);return(0,p.jsx)(x.Provider,{value:S,children:(0,p.jsx)("div",{ref:g,className:(0,b.cn)(y({size:r,error:l}),i),"data-hook":n,"data-slot":"input-group","data-tracking-el":s,"data-tracking-label":c,...h})})});w.displayName="InputGroup";var R=t.forwardRef(({className:i,onChange:r,...l},n)=>{const s=t.useContext(x),c=t.useRef(null),h=s?.registerInput,g=t.useCallback(e=>{c.current=e,h?.(e),typeof n=="function"?n(e):n&&(n.current=e)},[h,n]),o=s?.syncInputState;t.useEffect(()=>{o?.()}),t.useEffect(()=>{const e=c.current?.form;if(!e||!o)return;const a=()=>queueMicrotask(o);return e.addEventListener("reset",a),()=>e.removeEventListener("reset",a)},[o]);const d=s?.registerClearHandler;t.useEffect(()=>{d?.(e=>{const a=c.current;if(!a)return;a.value="";const I=Object.create(e,{target:{value:a,enumerable:!0},currentTarget:{value:a,enumerable:!0}});r?.(I),o?.(),a.focus()})}),t.useEffect(()=>()=>d?.(null),[d]);const f=e=>{o?.(),r?.(e)};return(0,p.jsx)(B.Input,{ref:g,className:(0,b.cn)("border-0 focus-visible:border-0 focus-visible:shadow-[none]","h-full",i),dataHook:"input-group-input",onChange:f,...l})});R.displayName="InputGroupInput";var M=(0,G.cva)("flex shrink-0 items-center text-muted-foreground",{variants:{align:{"inline-start":["pl-(--input-group-addon-inset) [--input-group-addon-inset:--spacing(3)]","has-[>button,>[data-slot=input-group-button]]:[--input-group-addon-inset:--spacing(1)]"],"inline-end":["ml-auto pr-(--input-group-addon-inset) [--input-group-addon-inset:--spacing(3)]","has-[>button,>[data-slot=input-group-button]]:[--input-group-addon-inset:--spacing(1)]"],"block-start":"self-start","block-end":"self-end"}},defaultVariants:{align:"inline-start"}}),V=t.forwardRef(({className:i,align:r,...l},n)=>(0,p.jsx)("div",{ref:n,className:(0,b.cn)(M({align:r}),i),"data-slot":"input-group-addon",...l}));V.displayName="InputGroupAddon";var q=t.forwardRef(({className:i,count:r,...l},n)=>{const s=t.useContext(x);return(0,p.jsx)(z.CountIndicator,{ref:n,className:(0,b.cn)("pr-3",i),count:r??s?.inputState.length??0,ready:r!==void 0||(s?.inputState.ready??!0),...l})});q.displayName="InputGroupCount";var N=(0,G.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","cursor-pointer 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"}}),C=t.forwardRef(({className:i,variant:r,size:l,asChild:n=!1,...s},c)=>(0,p.jsx)(n?A.Slot:"button",{ref:c,className:(0,b.cn)(N({variant:r,size:l,className:i})),"data-slot":"input-group-button",type:n?void 0:"button",...s}));C.displayName="InputGroupButton";var j=t.forwardRef(({className:i,clearSearchAriaLabel:r,onClear:l,dataHook:n,trackingEl:s,trackingLabel:c,...h},g)=>{const o=t.useContext(x);if(!o)throw new Error("InputGroupClear must be used within <InputGroup>");const{inputState:d,clearInput:f}=o;if(!d.hasValue||d.disabled)return null;const e=a=>{f(a),l?.()};return(0,p.jsx)(C,{ref:g,"aria-label":r??"Clear search",className:(0,b.cn)("mr-1 ml-auto shrink-0 rounded-full",i),"data-hook":n??"input-group-clear","data-slot":"input-group-clear","data-tracking-el":s,"data-tracking-label":c,size:"icon-xs",onClick:e,...h,children:(0,p.jsx)(H.X,{size:14})})});j.displayName="InputGroupClear";exports.InputGroup=w;exports.InputGroupAddon=V;exports.InputGroupButton=C;exports.InputGroupClear=j;exports.InputGroupCount=q;exports.InputGroupInput=R;exports.inputGroupButtonVariants=N;exports.inputGroupVariants=y;
|
package/dist/input-group.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { CountIndicatorProps } from './count-indicator';
|
|
2
3
|
import { InputProps } from './input';
|
|
3
4
|
import * as React from "react";
|
|
4
5
|
declare const inputGroupVariants: (props?: ({
|
|
@@ -30,8 +31,42 @@ declare const inputGroupAddonVariants: (props?: ({
|
|
|
30
31
|
align?: "inline-end" | "inline-start" | "block-end" | "block-start" | null | undefined;
|
|
31
32
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
32
33
|
interface InputGroupAddonProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof inputGroupAddonVariants> {
|
|
34
|
+
/**
|
|
35
|
+
* Which side of the input the addon sits on. Inline addons are inset 12px
|
|
36
|
+
* on their inner side (4px when the addon holds an `InputGroupButton`, so
|
|
37
|
+
* the button's icon lands on the same line), so no padding is needed.
|
|
38
|
+
* @default "inline-start"
|
|
39
|
+
*/
|
|
40
|
+
align?: "inline-start" | "inline-end" | "block-start" | "block-end" | null;
|
|
33
41
|
}
|
|
34
42
|
declare const InputGroupAddon: React.ForwardRefExoticComponent<InputGroupAddonProps & React.RefAttributes<HTMLDivElement>>;
|
|
43
|
+
/**
|
|
44
|
+
* Props for InputGroupCount. `count` is optional: by default the group counts
|
|
45
|
+
* the characters in its input.
|
|
46
|
+
*/
|
|
47
|
+
interface InputGroupCountProps extends Omit<CountIndicatorProps, "count"> {
|
|
48
|
+
/**
|
|
49
|
+
* Count to show. Omit it to count the characters in the group's input; pass
|
|
50
|
+
* it when the group counts something else.
|
|
51
|
+
*/
|
|
52
|
+
count?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Count against a limit at the end of the group, such as `12 / 125`. Place it
|
|
56
|
+
* last, after the input (and before a clear button, if there is one).
|
|
57
|
+
*
|
|
58
|
+
* It never blocks typing. Over the limit the count turns red and the group
|
|
59
|
+
* takes the error border; show the error message and stop the save yourself.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <InputGroup dataHook="alt-group">
|
|
64
|
+
* <InputGroupInput value={alt} onChange={...} />
|
|
65
|
+
* <InputGroupCount dataHook="alt-count" limit={125} />
|
|
66
|
+
* </InputGroup>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare const InputGroupCount: React.ForwardRefExoticComponent<InputGroupCountProps & React.RefAttributes<HTMLSpanElement>>;
|
|
35
70
|
declare const inputGroupButtonVariants: (props?: ({
|
|
36
71
|
variant?: "default" | "ghost" | null | undefined;
|
|
37
72
|
size?: "default" | "icon" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
@@ -76,6 +111,6 @@ interface InputGroupClearProps extends Omit<React.ButtonHTMLAttributes<HTMLButto
|
|
|
76
111
|
* so controlled and uncontrolled usage both work) and returns focus to it.
|
|
77
112
|
*/
|
|
78
113
|
declare const InputGroupClear: React.ForwardRefExoticComponent<InputGroupClearProps & React.RefAttributes<HTMLButtonElement>>;
|
|
79
|
-
export { InputGroup, InputGroupInput, InputGroupAddon, InputGroupButton, InputGroupClear, inputGroupVariants, inputGroupButtonVariants, };
|
|
80
|
-
export type { InputGroupProps, InputGroupInputProps, InputGroupAddonProps, InputGroupButtonProps, InputGroupClearProps, };
|
|
114
|
+
export { InputGroup, InputGroupInput, InputGroupAddon, InputGroupButton, InputGroupClear, InputGroupCount, inputGroupVariants, inputGroupButtonVariants, };
|
|
115
|
+
export type { InputGroupProps, InputGroupInputProps, InputGroupAddonProps, InputGroupButtonProps, InputGroupClearProps, InputGroupCountProps, };
|
|
81
116
|
//# sourceMappingURL=input-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-group.d.ts","sourceRoot":"","sources":["../../src/components/input-group.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"input-group.d.ts","sourceRoot":"","sources":["../../src/components/input-group.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAmCjD,QAAA,MAAM,kBAAkB;;;8EAsBvB,CAAC;AAEF,UAAU,eACR,SACE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,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