xmlui 0.9.31 → 0.9.32

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.
@@ -0,0 +1,544 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.handleDownloadZip = exports.INITIAL_PLAYGROUND_STATE = exports.builtInThemes = exports.usePlayground = exports.playgroundReducer = exports.PlaygroundContext = void 0;
16
+ exports.toneChanged = toneChanged;
17
+ exports.textChanged = textChanged;
18
+ exports.contentChanged = contentChanged;
19
+ exports.previewMode = previewMode;
20
+ exports.resetApp = resetApp;
21
+ exports.swapApp = swapApp;
22
+ exports.changeOrientation = changeOrientation;
23
+ exports.appDescriptionInitialized = appDescriptionInitialized;
24
+ exports.optionsInitialized = optionsInitialized;
25
+ exports.activeThemeChanged = activeThemeChanged;
26
+ exports.editorStatusChanged = editorStatusChanged;
27
+ exports.compress = compress;
28
+ exports.decompress = decompress;
29
+ exports.createQueryString = createQueryString;
30
+ exports.serialize = serialize;
31
+ exports.decompressData = decompressData;
32
+ exports.preprocessCode = preprocessCode;
33
+ const react_1 = require("react");
34
+ const immer_1 = __importDefault(require("immer"));
35
+ const xmlui_parser_1 = require("../../components-core/xmlui-parser");
36
+ const react_2 = require("react");
37
+ const xmlui_serializer_1 = require("../../parsers/xmlui-parser/xmlui-serializer");
38
+ const solid_1 = require("../../components-core/theming/themes/solid");
39
+ const xmlui_1 = require("../../components-core/theming/themes/xmlui");
40
+ const jszip_1 = __importDefault(require("jszip"));
41
+ const file_saver_1 = require("file-saver");
42
+ const misc_1 = require("../../components-core/utils/misc");
43
+ exports.PlaygroundContext = (0, react_1.createContext)(undefined);
44
+ var PlaygroundActionKind;
45
+ (function (PlaygroundActionKind) {
46
+ PlaygroundActionKind["TEXT_CHANGED"] = "PlaygroundActionKind:TEXT_CHANGED";
47
+ PlaygroundActionKind["CONTENT_CHANGED"] = "PlaygroundActionKind:CONTENT_CHANGED";
48
+ PlaygroundActionKind["PREVIEW_MODE"] = "PlaygroundActionKind:PREVIEW_MODE";
49
+ PlaygroundActionKind["RESET_APP"] = "PlaygroundActionKind:RESET_APP";
50
+ PlaygroundActionKind["APP_SWAPPED"] = "PlaygroundActionKind:APP_SWAPPED";
51
+ PlaygroundActionKind["ORIENTATION_CHANGED"] = "PlaygroundActionKind:ORIENTATION_CHANGED";
52
+ PlaygroundActionKind["APP_DESCRIPTION_INITIALIZED"] = "PlaygroundActionKind:APP_DESCRIPTION_INITIALIZED";
53
+ PlaygroundActionKind["EDITOR_STATUS_CHANGED"] = "PlaygroundActionKind:EDITOR_STATUS_CHANGED";
54
+ PlaygroundActionKind["OPTIONS_INITIALIZED"] = "PlaygroundActionKind:OPTIONS_INITIALIZED";
55
+ PlaygroundActionKind["ACTIVE_THEME_CHANGED"] = "PlaygroundActionKind:ACTIVE_THEME_CHANGED";
56
+ PlaygroundActionKind["TONE_CHANGED"] = "PlaygroundActionKind:TONE_CHANGED";
57
+ })(PlaygroundActionKind || (PlaygroundActionKind = {}));
58
+ function toneChanged(activeTone) {
59
+ return {
60
+ type: PlaygroundActionKind.TONE_CHANGED,
61
+ payload: {
62
+ activeTone,
63
+ },
64
+ };
65
+ }
66
+ function textChanged(text) {
67
+ return {
68
+ type: PlaygroundActionKind.TEXT_CHANGED,
69
+ payload: {
70
+ text,
71
+ },
72
+ };
73
+ }
74
+ function contentChanged(content) {
75
+ return {
76
+ type: PlaygroundActionKind.CONTENT_CHANGED,
77
+ payload: {
78
+ content,
79
+ },
80
+ };
81
+ }
82
+ function previewMode(previewMode) {
83
+ return {
84
+ type: PlaygroundActionKind.PREVIEW_MODE,
85
+ payload: {
86
+ previewMode,
87
+ },
88
+ };
89
+ }
90
+ function resetApp() {
91
+ return {
92
+ type: PlaygroundActionKind.RESET_APP,
93
+ payload: {},
94
+ };
95
+ }
96
+ function swapApp() {
97
+ return {
98
+ type: PlaygroundActionKind.APP_SWAPPED,
99
+ payload: {},
100
+ };
101
+ }
102
+ function changeOrientation() {
103
+ return {
104
+ type: PlaygroundActionKind.ORIENTATION_CHANGED,
105
+ payload: {},
106
+ };
107
+ }
108
+ function appDescriptionInitialized(appDescription) {
109
+ return {
110
+ type: PlaygroundActionKind.APP_DESCRIPTION_INITIALIZED,
111
+ payload: {
112
+ appDescription,
113
+ },
114
+ };
115
+ }
116
+ function optionsInitialized(options) {
117
+ return {
118
+ type: PlaygroundActionKind.OPTIONS_INITIALIZED,
119
+ payload: {
120
+ options,
121
+ },
122
+ };
123
+ }
124
+ function activeThemeChanged(activeTheme) {
125
+ return {
126
+ type: PlaygroundActionKind.ACTIVE_THEME_CHANGED,
127
+ payload: {
128
+ activeTheme,
129
+ },
130
+ };
131
+ }
132
+ function editorStatusChanged(editorStatus) {
133
+ return {
134
+ type: PlaygroundActionKind.EDITOR_STATUS_CHANGED,
135
+ payload: {
136
+ editorStatus,
137
+ },
138
+ };
139
+ }
140
+ exports.playgroundReducer = (0, immer_1.default)((state, action) => {
141
+ var _a, _b, _c, _d, _e, _f, _g;
142
+ switch (action.type) {
143
+ case PlaygroundActionKind.EDITOR_STATUS_CHANGED: {
144
+ state.editorStatus = action.payload.editorStatus || "idle";
145
+ break;
146
+ }
147
+ case PlaygroundActionKind.APP_DESCRIPTION_INITIALIZED: {
148
+ state.status = "loading";
149
+ if (action.payload.appDescription) {
150
+ const compoundComponents = action.payload.appDescription.components.map((src) => {
151
+ if (typeof src === "string") {
152
+ let { errors, component, erroneousCompoundComponentName } = (0, xmlui_parser_1.xmlUiMarkupToComponent)(src);
153
+ if (errors.length > 0) {
154
+ return (0, xmlui_parser_1.errReportComponent)(errors, "Preview source file", erroneousCompoundComponentName);
155
+ }
156
+ return {
157
+ name: component.name,
158
+ component: src,
159
+ };
160
+ }
161
+ return src;
162
+ });
163
+ state.appDescription.components = compoundComponents;
164
+ state.appDescription.app = action.payload.appDescription.app;
165
+ state.appDescription.config = action.payload.appDescription.config;
166
+ state.appDescription.api = action.payload.appDescription.api;
167
+ state.text = action.payload.appDescription.app;
168
+ const themes = action.payload.appDescription.config.themes || [];
169
+ state.appDescription.availableThemes = [...themes, ...exports.builtInThemes];
170
+ state.options.activeTheme =
171
+ state.appDescription.config.defaultTheme || state.appDescription.availableThemes[0].id;
172
+ state.originalAppDescription = Object.assign({}, state.appDescription);
173
+ }
174
+ state.status = "loaded";
175
+ break;
176
+ }
177
+ case PlaygroundActionKind.OPTIONS_INITIALIZED: {
178
+ state.options = action.payload.options || state.options;
179
+ break;
180
+ }
181
+ case PlaygroundActionKind.ACTIVE_THEME_CHANGED: {
182
+ if (action.payload.activeTheme) {
183
+ state.options.activeTheme = action.payload.activeTheme;
184
+ }
185
+ break;
186
+ }
187
+ case PlaygroundActionKind.PREVIEW_MODE: {
188
+ state.options.previewMode = action.payload.previewMode || false;
189
+ break;
190
+ }
191
+ case PlaygroundActionKind.APP_SWAPPED: {
192
+ state.options.swapped = !state.options.swapped;
193
+ break;
194
+ }
195
+ case PlaygroundActionKind.ORIENTATION_CHANGED: {
196
+ state.options.orientation =
197
+ state.options.orientation === "horizontal" ? "vertical" : "horizontal";
198
+ break;
199
+ }
200
+ case PlaygroundActionKind.RESET_APP: {
201
+ state.options.id = state.options.id + 1;
202
+ state.appDescription = Object.assign({}, state.originalAppDescription);
203
+ if (state.options.content === "app") {
204
+ state.text = state.originalAppDescription.app;
205
+ }
206
+ if (state.options.content === "config") {
207
+ state.text = JSON.stringify(state.originalAppDescription.config, null, 2);
208
+ }
209
+ else if (state.appDescription.components
210
+ .map((c) => c.name.toLowerCase())
211
+ .includes((_a = state.options.content) === null || _a === void 0 ? void 0 : _a.toLowerCase())) {
212
+ state.text =
213
+ ((_b = state.originalAppDescription.components.find((component) => component.name === state.options.content)) === null || _b === void 0 ? void 0 : _b.component) || "";
214
+ }
215
+ break;
216
+ }
217
+ case PlaygroundActionKind.CONTENT_CHANGED: {
218
+ state.options.content = action.payload.content || "app";
219
+ if (state.options.content === "app") {
220
+ state.text = state.appDescription.app;
221
+ state.options.language = "xmlui";
222
+ }
223
+ else if (state.options.content === "config") {
224
+ state.text = JSON.stringify(state.appDescription.config, null, 2);
225
+ state.options.language = "json";
226
+ }
227
+ else if (state.appDescription.components
228
+ .map((c) => c.name.toLowerCase())
229
+ .includes((_c = state.options.content) === null || _c === void 0 ? void 0 : _c.toLowerCase())) {
230
+ state.text =
231
+ ((_d = state.appDescription.components.find((component) => component.name === state.options.content)) === null || _d === void 0 ? void 0 : _d.component) || "";
232
+ state.options.language = "xmlui";
233
+ }
234
+ else if (state.appDescription.config.themes
235
+ .map((t) => t.id.toLowerCase())
236
+ .includes((_e = state.options.content) === null || _e === void 0 ? void 0 : _e.toLowerCase())) {
237
+ state.text = JSON.stringify(state.appDescription.config.themes.find((theme) => theme.id === state.options.content), null, 2);
238
+ state.options.language = "json";
239
+ }
240
+ break;
241
+ }
242
+ case PlaygroundActionKind.TONE_CHANGED: {
243
+ state.options.id = state.options.id + 1;
244
+ state.options.activeTone = action.payload.activeTone;
245
+ break;
246
+ }
247
+ case PlaygroundActionKind.TEXT_CHANGED:
248
+ state.options.id = state.options.id + 1;
249
+ {
250
+ state.text = action.payload.text || "";
251
+ if (state.options.content === "app") {
252
+ state.appDescription.app = state.text;
253
+ }
254
+ else if (state.options.content === "config") {
255
+ try {
256
+ state.appDescription.config = JSON.parse(state.text || "");
257
+ }
258
+ catch (e) {
259
+ console.log(e);
260
+ }
261
+ }
262
+ else if ((_f = state.appDescription.components) === null || _f === void 0 ? void 0 : _f.some((component) => component.name === state.options.content)) {
263
+ state.appDescription.components = state.appDescription.components.map((component) => {
264
+ if (component.name === state.options.content) {
265
+ return {
266
+ name: component.name,
267
+ component: state.text || "",
268
+ };
269
+ }
270
+ return component;
271
+ });
272
+ }
273
+ else if ((_g = state.appDescription.config.themes) === null || _g === void 0 ? void 0 : _g.some((theme) => theme.id === state.options.content)) {
274
+ try {
275
+ state.appDescription.config.themes = state.appDescription.config.themes.map((theme) => {
276
+ if (theme.id === state.options.content) {
277
+ return JSON.parse(state.text || "");
278
+ }
279
+ return theme;
280
+ });
281
+ }
282
+ catch (e) {
283
+ console.log(e);
284
+ }
285
+ }
286
+ }
287
+ break;
288
+ }
289
+ });
290
+ const usePlayground = () => {
291
+ const context = (0, react_2.useContext)(exports.PlaygroundContext);
292
+ if (context === undefined) {
293
+ throw new Error("usePlayground must be used within a PlaygroundProvider");
294
+ }
295
+ return context;
296
+ };
297
+ exports.usePlayground = usePlayground;
298
+ /**
299
+ * Convert a string to its UTF-8 bytes and compress it.
300
+ *
301
+ * @param {string} str
302
+ * @returns {Promise<Uint8Array>}
303
+ */
304
+ function compress(str) {
305
+ return __awaiter(this, void 0, void 0, function* () {
306
+ // Convert the string to a byte stream.
307
+ const stream = new Blob([str]).stream();
308
+ // Create a compressed stream.
309
+ const compressedStream = stream.pipeThrough(new CompressionStream("gzip"));
310
+ // Convert the string to a byte stream.
311
+ const reader = compressedStream.getReader();
312
+ const chunks = [];
313
+ while (true) {
314
+ const { done, value } = yield reader.read();
315
+ if (done)
316
+ break;
317
+ chunks.push(value);
318
+ }
319
+ return yield concatUint8Arrays(chunks);
320
+ });
321
+ }
322
+ /**
323
+ * Decompress bytes into a UTF-8 string.
324
+ *
325
+ * @param {Uint8Array} compressedBytes
326
+ * @returns {Promise<string>}
327
+ */
328
+ function decompress(compressedBytes) {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ // Convert the bytes to a stream.
331
+ const stream = new Blob([compressedBytes]).stream();
332
+ // Create a decompressed stream.
333
+ const decompressedStream = stream.pipeThrough(new DecompressionStream("gzip"));
334
+ // Convert the string to a byte stream.
335
+ const reader = decompressedStream.getReader();
336
+ const chunks = [];
337
+ while (true) {
338
+ const { done, value } = yield reader.read();
339
+ if (done)
340
+ break;
341
+ chunks.push(value);
342
+ }
343
+ const stringBytes = yield concatUint8Arrays(chunks);
344
+ // Convert the bytes to a string.
345
+ return new TextDecoder().decode(stringBytes);
346
+ });
347
+ }
348
+ /**
349
+ * Combine multiple Uint8Arrays into one.
350
+ *
351
+ * @param {ReadonlyArray<Uint8Array>} uint8arrays
352
+ * @returns {Promise<Uint8Array>}
353
+ */
354
+ function concatUint8Arrays(uint8arrays) {
355
+ return __awaiter(this, void 0, void 0, function* () {
356
+ const blob = new Blob(uint8arrays);
357
+ const buffer = yield blob.arrayBuffer();
358
+ return new Uint8Array(buffer);
359
+ });
360
+ }
361
+ function createQueryString(target) {
362
+ return __awaiter(this, void 0, void 0, function* () {
363
+ // Convert the Uint8Array to a Base64 string.
364
+ const compressed = yield compress(target);
365
+ const base64 = btoa(String.fromCharCode(...compressed));
366
+ // Create a query string.
367
+ return encodeURIComponent(base64);
368
+ });
369
+ }
370
+ function fetchWithoutCache(url) {
371
+ return __awaiter(this, void 0, void 0, function* () {
372
+ return fetch((0, misc_1.normalizePath)(url), {
373
+ headers: {
374
+ "Cache-Control": "no-cache, no-store",
375
+ },
376
+ });
377
+ });
378
+ }
379
+ function serialize(component) {
380
+ if (component) {
381
+ const xh = new xmlui_serializer_1.XmlUiHelper();
382
+ try {
383
+ const node = xh.transformComponentDefinition(component);
384
+ return xh.serialize(node, { prettify: true });
385
+ }
386
+ catch (e) {
387
+ console.log(e);
388
+ return "";
389
+ }
390
+ }
391
+ return "";
392
+ }
393
+ function decompressData(source) {
394
+ return __awaiter(this, void 0, void 0, function* () {
395
+ const base64 = decodeURIComponent(source);
396
+ const compressed = Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
397
+ return yield decompress(compressed);
398
+ });
399
+ }
400
+ exports.builtInThemes = [
401
+ Object.assign(Object.assign({}, solid_1.SolidThemeDefinition), { name: "Solid" }),
402
+ Object.assign(Object.assign({}, xmlui_1.XmlUiThemeDefinition), { name: "Xmlui" }),
403
+ ];
404
+ exports.INITIAL_PLAYGROUND_STATE = {
405
+ editorStatus: "idle",
406
+ status: "idle",
407
+ options: {
408
+ orientation: "horizontal",
409
+ swapped: false,
410
+ content: "app",
411
+ previewMode: false,
412
+ id: 0,
413
+ language: "xmlui",
414
+ },
415
+ text: "",
416
+ appDescription: {
417
+ config: {
418
+ name: "",
419
+ appGlobals: {},
420
+ resources: {},
421
+ themes: [],
422
+ },
423
+ components: [],
424
+ app: "",
425
+ },
426
+ originalAppDescription: {
427
+ config: {
428
+ name: "",
429
+ appGlobals: {},
430
+ resources: {},
431
+ themes: [],
432
+ },
433
+ components: [],
434
+ app: "",
435
+ },
436
+ };
437
+ function removeWhitespace(obj) {
438
+ if (typeof obj === 'string') {
439
+ return obj.replace(/\s+/g, ' ').trim(); // Remove extra whitespaces and newlines
440
+ }
441
+ else if (typeof obj === 'object' && obj !== null) {
442
+ const newObj = Array.isArray(obj) ? [] : {};
443
+ for (const key in obj) {
444
+ newObj[key] = removeWhitespace(obj[key]);
445
+ }
446
+ return newObj;
447
+ }
448
+ return obj; // Return the value as is if not a string or object
449
+ }
450
+ const handleDownloadZip = (appDescription) => __awaiter(void 0, void 0, void 0, function* () {
451
+ const operatingSystem = getOperatingSystem();
452
+ const zip = new jszip_1.default();
453
+ const xmluiFolder = zip.folder("xmlui");
454
+ const xmluiStandalone = yield fetchWithoutCache("/resources/files/for-download/xmlui/xmlui-standalone.umd.js").then((res) => res.blob());
455
+ xmluiFolder.file("xmlui-standalone.umd.js", xmluiStandalone);
456
+ zip.file("Main.xmlui", appDescription.app);
457
+ zip.file("config.json", JSON.stringify(appDescription.config, null, 2));
458
+ if (appDescription.components.length > 0) {
459
+ const components = zip.folder("components");
460
+ appDescription.components.forEach((component) => {
461
+ components.file(`${component.name}.xmlui`, component.component);
462
+ });
463
+ }
464
+ if (appDescription.config.themes.length > 0) {
465
+ const themes = zip.folder("themes");
466
+ appDescription.config.themes.forEach((theme) => {
467
+ themes.file(`${theme.id}.json`, JSON.stringify(theme, null, 2));
468
+ });
469
+ }
470
+ const emulatedApi = appDescription.api;
471
+ if (emulatedApi) {
472
+ const indexWithApiHtml = yield fetchWithoutCache("/resources/files/for-download/index-with-api.html").then((res) => res.blob());
473
+ zip.file("index.html", indexWithApiHtml);
474
+ xmluiFolder.file("mockApiDef.js", `window.XMLUI_MOCK_API = ${JSON.stringify(removeWhitespace(emulatedApi), null, 2)};`);
475
+ const emulatedApiWorker = yield fetchWithoutCache("/resources/files/for-download/mockApi.js").then((res) => res.blob());
476
+ zip.file("mockApi.js", emulatedApiWorker);
477
+ }
478
+ else {
479
+ const indexHtml = yield fetchWithoutCache("/resources/files/for-download/index.html").then((res) => res.blob());
480
+ zip.file("index.html", indexHtml);
481
+ }
482
+ const startBat = yield fetchWithoutCache("/resources/files/for-download/start.bat").then((res) => res.blob());
483
+ if (operatingSystem === "Windows") {
484
+ zip.file("start.bat", startBat);
485
+ }
486
+ else {
487
+ let fileName = operatingSystem === "Linux" ? "start-linux.sh" : "start-darwin.sh";
488
+ const startSh = yield fetchWithoutCache(`/resources/files/for-download/${fileName}`).then((res) => res.blob());
489
+ zip.file("start.sh", startSh, {
490
+ unixPermissions: "777"
491
+ });
492
+ }
493
+ try {
494
+ const content = yield zip.generateAsync({ type: "blob", platform: operatingSystem === "Windows" ? "DOS" : "UNIX" });
495
+ (0, file_saver_1.saveAs)(content, `${appDescription.config.name.trim()}.zip`);
496
+ }
497
+ catch (error) {
498
+ console.error("An error occurred while generating the ZIP:", error);
499
+ }
500
+ });
501
+ exports.handleDownloadZip = handleDownloadZip;
502
+ function preprocessCode(code) {
503
+ // Split code by newlines
504
+ const lines = code.split("\n");
505
+ // Remove whitespace-only lines from the beginning and end
506
+ let start = 0;
507
+ while (start < lines.length && lines[start].trim() === "") {
508
+ start++;
509
+ }
510
+ let end = lines.length - 1;
511
+ while (end >= 0 && lines[end].trim() === "") {
512
+ end--;
513
+ }
514
+ const trimmedLines = lines.slice(start, end + 1);
515
+ // Calculate the minimum indentation
516
+ const minIndent = Math.min(...trimmedLines
517
+ .filter(line => line.trim() !== "") // Ignore empty lines for indentation
518
+ .map(line => line.match(/^\s*/)[0].length) // Count leading spaces
519
+ );
520
+ // Remove minIndent spaces from the beginning of each line
521
+ const result = trimmedLines.map(line => line.startsWith(" ".repeat(minIndent)) ? line.slice(minIndent) : line);
522
+ // Join lines back into a single string
523
+ return result.join("\n");
524
+ }
525
+ function getOperatingSystem() {
526
+ const userAgent = window.navigator.userAgent;
527
+ const platform = window.navigator.platform;
528
+ if (/Win/.test(platform)) {
529
+ return "Windows";
530
+ }
531
+ if (/Mac/.test(platform)) {
532
+ return "MacOS";
533
+ }
534
+ if (/Linux/.test(platform)) {
535
+ return "Linux";
536
+ }
537
+ if (/Android/.test(userAgent)) {
538
+ return "Android";
539
+ }
540
+ if (/iPhone|iPad|iPod/.test(userAgent)) {
541
+ return "iOS";
542
+ }
543
+ return "Unknown OS";
544
+ }
@@ -22,8 +22,8 @@ exports.pageRenderer = (0, renderers_1.createComponentRenderer)(PAGE, exports.Pa
22
22
  });
