@telia/teddy 0.4.12 → 0.4.13

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.
@@ -21,6 +21,8 @@ export type RootProps = React.ComponentPropsWithoutRef<'div'> & {
21
21
  currentPath: string | undefined;
22
22
  onSearchInputChange?: (e: React.ChangeEvent<HTMLInputElement>, value?: string) => void;
23
23
  onSearchKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
24
+ searchValue?: string;
25
+ onClear?: () => void;
24
26
  };
25
27
  type RootContext = {
26
28
  selectedMenuItem: string | undefined;
@@ -31,9 +33,9 @@ type RootContext = {
31
33
  setPathname: (v: string) => void;
32
34
  specifiedLink?: string;
33
35
  setSpecifiedLink: (v: string) => void;
34
- } & Pick<RootProps, 'onSearchSubmit' | 'additionalSearchContent' | 'shoppingCart' | 'shoppingCartNumberOfItems' | 'loggedInUser' | 'appKey' | 'onLogoutClick' | 'linkComponent' | 'isCartOpen' | 'onCartOpenChange' | 'drawerSize' | "onSearchInputChange" | 'onSearchKeyDown'>;
36
+ } & Pick<RootProps, 'onSearchSubmit' | 'additionalSearchContent' | 'shoppingCart' | 'shoppingCartNumberOfItems' | 'loggedInUser' | 'appKey' | 'onLogoutClick' | 'linkComponent' | 'isCartOpen' | 'onCartOpenChange' | 'drawerSize' | "onSearchInputChange" | 'onSearchKeyDown' | 'searchValue' | 'onClear'>;
35
37
  export declare const RootContext: React.Context<RootContext | null>;
36
- export declare function Root({ className, appKey, loggedInUser, linkComponent, onLogoutClick, shoppingCart, shoppingCartNumberOfItems, onSearchSubmit, additionalSearchContent, isCartOpen, onCartOpenChange, drawerSize, isSimplified, currentPath, onSearchInputChange, onSearchKeyDown, ...props }: RootProps): import("react/jsx-runtime").JSX.Element;
38
+ export declare function Root({ className, appKey, loggedInUser, linkComponent, onLogoutClick, shoppingCart, shoppingCartNumberOfItems, onSearchSubmit, additionalSearchContent, isCartOpen, onCartOpenChange, drawerSize, isSimplified, currentPath, onSearchInputChange, onSearchKeyDown, searchValue, onClear, ...props }: RootProps): import("react/jsx-runtime").JSX.Element;
37
39
  export declare namespace Root {
38
40
  var displayName: string;
39
41
  }
@@ -690,6 +690,7 @@ const SearchField = React.forwardRef(
690
690
  components_textField_index.TextField.Input,
691
691
  {
692
692
  ref: composedRef,
693
+ value: context == null ? void 0 : context.searchValue,
693
694
  onChange: (e) => {
694
695
  var _a, _b;
695
696
  if (((_a = ref.current) == null ? void 0 : _a.value) && (context == null ? void 0 : context.onSearchInputChange)) {
@@ -704,7 +705,11 @@ const SearchField = React.forwardRef(
704
705
  placeholder: "Søk her"
705
706
  }
706
707
  ),
707
- /* @__PURE__ */ jsxRuntime.jsx(components_textField_index.TextField.ClearButton, {})
708
+ /* @__PURE__ */ jsxRuntime.jsx(components_textField_index.TextField.ClearButton, { onClick: () => {
709
+ if (context == null ? void 0 : context.onClear) {
710
+ context.onClear();
711
+ }
712
+ } })
708
713
  ] }),
709
714
  /* @__PURE__ */ jsxRuntime.jsx(components_textField_index.TextField.Button, { variant: "separated", children: "Søk" })
710
715
  ] })
@@ -1215,6 +1220,8 @@ function Root({
1215
1220
  currentPath,
1216
1221
  onSearchInputChange,
1217
1222
  onSearchKeyDown,
1223
+ searchValue,
1224
+ onClear,
1218
1225
  ...props
1219
1226
  }) {
1220
1227
  const [selectedMenuItem, setSelectedMenuItem] = React.useState(getInitialMenuItem(currentPath));
@@ -1261,7 +1268,9 @@ function Root({
1261
1268
  specifiedLink,
1262
1269
  setSpecifiedLink,
1263
1270
  onSearchInputChange,
1264
- onSearchKeyDown
1271
+ onSearchKeyDown,
1272
+ searchValue,
1273
+ onClear
1265
1274
  },
1266
1275
  children: /* @__PURE__ */ jsxRuntime.jsx(components_box_box.Box, { ...props, className: classes, children: /* @__PURE__ */ jsxRuntime.jsxs(
1267
1276
  NavigationMenu,
@@ -669,6 +669,7 @@ const SearchField = React__default.forwardRef(
669
669
  TextField.Input,
670
670
  {
671
671
  ref: composedRef,
672
+ value: context == null ? void 0 : context.searchValue,
672
673
  onChange: (e) => {
673
674
  var _a, _b;
674
675
  if (((_a = ref.current) == null ? void 0 : _a.value) && (context == null ? void 0 : context.onSearchInputChange)) {
@@ -683,7 +684,11 @@ const SearchField = React__default.forwardRef(
683
684
  placeholder: "Søk her"
684
685
  }
685
686
  ),
686
- /* @__PURE__ */ jsx(TextField.ClearButton, {})
687
+ /* @__PURE__ */ jsx(TextField.ClearButton, { onClick: () => {
688
+ if (context == null ? void 0 : context.onClear) {
689
+ context.onClear();
690
+ }
691
+ } })
687
692
  ] }),
688
693
  /* @__PURE__ */ jsx(TextField.Button, { variant: "separated", children: "Søk" })
689
694
  ] })
@@ -1194,6 +1199,8 @@ function Root({
1194
1199
  currentPath,
1195
1200
  onSearchInputChange,
1196
1201
  onSearchKeyDown,
1202
+ searchValue,
1203
+ onClear,
1197
1204
  ...props
1198
1205
  }) {
1199
1206
  const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath));
@@ -1240,7 +1247,9 @@ function Root({
1240
1247
  specifiedLink,
1241
1248
  setSpecifiedLink,
1242
1249
  onSearchInputChange,
1243
- onSearchKeyDown
1250
+ onSearchKeyDown,
1251
+ searchValue,
1252
+ onClear
1244
1253
  },
1245
1254
  children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
1246
1255
  NavigationMenu,
package/package.json CHANGED
@@ -20,7 +20,7 @@
20
20
  "pnpm": ">=9"
21
21
  },
22
22
  "private": false,
23
- "version": "0.4.12",
23
+ "version": "0.4.13",
24
24
  "sideEffects": [
25
25
  "**/*.css",
26
26
  "**/*.svg"