@edifice.io/react 2.3.2-develop-b2school-actualites.20251020144208 → 2.3.2-develop-b2school-actualites.20251022111214

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.
@@ -14,7 +14,7 @@ export interface OptionsType {
14
14
  */
15
15
  icon?: JSX.Element;
16
16
  }
17
- export interface SelectProps extends Omit<DropdownProps, 'children'>, Omit<DropdownTriggerProps, 'badgeContent'> {
17
+ export interface SelectProps extends Omit<DropdownProps, 'children'>, Omit<DropdownTriggerProps, 'badgeContent' | 'defaultValue'> {
18
18
  /**
19
19
  * Default select label
20
20
  */
@@ -27,13 +27,17 @@ export interface SelectProps extends Omit<DropdownProps, 'children'>, Omit<Dropd
27
27
  * Callback to get value
28
28
  */
29
29
  onValueChange?: (option: OptionsType | string) => void;
30
+ /**
31
+ * Default value
32
+ */
33
+ defaultValue?: string;
30
34
  }
31
35
  /**
32
36
  *
33
37
  * Select component is based on Dropdown Component. It extends `Dropdown` and `Dropdown.Trigger` props `block`, `overflow`, `icon`, `variant`, `size`, `disabled`
34
38
  */
35
39
  declare const Select: {
36
- ({ icon, options, overflow, block, variant, size, disabled, placeholderOption, onValueChange, }: SelectProps): import("react/jsx-runtime").JSX.Element;
40
+ ({ icon, options, overflow, block, variant, size, disabled, placeholderOption, onValueChange, defaultValue, }: SelectProps): import("react/jsx-runtime").JSX.Element;
37
41
  displayName: string;
38
42
  };
39
43
  export default Select;
@@ -12,7 +12,8 @@ const Select = ({
12
12
  size,
13
13
  disabled,
14
14
  placeholderOption,
15
- onValueChange
15
+ onValueChange,
16
+ defaultValue
16
17
  }) => {
17
18
  const [localValue, setLocalValue] = useState(), {
18
19
  t
@@ -22,7 +23,12 @@ const Select = ({
22
23
  const value = typeof localValue == "object" ? localValue.value : localValue;
23
24
  onValueChange == null || onValueChange(value);
24
25
  }
25
- }, [localValue]);
26
+ }, [localValue]), useEffect(() => {
27
+ if (defaultValue) {
28
+ const foundOption = options.find((option) => (typeof option == "object" ? option.value : option) === defaultValue);
29
+ foundOption !== void 0 && setLocalValue(foundOption);
30
+ }
31
+ }, []);
26
32
  const label = typeof localValue == "object" ? localValue.label : localValue, iconChange = typeof localValue == "object" ? localValue.icon : void 0;
27
33
  return /* @__PURE__ */ jsxs(Dropdown, { overflow, block, children: [
28
34
  /* @__PURE__ */ jsx(SelectTrigger, { icon: iconChange || icon, label: /* @__PURE__ */ jsx("span", { className: "text-truncate", children: t(label || placeholderOption) }), variant, size, disabled }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.3.2-develop-b2school-actualites.20251020144208",
3
+ "version": "2.3.2-develop-b2school-actualites.20251022111214",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -131,9 +131,9 @@
131
131
  "react-slugify": "^3.0.3",
132
132
  "swiper": "^10.1.0",
133
133
  "ua-parser-js": "^1.0.36",
134
- "@edifice.io/bootstrap": "2.3.2-develop-b2school-actualites.20251020144208",
135
- "@edifice.io/tiptap-extensions": "2.3.2-develop-b2school-actualites.20251020144208",
136
- "@edifice.io/utilities": "2.3.2-develop-b2school-actualites.20251020144208"
134
+ "@edifice.io/bootstrap": "2.3.2-develop-b2school-actualites.20251022111214",
135
+ "@edifice.io/tiptap-extensions": "2.3.2-develop-b2school-actualites.20251022111214",
136
+ "@edifice.io/utilities": "2.3.2-develop-b2school-actualites.20251022111214"
137
137
  },
138
138
  "devDependencies": {
139
139
  "@babel/plugin-transform-react-pure-annotations": "^7.23.3",
@@ -164,8 +164,8 @@
164
164
  "vite": "^5.4.11",
165
165
  "vite-plugin-dts": "^4.1.0",
166
166
  "vite-tsconfig-paths": "^5.0.1",
167
- "@edifice.io/config": "2.3.2-develop-b2school-actualites.20251020144208",
168
- "@edifice.io/client": "2.3.2-develop-b2school-actualites.20251020144208"
167
+ "@edifice.io/client": "2.3.2-develop-b2school-actualites.20251022111214",
168
+ "@edifice.io/config": "2.3.2-develop-b2school-actualites.20251022111214"
169
169
  },
170
170
  "peerDependencies": {
171
171
  "@react-spring/web": "^9.7.5",