@okta/odyssey-react-mui 1.34.0 → 1.35.0
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/cjs/Dialog.cjs +9 -1
- package/dist/cjs/Dialog.cjs.map +1 -1
- package/dist/cjs/Select.cjs +3 -1
- package/dist/cjs/Select.cjs.map +1 -1
- package/dist/cjs/Typography.cjs +8 -4
- package/dist/cjs/Typography.cjs.map +1 -1
- package/dist/cjs/labs/OdysseyPickers/SearchDropdown.cjs +269 -0
- package/dist/cjs/labs/OdysseyPickers/SearchDropdown.cjs.map +1 -0
- package/dist/cjs/labs/OdysseyPickers/index.cjs +9 -1
- package/dist/cjs/labs/OdysseyPickers/index.cjs.map +1 -1
- package/dist/esm/Dialog.js +9 -1
- package/dist/esm/Dialog.js.map +1 -1
- package/dist/esm/Select.js +3 -1
- package/dist/esm/Select.js.map +1 -1
- package/dist/esm/Typography.js +8 -4
- package/dist/esm/Typography.js.map +1 -1
- package/dist/esm/labs/OdysseyPickers/SearchDropdown.js +263 -0
- package/dist/esm/labs/OdysseyPickers/SearchDropdown.js.map +1 -0
- package/dist/esm/labs/OdysseyPickers/index.js +1 -0
- package/dist/esm/labs/OdysseyPickers/index.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.scss +1 -1
- package/dist/tsconfig.production.tsbuildinfo +1 -1
- package/dist/types/Dialog.d.ts.map +1 -1
- package/dist/types/Select.d.ts +1 -0
- package/dist/types/Select.d.ts.map +1 -1
- package/dist/types/Typography.d.ts +6 -2
- package/dist/types/Typography.d.ts.map +1 -1
- package/dist/types/labs/OdysseyPickers/SearchDropdown.d.ts +33 -0
- package/dist/types/labs/OdysseyPickers/SearchDropdown.d.ts.map +1 -0
- package/dist/types/labs/OdysseyPickers/index.d.ts +2 -0
- package/dist/types/labs/OdysseyPickers/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SearchDropdown = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
9
|
+
var _ComposablePicker = require("./ComposablePicker.cjs");
|
|
10
|
+
var _OdysseyDesignTokensContext = require("../../OdysseyDesignTokensContext.cjs");
|
|
11
|
+
var _Picker = require("./Picker.cjs");
|
|
12
|
+
var _Typography = require("../../Typography.cjs");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
/*!
|
|
16
|
+
* Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
17
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
18
|
+
*
|
|
19
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
22
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
+
*
|
|
24
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const OptionAdornmentContainer = (0, _styled.default)("div", {
|
|
28
|
+
shouldForwardProp: prop => prop !== "odysseyDesignTokens" && prop !== "adornmentSize" && prop !== "isTagContainer"
|
|
29
|
+
})(({
|
|
30
|
+
adornmentSize = "small",
|
|
31
|
+
isTagContainer = false,
|
|
32
|
+
odysseyDesignTokens,
|
|
33
|
+
position = "left"
|
|
34
|
+
}) => ({
|
|
35
|
+
position: "relative",
|
|
36
|
+
bottom: "1px",
|
|
37
|
+
alignSelf: "flex-start",
|
|
38
|
+
width: odysseyDesignTokens.Spacing5,
|
|
39
|
+
height: odysseyDesignTokens.Spacing5,
|
|
40
|
+
overflow: "hidden",
|
|
41
|
+
...(position === "left" && {
|
|
42
|
+
marginInlineEnd: odysseyDesignTokens.Spacing3
|
|
43
|
+
}),
|
|
44
|
+
...(position === "right" && {
|
|
45
|
+
marginInlineStart: odysseyDesignTokens.Spacing3
|
|
46
|
+
}),
|
|
47
|
+
svg: {
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "auto"
|
|
50
|
+
},
|
|
51
|
+
img: {
|
|
52
|
+
position: "absolute",
|
|
53
|
+
top: "50%",
|
|
54
|
+
left: "50%",
|
|
55
|
+
width: "100%",
|
|
56
|
+
transform: "translate(-50%, -50%)"
|
|
57
|
+
},
|
|
58
|
+
...(adornmentSize === "large" && !isTagContainer && {
|
|
59
|
+
bottom: 0,
|
|
60
|
+
width: odysseyDesignTokens.Spacing8,
|
|
61
|
+
height: odysseyDesignTokens.Spacing8
|
|
62
|
+
}),
|
|
63
|
+
...(isTagContainer && {
|
|
64
|
+
bottom: 0,
|
|
65
|
+
alignSelf: "center",
|
|
66
|
+
width: odysseyDesignTokens.Spacing4,
|
|
67
|
+
height: "auto",
|
|
68
|
+
maxHeight: odysseyDesignTokens.Spacing4,
|
|
69
|
+
marginInlineEnd: odysseyDesignTokens.Spacing2,
|
|
70
|
+
svg: {
|
|
71
|
+
display: "flex",
|
|
72
|
+
width: "100%",
|
|
73
|
+
height: "auto"
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
}));
|
|
77
|
+
const CustomOptionContainer = (0, _styled.default)("div", {
|
|
78
|
+
shouldForwardProp: prop => prop !== "odysseyDesignTokens"
|
|
79
|
+
})(() => ({
|
|
80
|
+
display: "flex",
|
|
81
|
+
justifyContent: "space-between",
|
|
82
|
+
width: "100%"
|
|
83
|
+
}));
|
|
84
|
+
const CustomOptionLeftContainer = (0, _styled.default)("div", {
|
|
85
|
+
shouldForwardProp: prop => prop !== "odysseyDesignTokens"
|
|
86
|
+
})(() => ({
|
|
87
|
+
display: "flex"
|
|
88
|
+
}));
|
|
89
|
+
const OptionAdornment = ({
|
|
90
|
+
adornment,
|
|
91
|
+
adornmentSize,
|
|
92
|
+
odysseyDesignTokens
|
|
93
|
+
}) => {
|
|
94
|
+
const isImageAdornment = typeof adornment === "string";
|
|
95
|
+
if (isImageAdornment) {
|
|
96
|
+
return (0, _jsxRuntime.jsx)(OptionAdornmentContainer, {
|
|
97
|
+
adornmentSize: adornmentSize,
|
|
98
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
99
|
+
children: (0, _jsxRuntime.jsx)("img", {
|
|
100
|
+
src: adornment,
|
|
101
|
+
alt: "",
|
|
102
|
+
role: "presentation"
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
return (0, _jsxRuntime.jsx)(OptionAdornmentContainer, {
|
|
107
|
+
adornmentSize: adornmentSize,
|
|
108
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
109
|
+
children: adornment
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const Extra = ({
|
|
114
|
+
content,
|
|
115
|
+
size,
|
|
116
|
+
odysseyDesignTokens,
|
|
117
|
+
onClick
|
|
118
|
+
}) => {
|
|
119
|
+
const handleClick = (0, _react.useCallback)(event => {
|
|
120
|
+
event.stopPropagation();
|
|
121
|
+
onClick();
|
|
122
|
+
}, [onClick]);
|
|
123
|
+
return (0, _jsxRuntime.jsx)(OptionAdornmentContainer, {
|
|
124
|
+
adornmentSize: size,
|
|
125
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
126
|
+
onClick: handleClick,
|
|
127
|
+
children: content
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
const CustomOption = ({
|
|
131
|
+
adornmentSize,
|
|
132
|
+
muiProps,
|
|
133
|
+
odysseyDesignTokens,
|
|
134
|
+
option
|
|
135
|
+
}) => {
|
|
136
|
+
const {
|
|
137
|
+
adornment,
|
|
138
|
+
description,
|
|
139
|
+
label,
|
|
140
|
+
metaData,
|
|
141
|
+
extra,
|
|
142
|
+
value,
|
|
143
|
+
onClick,
|
|
144
|
+
isInteractive = true
|
|
145
|
+
} = option;
|
|
146
|
+
const handleOptionClick = (0, _react.useCallback)(event => {
|
|
147
|
+
if (!isInteractive) {
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
onClick?.();
|
|
153
|
+
}, [onClick, isInteractive]);
|
|
154
|
+
const extendedMuiProps = (0, _react.useMemo)(() => {
|
|
155
|
+
return {
|
|
156
|
+
...muiProps,
|
|
157
|
+
onClick: isInteractive ? handleOptionClick : undefined,
|
|
158
|
+
"aria-disabled": !isInteractive ? "true" : undefined,
|
|
159
|
+
role: "option"
|
|
160
|
+
};
|
|
161
|
+
}, [muiProps, isInteractive, handleOptionClick]);
|
|
162
|
+
return (0, _jsxRuntime.jsx)(_Picker.Option, {
|
|
163
|
+
hasAdornment: true,
|
|
164
|
+
muiProps: extendedMuiProps,
|
|
165
|
+
children: (0, _jsxRuntime.jsxs)(CustomOptionContainer, {
|
|
166
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
167
|
+
children: [(0, _jsxRuntime.jsxs)(CustomOptionLeftContainer, {
|
|
168
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
169
|
+
children: [(0, _jsxRuntime.jsx)(OptionAdornment, {
|
|
170
|
+
adornment: adornment,
|
|
171
|
+
adornmentSize: adornmentSize,
|
|
172
|
+
odysseyDesignTokens: odysseyDesignTokens
|
|
173
|
+
}), (0, _jsxRuntime.jsxs)("div", {
|
|
174
|
+
children: [(0, _jsxRuntime.jsxs)(_Picker.OptionLabelContainer, {
|
|
175
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
176
|
+
children: [(0, _jsxRuntime.jsx)(_Typography.Heading6, {
|
|
177
|
+
component: "p",
|
|
178
|
+
children: label
|
|
179
|
+
}), (0, _jsxRuntime.jsx)(_Picker.OptionDescriptionComponent, {
|
|
180
|
+
description: description,
|
|
181
|
+
odysseyDesignTokens: odysseyDesignTokens
|
|
182
|
+
})]
|
|
183
|
+
}), metaData && (0, _jsxRuntime.jsx)(_Picker.OptionMetadataComponent, {
|
|
184
|
+
metaData: metaData,
|
|
185
|
+
odysseyDesignTokens: odysseyDesignTokens
|
|
186
|
+
})]
|
|
187
|
+
})]
|
|
188
|
+
}), extra && (0, _jsxRuntime.jsx)(Extra, {
|
|
189
|
+
content: extra.content,
|
|
190
|
+
size: extra.size || adornmentSize,
|
|
191
|
+
onClick: extra.onClick,
|
|
192
|
+
odysseyDesignTokens: odysseyDesignTokens
|
|
193
|
+
})]
|
|
194
|
+
})
|
|
195
|
+
}, value);
|
|
196
|
+
};
|
|
197
|
+
const SearchDropdown = ({
|
|
198
|
+
adornmentSize = "small",
|
|
199
|
+
ariaDescribedBy,
|
|
200
|
+
defaultValue,
|
|
201
|
+
errorMessage,
|
|
202
|
+
errorMessageList,
|
|
203
|
+
getIsOptionEqualToValue,
|
|
204
|
+
groupOptionsBy,
|
|
205
|
+
id: idOverride,
|
|
206
|
+
inputValue,
|
|
207
|
+
isCustomValueAllowed,
|
|
208
|
+
isDisabled,
|
|
209
|
+
isFullWidth = false,
|
|
210
|
+
isLoading,
|
|
211
|
+
isOptional = false,
|
|
212
|
+
isReadOnly,
|
|
213
|
+
isVirtualized: isVirtualizedProp = false,
|
|
214
|
+
hint,
|
|
215
|
+
HintLinkComponent,
|
|
216
|
+
label,
|
|
217
|
+
name: nameOverride,
|
|
218
|
+
onBlur,
|
|
219
|
+
onChange: onChangeProp,
|
|
220
|
+
onInputChange: onInputChangeProp,
|
|
221
|
+
onFocus,
|
|
222
|
+
options,
|
|
223
|
+
value,
|
|
224
|
+
testId,
|
|
225
|
+
translate
|
|
226
|
+
}) => {
|
|
227
|
+
const odysseyDesignTokens = (0, _OdysseyDesignTokensContext.useOdysseyDesignTokens)();
|
|
228
|
+
const customOptionRender = (0, _react.useCallback)((muiProps, option) => {
|
|
229
|
+
return (0, _jsxRuntime.jsx)(CustomOption, {
|
|
230
|
+
adornmentSize: adornmentSize,
|
|
231
|
+
muiProps: muiProps,
|
|
232
|
+
odysseyDesignTokens: odysseyDesignTokens,
|
|
233
|
+
option: option
|
|
234
|
+
});
|
|
235
|
+
}, [adornmentSize, odysseyDesignTokens]);
|
|
236
|
+
return (0, _jsxRuntime.jsx)(_ComposablePicker.ComposablePicker, {
|
|
237
|
+
ariaDescribedBy: ariaDescribedBy,
|
|
238
|
+
defaultValue: defaultValue,
|
|
239
|
+
errorMessage: errorMessage,
|
|
240
|
+
errorMessageList: errorMessageList,
|
|
241
|
+
getIsOptionEqualToValue: getIsOptionEqualToValue,
|
|
242
|
+
groupOptionsBy: groupOptionsBy,
|
|
243
|
+
id: idOverride,
|
|
244
|
+
inputValue: inputValue,
|
|
245
|
+
isCustomValueAllowed: isCustomValueAllowed,
|
|
246
|
+
isDisabled: isDisabled,
|
|
247
|
+
isFullWidth: isFullWidth,
|
|
248
|
+
isLoading: isLoading,
|
|
249
|
+
isOptional: isOptional,
|
|
250
|
+
isReadOnly: isReadOnly,
|
|
251
|
+
isVirtualized: isVirtualizedProp,
|
|
252
|
+
hint: hint,
|
|
253
|
+
HintLinkComponent: HintLinkComponent,
|
|
254
|
+
label: label,
|
|
255
|
+
name: nameOverride,
|
|
256
|
+
onBlur: onBlur,
|
|
257
|
+
onChange: onChangeProp,
|
|
258
|
+
onInputChange: onInputChangeProp,
|
|
259
|
+
onFocus: onFocus,
|
|
260
|
+
options: options,
|
|
261
|
+
renderOption: customOptionRender,
|
|
262
|
+
value: value,
|
|
263
|
+
testId: testId,
|
|
264
|
+
translate: translate
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
const MemoizedSearchDropdown = exports.SearchDropdown = (0, _react.memo)(SearchDropdown);
|
|
268
|
+
MemoizedSearchDropdown.displayName = "MemoizedSearchDropdown";
|
|
269
|
+
//# sourceMappingURL=SearchDropdown.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchDropdown.cjs","names":["_react","require","_styled","_interopRequireDefault","_ComposablePicker","_OdysseyDesignTokensContext","_Picker","_Typography","_jsxRuntime","e","__esModule","default","OptionAdornmentContainer","styled","shouldForwardProp","prop","adornmentSize","isTagContainer","odysseyDesignTokens","position","bottom","alignSelf","width","Spacing5","height","overflow","marginInlineEnd","Spacing3","marginInlineStart","svg","img","top","left","transform","Spacing8","Spacing4","maxHeight","Spacing2","display","CustomOptionContainer","justifyContent","CustomOptionLeftContainer","OptionAdornment","adornment","isImageAdornment","jsx","children","src","alt","role","Extra","content","size","onClick","handleClick","useCallback","event","stopPropagation","CustomOption","muiProps","option","description","label","metaData","extra","value","isInteractive","handleOptionClick","preventDefault","extendedMuiProps","useMemo","undefined","Option","hasAdornment","jsxs","OptionLabelContainer","Heading6","component","OptionDescriptionComponent","OptionMetadataComponent","SearchDropdown","ariaDescribedBy","defaultValue","errorMessage","errorMessageList","getIsOptionEqualToValue","groupOptionsBy","id","idOverride","inputValue","isCustomValueAllowed","isDisabled","isFullWidth","isLoading","isOptional","isReadOnly","isVirtualized","isVirtualizedProp","hint","HintLinkComponent","name","nameOverride","onBlur","onChange","onChangeProp","onInputChange","onInputChangeProp","onFocus","options","testId","translate","useOdysseyDesignTokens","customOptionRender","ComposablePicker","renderOption","MemoizedSearchDropdown","exports","memo","displayName"],"sources":["../../../../src/labs/OdysseyPickers/SearchDropdown.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n HTMLAttributes,\n memo,\n ReactElement,\n ReactNode,\n useCallback,\n useMemo,\n} from \"react\";\nimport styled from \"@emotion/styled\";\n\nimport {\n ComposablePicker,\n type AdornmentSize,\n type BasePickerProps,\n type BasePickerType,\n} from \"./ComposablePicker.js\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"../../OdysseyDesignTokensContext.js\";\nimport {\n type BaseOptionProps,\n type LabelDescription,\n type Metadata,\n Option,\n OptionDescriptionComponent,\n OptionLabelContainer,\n OptionMetadataComponent,\n OptionProps,\n} from \"./Picker.js\";\nimport { Heading6 } from \"../../Typography.js\";\n\ntype Adornment = ReactNode | string;\ntype ExtraType = {\n content: ReactNode | string;\n size?: AdornmentSize;\n onClick: () => void;\n};\n\ntype AdornmentLabelDescription = LabelDescription & {\n adornment: Adornment;\n extra?: ExtraType;\n onClick?: () => void;\n isInteractive?: boolean;\n};\n\nexport type CustomOptionType = AdornmentLabelDescription & Partial<Metadata>;\n\nconst OptionAdornmentContainer = styled(\"div\", {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" &&\n prop !== \"adornmentSize\" &&\n prop !== \"isTagContainer\",\n})<{\n adornmentSize?: AdornmentSize;\n isTagContainer?: boolean;\n odysseyDesignTokens: DesignTokens;\n position?: \"left\" | \"right\";\n}>(\n ({\n adornmentSize = \"small\",\n isTagContainer = false,\n\n odysseyDesignTokens,\n position = \"left\",\n }) => ({\n position: \"relative\",\n // push icon up by one px for better visual alignment\n bottom: \"1px\",\n alignSelf: \"flex-start\",\n width: odysseyDesignTokens.Spacing5,\n height: odysseyDesignTokens.Spacing5,\n overflow: \"hidden\",\n\n ...(position === \"left\" && {\n marginInlineEnd: odysseyDesignTokens.Spacing3,\n }),\n ...(position === \"right\" && {\n marginInlineStart: odysseyDesignTokens.Spacing3,\n }),\n\n svg: {\n width: \"100%\",\n height: \"auto\",\n },\n\n img: {\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n width: \"100%\",\n transform: \"translate(-50%, -50%)\",\n },\n\n ...(adornmentSize === \"large\" &&\n !isTagContainer && {\n bottom: 0,\n width: odysseyDesignTokens.Spacing8,\n height: odysseyDesignTokens.Spacing8,\n }),\n\n ...(isTagContainer && {\n bottom: 0,\n alignSelf: \"center\",\n width: odysseyDesignTokens.Spacing4,\n height: \"auto\",\n maxHeight: odysseyDesignTokens.Spacing4,\n marginInlineEnd: odysseyDesignTokens.Spacing2,\n\n svg: {\n display: \"flex\",\n width: \"100%\",\n height: \"auto\",\n },\n }),\n }),\n);\n\ntype OptionAdornmentProps = {\n adornment: Adornment;\n adornmentSize: AdornmentSize;\n odysseyDesignTokens: DesignTokens;\n};\n\ntype ExtraProps = {\n content: Adornment;\n size?: AdornmentSize;\n odysseyDesignTokens: DesignTokens;\n onClick: () => void;\n};\n\nconst CustomOptionContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{ odysseyDesignTokens: DesignTokens }>(() => ({\n display: \"flex\",\n justifyContent: \"space-between\",\n width: \"100%\",\n}));\n\nconst CustomOptionLeftContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{ odysseyDesignTokens: DesignTokens }>(() => ({\n display: \"flex\",\n}));\n\nconst OptionAdornment = ({\n adornment,\n adornmentSize,\n odysseyDesignTokens,\n}: OptionAdornmentProps) => {\n const isImageAdornment = typeof adornment === \"string\";\n\n if (isImageAdornment) {\n return (\n <OptionAdornmentContainer\n adornmentSize={adornmentSize}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <img src={adornment} alt=\"\" role=\"presentation\" />\n </OptionAdornmentContainer>\n );\n } else {\n return (\n <OptionAdornmentContainer\n adornmentSize={adornmentSize}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {adornment}\n </OptionAdornmentContainer>\n );\n }\n};\n\nconst Extra = ({ content, size, odysseyDesignTokens, onClick }: ExtraProps) => {\n const handleClick = useCallback(\n (event: React.MouseEvent) => {\n event.stopPropagation();\n onClick();\n },\n [onClick],\n );\n\n return (\n <OptionAdornmentContainer\n adornmentSize={size}\n odysseyDesignTokens={odysseyDesignTokens}\n onClick={handleClick}\n >\n {content}\n </OptionAdornmentContainer>\n );\n};\n\nconst CustomOption = <OptionType extends CustomOptionType>({\n adornmentSize,\n muiProps,\n odysseyDesignTokens,\n option,\n}: BaseOptionProps &\n OptionProps<OptionType> & {\n adornmentSize: AdornmentSize;\n }) => {\n const {\n adornment,\n description,\n label,\n metaData,\n extra,\n value,\n onClick,\n isInteractive = true,\n } = option;\n\n const handleOptionClick = useCallback(\n (event: React.MouseEvent) => {\n if (!isInteractive) {\n event.preventDefault();\n return;\n }\n event.stopPropagation();\n onClick?.();\n },\n [onClick, isInteractive],\n );\n\n const extendedMuiProps = useMemo(() => {\n return {\n ...muiProps,\n onClick: isInteractive ? handleOptionClick : undefined,\n \"aria-disabled\": !isInteractive ? \"true\" : undefined,\n role: \"option\",\n } as HTMLAttributes<HTMLLIElement>;\n }, [muiProps, isInteractive, handleOptionClick]);\n\n return (\n <Option hasAdornment key={value} muiProps={extendedMuiProps}>\n <CustomOptionContainer odysseyDesignTokens={odysseyDesignTokens}>\n <CustomOptionLeftContainer odysseyDesignTokens={odysseyDesignTokens}>\n <OptionAdornment\n adornment={adornment}\n adornmentSize={adornmentSize}\n odysseyDesignTokens={odysseyDesignTokens}\n />\n <div>\n <OptionLabelContainer odysseyDesignTokens={odysseyDesignTokens}>\n <Heading6 component=\"p\">{label}</Heading6>\n <OptionDescriptionComponent\n description={description}\n odysseyDesignTokens={odysseyDesignTokens}\n />\n </OptionLabelContainer>\n {metaData && (\n <OptionMetadataComponent\n metaData={metaData}\n odysseyDesignTokens={odysseyDesignTokens}\n />\n )}\n </div>\n </CustomOptionLeftContainer>\n {extra && (\n <Extra\n content={extra.content}\n size={extra.size || adornmentSize}\n onClick={extra.onClick}\n odysseyDesignTokens={odysseyDesignTokens}\n />\n )}\n </CustomOptionContainer>\n </Option>\n );\n};\n\nexport type SearchDropdownProps<\n OptionType extends CustomOptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n> = BasePickerProps<OptionType, HasMultipleChoices, IsCustomValueAllowed> & {\n adornmentSize?: AdornmentSize;\n};\n\ntype PickerWithOptionAdornmentComponentType = {\n <\n OptionType extends CustomOptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n >(\n props: SearchDropdownProps<\n OptionType,\n HasMultipleChoices,\n IsCustomValueAllowed\n >,\n ): ReactElement;\n <\n OptionType extends CustomOptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n >(\n props: SearchDropdownProps<\n OptionType,\n HasMultipleChoices,\n IsCustomValueAllowed\n >,\n ): ReactElement;\n};\n\nconst SearchDropdown: PickerWithOptionAdornmentComponentType = <\n OptionType extends CustomOptionType,\n HasMultipleChoices extends boolean | undefined,\n IsCustomValueAllowed extends boolean | undefined,\n>({\n adornmentSize = \"small\",\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n getIsOptionEqualToValue,\n groupOptionsBy,\n id: idOverride,\n inputValue,\n isCustomValueAllowed,\n isDisabled,\n isFullWidth = false,\n isLoading,\n isOptional = false,\n isReadOnly,\n isVirtualized: isVirtualizedProp = false,\n hint,\n HintLinkComponent,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onInputChange: onInputChangeProp,\n onFocus,\n options,\n value,\n testId,\n translate,\n}: SearchDropdownProps<\n OptionType,\n HasMultipleChoices,\n IsCustomValueAllowed\n>) => {\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n const customOptionRender = useCallback<\n (props: HTMLAttributes<HTMLLIElement>, option: OptionType) => ReactNode\n >(\n (muiProps, option) => {\n return (\n <CustomOption\n adornmentSize={adornmentSize}\n muiProps={muiProps}\n odysseyDesignTokens={odysseyDesignTokens}\n option={option}\n />\n );\n },\n [adornmentSize, odysseyDesignTokens],\n );\n\n return (\n <ComposablePicker<OptionType, HasMultipleChoices, IsCustomValueAllowed>\n ariaDescribedBy={ariaDescribedBy}\n defaultValue={defaultValue}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n getIsOptionEqualToValue={getIsOptionEqualToValue}\n groupOptionsBy={groupOptionsBy}\n id={idOverride}\n inputValue={inputValue}\n isCustomValueAllowed={isCustomValueAllowed}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isLoading={isLoading}\n isOptional={isOptional}\n isReadOnly={isReadOnly}\n isVirtualized={isVirtualizedProp}\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n label={label}\n name={nameOverride}\n onBlur={onBlur}\n onChange={onChangeProp}\n onInputChange={onInputChangeProp}\n onFocus={onFocus}\n options={options}\n renderOption={customOptionRender}\n value={value}\n testId={testId}\n translate={translate}\n />\n );\n};\n\n// Need the `as BasePickerType` because generics don't get passed through\nconst MemoizedSearchDropdown = memo(SearchDropdown) as BasePickerType;\n\nMemoizedSearchDropdown.displayName = \"MemoizedSearchDropdown\";\n\nexport { MemoizedSearchDropdown as SearchDropdown };\n"],"mappings":";;;;;;AAYA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAH,OAAA;AAMA,IAAAI,2BAAA,GAAAJ,OAAA;AAIA,IAAAK,OAAA,GAAAL,OAAA;AAUA,IAAAM,WAAA,GAAAN,OAAA;AAA+C,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAE,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA1C/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkDA,MAAMG,wBAAwB,GAAG,IAAAC,eAAM,EAAC,KAAK,EAAE;EAC7CC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AAuB,EAAEA,uBAAwB;IACjDC,cAAc,EAAEA,cAAe;IAC/BC,EAAE,EAAEC,UAAW;IACfC,UAAU,EAAEA,UAAW;IACvBC,oBAAoB,EAAEA,oBAAqB;IAC3CC,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBC,SAAS,EAAEA,SAAU;IACrBC,UAAU,EAAEA,UAAW;IACvBC,UAAU,EAAEA,UAAW;IACvBC,aAAa,EAAEC,iBAAkB;IACjCC,IAAI,EAAEA,IAAK;IACXC,iBAAiB,EAAEA,iBAAkB;IACrCrC,KAAK,EAAEA,KAAM;IACbsC,IAAI,EAAEC,YAAa;IACnBC,MAAM,EAAEA,MAAO;IACfC,QAAQ,EAAEC,YAAa;IACvBC,aAAa,EAAEC,iBAAkB;IACjCC,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBM,YAAY,EAAEF,kBAAmB;IACjC/C,KAAK,EAAEA,KAAM;IACb4C,MAAM,EAAEA,MAAO;IACfC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAGD,MAAMK,sBAAsB,GAAAC,OAAA,CAAApC,cAAA,GAAG,IAAAqC,WAAI,EAACrC,cAAc,CAAmB;AAErEmC,sBAAsB,CAACG,WAAW,GAAG,wBAAwB","ignoreList":[]}
|
|
@@ -4,8 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
adornmentSizeValues: true
|
|
7
|
+
adornmentSizeValues: true,
|
|
8
|
+
SearchDropdown: true
|
|
8
9
|
};
|
|
10
|
+
Object.defineProperty(exports, "SearchDropdown", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _SearchDropdown.SearchDropdown;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
9
16
|
Object.defineProperty(exports, "adornmentSizeValues", {
|
|
10
17
|
enumerable: true,
|
|
11
18
|
get: function () {
|
|
@@ -37,4 +44,5 @@ Object.keys(_PickerWithOptionAdornment).forEach(function (key) {
|
|
|
37
44
|
}
|
|
38
45
|
});
|
|
39
46
|
});
|
|
47
|
+
var _SearchDropdown = require("./SearchDropdown.cjs");
|
|
40
48
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["_ComposablePicker","require","_Picker","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_PickerWithOptionAdornment"],"sources":["../../../../src/labs/OdysseyPickers/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport { adornmentSizeValues } from \"./ComposablePicker.js\";\nexport * from \"./Picker.js\";\nexport * from \"./PickerWithOptionAdornment.js\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["_ComposablePicker","require","_Picker","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_PickerWithOptionAdornment","_SearchDropdown"],"sources":["../../../../src/labs/OdysseyPickers/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport { adornmentSizeValues } from \"./ComposablePicker.js\";\nexport * from \"./Picker.js\";\nexport * from \"./PickerWithOptionAdornment.js\";\nexport { SearchDropdown } from \"./SearchDropdown.js\";\nexport type {\n SearchDropdownProps,\n CustomOptionType,\n} from \"./SearchDropdown.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,0BAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,0BAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,0BAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,0BAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,eAAA,GAAAf,OAAA","ignoreList":[]}
|
package/dist/esm/Dialog.js
CHANGED
|
@@ -19,6 +19,7 @@ import { useTranslation } from "react-i18next";
|
|
|
19
19
|
import { Button } from "./Buttons/index.js";
|
|
20
20
|
import { CloseIcon } from "./icons.generated/index.js";
|
|
21
21
|
import { cloneElement, memo, useState, useEffect, useRef } from "react";
|
|
22
|
+
import { useUniqueId } from "./useUniqueId.js";
|
|
22
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
24
|
const Dialog = ({
|
|
24
25
|
primaryCallToActionComponent,
|
|
@@ -39,6 +40,8 @@ const Dialog = ({
|
|
|
39
40
|
} = useTranslation();
|
|
40
41
|
const [isContentScrollable, setIsContentScrollable] = useState(false);
|
|
41
42
|
const dialogContentRef = useRef(null);
|
|
43
|
+
const dialogTitleId = useUniqueId();
|
|
44
|
+
const dialogLabelId = useUniqueId();
|
|
42
45
|
useEffect(() => {
|
|
43
46
|
let frameId;
|
|
44
47
|
const handleContentScroll = () => {
|
|
@@ -64,9 +67,14 @@ const Dialog = ({
|
|
|
64
67
|
"data-se": testId,
|
|
65
68
|
open: isOpen,
|
|
66
69
|
onClose: onClose,
|
|
70
|
+
"aria-labelledby": dialogLabelId,
|
|
67
71
|
children: [_jsxs(_DialogTitle, {
|
|
72
|
+
id: dialogTitleId,
|
|
68
73
|
translate: translate,
|
|
69
|
-
children: [
|
|
74
|
+
children: [_jsx("span", {
|
|
75
|
+
id: dialogLabelId,
|
|
76
|
+
children: title
|
|
77
|
+
}), _jsx(Button, {
|
|
70
78
|
ariaLabel: t("close.text"),
|
|
71
79
|
onClick: onClose,
|
|
72
80
|
size: "small",
|
package/dist/esm/Dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["useTranslation","Button","CloseIcon","cloneElement","memo","useState","useEffect","useRef","jsx","_jsx","jsxs","_jsxs","Dialog","primaryCallToActionComponent","secondaryCallToActionComponent","tertiaryCallToActionComponent","callToActionFirstComponent","callToActionSecondComponent","callToActionLastComponent","children","isOpen","onClose","testId","title","translate","t","isContentScrollable","setIsContentScrollable","dialogContentRef","frameId","handleContentScroll","dialogContentElement","current","cancelAnimationFrame","scrollHeight","clientHeight","requestAnimationFrame","content","_DialogContentText","actionButtons","filter","Boolean","_Dialog","open","_DialogTitle","ariaLabel","onClick","size","startIcon","variant","_DialogContent","tabIndex","dividers","ref","length","_DialogActions","map","actionButton","index","key","MemoizedDialog","displayName"],"sources":["../../src/Dialog.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { useTranslation } from \"react-i18next\";\nimport {\n Dialog as MuiDialog,\n DialogTitle,\n DialogContent,\n DialogContentText,\n DialogActions,\n} from \"@mui/material\";\nimport { Button } from \"./Buttons/index.js\";\nimport { CloseIcon } from \"./icons.generated/index.js\";\nimport {\n cloneElement,\n memo,\n useState,\n useEffect,\n useRef,\n ReactElement,\n ReactNode,\n} from \"react\";\n\nimport type { HtmlProps } from \"./HtmlProps.js\";\n\nexport type DialogProps = {\n /**\n * @deprecated `aria-label` for close button comes from translation file\n */\n ariaLabel?: string;\n\n /**\n * An optional Button object to be situated in the Dialog footer as the primary call to action.\n */\n primaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `primaryCallToActionComponent` instead.\n */\n callToActionFirstComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Dialog footer as the secondary call to action, alongside the `primaryCallToActionComponent`.\n */\n secondaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `secondaryCallToActionComponent` instead.\n */\n callToActionSecondComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Dialog footer as the tertiary call to action, alongside the other `callToAction` components.\n */\n tertiaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `tertiaryCallToActionComponent` instead.\n */\n callToActionLastComponent?: ReactElement<typeof Button>;\n /**\n * The content of the Dialog. May be a `string` or any other `ReactNode` or array of `ReactNode`s.\n */\n children: ReactNode;\n\n /**\n * When set to `true`, the Dialog will be visible.\n */\n isOpen: boolean;\n\n /**\n * Callback that controls what happens when the Dialog is dismissed.\n */\n onClose: () => void;\n\n /**\n * The title of the Dialog.\n */\n title: string;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst Dialog = ({\n primaryCallToActionComponent,\n secondaryCallToActionComponent,\n tertiaryCallToActionComponent,\n callToActionFirstComponent,\n callToActionSecondComponent,\n callToActionLastComponent,\n children,\n isOpen,\n onClose,\n testId,\n title,\n translate,\n}: DialogProps) => {\n const { t } = useTranslation();\n const [isContentScrollable, setIsContentScrollable] = useState(false);\n const dialogContentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n let frameId: number;\n\n const handleContentScroll = () => {\n const dialogContentElement = dialogContentRef.current;\n if (dialogContentElement) {\n cancelAnimationFrame(frameId);\n setIsContentScrollable(\n dialogContentElement.scrollHeight > dialogContentElement.clientHeight,\n );\n }\n frameId = requestAnimationFrame(handleContentScroll);\n };\n\n if (isOpen) {\n frameId = requestAnimationFrame(handleContentScroll);\n }\n\n return () => {\n cancelAnimationFrame(frameId);\n };\n }, [isOpen]);\n\n const content =\n typeof children === \"string\" ? (\n <DialogContentText>{children}</DialogContentText>\n ) : (\n children\n );\n\n // Prioritize new action button format (|| used as a fallback)\n const actionButtons = [\n tertiaryCallToActionComponent || callToActionLastComponent,\n secondaryCallToActionComponent || callToActionSecondComponent,\n primaryCallToActionComponent || callToActionFirstComponent,\n ].filter(Boolean);\n\n return (\n <MuiDialog
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["useTranslation","Button","CloseIcon","cloneElement","memo","useState","useEffect","useRef","useUniqueId","jsx","_jsx","jsxs","_jsxs","Dialog","primaryCallToActionComponent","secondaryCallToActionComponent","tertiaryCallToActionComponent","callToActionFirstComponent","callToActionSecondComponent","callToActionLastComponent","children","isOpen","onClose","testId","title","translate","t","isContentScrollable","setIsContentScrollable","dialogContentRef","dialogTitleId","dialogLabelId","frameId","handleContentScroll","dialogContentElement","current","cancelAnimationFrame","scrollHeight","clientHeight","requestAnimationFrame","content","_DialogContentText","actionButtons","filter","Boolean","_Dialog","open","_DialogTitle","id","ariaLabel","onClick","size","startIcon","variant","_DialogContent","tabIndex","dividers","ref","length","_DialogActions","map","actionButton","index","key","MemoizedDialog","displayName"],"sources":["../../src/Dialog.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { useTranslation } from \"react-i18next\";\nimport {\n Dialog as MuiDialog,\n DialogTitle,\n DialogContent,\n DialogContentText,\n DialogActions,\n} from \"@mui/material\";\nimport { Button } from \"./Buttons/index.js\";\nimport { CloseIcon } from \"./icons.generated/index.js\";\nimport {\n cloneElement,\n memo,\n useState,\n useEffect,\n useRef,\n ReactElement,\n ReactNode,\n} from \"react\";\n\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport { useUniqueId } from \"./useUniqueId.js\";\n\nexport type DialogProps = {\n /**\n * @deprecated `aria-label` for close button comes from translation file\n */\n ariaLabel?: string;\n\n /**\n * An optional Button object to be situated in the Dialog footer as the primary call to action.\n */\n primaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `primaryCallToActionComponent` instead.\n */\n callToActionFirstComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Dialog footer as the secondary call to action, alongside the `primaryCallToActionComponent`.\n */\n secondaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `secondaryCallToActionComponent` instead.\n */\n callToActionSecondComponent?: ReactElement<typeof Button>;\n /**\n * An optional Button object to be situated in the Dialog footer as the tertiary call to action, alongside the other `callToAction` components.\n */\n tertiaryCallToActionComponent?: ReactElement<typeof Button>;\n /**\n * @deprecated Will be removed in a future Odyssey version. Use `tertiaryCallToActionComponent` instead.\n */\n callToActionLastComponent?: ReactElement<typeof Button>;\n /**\n * The content of the Dialog. May be a `string` or any other `ReactNode` or array of `ReactNode`s.\n */\n children: ReactNode;\n\n /**\n * When set to `true`, the Dialog will be visible.\n */\n isOpen: boolean;\n\n /**\n * Callback that controls what happens when the Dialog is dismissed.\n */\n onClose: () => void;\n\n /**\n * The title of the Dialog.\n */\n title: string;\n} & Pick<HtmlProps, \"testId\" | \"translate\">;\n\nconst Dialog = ({\n primaryCallToActionComponent,\n secondaryCallToActionComponent,\n tertiaryCallToActionComponent,\n callToActionFirstComponent,\n callToActionSecondComponent,\n callToActionLastComponent,\n children,\n isOpen,\n onClose,\n testId,\n title,\n translate,\n}: DialogProps) => {\n const { t } = useTranslation();\n const [isContentScrollable, setIsContentScrollable] = useState(false);\n const dialogContentRef = useRef<HTMLDivElement>(null);\n const dialogTitleId = useUniqueId();\n const dialogLabelId = useUniqueId();\n\n useEffect(() => {\n let frameId: number;\n\n const handleContentScroll = () => {\n const dialogContentElement = dialogContentRef.current;\n if (dialogContentElement) {\n cancelAnimationFrame(frameId);\n setIsContentScrollable(\n dialogContentElement.scrollHeight > dialogContentElement.clientHeight,\n );\n }\n frameId = requestAnimationFrame(handleContentScroll);\n };\n\n if (isOpen) {\n frameId = requestAnimationFrame(handleContentScroll);\n }\n\n return () => {\n cancelAnimationFrame(frameId);\n };\n }, [isOpen]);\n\n const content =\n typeof children === \"string\" ? (\n <DialogContentText>{children}</DialogContentText>\n ) : (\n children\n );\n\n // Prioritize new action button format (|| used as a fallback)\n const actionButtons = [\n tertiaryCallToActionComponent || callToActionLastComponent,\n secondaryCallToActionComponent || callToActionSecondComponent,\n primaryCallToActionComponent || callToActionFirstComponent,\n ].filter(Boolean);\n\n return (\n <MuiDialog\n data-se={testId}\n open={isOpen}\n onClose={onClose}\n aria-labelledby={dialogLabelId}\n >\n <DialogTitle\n id={dialogTitleId} // We need to explicitly unset `id` for MUI to automatically set it based on the `aria-labelledby` prop passed to `MuiDialog`\n translate={translate}\n >\n <span id={dialogLabelId}>{title}</span>\n <Button\n ariaLabel={t(\"close.text\")}\n onClick={onClose}\n size=\"small\"\n startIcon={<CloseIcon />}\n variant=\"floating\"\n />\n </DialogTitle>\n <DialogContent\n {...(isContentScrollable && {\n // Sets tabIndex on content element if scrollable so content is easier to navigate with the keyboard\n tabIndex: 0,\n })}\n dividers={isContentScrollable}\n ref={dialogContentRef}\n >\n {content}\n </DialogContent>\n\n {actionButtons.length > 0 && (\n <DialogActions>\n {actionButtons.map((actionButton, index) =>\n actionButton ? cloneElement(actionButton, { key: index }) : null,\n )}\n </DialogActions>\n )}\n </MuiDialog>\n );\n};\n\nconst MemoizedDialog = memo(Dialog);\nMemoizedDialog.displayName = \"Dialog\";\n\nexport { MemoizedDialog as Dialog };\n"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,eAAe;AAQ9C,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SACEC,YAAY,EACZC,IAAI,E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IAC9D;IAAC,CACY,CAChB;EAAA,CACQ,CAAC;AAEhB,CAAC;AAED,MAAME,cAAc,GAAG5D,IAAI,CAACS,MAAM,CAAC;AACnCmD,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAInD,MAAM","ignoreList":[]}
|
package/dist/esm/Select.js
CHANGED
|
@@ -195,7 +195,8 @@ const Select = ({
|
|
|
195
195
|
return {
|
|
196
196
|
text: option.text,
|
|
197
197
|
value,
|
|
198
|
-
type: option.type === "heading" ? "heading" : "option"
|
|
198
|
+
type: option.type === "heading" ? "heading" : "option",
|
|
199
|
+
lang: option.language
|
|
199
200
|
};
|
|
200
201
|
}
|
|
201
202
|
return {
|
|
@@ -256,6 +257,7 @@ const Select = ({
|
|
|
256
257
|
"data-empty": !option.text,
|
|
257
258
|
value: option.value,
|
|
258
259
|
selected: isSelected,
|
|
260
|
+
lang: option.lang,
|
|
259
261
|
children: [hasMultipleChoices && _jsx(_Checkbox, {
|
|
260
262
|
checked: isSelected
|
|
261
263
|
}), option.text, !hasMultipleChoices && internalSelectedValues === option.value && _jsx(_ListItemSecondaryAction, {
|
package/dist/esm/Select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","useImperativeHandle","styled","Field","CheckIcon","CloseCircleFilledIcon","ComponentControlledState","useInputValues","getControlState","useOdysseyDesignTokens","normalizedKey","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SelectTestSelector","accessibleText","errorMessage","hint","label","children","list","listItem","elementSelector","method","options","role","isControlledElement","SelectContainer","div","ChipsPositioningContainer","shouldForwardProp","prop","odysseyDesignTokens","Spacing0","Spacing5","Spacing1","BorderWidthMain","NonInteractiveIcon","Spacing2","ChipsInnerContainer","_Box","isInteractive","isReadOnly","Spacing6","CONTROLLED","Select","ariaDescribedBy","defaultValue","errorMessageList","hasMultipleChoices","hasMultipleChoicesProp","HintLinkComponent","id","idOverride","inputRef","isDisabled","isFullWidth","isMultiSelect","isOptional","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","testId","translate","value","selectRef","undefined","controlledStateRef","controlledValue","uncontrolledValue","internalSelectedValues","setInternalSelectedValues","current","localInputRef","focus","inputValues","controlState","event","child","preventDefault","target","split","normalizedOptions","normalizedOptionsMap","map","option","text","type","Map","removeSelectedValue","selectedValue","Array","isArray","newValue","filter","internalSelectedValue","syntheticEvent","Chips","stopPropagation","hasNonInteractiveIcon","item","length","_Chip","get","tabIndex","onDelete","deleteIcon","sx","pointerEvents","onMouseDown","renderedOptions","index","_ListSubheader","isSelected","includes","_MenuItem","selected","_Checkbox","checked","_ListItemSecondaryAction","toString","renderValue","renderFieldComponent","errorMessageElementId","labelElementId","_Select","displayEmpty","inputProps","readOnly","el","labelId","MenuProps","maxHeight","multiple","fieldType","hasVisibleLabel","MemoizedSelect","displayName"],"sources":["../../src/Select.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useImperativeHandle,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport {\n Box as MuiBox,\n Checkbox as MuiCheckbox,\n Chip as MuiChip,\n ListItemSecondaryAction,\n ListSubheader,\n MenuItem as MuiMenuItem,\n Select as MuiSelect,\n SelectProps as MuiSelectProps,\n SelectChangeEvent,\n} from \"@mui/material\";\n\nimport { Field } from \"./Field.js\";\nimport {\n FieldComponentProps,\n FieldComponentRenderProps,\n} from \"./FieldComponentProps.js\";\nimport { CheckIcon, CloseCircleFilledIcon } from \"./icons.generated/index.js\";\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport {\n ComponentControlledState,\n FocusHandle,\n useInputValues,\n getControlState,\n} from \"./inputUtils.js\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { TestSelector } from \"./test-selectors/index.js\";\nimport { normalizedKey } from \"./useNormalizedKey.js\";\n\nexport const SelectTestSelector = {\n accessibleText: {\n errorMessage: \"errorMessage\",\n hint: \"description\",\n label: \"label\",\n },\n children: {\n list: {\n accessibleText: {\n label: \"label\",\n },\n children: {\n listItem: {\n accessibleText: {\n label: \"label\",\n },\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"option\",\n },\n },\n },\n isControlledElement: true,\n },\n },\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"combobox\",\n },\n} as const satisfies TestSelector;\n\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n};\n\nconst SelectContainer = styled.div`\n position: relative;\n width: 100%;\n display: flex;\n`;\n\nconst ChipsPositioningContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n align-items: center;\n position: absolute;\n top: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n right: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing5};\n bottom: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n left: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.BorderWidthMain};\n opacity: 1;\n pointer-events: none;\n`;\n\nconst NonInteractiveIcon = styled(CloseCircleFilledIcon, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n font-size: 1em;\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.Spacing2};\n margin-inline-end: -${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-block-end: -1px;\n`;\n\nconst ChipsInnerContainer = styled(MuiBox, {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" &&\n prop !== \"isInteractive\" &&\n prop !== \"isReadOnly\",\n})<{\n isInteractive?: boolean;\n isReadOnly?: boolean;\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n flex-wrap: wrap;\n gap: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n pointer-events: none;\n opacity: ${({ isInteractive, isReadOnly }) =>\n isInteractive || isReadOnly ? 1 : 0};\n min-height: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing6};\n`;\n\nexport type SelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type SelectProps<\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiSelectProps<Value>[\"defaultValue\"];\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * The ref forwarded to the Select\n */\n inputRef?: React.RefObject<FocusHandle>;\n /**\n * @deprecated Use `hasMultipleChoices` instead.\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isReadOnly\"\n | \"name\"\n> &\n Pick<HtmlProps, \"ariaDescribedBy\" | \"testId\" | \"translate\">;\n\ntype SelectRenderProps = Partial<\n Pick<FieldComponentRenderProps, \"ariaDescribedBy\" | \"errorMessageElementId\">\n> &\n Pick<FieldComponentRenderProps, \"id\" | \"labelElementId\">;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst { CONTROLLED } = ComponentControlledState;\nconst Select = <\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n HintLinkComponent,\n id: idOverride,\n inputRef,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n isReadOnly = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n options,\n testId,\n translate,\n value,\n}: SelectProps<Value, HasMultipleChoices>) => {\n const selectRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect],\n );\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n const [internalSelectedValues, setInternalSelectedValues] = useState(\n controlledStateRef.current === CONTROLLED ? value : defaultValue,\n );\n\n const localInputRef = useRef<HTMLSelectElement>(null);\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n useImperativeHandle(inputRef, () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n }, []);\n\n useEffect(() => {\n if (controlledStateRef.current === CONTROLLED) {\n setInternalSelectedValues(value);\n }\n }, [value]);\n\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<NonNullable<MuiSelectProps<Value>[\"onChange\"]>>(\n (event, child) => {\n if (isReadOnly) {\n event.preventDefault();\n } else {\n const {\n target: { value },\n } = event;\n if (controlledStateRef.current !== CONTROLLED) {\n setInternalSelectedValues(\n (typeof value === \"string\" && hasMultipleChoices\n ? value.split(\",\")\n : value) as Value,\n );\n }\n onChangeProp?.(event, child);\n }\n },\n [hasMultipleChoices, onChangeProp, isReadOnly],\n );\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const [normalizedOptions, normalizedOptionsMap] = useMemo(() => {\n const normalizedOptions = options.map((option) => {\n if (typeof option === \"object\") {\n /**\n * If the value of `option?.value is an empty string, we need to make sure that we\n * set an empty string to `value` in the normalized option so that the select component\n * can potentially set it as the selected one in the text input\n */\n const value =\n option?.value === \"\" ? option.value : option.value || option.text;\n return {\n text: option.text,\n value,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n };\n }\n\n return { text: option, value: option, type: \"option\" };\n });\n\n const normalizedOptionsMap = new Map(\n normalizedOptions.map((option) => [option.value, option]),\n );\n return [normalizedOptions, normalizedOptionsMap];\n }, [options]);\n\n const removeSelectedValue = useCallback(\n (selectedValue: string) => {\n if (Array.isArray(internalSelectedValues)) {\n const newValue = internalSelectedValues.filter(\n (internalSelectedValue) => internalSelectedValue !== selectedValue,\n );\n\n const syntheticEvent = {\n target: { value: newValue },\n } as SelectChangeEvent<Value>;\n\n onChange(syntheticEvent, null);\n }\n },\n [internalSelectedValues, onChange],\n );\n\n const Chips = useCallback(\n ({\n isInteractive,\n isReadOnly,\n }: {\n isInteractive: boolean;\n isReadOnly?: boolean;\n }) => {\n const stopPropagation = (event: React.MouseEvent<SVGSVGElement>) =>\n event.stopPropagation();\n\n const hasNonInteractiveIcon =\n !isInteractive &&\n controlledStateRef.current === CONTROLLED &&\n hasMultipleChoices;\n return (\n Array.isArray(internalSelectedValues) && (\n <ChipsInnerContainer\n isInteractive={isInteractive}\n isReadOnly={isReadOnly}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {internalSelectedValues.map(\n (item) =>\n item?.length > 0 && (\n <MuiChip\n key={item}\n label={\n <>\n {normalizedOptionsMap.get(item)?.text}\n {hasNonInteractiveIcon && (\n <NonInteractiveIcon\n odysseyDesignTokens={odysseyDesignTokens}\n />\n )}\n </>\n }\n tabIndex={-1}\n onDelete={\n isInteractive && controlledStateRef.current === CONTROLLED\n ? () => removeSelectedValue(item)\n : undefined\n }\n deleteIcon={\n <CloseCircleFilledIcon\n sx={{ pointerEvents: \"auto\" }}\n // We need to stop event propagation on mouse down to prevent the deletion\n // from being blocked by the Select list opening, and also ensure that\n // the pointerEvent is registered even when the parent's are not\n onMouseDown={stopPropagation}\n />\n }\n />\n ),\n )}\n </ChipsInnerContainer>\n )\n );\n },\n [\n controlledStateRef,\n hasMultipleChoices,\n internalSelectedValues,\n odysseyDesignTokens,\n removeSelectedValue,\n normalizedOptionsMap,\n ],\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const renderedOptions = useMemo(\n () =>\n normalizedOptions.map((option, index) => {\n if (option.type === \"heading\") {\n return (\n <ListSubheader key={option.text}> {option.text} </ListSubheader>\n );\n }\n\n const isSelected = hasMultipleChoices\n ? internalSelectedValues?.includes(option.value)\n : internalSelectedValues === option.value;\n\n return (\n <MuiMenuItem\n data-empty={!option.text}\n key={normalizedKey(option.text, index.toString())}\n value={option.value}\n selected={isSelected}\n >\n {hasMultipleChoices && <MuiCheckbox checked={isSelected} />}\n {option.text}\n {!hasMultipleChoices && internalSelectedValues === option.value && (\n <ListItemSecondaryAction>\n <CheckIcon />\n </ListItemSecondaryAction>\n )}\n </MuiMenuItem>\n );\n }),\n [hasMultipleChoices, normalizedOptions, internalSelectedValues],\n );\n\n const renderValue = useCallback(\n (value: Value) => Array.isArray(value) && <Chips isInteractive={false} />,\n [Chips],\n );\n\n const renderFieldComponent = useCallback(\n ({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n }: SelectRenderProps) => (\n <SelectContainer>\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n displayEmpty\n id={id}\n inputProps={{\n \"data-se\": testId,\n \"aria-disabled\": isDisabled || isReadOnly,\n readOnly: isReadOnly,\n }}\n inputRef={(el: HTMLInputElement | HTMLTextAreaElement | null) => {\n if (localInputRef.current !== el) {\n (localInputRef as React.MutableRefObject<typeof el>).current = el;\n }\n selectRef.current = el;\n }}\n labelId={labelElementId}\n MenuProps={{\n sx: {\n \".MuiPaper-root\": {\n maxHeight: \"50vh\",\n },\n },\n }}\n multiple={hasMultipleChoices}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n renderValue={hasMultipleChoices ? renderValue : undefined}\n translate={translate}\n >\n {renderedOptions}\n </MuiSelect>\n {hasMultipleChoices && (\n <>\n <ChipsPositioningContainer\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <Chips isInteractive={!isReadOnly} isReadOnly={isReadOnly} />\n </ChipsPositioningContainer>\n </>\n )}\n </SelectContainer>\n ),\n [\n Chips,\n inputValues,\n hasMultipleChoices,\n isDisabled,\n isReadOnly,\n nameOverride,\n odysseyDesignTokens,\n onBlur,\n onChange,\n onFocus,\n renderedOptions,\n renderValue,\n testId,\n translate,\n ],\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \"Select\";\n\nexport { MemoizedSelect as Select };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EACJC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,mBAAmB,QACd,OAAO;AACd,OAAOC,MAAM,MAAM,iBAAiB;AAapC,SAASC,KAAK,QAAQ,YAAY;AAKlC,SAASC,SAAS,EAAEC,qBAAqB,QAAQ,4BAA4B;AAE7E,SACEC,wBAAwB,EAExBC,cAAc,EACdC,eAAe,QACV,iBAAiB;AACxB,SACEC,sBAAsB,QAEjB,iCAAiC;AAExC,SAASC,aAAa,QAAQ,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtD,OAAO,MAAMC,kBAAkB,GAAG;EAChCC,cAAc,EAAE;IACdC,YAAY,EAAE,cAAc;IAC5BC,IAAI,EAAE,aAAa;IACnBC,KAAK,EAAE;EACT,CAAC;EACDC,QAAQ,EAAE;IACRC,IAAI,EAAE;MACJL,cAAc,EAAE;QACdG,KAAK,EAAE;MACT,CAAC;MACDC,QAAQ,EAAE;QACRE,QAAQ,EAAE;UACRN,cAAc,EAAE;YACdG,KAAK,EAAE;UACT,CAAC;UACDI,eAAe,EAAE;YACfC,MAAM,EAAE,QAAQ;YAChBC,OAAO,EAAE;cACPN,KAAK,EAAE;YACT,CAAC;YACDO,IAAI,EAAE;UACR;QACF;MACF,CAAC;MACDC,mBAAmB,EAAE;IACvB;EACF,CAAC;EACDJ,eAAe,EAAE;IACfC,MAAM,EAAE,QAAQ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O,EACPiD,eAAe,EACfW,WAAW,EACX3D,MAAM,EACNC,SAAS,CAEb,CAAC;EAED,OACEzD,IAAA,CAACT,KAAK;IACJ8C,eAAe,EAAEA,eAAgB;IACjC9B,YAAY,EAAEA,YAAa;IAC3BgC,gBAAgB,EAAEA,gBAAiB;IACnCyF,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACfzH,IAAI,EAAEA,IAAK;IACXkC,iBAAiB,EAAEA,iBAAkB;IACrCC,EAAE,EAAEC,UAAW;IACfE,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBE,UAAU,EAAEA,UAAW;IACvBxC,KAAK,EAAEA,KAAM;IACb2G,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CAAC;AAED,MAAMc,cAAc,GAAGnJ,IAAI,CAACqD,MAAM,CAAC;AACnC8F,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAI9F,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Select.js","names":["memo","useCallback","useEffect","useMemo","useRef","useState","useImperativeHandle","styled","Field","CheckIcon","CloseCircleFilledIcon","ComponentControlledState","useInputValues","getControlState","useOdysseyDesignTokens","normalizedKey","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","SelectTestSelector","accessibleText","errorMessage","hint","label","children","list","listItem","elementSelector","method","options","role","isControlledElement","SelectContainer","div","ChipsPositioningContainer","shouldForwardProp","prop","odysseyDesignTokens","Spacing0","Spacing5","Spacing1","BorderWidthMain","NonInteractiveIcon","Spacing2","ChipsInnerContainer","_Box","isInteractive","isReadOnly","Spacing6","CONTROLLED","Select","ariaDescribedBy","defaultValue","errorMessageList","hasMultipleChoices","hasMultipleChoicesProp","HintLinkComponent","id","idOverride","inputRef","isDisabled","isFullWidth","isMultiSelect","isOptional","name","nameOverride","onBlur","onChange","onChangeProp","onFocus","testId","translate","value","selectRef","undefined","controlledStateRef","controlledValue","uncontrolledValue","internalSelectedValues","setInternalSelectedValues","current","localInputRef","focus","inputValues","controlState","event","child","preventDefault","target","split","normalizedOptions","normalizedOptionsMap","map","option","text","type","lang","language","Map","removeSelectedValue","selectedValue","Array","isArray","newValue","filter","internalSelectedValue","syntheticEvent","Chips","stopPropagation","hasNonInteractiveIcon","item","length","_Chip","get","tabIndex","onDelete","deleteIcon","sx","pointerEvents","onMouseDown","renderedOptions","index","_ListSubheader","isSelected","includes","_MenuItem","selected","_Checkbox","checked","_ListItemSecondaryAction","toString","renderValue","renderFieldComponent","errorMessageElementId","labelElementId","_Select","displayEmpty","inputProps","readOnly","el","labelId","MenuProps","maxHeight","multiple","fieldType","hasVisibleLabel","MemoizedSelect","displayName"],"sources":["../../src/Select.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2022-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport {\n memo,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n useImperativeHandle,\n} from \"react\";\nimport styled from \"@emotion/styled\";\nimport {\n Box as MuiBox,\n Checkbox as MuiCheckbox,\n Chip as MuiChip,\n ListItemSecondaryAction,\n ListSubheader,\n MenuItem as MuiMenuItem,\n Select as MuiSelect,\n SelectProps as MuiSelectProps,\n SelectChangeEvent,\n} from \"@mui/material\";\n\nimport { Field } from \"./Field.js\";\nimport {\n FieldComponentProps,\n FieldComponentRenderProps,\n} from \"./FieldComponentProps.js\";\nimport { CheckIcon, CloseCircleFilledIcon } from \"./icons.generated/index.js\";\nimport type { HtmlProps } from \"./HtmlProps.js\";\nimport {\n ComponentControlledState,\n FocusHandle,\n useInputValues,\n getControlState,\n} from \"./inputUtils.js\";\nimport {\n useOdysseyDesignTokens,\n DesignTokens,\n} from \"./OdysseyDesignTokensContext.js\";\nimport { TestSelector } from \"./test-selectors/index.js\";\nimport { normalizedKey } from \"./useNormalizedKey.js\";\n\nexport const SelectTestSelector = {\n accessibleText: {\n errorMessage: \"errorMessage\",\n hint: \"description\",\n label: \"label\",\n },\n children: {\n list: {\n accessibleText: {\n label: \"label\",\n },\n children: {\n listItem: {\n accessibleText: {\n label: \"label\",\n },\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"option\",\n },\n },\n },\n isControlledElement: true,\n },\n },\n elementSelector: {\n method: \"ByRole\",\n options: {\n label: \"name\",\n },\n role: \"combobox\",\n },\n} as const satisfies TestSelector;\n\nexport type SelectOption = {\n text: string;\n type?: \"heading\" | \"option\";\n value?: string;\n language?: string;\n};\n\nconst SelectContainer = styled.div`\n position: relative;\n width: 100%;\n display: flex;\n`;\n\nconst ChipsPositioningContainer = styled(\"div\", {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n align-items: center;\n position: absolute;\n top: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n right: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing5};\n bottom: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing0};\n left: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.BorderWidthMain};\n opacity: 1;\n pointer-events: none;\n`;\n\nconst NonInteractiveIcon = styled(CloseCircleFilledIcon, {\n shouldForwardProp: (prop) => prop !== \"odysseyDesignTokens\",\n})<{\n odysseyDesignTokens: DesignTokens;\n}>`\n font-size: 1em;\n margin-inline-start: ${({ odysseyDesignTokens }) =>\n odysseyDesignTokens.Spacing2};\n margin-inline-end: -${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n margin-block-end: -1px;\n`;\n\nconst ChipsInnerContainer = styled(MuiBox, {\n shouldForwardProp: (prop) =>\n prop !== \"odysseyDesignTokens\" &&\n prop !== \"isInteractive\" &&\n prop !== \"isReadOnly\",\n})<{\n isInteractive?: boolean;\n isReadOnly?: boolean;\n odysseyDesignTokens: DesignTokens;\n}>`\n display: flex;\n flex-wrap: wrap;\n gap: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing1};\n pointer-events: none;\n opacity: ${({ isInteractive, isReadOnly }) =>\n isInteractive || isReadOnly ? 1 : 0};\n min-height: ${({ odysseyDesignTokens }) => odysseyDesignTokens.Spacing6};\n`;\n\nexport type SelectValueType<HasMultipleChoices> =\n HasMultipleChoices extends true ? string[] : string;\n\nexport type SelectProps<\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n> = {\n /**\n * The default value. Use when the component is not controlled.\n */\n defaultValue?: MuiSelectProps<Value>[\"defaultValue\"];\n /**\n * If `true`, the Select allows multiple selections\n */\n hasMultipleChoices?: HasMultipleChoices;\n /**\n * The ref forwarded to the Select\n */\n inputRef?: React.RefObject<FocusHandle>;\n /**\n * @deprecated Use `hasMultipleChoices` instead.\n */\n /** **Deprecated:** use `hasMultipleChoices` */\n isMultiSelect?: HasMultipleChoices;\n /**\n * The label text for the Select\n */\n label: string;\n /**\n * Callback fired when the Select loses focus\n */\n onBlur?: MuiSelectProps<Value>[\"onBlur\"];\n /**\n * Callback fired when the value of the Select changes\n */\n onChange?: MuiSelectProps<Value>[\"onChange\"];\n /**\n * Callback fired when the Select gains focus\n */\n onFocus?: MuiSelectProps<Value>[\"onFocus\"];\n /**\n * The options for the Select\n */\n options: (string | SelectOption)[];\n /**\n * The value or values selected in the Select\n */\n value?: Value;\n} & Pick<\n FieldComponentProps,\n | \"errorMessage\"\n | \"errorMessageList\"\n | \"hint\"\n | \"HintLinkComponent\"\n | \"id\"\n | \"isDisabled\"\n | \"isFullWidth\"\n | \"isOptional\"\n | \"isReadOnly\"\n | \"name\"\n> &\n Pick<HtmlProps, \"ariaDescribedBy\" | \"testId\" | \"translate\">;\n\ntype SelectRenderProps = Partial<\n Pick<FieldComponentRenderProps, \"ariaDescribedBy\" | \"errorMessageElementId\">\n> &\n Pick<FieldComponentRenderProps, \"id\" | \"labelElementId\">;\n\n/**\n * Options in Odyssey <Select> are passed as an array, which can contain any combination\n * of the following:\n * - string — A simple string. The string will be both the text and the value of the resulting option.\n * <option value=\"string\">string</option>\n *\n * - { text: string } — Same as above, but the string is contained within an object.\n * <option value=\"text\">text</option>\n *\n * - { text: string, value: string } — The option text will be text, and the option value will be value.\n * <option value=\"value\">text</option>\n *\n * - { text: string, type: \"heading\" } — Used to display a group heading with the text\n */\n\nconst { CONTROLLED } = ComponentControlledState;\nconst Select = <\n Value extends SelectValueType<HasMultipleChoices>,\n HasMultipleChoices extends boolean,\n>({\n ariaDescribedBy,\n defaultValue,\n errorMessage,\n errorMessageList,\n hasMultipleChoices: hasMultipleChoicesProp,\n hint,\n HintLinkComponent,\n id: idOverride,\n inputRef,\n isDisabled = false,\n isFullWidth = false,\n isMultiSelect,\n isOptional = false,\n isReadOnly = false,\n label,\n name: nameOverride,\n onBlur,\n onChange: onChangeProp,\n onFocus,\n options,\n testId,\n translate,\n value,\n}: SelectProps<Value, HasMultipleChoices>) => {\n const selectRef = useRef<HTMLInputElement | HTMLTextAreaElement | null>(null);\n\n const hasMultipleChoices = useMemo(\n () =>\n hasMultipleChoicesProp === undefined\n ? isMultiSelect\n : hasMultipleChoicesProp,\n [hasMultipleChoicesProp, isMultiSelect],\n );\n\n const controlledStateRef = useRef(\n getControlState({\n controlledValue: value,\n uncontrolledValue: defaultValue,\n }),\n );\n const [internalSelectedValues, setInternalSelectedValues] = useState(\n controlledStateRef.current === CONTROLLED ? value : defaultValue,\n );\n\n const localInputRef = useRef<HTMLSelectElement>(null);\n const odysseyDesignTokens = useOdysseyDesignTokens();\n\n useImperativeHandle(inputRef, () => {\n return {\n focus: () => {\n localInputRef.current?.focus();\n },\n };\n }, []);\n\n useEffect(() => {\n if (controlledStateRef.current === CONTROLLED) {\n setInternalSelectedValues(value);\n }\n }, [value]);\n\n const inputValues = useInputValues({\n defaultValue,\n value,\n controlState: controlledStateRef.current,\n });\n\n const onChange = useCallback<NonNullable<MuiSelectProps<Value>[\"onChange\"]>>(\n (event, child) => {\n if (isReadOnly) {\n event.preventDefault();\n } else {\n const {\n target: { value },\n } = event;\n if (controlledStateRef.current !== CONTROLLED) {\n setInternalSelectedValues(\n (typeof value === \"string\" && hasMultipleChoices\n ? value.split(\",\")\n : value) as Value,\n );\n }\n onChangeProp?.(event, child);\n }\n },\n [hasMultipleChoices, onChangeProp, isReadOnly],\n );\n // Normalize the options array to accommodate the various\n // data types that might be passed\n const [normalizedOptions, normalizedOptionsMap] = useMemo(() => {\n const normalizedOptions = options.map((option) => {\n if (typeof option === \"object\") {\n /**\n * If the value of `option?.value is an empty string, we need to make sure that we\n * set an empty string to `value` in the normalized option so that the select component\n * can potentially set it as the selected one in the text input\n */\n const value =\n option?.value === \"\" ? option.value : option.value || option.text;\n return {\n text: option.text,\n value,\n type: option.type === \"heading\" ? \"heading\" : \"option\",\n lang: option.language,\n };\n }\n\n return { text: option, value: option, type: \"option\" };\n });\n\n const normalizedOptionsMap = new Map(\n normalizedOptions.map((option) => [option.value, option]),\n );\n return [normalizedOptions, normalizedOptionsMap];\n }, [options]);\n\n const removeSelectedValue = useCallback(\n (selectedValue: string) => {\n if (Array.isArray(internalSelectedValues)) {\n const newValue = internalSelectedValues.filter(\n (internalSelectedValue) => internalSelectedValue !== selectedValue,\n );\n\n const syntheticEvent = {\n target: { value: newValue },\n } as SelectChangeEvent<Value>;\n\n onChange(syntheticEvent, null);\n }\n },\n [internalSelectedValues, onChange],\n );\n\n const Chips = useCallback(\n ({\n isInteractive,\n isReadOnly,\n }: {\n isInteractive: boolean;\n isReadOnly?: boolean;\n }) => {\n const stopPropagation = (event: React.MouseEvent<SVGSVGElement>) =>\n event.stopPropagation();\n\n const hasNonInteractiveIcon =\n !isInteractive &&\n controlledStateRef.current === CONTROLLED &&\n hasMultipleChoices;\n return (\n Array.isArray(internalSelectedValues) && (\n <ChipsInnerContainer\n isInteractive={isInteractive}\n isReadOnly={isReadOnly}\n odysseyDesignTokens={odysseyDesignTokens}\n >\n {internalSelectedValues.map(\n (item) =>\n item?.length > 0 && (\n <MuiChip\n key={item}\n label={\n <>\n {normalizedOptionsMap.get(item)?.text}\n {hasNonInteractiveIcon && (\n <NonInteractiveIcon\n odysseyDesignTokens={odysseyDesignTokens}\n />\n )}\n </>\n }\n tabIndex={-1}\n onDelete={\n isInteractive && controlledStateRef.current === CONTROLLED\n ? () => removeSelectedValue(item)\n : undefined\n }\n deleteIcon={\n <CloseCircleFilledIcon\n sx={{ pointerEvents: \"auto\" }}\n // We need to stop event propagation on mouse down to prevent the deletion\n // from being blocked by the Select list opening, and also ensure that\n // the pointerEvent is registered even when the parent's are not\n onMouseDown={stopPropagation}\n />\n }\n />\n ),\n )}\n </ChipsInnerContainer>\n )\n );\n },\n [\n controlledStateRef,\n hasMultipleChoices,\n internalSelectedValues,\n odysseyDesignTokens,\n removeSelectedValue,\n normalizedOptionsMap,\n ],\n );\n\n // Convert the options into the ReactNode children\n // that will populate the <Select>\n const renderedOptions = useMemo(\n () =>\n normalizedOptions.map((option, index) => {\n if (option.type === \"heading\") {\n return (\n <ListSubheader key={option.text}> {option.text} </ListSubheader>\n );\n }\n\n const isSelected = hasMultipleChoices\n ? internalSelectedValues?.includes(option.value)\n : internalSelectedValues === option.value;\n\n return (\n <MuiMenuItem\n data-empty={!option.text}\n key={normalizedKey(option.text, index.toString())}\n value={option.value}\n selected={isSelected}\n lang={option.lang}\n >\n {hasMultipleChoices && <MuiCheckbox checked={isSelected} />}\n {option.text}\n {!hasMultipleChoices && internalSelectedValues === option.value && (\n <ListItemSecondaryAction>\n <CheckIcon />\n </ListItemSecondaryAction>\n )}\n </MuiMenuItem>\n );\n }),\n [hasMultipleChoices, normalizedOptions, internalSelectedValues],\n );\n\n const renderValue = useCallback(\n (value: Value) => Array.isArray(value) && <Chips isInteractive={false} />,\n [Chips],\n );\n\n const renderFieldComponent = useCallback(\n ({\n ariaDescribedBy,\n errorMessageElementId,\n id,\n labelElementId,\n }: SelectRenderProps) => (\n <SelectContainer>\n <MuiSelect\n {...inputValues}\n aria-describedby={ariaDescribedBy}\n aria-errormessage={errorMessageElementId}\n displayEmpty\n id={id}\n inputProps={{\n \"data-se\": testId,\n \"aria-disabled\": isDisabled || isReadOnly,\n readOnly: isReadOnly,\n }}\n inputRef={(el: HTMLInputElement | HTMLTextAreaElement | null) => {\n if (localInputRef.current !== el) {\n (localInputRef as React.MutableRefObject<typeof el>).current = el;\n }\n selectRef.current = el;\n }}\n labelId={labelElementId}\n MenuProps={{\n sx: {\n \".MuiPaper-root\": {\n maxHeight: \"50vh\",\n },\n },\n }}\n multiple={hasMultipleChoices}\n name={nameOverride ?? id}\n onBlur={onBlur}\n onChange={onChange}\n onFocus={onFocus}\n renderValue={hasMultipleChoices ? renderValue : undefined}\n translate={translate}\n >\n {renderedOptions}\n </MuiSelect>\n {hasMultipleChoices && (\n <>\n <ChipsPositioningContainer\n odysseyDesignTokens={odysseyDesignTokens}\n >\n <Chips isInteractive={!isReadOnly} isReadOnly={isReadOnly} />\n </ChipsPositioningContainer>\n </>\n )}\n </SelectContainer>\n ),\n [\n Chips,\n inputValues,\n hasMultipleChoices,\n isDisabled,\n isReadOnly,\n nameOverride,\n odysseyDesignTokens,\n onBlur,\n onChange,\n onFocus,\n renderedOptions,\n renderValue,\n testId,\n translate,\n ],\n );\n\n return (\n <Field\n ariaDescribedBy={ariaDescribedBy}\n errorMessage={errorMessage}\n errorMessageList={errorMessageList}\n fieldType=\"single\"\n hasVisibleLabel\n hint={hint}\n HintLinkComponent={HintLinkComponent}\n id={idOverride}\n isDisabled={isDisabled}\n isFullWidth={isFullWidth}\n isOptional={isOptional}\n label={label}\n renderFieldComponent={renderFieldComponent}\n />\n );\n};\n\nconst MemoizedSelect = memo(Select);\nMemoizedSelect.displayName = \"Select\";\n\nexport { MemoizedSelect as Select };\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,IAAI,EACJC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,EACRC,mBAAmB,QACd,OAAO;AACd,OAAOC,MAAM,MAAM,iBAAiB;AAapC,SAASC,KAAK,QAAQ,YAAY;AAKlC,SAASC,SAAS,EAAEC,qBAAqB,QAAQ,4BAA4B;AAE7E,SACEC,wBAAwB,EAExBC,cAAc,EACdC,eAAe,QACV,iBAAiB;AACxB,SACEC,sBAAsB,QAEjB,iCAAiC;AAExC,SAASC,aAAa,QAAQ,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtD,OAAO,MAAMC,kBAAkB,GAAG;EAChCC,cAAc,EAAE;IACdC,YAAY,EAAE,cAAc;IAC5BC,IAAI,EAAE,aAAa;IACnBC,KAAK,EAAE;EACT,CAAC;EACDC,QAAQ,EAAE;IACRC,IAAI,EAAE;MACJL,cAAc,EAAE;QACdG,KAAK,EAAE;MACT,CAAC;MACDC,QAAQ,EAAE;QACRE,QAAQ,EAAE;UACRN,cAAc,EAAE;YACdG,KAAK,EAAE;UACT,CAAC;UACDI,eAAe,EAAE;YACfC,MAAM,EAAE,QAAQ;YAChBC,OAAO,EAAE;cACPN,KAAK,EAAE;YACT,CAAC;YACDO,IAAI,EAAE;UACR;QACF;MACF,CAAC;MACDC,mBAAmB,EAAE;IACvB;EACF,CAAC;EACDJ,eAAe,EAAE;IACfC,MAAM,EAAE,QAAQ;IAChBC,OAAO,EAAE;MACPN,KAAK,EAAE;IACT,CAAC;IACDO,IAAI,EAAE;EACR;AACF,CAAiC;AASjC,MAAME,eAAe,G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AW,EACX7D,MAAM,EACNC,SAAS,CAEb,CAAC;EAED,OACEzD,IAAA,CAACT,KAAK;IACJ8C,eAAe,EAAEA,eAAgB;IACjC9B,YAAY,EAAEA,YAAa;IAC3BgC,gBAAgB,EAAEA,gBAAiB;IACnC2F,SAAS,EAAC,QAAQ;IAClBC,eAAe;IACf3H,IAAI,EAAEA,IAAK;IACXkC,iBAAiB,EAAEA,iBAAkB;IACrCC,EAAE,EAAEC,UAAW;IACfE,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBE,UAAU,EAAEA,UAAW;IACvBxC,KAAK,EAAEA,KAAM;IACb6G,oBAAoB,EAAEA;EAAqB,CAC5C,CAAC;AAEN,CAAC;AAED,MAAMc,cAAc,GAAGrJ,IAAI,CAACqD,MAAM,CAAC;AACnCgG,cAAc,CAACC,WAAW,GAAG,QAAQ;AAErC,SAASD,cAAc,IAAIhG,MAAM","ignoreList":[]}
|
package/dist/esm/Typography.js
CHANGED
|
@@ -38,7 +38,8 @@ const Typography = ({
|
|
|
38
38
|
testId,
|
|
39
39
|
translate,
|
|
40
40
|
typographyRef,
|
|
41
|
-
variant = "body"
|
|
41
|
+
variant = "body",
|
|
42
|
+
isPresentational
|
|
42
43
|
}) => {
|
|
43
44
|
const component = useMemo(() => {
|
|
44
45
|
if (!componentProp) {
|
|
@@ -70,7 +71,8 @@ const Typography = ({
|
|
|
70
71
|
ref: localTypographyRef,
|
|
71
72
|
tabIndex: -1,
|
|
72
73
|
translate: translate,
|
|
73
|
-
variant: typographyVariantMapping[variant]
|
|
74
|
+
variant: typographyVariantMapping[variant],
|
|
75
|
+
role: isPresentational ? "presentation" : undefined
|
|
74
76
|
});
|
|
75
77
|
};
|
|
76
78
|
const MemoizedTypography = memo(Typography);
|
|
@@ -84,7 +86,8 @@ const Heading1 = ({
|
|
|
84
86
|
color,
|
|
85
87
|
component,
|
|
86
88
|
testId,
|
|
87
|
-
translate
|
|
89
|
+
translate,
|
|
90
|
+
isPresentational
|
|
88
91
|
}) => _jsx(Typography, {
|
|
89
92
|
ariaCurrent: ariaCurrent,
|
|
90
93
|
ariaDescribedBy: ariaDescribedBy,
|
|
@@ -95,7 +98,8 @@ const Heading1 = ({
|
|
|
95
98
|
component: component,
|
|
96
99
|
testId: testId,
|
|
97
100
|
translate: translate,
|
|
98
|
-
variant: "h1"
|
|
101
|
+
variant: "h1",
|
|
102
|
+
isPresentational: isPresentational
|
|
99
103
|
});
|
|
100
104
|
const MemoizedHeading1 = memo(Heading1);
|
|
101
105
|
MemoizedHeading1.displayName = "Heading1";
|