@telia/teddy 0.4.11 → 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.
|
@@ -20,6 +20,9 @@ export type RootProps = React.ComponentPropsWithoutRef<'div'> & {
|
|
|
20
20
|
isSimplified?: boolean;
|
|
21
21
|
currentPath: string | undefined;
|
|
22
22
|
onSearchInputChange?: (e: React.ChangeEvent<HTMLInputElement>, value?: string) => void;
|
|
23
|
+
onSearchKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
24
|
+
searchValue?: string;
|
|
25
|
+
onClear?: () => void;
|
|
23
26
|
};
|
|
24
27
|
type RootContext = {
|
|
25
28
|
selectedMenuItem: string | undefined;
|
|
@@ -30,9 +33,9 @@ type RootContext = {
|
|
|
30
33
|
setPathname: (v: string) => void;
|
|
31
34
|
specifiedLink?: string;
|
|
32
35
|
setSpecifiedLink: (v: string) => void;
|
|
33
|
-
} & Pick<RootProps, 'onSearchSubmit' | 'additionalSearchContent' | 'shoppingCart' | 'shoppingCartNumberOfItems' | 'loggedInUser' | 'appKey' | 'onLogoutClick' | 'linkComponent' | 'isCartOpen' | 'onCartOpenChange' | 'drawerSize' | "onSearchInputChange">;
|
|
36
|
+
} & Pick<RootProps, 'onSearchSubmit' | 'additionalSearchContent' | 'shoppingCart' | 'shoppingCartNumberOfItems' | 'loggedInUser' | 'appKey' | 'onLogoutClick' | 'linkComponent' | 'isCartOpen' | 'onCartOpenChange' | 'drawerSize' | "onSearchInputChange" | 'onSearchKeyDown' | 'searchValue' | 'onClear'>;
|
|
34
37
|
export declare const RootContext: React.Context<RootContext | null>;
|
|
35
|
-
export declare function Root({ className, appKey, loggedInUser, linkComponent, onLogoutClick, shoppingCart, shoppingCartNumberOfItems, onSearchSubmit, additionalSearchContent, isCartOpen, onCartOpenChange, drawerSize, isSimplified, currentPath, onSearchInputChange, ...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;
|
|
36
39
|
export declare namespace Root {
|
|
37
40
|
var displayName: string;
|
|
38
41
|
}
|
|
@@ -690,16 +690,26 @@ 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)) {
|
|
696
697
|
context == null ? void 0 : context.onSearchInputChange(e, (_b = ref.current) == null ? void 0 : _b.value);
|
|
697
698
|
}
|
|
698
699
|
},
|
|
700
|
+
onKeyDown: (e) => {
|
|
701
|
+
if (context == null ? void 0 : context.onSearchKeyDown) {
|
|
702
|
+
context.onSearchKeyDown(e);
|
|
703
|
+
}
|
|
704
|
+
},
|
|
699
705
|
placeholder: "Søk her"
|
|
700
706
|
}
|
|
701
707
|
),
|
|
702
|
-
/* @__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
|
+
} })
|
|
703
713
|
] }),
|
|
704
714
|
/* @__PURE__ */ jsxRuntime.jsx(components_textField_index.TextField.Button, { variant: "separated", children: "Søk" })
|
|
705
715
|
] })
|
|
@@ -1209,6 +1219,9 @@ function Root({
|
|
|
1209
1219
|
isSimplified,
|
|
1210
1220
|
currentPath,
|
|
1211
1221
|
onSearchInputChange,
|
|
1222
|
+
onSearchKeyDown,
|
|
1223
|
+
searchValue,
|
|
1224
|
+
onClear,
|
|
1212
1225
|
...props
|
|
1213
1226
|
}) {
|
|
1214
1227
|
const [selectedMenuItem, setSelectedMenuItem] = React.useState(getInitialMenuItem(currentPath));
|
|
@@ -1254,7 +1267,10 @@ function Root({
|
|
|
1254
1267
|
drawerSize,
|
|
1255
1268
|
specifiedLink,
|
|
1256
1269
|
setSpecifiedLink,
|
|
1257
|
-
onSearchInputChange
|
|
1270
|
+
onSearchInputChange,
|
|
1271
|
+
onSearchKeyDown,
|
|
1272
|
+
searchValue,
|
|
1273
|
+
onClear
|
|
1258
1274
|
},
|
|
1259
1275
|
children: /* @__PURE__ */ jsxRuntime.jsx(components_box_box.Box, { ...props, className: classes, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1260
1276
|
NavigationMenu,
|
|
@@ -669,16 +669,26 @@ 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)) {
|
|
675
676
|
context == null ? void 0 : context.onSearchInputChange(e, (_b = ref.current) == null ? void 0 : _b.value);
|
|
676
677
|
}
|
|
677
678
|
},
|
|
679
|
+
onKeyDown: (e) => {
|
|
680
|
+
if (context == null ? void 0 : context.onSearchKeyDown) {
|
|
681
|
+
context.onSearchKeyDown(e);
|
|
682
|
+
}
|
|
683
|
+
},
|
|
678
684
|
placeholder: "Søk her"
|
|
679
685
|
}
|
|
680
686
|
),
|
|
681
|
-
/* @__PURE__ */ jsx(TextField.ClearButton, {
|
|
687
|
+
/* @__PURE__ */ jsx(TextField.ClearButton, { onClick: () => {
|
|
688
|
+
if (context == null ? void 0 : context.onClear) {
|
|
689
|
+
context.onClear();
|
|
690
|
+
}
|
|
691
|
+
} })
|
|
682
692
|
] }),
|
|
683
693
|
/* @__PURE__ */ jsx(TextField.Button, { variant: "separated", children: "Søk" })
|
|
684
694
|
] })
|
|
@@ -1188,6 +1198,9 @@ function Root({
|
|
|
1188
1198
|
isSimplified,
|
|
1189
1199
|
currentPath,
|
|
1190
1200
|
onSearchInputChange,
|
|
1201
|
+
onSearchKeyDown,
|
|
1202
|
+
searchValue,
|
|
1203
|
+
onClear,
|
|
1191
1204
|
...props
|
|
1192
1205
|
}) {
|
|
1193
1206
|
const [selectedMenuItem, setSelectedMenuItem] = React__default.useState(getInitialMenuItem(currentPath));
|
|
@@ -1233,7 +1246,10 @@ function Root({
|
|
|
1233
1246
|
drawerSize,
|
|
1234
1247
|
specifiedLink,
|
|
1235
1248
|
setSpecifiedLink,
|
|
1236
|
-
onSearchInputChange
|
|
1249
|
+
onSearchInputChange,
|
|
1250
|
+
onSearchKeyDown,
|
|
1251
|
+
searchValue,
|
|
1252
|
+
onClear
|
|
1237
1253
|
},
|
|
1238
1254
|
children: /* @__PURE__ */ jsx(Box, { ...props, className: classes, children: /* @__PURE__ */ jsxs(
|
|
1239
1255
|
NavigationMenu,
|