@edifice.io/react 2.0.0-develop-enabling.20250702095446 → 2.0.0-develop-enabling.20250703141047

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.
@@ -1,51 +1,74 @@
1
1
  import { ChangeEvent } from 'react';
2
2
  import { Size } from '../../types';
3
+ /**
4
+ * Base props shared by both SearchBar variants
5
+ */
3
6
  export interface BaseProps {
4
7
  /**
5
- * String or Template literal with React i18next namespace
8
+ * String or template literal key for i18next translation
6
9
  */
7
10
  placeholder?: string;
8
11
  /**
9
- * Control SearchBar size
12
+ * Control SearchBar size (excluding 'sm')
10
13
  */
11
14
  size?: Exclude<Size, 'sm'>;
12
15
  /**
13
- * Disabled status
16
+ * Disable the input
14
17
  */
15
18
  disabled?: boolean;
16
19
  /**
17
- * Optional class for styling purpose
20
+ * Optional class for custom styling
18
21
  */
19
22
  className?: string;
20
23
  /**
21
- * ChangeEvent Handler
24
+ * onChange handler for input changes
22
25
  */
23
26
  onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
27
+ /**
28
+ * Current value of the input
29
+ */
30
+ value?: string;
31
+ /**
32
+ * Show a clear (reset) button when value is present
33
+ */
34
+ clearable?: boolean;
24
35
  }
36
+ /**
37
+ * Default SearchBar with a submit button
38
+ */
25
39
  type DefaultSearchBar = {
26
40
  /**
27
- * Switch between button or dynamic search bar
41
+ * Use false to render the default SearchBar (with a button)
28
42
  */
29
43
  isVariant: false;
30
44
  /**
31
- * Handle Search with Default SearchBar
45
+ * Callback when clicking the search button
32
46
  */
33
47
  onClick: () => void;
34
48
  };
49
+ /**
50
+ * Dynamic SearchBar with icon and no submit button
51
+ */
35
52
  type DynamicSearchBar = {
36
53
  /**
37
- * Switch between button or dynamic search bar
54
+ * Use true to render the dynamic SearchBar (with an icon inside input)
38
55
  */
39
56
  isVariant: true;
40
57
  /**
41
- * Handle Search with Default SearchBar
58
+ * onClick must be undefined for dynamic variant
42
59
  */
43
60
  onClick?: undefined;
44
61
  };
62
+ /**
63
+ * Props for the SearchBar component
64
+ */
45
65
  export type Props = DefaultSearchBar | DynamicSearchBar;
46
66
  export type SearchBarProps = BaseProps & Props;
67
+ /**
68
+ * SearchBar component to handle dynamic or static search input
69
+ */
47
70
  declare const SearchBar: {
48
- ({ isVariant, size, placeholder, className, disabled, onChange, onClick, ...restProps }: SearchBarProps): import("react/jsx-runtime").JSX.Element;
71
+ ({ isVariant, size, placeholder, className, disabled, onChange, onClick, value, clearable, ...restProps }: SearchBarProps): import("react/jsx-runtime").JSX.Element;
49
72
  displayName: string;
50
73
  };
51
74
  export default SearchBar;
@@ -1,6 +1,7 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import clsx from "clsx";
3
3
  import { useTranslation } from "react-i18next";
4
+ import SvgIconClose from "../../modules/icons/components/IconClose.js";
4
5
  import SvgIconSearch from "../../modules/icons/components/IconSearch.js";
5
6
  import FormControl from "../Form/FormControl.js";
6
7
  import SearchButton from "../Button/SearchButton.js";
@@ -12,6 +13,8 @@ const SearchBar = ({
12
13
  disabled,
13
14
  onChange,
14
15
  onClick,
16
+ value,
17
+ clearable = !1,
15
18
  ...restProps
16
19
  }) => {
17
20
  const {
@@ -21,13 +24,25 @@ const SearchBar = ({
21
24
  "position-relative": isVariant
22
25
  }), input = clsx({
23
26
  "border-end-0": !isVariant,
24
- "ps-48": isVariant
27
+ "ps-48": isVariant,
28
+ "searchbar-hide-native-clear": isVariant && clearable
25
29
  }), handleClick = () => {
26
30
  onClick == null || onClick();
31
+ }, handleClear = () => {
32
+ const event = {
33
+ target: {
34
+ value: ""
35
+ }
36
+ };
37
+ onChange == null || onChange(event);
27
38
  };
28
39
  return /* @__PURE__ */ jsxs(FormControl, { id: "search-bar", className: searchbar, children: [
29
40
  isVariant && /* @__PURE__ */ jsx("div", { className: "position-absolute z-1 top-50 start-0 translate-middle-y border-0 ps-12 bg-transparent", children: /* @__PURE__ */ jsx(SvgIconSearch, {}) }),
30
- /* @__PURE__ */ jsx(FormControl.Input, { type: "search", placeholder: t(placeholder), size, noValidationIcon: !0, className: input, onChange, disabled, ...restProps }),
41
+ /* @__PURE__ */ jsx(FormControl.Input, { type: "search", placeholder: t(placeholder), size, noValidationIcon: !0, className: input, onChange, value, disabled, ...restProps }),
42
+ isVariant && clearable && value && onChange && /* @__PURE__ */ jsx("button", { type: "button", onClick: handleClear, className: "position-absolute end-0 top-50 translate-middle-y pe-12 bg-transparent border-0", "aria-label": t("clear"), children: /* @__PURE__ */ jsx(SvgIconClose, { className: "color-gray", style: {
43
+ width: 12,
44
+ height: 12
45
+ } }) }),
31
46
  !isVariant && /* @__PURE__ */ jsx(SearchButton, { type: "submit", "aria-label": t("search"), icon: /* @__PURE__ */ jsx(SvgIconSearch, {}), className: "border-start-0", onClick: handleClick })
32
47
  ] });
33
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.0.0-develop-enabling.20250702095446",
3
+ "version": "2.0.0-develop-enabling.20250703141047",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -118,9 +118,9 @@
118
118
  "react-slugify": "^3.0.3",
119
119
  "swiper": "^10.1.0",
120
120
  "ua-parser-js": "^1.0.36",
121
- "@edifice.io/bootstrap": "2.0.0-develop-enabling.20250702095446",
122
- "@edifice.io/tiptap-extensions": "2.0.0-develop-enabling.20250702095446",
123
- "@edifice.io/utilities": "2.0.0-develop-enabling.20250702095446"
121
+ "@edifice.io/bootstrap": "2.0.0-develop-enabling.20250703141047",
122
+ "@edifice.io/tiptap-extensions": "2.0.0-develop-enabling.20250703141047",
123
+ "@edifice.io/utilities": "2.0.0-develop-enabling.20250703141047"
124
124
  },
125
125
  "devDependencies": {
126
126
  "@babel/plugin-transform-react-pure-annotations": "^7.23.3",
@@ -151,8 +151,8 @@
151
151
  "vite": "^5.4.11",
152
152
  "vite-plugin-dts": "^4.1.0",
153
153
  "vite-tsconfig-paths": "^5.0.1",
154
- "@edifice.io/client": "2.0.0-develop-enabling.20250702095446",
155
- "@edifice.io/config": "2.0.0-develop-enabling.20250702095446"
154
+ "@edifice.io/client": "2.0.0-develop-enabling.20250703141047",
155
+ "@edifice.io/config": "2.0.0-develop-enabling.20250703141047"
156
156
  },
157
157
  "peerDependencies": {
158
158
  "@react-spring/web": "^9.7.5",