23
23
  const COMP = "Pages";
24
24
  exports.PagesMd = (0, ComponentDefs_1.createMetadata)({
25
- description: `The \`${COMP}\` component is used as a container for [\`Page\`](./Page.mdx) components ` +
26
- `within an [\`App\`](./App.mdx).`,
25
+ description: `The \`${COMP}\` component is used as a container for [\`Page\`](/components/Page) components ` +
26
+ `within an [\`App\`](/components/App).`,
27
27
  props: {
28
28
  defaultRoute: (0, ComponentDefs_1.d)(`The default route when displaying the app`),
29
29
  },
@@ -75,7 +75,7 @@ const SimpleSelect = (0, react_1.forwardRef)(function SimpleSelect(props, forwar
75
75
  [Select_module_scss_1.default.error]: validationStatus === "error",
76
76
  [Select_module_scss_1.default.warning]: validationStatus === "warning",
77
77
  [Select_module_scss_1.default.valid]: validationStatus === "valid",
78
- }), ref: ref, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectValue, children: readOnly ? (((_a = Array.from(options).find((o) => `${o.value}` === stringValue)) === null || _a === void 0 ? void 0 : _a.label) || (0, jsx_runtime_1.jsx)("span", { children: placeholder })) : ((0, jsx_runtime_1.jsx)(react_select_1.Value, { placeholder: placeholder })) }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent, position: "popper", style: { height: height }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsx)(react_select_1.SelectViewport, { className: Select_module_scss_1.default.selectViewport, role: "listbox", children: children }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }));
78
+ }), ref: ref, autoFocus: autoFocus, children: [(0, jsx_runtime_1.jsx)("div", { className: Select_module_scss_1.default.selectValue, children: readOnly ? (((_a = Array.from(options).find((o) => `${o.value}` === stringValue)) === null || _a === void 0 ? void 0 : _a.label) || ((0, jsx_runtime_1.jsx)("span", { "aria-placeholder": placeholder, children: placeholder }))) : ((0, jsx_runtime_1.jsx)(react_select_1.Value, { "aria-placeholder": placeholder, placeholder: placeholder })) }), (0, jsx_runtime_1.jsx)(react_select_1.Icon, { asChild: true, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }), (0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsxs)(react_select_1.Content, { className: Select_module_scss_1.default.selectContent, position: "popper", style: { height: height }, children: [(0, jsx_runtime_1.jsx)(react_select_1.ScrollUpButton, { className: Select_module_scss_1.default.selectScrollUpButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevronup" }) }), (0, jsx_runtime_1.jsx)(react_select_1.SelectViewport, { className: Select_module_scss_1.default.selectViewport, role: "listbox", children: children }), (0, jsx_runtime_1.jsx)(react_select_1.ScrollDownButton, { className: Select_module_scss_1.default.selectScrollDownButton, children: (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" }) })] }) })] }));
79
79
  });
