gridsmith-ui 0.2.17 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -55,7 +55,7 @@ interface BulkActionBarProps {
55
55
  declare function BulkActionBar({ selectedCount, actions, onClearSelection, className }: BulkActionBarProps): react_jsx_runtime.JSX.Element | null;
56
56
 
57
57
  type InputSize = "sm" | "md";
58
- declare function Input({ className, size, error, prefix, suffix, ...props }: Omit<InputHTMLAttributes<HTMLInputElement>, "size"> & {
58
+ declare function Input({ className, size, error, prefix, suffix, ...props }: Omit<InputHTMLAttributes<HTMLInputElement>, "size" | "prefix"> & {
59
59
  size?: InputSize;
60
60
  error?: boolean;
61
61
  prefix?: ReactNode;
@@ -172,8 +172,10 @@ interface DatePickerProps {
172
172
  container?: Element | DocumentFragment;
173
173
  error?: boolean;
174
174
  label?: string;
175
+ /** Forwarded to the trigger button so an external Label htmlFor can be associated. Defaults to a generated id used by the built-in label. */
176
+ id?: string;
175
177
  }
176
- declare function DatePicker({ value, onChange, placeholder, disabled, className, ref, container, error, label }: DatePickerProps): react_jsx_runtime.JSX.Element;
178
+ declare function DatePicker({ value, onChange, placeholder, disabled, className, ref, container, error, label, id }: DatePickerProps): react_jsx_runtime.JSX.Element;
177
179
 
178
180
  interface FileUploadProps {
179
181
  onFiles: (files: File[]) => void;
@@ -210,8 +212,10 @@ interface TimePickerProps {
210
212
  ref?: Ref<HTMLDivElement>;
211
213
  container?: Element | DocumentFragment;
212
214
  error?: boolean;
215
+ /** Forwarded to the trigger button so a Label htmlFor can be associated. */
216
+ id?: string;
213
217
  }
214
- declare function TimePicker({ value, onChange, use24Hour, minuteStep, disabled, className, ref, container, error, }: TimePickerProps): react_jsx_runtime.JSX.Element;
218
+ declare function TimePicker({ value, onChange, use24Hour, minuteStep, disabled, className, ref, container, error, id, }: TimePickerProps): react_jsx_runtime.JSX.Element;
215
219
 
216
220
  interface NumberInputProps {
217
221
  value: number;
@@ -226,8 +230,10 @@ interface NumberInputProps {
226
230
  size?: "sm" | "md" | "lg";
227
231
  className?: string;
228
232
  error?: boolean;
233
+ /** Forwarded to the inner input element so a Label htmlFor can be associated. */
234
+ id?: string;
229
235
  }
230
- declare function NumberInput({ value, onChange, min, max, step, disabled, placeholder, prefix, suffix, size, className, error, }: NumberInputProps): react_jsx_runtime.JSX.Element;
236
+ declare function NumberInput({ value, onChange, min, max, step, disabled, placeholder, prefix, suffix, size, className, error, id, }: NumberInputProps): react_jsx_runtime.JSX.Element;
231
237
 
232
238
  interface TagInputProps {
233
239
  value: string[];
@@ -237,8 +243,10 @@ interface TagInputProps {
237
243
  disabled?: boolean;
238
244
  className?: string;
239
245
  error?: boolean;
246
+ /** Forwarded to the inner input element so a Label htmlFor can be associated. */
247
+ id?: string;
240
248
  }
241
- declare function TagInput({ value, onChange, placeholder, maxTags, disabled, className, error, }: TagInputProps): react_jsx_runtime.JSX.Element;
249
+ declare function TagInput({ value, onChange, placeholder, maxTags, disabled, className, error, id, }: TagInputProps): react_jsx_runtime.JSX.Element;
242
250
 
243
251
  interface PinInputProps {
244
252
  value: string;
@@ -249,8 +257,10 @@ interface PinInputProps {
249
257
  size?: "sm" | "md" | "lg";
250
258
  className?: string;
251
259
  error?: boolean;
260
+ /** Forwarded to the first pin box so a Label htmlFor can be associated. */
261
+ id?: string;
252
262
  }
253
- declare function PinInput({ value, onChange, length, mask, disabled, size, className, error, }: PinInputProps): react_jsx_runtime.JSX.Element;
263
+ declare function PinInput({ value, onChange, length, mask, disabled, size, className, error, id, }: PinInputProps): react_jsx_runtime.JSX.Element;
254
264
 
255
265
  interface RatingProps {
256
266
  value: number;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { cn, GLASS_BACKDROP, lockBodyScroll, unlockBodyScroll, GLASS_OVERLAY, GLASS_DROPDOWN, GLASS_SURFACE } from './chunk-5XIPPVH7.js';
1
+ import { cn, GLASS_BACKDROP, GLASS_DROPDOWN, lockBodyScroll, unlockBodyScroll, GLASS_OVERLAY, GLASS_SURFACE } from './chunk-5XIPPVH7.js';
2
2
  import { Icon } from './chunk-H2XI6OUB.js';
3
3
  import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
4
4
  import * as React6 from 'react';
5
- import React6__default, { createContext, forwardRef, useState, useCallback, useRef, useContext, useId, useMemo, useEffect, createElement, Fragment as Fragment$1, useLayoutEffect, isValidElement, cloneElement, useDebugValue, memo, useReducer, useSyncExternalStore as useSyncExternalStore$1, useImperativeHandle } from 'react';
5
+ import React6__default, { createContext, forwardRef, useState, useCallback, useRef, useContext, useId, useMemo, useEffect, useLayoutEffect, isValidElement, cloneElement, createElement, Fragment as Fragment$1, useDebugValue, memo, useReducer, useSyncExternalStore as useSyncExternalStore$1, useImperativeHandle } from 'react';
6
6
  import ReactDOM, { createPortal, unstable_batchedUpdates, flushSync } from 'react-dom';
7
7
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
8
8
  import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
@@ -2723,12 +2723,13 @@ function isSameDay(a, b) {
2723
2723
  function formatDate(d2) {
2724
2724
  return `${MONTHS[d2.getMonth()].slice(0, 3)} ${d2.getDate()}, ${d2.getFullYear()}`;
2725
2725
  }
2726
- function DatePicker({ value, onChange, placeholder = "Pick a date", disabled, className, ref, container, error = false, label }) {
2726
+ function DatePicker({ value, onChange, placeholder = "Pick a date", disabled, className, ref, container, error = false, label, id }) {
2727
2727
  const [open, setOpen] = useState(false);
2728
2728
  const [viewDate, setViewDate] = useState(() => value ?? /* @__PURE__ */ new Date());
2729
2729
  const triggerRef = useRef(null);
2730
2730
  const panelRef = useRef(null);
2731
- const inputId = useId();
2731
+ const generatedId = useId();
2732
+ const inputId = id ?? generatedId;
2732
2733
  const pos = usePosition(triggerRef, panelRef, open, { side: "bottom", align: "start", offset: 4, flip: true });
2733
2734
  const year = viewDate.getFullYear();
2734
2735
  const month = viewDate.getMonth();
@@ -3205,7 +3206,8 @@ function TimePicker({
3205
3206
  className,
3206
3207
  ref,
3207
3208
  container,
3208
- error = false
3209
+ error = false,
3210
+ id
3209
3211
  }) {
3210
3212
  const [open, setOpen] = useState(false);
3211
3213
  const triggerRef = useRef(null);
@@ -3244,12 +3246,13 @@ function TimePicker({
3244
3246
  /* @__PURE__ */ jsxs(
3245
3247
  "button",
3246
3248
  {
3249
+ id,
3247
3250
  ref: triggerRef,
3248
3251
  onClick: () => !disabled && setOpen(!open),
3249
3252
  disabled,
3250
3253
  "aria-invalid": error || void 0,
3251
3254
  className: cn(
3252
- "inline-flex items-center gap-ds-2 text-sm",
3255
+ "flex w-full items-center gap-ds-2 text-sm",
3253
3256
  "border-[length:var(--ds-border-width)]",
3254
3257
  error ? "border-[var(--ds-status-error)]" : "border-[var(--ds-input-border)]",
3255
3258
  "bg-[var(--ds-input-bg)] rounded-[var(--ds-radius-md)]",
@@ -3349,7 +3352,8 @@ function NumberInput({
3349
3352
  suffix,
3350
3353
  size = "md",
3351
3354
  className,
3352
- error = false
3355
+ error = false,
3356
+ id
3353
3357
  }) {
3354
3358
  const intervalRef = useRef(void 0);
3355
3359
  const timeoutRef = useRef(void 0);
@@ -3401,7 +3405,7 @@ function NumberInput({
3401
3405
  "div",
3402
3406
  {
3403
3407
  className: cn(
3404
- "inline-flex items-center",
3408
+ "flex items-center w-full",
3405
3409
  "border-[length:var(--ds-border-width)]",
3406
3410
  error ? "border-[var(--ds-status-error)]" : "border-[var(--ds-input-border)]",
3407
3411
  "rounded-[var(--ds-radius-md)]",
@@ -3442,6 +3446,7 @@ function NumberInput({
3442
3446
  /* @__PURE__ */ jsx(
3443
3447
  "input",
3444
3448
  {
3449
+ id,
3445
3450
  type: "text",
3446
3451
  inputMode: "decimal",
3447
3452
  "aria-invalid": error || void 0,
@@ -3567,7 +3572,8 @@ function TagInput({
3567
3572
  maxTags = Infinity,
3568
3573
  disabled = false,
3569
3574
  className,
3570
- error = false
3575
+ error = false,
3576
+ id
3571
3577
  }) {
3572
3578
  const [input, setInput] = useState("");
3573
3579
  const inputRef = useRef(null);
@@ -3645,6 +3651,7 @@ function TagInput({
3645
3651
  /* @__PURE__ */ jsx(
3646
3652
  "input",
3647
3653
  {
3654
+ id,
3648
3655
  ref: inputRef,
3649
3656
  type: "text",
3650
3657
  "aria-invalid": error || void 0,
@@ -3682,7 +3689,8 @@ function PinInput({
3682
3689
  disabled = false,
3683
3690
  size = "md",
3684
3691
  className,
3685
- error = false
3692
+ error = false,
3693
+ id
3686
3694
  }) {
3687
3695
  const inputsRef = useRef([]);
3688
3696
  const digits = value.padEnd(length, " ").slice(0, length).split("");
@@ -3743,6 +3751,7 @@ function PinInput({
3743
3751
  children: digits.map((digit, i) => /* @__PURE__ */ jsx(
3744
3752
  "input",
3745
3753
  {
3754
+ id: i === 0 ? id : void 0,
3746
3755
  ref: (el) => {
3747
3756
  inputsRef.current[i] = el;
3748
3757
  },
@@ -94140,26 +94149,29 @@ var Sidebar = forwardRef(function Sidebar2({
94140
94149
  }
94141
94150
  ),
94142
94151
  /* @__PURE__ */ jsx(ScrollArea, { className: "flex-1", children }),
94143
- showCollapse && /* @__PURE__ */ jsxs(
94144
- "button",
94145
- {
94146
- onClick: () => handleCollapsedChange(!collapsed),
94147
- "aria-expanded": !collapsed,
94148
- "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
94149
- className: cn(
94150
- "flex items-center gap-ds-2 py-ds-2 mx-ds-2 text-sm rounded-[var(--ds-radius-md)]",
94151
- "transition-colors cursor-pointer",
94152
- "text-[var(--ds-sidebar-text-muted)] hover:bg-[var(--ds-sidebar-item-hover)] hover:text-[var(--ds-sidebar-text)]",
94153
- "focus-visible:outline-none focus-visible:shadow-[var(--ds-shadow-focus)]",
94154
- collapsed ? "justify-center px-0" : "px-ds-3"
94155
- ),
94156
- style: { marginBottom: footer ? 0 : "var(--ds-space-3)" },
94157
- children: [
94158
- /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: 16, className: cn("transition-transform", !collapsed && "rotate-180") }),
94159
- !collapsed && /* @__PURE__ */ jsx("span", { children: "Collapse" })
94160
- ]
94161
- }
94162
- ),
94152
+ showCollapse && (() => {
94153
+ const collapseButton = /* @__PURE__ */ jsxs(
94154
+ "button",
94155
+ {
94156
+ onClick: () => handleCollapsedChange(!collapsed),
94157
+ "aria-expanded": !collapsed,
94158
+ "aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
94159
+ className: cn(
94160
+ "flex items-center gap-ds-2 py-ds-2 mx-ds-2 text-sm rounded-[var(--ds-radius-md)]",
94161
+ "transition-colors cursor-pointer",
94162
+ "text-[var(--ds-sidebar-text-muted)] hover:bg-[var(--ds-sidebar-item-hover)] hover:text-[var(--ds-sidebar-text)]",
94163
+ "focus-visible:outline-none focus-visible:shadow-[var(--ds-shadow-focus)]",
94164
+ collapsed ? "justify-center px-0" : "px-ds-3"
94165
+ ),
94166
+ style: { marginBottom: footer ? 0 : "var(--ds-space-3)" },
94167
+ children: [
94168
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: 16, className: cn("transition-transform", !collapsed && "rotate-180") }),
94169
+ !collapsed && /* @__PURE__ */ jsx("span", { children: "Collapse" })
94170
+ ]
94171
+ }
94172
+ );
94173
+ return collapsed ? /* @__PURE__ */ jsx(Tooltip, { content: "Expand sidebar", side: "right", delay: 100, container: portalEl ?? void 0, children: collapseButton }) : collapseButton;
94174
+ })(),
94163
94175
  footer && /* @__PURE__ */ jsx(
94164
94176
  "div",
94165
94177
  {