@grandbazar/ui-baza 1.2.5 → 1.2.6

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.cjs CHANGED
@@ -45,6 +45,12 @@ function createRange(start, length) {
45
45
  return Array.from({ length }, (_, index) => start + index);
46
46
  }
47
47
 
48
+ function omit(object, ...keys) {
49
+ const omitKeys = new Set(keys.map((key) => key.trim()).filter(Boolean));
50
+ const filteredEntries = Object.entries(object).filter(([key]) => !omitKeys.has(key));
51
+ return Object.fromEntries(filteredEntries);
52
+ }
53
+
48
54
  const badge = "_badge_p5h5n_2";
49
55
  const primary$3 = "_primary_p5h5n_9";
50
56
  const secondary$4 = "_secondary_p5h5n_13";
@@ -2431,14 +2437,15 @@ const styles$7 = {
2431
2437
 
2432
2438
  function Search(props) {
2433
2439
  const searchId = React.useId();
2434
- const { onChange, value, className, placeholder, mode } = props;
2440
+ const { onChange, value, className, mode, onReset, ...inputProps } = props;
2441
+ const sanitizedInputProps = omit(inputProps, "buttonWidth", "onSearch");
2435
2442
  const inputField = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2436
2443
  /* @__PURE__ */ jsxRuntime.jsx(
2437
2444
  TextField.Input,
2438
2445
  {
2439
- placeholder,
2446
+ ...sanitizedInputProps,
2440
2447
  value,
2441
- onChange: (e) => onChange?.(e.target.value),
2448
+ onChange: (e) => onChange(e.target.value),
2442
2449
  id: `search-input-${searchId}`
2443
2450
  }
2444
2451
  ),
@@ -2448,7 +2455,13 @@ function Search(props) {
2448
2455
  className: styles$7.icon,
2449
2456
  "aria-label": "clear search",
2450
2457
  role: "button",
2451
- onClick: () => onChange(""),
2458
+ onClick: () => {
2459
+ if (onReset) {
2460
+ onReset();
2461
+ } else {
2462
+ onChange("");
2463
+ }
2464
+ },
2452
2465
  "data-element": "icon"
2453
2466
  }
2454
2467
  )
package/dist/index.d.ts CHANGED
@@ -458,14 +458,14 @@ export declare function RadioButton({ className, label, ...props }: TRadioButton
458
458
 
459
459
  /**
460
460
  * Search renders a search input field with icon and clear button.
461
- * Supports different modes: default (inline icon) and custom (separate search button).
461
+ * Supports TextField.Input props and two modes: default and custom.
462
462
  *
463
463
  * @param value - Current search query value
464
464
  * @param onChange - Callback fired when input value changes
465
- * @param placeholder - Placeholder text for the input
465
+ * @param onReset - Optional callback fired when clear button is clicked
466
466
  * @param mode - Display mode: 'default' (inline icon) or 'custom' (separate search button)
467
467
  * @param onSearch - (only for mode='custom') Callback fired when search button is clicked
468
- * @param className - Additional CSS classes
468
+ * @param buttonWidth - (only for mode='custom') Width of the search button in pixels
469
469
  */
470
470
  export declare function Search(props: TSearchProps): JSX.Element;
471
471
 
@@ -783,11 +783,10 @@ declare type TRadioButtonProps = React.InputHTMLAttributes<HTMLInputElement> & {
783
783
  ref?: React.RefObject<HTMLInputElement | null>;
784
784
  };
785
785
 
786
- declare type TSearchBaseProps = {
786
+ declare type TSearchBaseProps = Omit<ComponentProps<typeof TextField.Input>, 'value' | 'onChange' | 'id'> & {
787
787
  value: string;
788
788
  onChange: (value: string) => void;
789
- placeholder?: string;
790
- className?: string;
789
+ onReset?: VoidFunction;
791
790
  };
792
791
 
793
792
  declare type TSearchCustomProps = TSearchBaseProps & {
package/dist/index.js CHANGED
@@ -41,6 +41,12 @@ function createRange(start, length) {
41
41
  return Array.from({ length }, (_, index) => start + index);
42
42
  }
43
43
 
44
+ function omit(object, ...keys) {
45
+ const omitKeys = new Set(keys.map((key) => key.trim()).filter(Boolean));
46
+ const filteredEntries = Object.entries(object).filter(([key]) => !omitKeys.has(key));
47
+ return Object.fromEntries(filteredEntries);
48
+ }
49
+
44
50
  const badge = "_badge_p5h5n_2";
45
51
  const primary$3 = "_primary_p5h5n_9";
46
52
  const secondary$4 = "_secondary_p5h5n_13";
@@ -2427,14 +2433,15 @@ const styles$7 = {
2427
2433
 
2428
2434
  function Search(props) {
2429
2435
  const searchId = useId();
2430
- const { onChange, value, className, placeholder, mode } = props;
2436
+ const { onChange, value, className, mode, onReset, ...inputProps } = props;
2437
+ const sanitizedInputProps = omit(inputProps, "buttonWidth", "onSearch");
2431
2438
  const inputField = /* @__PURE__ */ jsxs(Fragment$1, { children: [
2432
2439
  /* @__PURE__ */ jsx(
2433
2440
  TextField.Input,
2434
2441
  {
2435
- placeholder,
2442
+ ...sanitizedInputProps,
2436
2443
  value,
2437
- onChange: (e) => onChange?.(e.target.value),
2444
+ onChange: (e) => onChange(e.target.value),
2438
2445
  id: `search-input-${searchId}`
2439
2446
  }
2440
2447
  ),
@@ -2444,7 +2451,13 @@ function Search(props) {
2444
2451
  className: styles$7.icon,
2445
2452
  "aria-label": "clear search",
2446
2453
  role: "button",
2447
- onClick: () => onChange(""),
2454
+ onClick: () => {
2455
+ if (onReset) {
2456
+ onReset();
2457
+ } else {
2458
+ onChange("");
2459
+ }
2460
+ },
2448
2461
  "data-element": "icon"
2449
2462
  }
2450
2463
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grandbazar/ui-baza",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "A lightweight and modular UI kit for building modern, accessible web interfaces. Designed for flexibility, scalability, and developer happiness.",
5
5
  "repository": {
6
6
  "type": "git",