80
80
  exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, value, enabled = true, placeholder, updateState = constants_1.noop, validationStatus = "none", onDidChange = constants_1.noop, onFocus = constants_1.noop, onBlur = constants_1.noop, registerComponentApi, emptyListTemplate, optionLabelRenderer, optionRenderer, valueRenderer, style, dropdownHeight, children, autoFocus = false, searchable = false, multiSelect = false, label, labelPosition, labelWidth, labelBreak = false, required = false, inProgress = false, inProgressNotificationMessage = "Loading...", readOnly = false, }, ref) {
81
81
  var _a;
@@ -188,7 +188,7 @@ exports.Select = (0, react_1.forwardRef)(function Select({ id, initialValue, val
188
188
  event.stopPropagation();
189
189
  toggleOption(v);
190
190
  } })] }, v));
191
- }) }) })) : ((0, jsx_runtime_1.jsx)("span", { className: Select_module_scss_1.default.placeholder, children: placeholder }))) : value !== undefined && value !== null ? ((0, jsx_runtime_1.jsx)("div", { children: (_a = Array.from(options).find((o) => o.value === value)) === null || _a === void 0 ? void 0 : _a.label })) : ((0, jsx_runtime_1.jsx)("span", { className: Select_module_scss_1.default.placeholder, children: placeholder || "" })), (0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.actions, children: [multiSelect && Array.isArray(value) && value.length > 0 && ((0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close", onClick: (event) => {
191
+ }) }) })) : ((0, jsx_runtime_1.jsx)("span", { "aria-placeholder": placeholder, className: Select_module_scss_1.default.placeholder, children: placeholder }))) : value !== undefined && value !== null ? ((0, jsx_runtime_1.jsx)("div", { children: (_a = Array.from(options).find((o) => o.value === value)) === null || _a === void 0 ? void 0 : _a.label })) : ((0, jsx_runtime_1.jsx)("span", { "aria-placeholder": placeholder, className: Select_module_scss_1.default.placeholder, children: placeholder || "" })), (0, jsx_runtime_1.jsxs)("div", { className: Select_module_scss_1.default.actions, children: [multiSelect && Array.isArray(value) && value.length > 0 && ((0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "close", onClick: (event) => {
192
192
  event.stopPropagation();
193
193
  clearValue();
194
194
  } })), (0, jsx_runtime_1.jsx)(IconNative_1.default, { name: "chevrondown" })] })] }), open && ((0, jsx_runtime_1.jsx)(react_select_1.Portal, { container: root, children: (0, jsx_runtime_1.jsx)(react_focus_scope_1.FocusScope, { asChild: true, loop: true, trapped: true, children: (0, jsx_runtime_1.jsx)(react_popover_1.PopoverContent, { style: { width, height: dropdownHeight }, className: Select_module_scss_1.default.selectContent, children: (0, jsx_runtime_1.jsxs)(cmdk_1.Command, { className: Select_module_scss_1.default.command, shouldFilter: searchable, filter: (value, search, keywords) => {