@storybook/react-native-ui 8.0.0-alpha.3

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +492 -0
  3. package/dist/index.js +2860 -0
  4. package/package.json +85 -0
  5. package/src/Button.stories.tsx +134 -0
  6. package/src/Button.tsx +243 -0
  7. package/src/Explorer.stories.tsx +46 -0
  8. package/src/Explorer.tsx +54 -0
  9. package/src/IconButton.tsx +11 -0
  10. package/src/Layout.stories.tsx +38 -0
  11. package/src/Layout.tsx +103 -0
  12. package/src/LayoutProvider.tsx +90 -0
  13. package/src/MobileAddonsPanel.tsx +166 -0
  14. package/src/MobileMenuDrawer.tsx +75 -0
  15. package/src/Refs.tsx +142 -0
  16. package/src/Search.tsx +336 -0
  17. package/src/SearchResults.tsx +315 -0
  18. package/src/Sidebar.stories.tsx +262 -0
  19. package/src/Sidebar.tsx +200 -0
  20. package/src/Tree.stories.tsx +139 -0
  21. package/src/Tree.tsx +441 -0
  22. package/src/TreeNode.stories.tsx +122 -0
  23. package/src/TreeNode.tsx +146 -0
  24. package/src/constants.ts +4 -0
  25. package/src/icon/BottomBarToggleIcon.tsx +23 -0
  26. package/src/icon/CloseIcon.tsx +22 -0
  27. package/src/icon/CollapseAllIcon.tsx +17 -0
  28. package/src/icon/CollapseIcon.tsx +39 -0
  29. package/src/icon/ComponentIcon.tsx +14 -0
  30. package/src/icon/ExpandAllIcon.tsx +17 -0
  31. package/src/icon/FaceHappyIcon.tsx +18 -0
  32. package/src/icon/GroupIcon.tsx +14 -0
  33. package/src/icon/MenuIcon.tsx +18 -0
  34. package/src/icon/SearchIcon.tsx +17 -0
  35. package/src/icon/StoryIcon.tsx +14 -0
  36. package/src/index.tsx +9 -0
  37. package/src/mockdata.large.ts +25217 -0
  38. package/src/mockdata.ts +287 -0
  39. package/src/types.ts +78 -0
  40. package/src/useExpanded.ts +130 -0
  41. package/src/useLastViewed.ts +48 -0
  42. package/src/util/status.tsx +70 -0
  43. package/src/util/tree.ts +91 -0
package/dist/index.js ADDED
@@ -0,0 +1,2860 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // ../../node_modules/lodash/isObject.js
33
+ var require_isObject = __commonJS({
34
+ "../../node_modules/lodash/isObject.js"(exports, module2) {
35
+ function isObject(value) {
36
+ var type = typeof value;
37
+ return value != null && (type == "object" || type == "function");
38
+ }
39
+ module2.exports = isObject;
40
+ }
41
+ });
42
+
43
+ // ../../node_modules/lodash/_freeGlobal.js
44
+ var require_freeGlobal = __commonJS({
45
+ "../../node_modules/lodash/_freeGlobal.js"(exports, module2) {
46
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
47
+ module2.exports = freeGlobal;
48
+ }
49
+ });
50
+
51
+ // ../../node_modules/lodash/_root.js
52
+ var require_root = __commonJS({
53
+ "../../node_modules/lodash/_root.js"(exports, module2) {
54
+ var freeGlobal = require_freeGlobal();
55
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
56
+ var root = freeGlobal || freeSelf || Function("return this")();
57
+ module2.exports = root;
58
+ }
59
+ });
60
+
61
+ // ../../node_modules/lodash/now.js
62
+ var require_now = __commonJS({
63
+ "../../node_modules/lodash/now.js"(exports, module2) {
64
+ var root = require_root();
65
+ var now = function() {
66
+ return root.Date.now();
67
+ };
68
+ module2.exports = now;
69
+ }
70
+ });
71
+
72
+ // ../../node_modules/lodash/_trimmedEndIndex.js
73
+ var require_trimmedEndIndex = __commonJS({
74
+ "../../node_modules/lodash/_trimmedEndIndex.js"(exports, module2) {
75
+ var reWhitespace = /\s/;
76
+ function trimmedEndIndex(string) {
77
+ var index = string.length;
78
+ while (index-- && reWhitespace.test(string.charAt(index))) {
79
+ }
80
+ return index;
81
+ }
82
+ module2.exports = trimmedEndIndex;
83
+ }
84
+ });
85
+
86
+ // ../../node_modules/lodash/_baseTrim.js
87
+ var require_baseTrim = __commonJS({
88
+ "../../node_modules/lodash/_baseTrim.js"(exports, module2) {
89
+ var trimmedEndIndex = require_trimmedEndIndex();
90
+ var reTrimStart = /^\s+/;
91
+ function baseTrim(string) {
92
+ return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
93
+ }
94
+ module2.exports = baseTrim;
95
+ }
96
+ });
97
+
98
+ // ../../node_modules/lodash/_Symbol.js
99
+ var require_Symbol = __commonJS({
100
+ "../../node_modules/lodash/_Symbol.js"(exports, module2) {
101
+ var root = require_root();
102
+ var Symbol2 = root.Symbol;
103
+ module2.exports = Symbol2;
104
+ }
105
+ });
106
+
107
+ // ../../node_modules/lodash/_getRawTag.js
108
+ var require_getRawTag = __commonJS({
109
+ "../../node_modules/lodash/_getRawTag.js"(exports, module2) {
110
+ var Symbol2 = require_Symbol();
111
+ var objectProto = Object.prototype;
112
+ var hasOwnProperty = objectProto.hasOwnProperty;
113
+ var nativeObjectToString = objectProto.toString;
114
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
115
+ function getRawTag(value) {
116
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
117
+ try {
118
+ value[symToStringTag] = void 0;
119
+ var unmasked = true;
120
+ } catch (e) {
121
+ }
122
+ var result = nativeObjectToString.call(value);
123
+ if (unmasked) {
124
+ if (isOwn) {
125
+ value[symToStringTag] = tag;
126
+ } else {
127
+ delete value[symToStringTag];
128
+ }
129
+ }
130
+ return result;
131
+ }
132
+ module2.exports = getRawTag;
133
+ }
134
+ });
135
+
136
+ // ../../node_modules/lodash/_objectToString.js
137
+ var require_objectToString = __commonJS({
138
+ "../../node_modules/lodash/_objectToString.js"(exports, module2) {
139
+ var objectProto = Object.prototype;
140
+ var nativeObjectToString = objectProto.toString;
141
+ function objectToString(value) {
142
+ return nativeObjectToString.call(value);
143
+ }
144
+ module2.exports = objectToString;
145
+ }
146
+ });
147
+
148
+ // ../../node_modules/lodash/_baseGetTag.js
149
+ var require_baseGetTag = __commonJS({
150
+ "../../node_modules/lodash/_baseGetTag.js"(exports, module2) {
151
+ var Symbol2 = require_Symbol();
152
+ var getRawTag = require_getRawTag();
153
+ var objectToString = require_objectToString();
154
+ var nullTag = "[object Null]";
155
+ var undefinedTag = "[object Undefined]";
156
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
157
+ function baseGetTag(value) {
158
+ if (value == null) {
159
+ return value === void 0 ? undefinedTag : nullTag;
160
+ }
161
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
162
+ }
163
+ module2.exports = baseGetTag;
164
+ }
165
+ });
166
+
167
+ // ../../node_modules/lodash/isObjectLike.js
168
+ var require_isObjectLike = __commonJS({
169
+ "../../node_modules/lodash/isObjectLike.js"(exports, module2) {
170
+ function isObjectLike(value) {
171
+ return value != null && typeof value == "object";
172
+ }
173
+ module2.exports = isObjectLike;
174
+ }
175
+ });
176
+
177
+ // ../../node_modules/lodash/isSymbol.js
178
+ var require_isSymbol = __commonJS({
179
+ "../../node_modules/lodash/isSymbol.js"(exports, module2) {
180
+ var baseGetTag = require_baseGetTag();
181
+ var isObjectLike = require_isObjectLike();
182
+ var symbolTag = "[object Symbol]";
183
+ function isSymbol(value) {
184
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
185
+ }
186
+ module2.exports = isSymbol;
187
+ }
188
+ });
189
+
190
+ // ../../node_modules/lodash/toNumber.js
191
+ var require_toNumber = __commonJS({
192
+ "../../node_modules/lodash/toNumber.js"(exports, module2) {
193
+ var baseTrim = require_baseTrim();
194
+ var isObject = require_isObject();
195
+ var isSymbol = require_isSymbol();
196
+ var NAN = 0 / 0;
197
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
198
+ var reIsBinary = /^0b[01]+$/i;
199
+ var reIsOctal = /^0o[0-7]+$/i;
200
+ var freeParseInt = parseInt;
201
+ function toNumber(value) {
202
+ if (typeof value == "number") {
203
+ return value;
204
+ }
205
+ if (isSymbol(value)) {
206
+ return NAN;
207
+ }
208
+ if (isObject(value)) {
209
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
210
+ value = isObject(other) ? other + "" : other;
211
+ }
212
+ if (typeof value != "string") {
213
+ return value === 0 ? value : +value;
214
+ }
215
+ value = baseTrim(value);
216
+ var isBinary = reIsBinary.test(value);
217
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
218
+ }
219
+ module2.exports = toNumber;
220
+ }
221
+ });
222
+
223
+ // ../../node_modules/lodash/debounce.js
224
+ var require_debounce = __commonJS({
225
+ "../../node_modules/lodash/debounce.js"(exports, module2) {
226
+ var isObject = require_isObject();
227
+ var now = require_now();
228
+ var toNumber = require_toNumber();
229
+ var FUNC_ERROR_TEXT = "Expected a function";
230
+ var nativeMax = Math.max;
231
+ var nativeMin = Math.min;
232
+ function debounce2(func, wait, options2) {
233
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
234
+ if (typeof func != "function") {
235
+ throw new TypeError(FUNC_ERROR_TEXT);
236
+ }
237
+ wait = toNumber(wait) || 0;
238
+ if (isObject(options2)) {
239
+ leading = !!options2.leading;
240
+ maxing = "maxWait" in options2;
241
+ maxWait = maxing ? nativeMax(toNumber(options2.maxWait) || 0, wait) : maxWait;
242
+ trailing = "trailing" in options2 ? !!options2.trailing : trailing;
243
+ }
244
+ function invokeFunc(time) {
245
+ var args = lastArgs, thisArg = lastThis;
246
+ lastArgs = lastThis = void 0;
247
+ lastInvokeTime = time;
248
+ result = func.apply(thisArg, args);
249
+ return result;
250
+ }
251
+ function leadingEdge(time) {
252
+ lastInvokeTime = time;
253
+ timerId = setTimeout(timerExpired, wait);
254
+ return leading ? invokeFunc(time) : result;
255
+ }
256
+ function remainingWait(time) {
257
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
258
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
259
+ }
260
+ function shouldInvoke(time) {
261
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
262
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
263
+ }
264
+ function timerExpired() {
265
+ var time = now();
266
+ if (shouldInvoke(time)) {
267
+ return trailingEdge(time);
268
+ }
269
+ timerId = setTimeout(timerExpired, remainingWait(time));
270
+ }
271
+ function trailingEdge(time) {
272
+ timerId = void 0;
273
+ if (trailing && lastArgs) {
274
+ return invokeFunc(time);
275
+ }
276
+ lastArgs = lastThis = void 0;
277
+ return result;
278
+ }
279
+ function cancel() {
280
+ if (timerId !== void 0) {
281
+ clearTimeout(timerId);
282
+ }
283
+ lastInvokeTime = 0;
284
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
285
+ }
286
+ function flush() {
287
+ return timerId === void 0 ? result : trailingEdge(now());
288
+ }
289
+ function debounced() {
290
+ var time = now(), isInvoking = shouldInvoke(time);
291
+ lastArgs = arguments;
292
+ lastThis = this;
293
+ lastCallTime = time;
294
+ if (isInvoking) {
295
+ if (timerId === void 0) {
296
+ return leadingEdge(lastCallTime);
297
+ }
298
+ if (maxing) {
299
+ clearTimeout(timerId);
300
+ timerId = setTimeout(timerExpired, wait);
301
+ return invokeFunc(lastCallTime);
302
+ }
303
+ }
304
+ if (timerId === void 0) {
305
+ timerId = setTimeout(timerExpired, wait);
306
+ }
307
+ return result;
308
+ }
309
+ debounced.cancel = cancel;
310
+ debounced.flush = flush;
311
+ return debounced;
312
+ }
313
+ module2.exports = debounce2;
314
+ }
315
+ });
316
+
317
+ // ../../node_modules/store2/dist/store2.js
318
+ var require_store2 = __commonJS({
319
+ "../../node_modules/store2/dist/store2.js"(exports, module2) {
320
+ (function(window, define) {
321
+ var _ = {
322
+ version: "2.14.3",
323
+ areas: {},
324
+ apis: {},
325
+ nsdelim: ".",
326
+ // utilities
327
+ inherit: function(api, o) {
328
+ for (var p in api) {
329
+ if (!o.hasOwnProperty(p)) {
330
+ Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
331
+ }
332
+ }
333
+ return o;
334
+ },
335
+ stringify: function(d, fn) {
336
+ return d === void 0 || typeof d === "function" ? d + "" : JSON.stringify(d, fn || _.replace);
337
+ },
338
+ parse: function(s, fn) {
339
+ try {
340
+ return JSON.parse(s, fn || _.revive);
341
+ } catch (e) {
342
+ return s;
343
+ }
344
+ },
345
+ // extension hooks
346
+ fn: function(name, fn) {
347
+ _.storeAPI[name] = fn;
348
+ for (var api in _.apis) {
349
+ _.apis[api][name] = fn;
350
+ }
351
+ },
352
+ get: function(area, key) {
353
+ return area.getItem(key);
354
+ },
355
+ set: function(area, key, string) {
356
+ area.setItem(key, string);
357
+ },
358
+ remove: function(area, key) {
359
+ area.removeItem(key);
360
+ },
361
+ key: function(area, i) {
362
+ return area.key(i);
363
+ },
364
+ length: function(area) {
365
+ return area.length;
366
+ },
367
+ clear: function(area) {
368
+ area.clear();
369
+ },
370
+ // core functions
371
+ Store: function(id, area, namespace) {
372
+ var store3 = _.inherit(_.storeAPI, function(key, data, overwrite) {
373
+ if (arguments.length === 0) {
374
+ return store3.getAll();
375
+ }
376
+ if (typeof data === "function") {
377
+ return store3.transact(key, data, overwrite);
378
+ }
379
+ if (data !== void 0) {
380
+ return store3.set(key, data, overwrite);
381
+ }
382
+ if (typeof key === "string" || typeof key === "number") {
383
+ return store3.get(key);
384
+ }
385
+ if (typeof key === "function") {
386
+ return store3.each(key);
387
+ }
388
+ if (!key) {
389
+ return store3.clear();
390
+ }
391
+ return store3.setAll(key, data);
392
+ });
393
+ store3._id = id;
394
+ try {
395
+ var testKey = "__store2_test";
396
+ area.setItem(testKey, "ok");
397
+ store3._area = area;
398
+ area.removeItem(testKey);
399
+ } catch (e) {
400
+ store3._area = _.storage("fake");
401
+ }
402
+ store3._ns = namespace || "";
403
+ if (!_.areas[id]) {
404
+ _.areas[id] = store3._area;
405
+ }
406
+ if (!_.apis[store3._ns + store3._id]) {
407
+ _.apis[store3._ns + store3._id] = store3;
408
+ }
409
+ return store3;
410
+ },
411
+ storeAPI: {
412
+ // admin functions
413
+ area: function(id, area) {
414
+ var store3 = this[id];
415
+ if (!store3 || !store3.area) {
416
+ store3 = _.Store(id, area, this._ns);
417
+ if (!this[id]) {
418
+ this[id] = store3;
419
+ }
420
+ }
421
+ return store3;
422
+ },
423
+ namespace: function(namespace, singleArea, delim) {
424
+ delim = delim || this._delim || _.nsdelim;
425
+ if (!namespace) {
426
+ return this._ns ? this._ns.substring(0, this._ns.length - delim.length) : "";
427
+ }
428
+ var ns = namespace, store3 = this[ns];
429
+ if (!store3 || !store3.namespace) {
430
+ store3 = _.Store(this._id, this._area, this._ns + ns + delim);
431
+ store3._delim = delim;
432
+ if (!this[ns]) {
433
+ this[ns] = store3;
434
+ }
435
+ if (!singleArea) {
436
+ for (var name in _.areas) {
437
+ store3.area(name, _.areas[name]);
438
+ }
439
+ }
440
+ }
441
+ return store3;
442
+ },
443
+ isFake: function(force) {
444
+ if (force) {
445
+ this._real = this._area;
446
+ this._area = _.storage("fake");
447
+ } else if (force === false) {
448
+ this._area = this._real || this._area;
449
+ }
450
+ return this._area.name === "fake";
451
+ },
452
+ toString: function() {
453
+ return "store" + (this._ns ? "." + this.namespace() : "") + "[" + this._id + "]";
454
+ },
455
+ // storage functions
456
+ has: function(key) {
457
+ if (this._area.has) {
458
+ return this._area.has(this._in(key));
459
+ }
460
+ return !!(this._in(key) in this._area);
461
+ },
462
+ size: function() {
463
+ return this.keys().length;
464
+ },
465
+ each: function(fn, fill) {
466
+ for (var i = 0, m = _.length(this._area); i < m; i++) {
467
+ var key = this._out(_.key(this._area, i));
468
+ if (key !== void 0) {
469
+ if (fn.call(this, key, this.get(key), fill) === false) {
470
+ break;
471
+ }
472
+ }
473
+ if (m > _.length(this._area)) {
474
+ m--;
475
+ i--;
476
+ }
477
+ }
478
+ return fill || this;
479
+ },
480
+ keys: function(fillList) {
481
+ return this.each(function(k, v, list) {
482
+ list.push(k);
483
+ }, fillList || []);
484
+ },
485
+ get: function(key, alt) {
486
+ var s = _.get(this._area, this._in(key)), fn;
487
+ if (typeof alt === "function") {
488
+ fn = alt;
489
+ alt = null;
490
+ }
491
+ return s !== null ? _.parse(s, fn) : alt != null ? alt : s;
492
+ },
493
+ getAll: function(fillObj) {
494
+ return this.each(function(k, v, all) {
495
+ all[k] = v;
496
+ }, fillObj || {});
497
+ },
498
+ transact: function(key, fn, alt) {
499
+ var val = this.get(key, alt), ret = fn(val);
500
+ this.set(key, ret === void 0 ? val : ret);
501
+ return this;
502
+ },
503
+ set: function(key, data, overwrite) {
504
+ var d = this.get(key), replacer;
505
+ if (d != null && overwrite === false) {
506
+ return data;
507
+ }
508
+ if (typeof overwrite === "function") {
509
+ replacer = overwrite;
510
+ overwrite = void 0;
511
+ }
512
+ return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
513
+ },
514
+ setAll: function(data, overwrite) {
515
+ var changed, val;
516
+ for (var key in data) {
517
+ val = data[key];
518
+ if (this.set(key, val, overwrite) !== val) {
519
+ changed = true;
520
+ }
521
+ }
522
+ return changed;
523
+ },
524
+ add: function(key, data, replacer) {
525
+ var d = this.get(key);
526
+ if (d instanceof Array) {
527
+ data = d.concat(data);
528
+ } else if (d !== null) {
529
+ var type = typeof d;
530
+ if (type === typeof data && type === "object") {
531
+ for (var k in data) {
532
+ d[k] = data[k];
533
+ }
534
+ data = d;
535
+ } else {
536
+ data = d + data;
537
+ }
538
+ }
539
+ _.set(this._area, this._in(key), _.stringify(data, replacer));
540
+ return data;
541
+ },
542
+ remove: function(key, alt) {
543
+ var d = this.get(key, alt);
544
+ _.remove(this._area, this._in(key));
545
+ return d;
546
+ },
547
+ clear: function() {
548
+ if (!this._ns) {
549
+ _.clear(this._area);
550
+ } else {
551
+ this.each(function(k) {
552
+ _.remove(this._area, this._in(k));
553
+ }, 1);
554
+ }
555
+ return this;
556
+ },
557
+ clearAll: function() {
558
+ var area = this._area;
559
+ for (var id in _.areas) {
560
+ if (_.areas.hasOwnProperty(id)) {
561
+ this._area = _.areas[id];
562
+ this.clear();
563
+ }
564
+ }
565
+ this._area = area;
566
+ return this;
567
+ },
568
+ // internal use functions
569
+ _in: function(k) {
570
+ if (typeof k !== "string") {
571
+ k = _.stringify(k);
572
+ }
573
+ return this._ns ? this._ns + k : k;
574
+ },
575
+ _out: function(k) {
576
+ return this._ns ? k && k.indexOf(this._ns) === 0 ? k.substring(this._ns.length) : void 0 : (
577
+ // so each() knows to skip it
578
+ k
579
+ );
580
+ }
581
+ },
582
+ // end _.storeAPI
583
+ storage: function(name) {
584
+ return _.inherit(_.storageAPI, { items: {}, name });
585
+ },
586
+ storageAPI: {
587
+ length: 0,
588
+ has: function(k) {
589
+ return this.items.hasOwnProperty(k);
590
+ },
591
+ key: function(i) {
592
+ var c = 0;
593
+ for (var k in this.items) {
594
+ if (this.has(k) && i === c++) {
595
+ return k;
596
+ }
597
+ }
598
+ },
599
+ setItem: function(k, v) {
600
+ if (!this.has(k)) {
601
+ this.length++;
602
+ }
603
+ this.items[k] = v;
604
+ },
605
+ removeItem: function(k) {
606
+ if (this.has(k)) {
607
+ delete this.items[k];
608
+ this.length--;
609
+ }
610
+ },
611
+ getItem: function(k) {
612
+ return this.has(k) ? this.items[k] : null;
613
+ },
614
+ clear: function() {
615
+ for (var k in this.items) {
616
+ this.removeItem(k);
617
+ }
618
+ }
619
+ }
620
+ // end _.storageAPI
621
+ };
622
+ var store2 = (
623
+ // safely set this up (throws error in IE10/32bit mode for local files)
624
+ _.Store("local", function() {
625
+ try {
626
+ return localStorage;
627
+ } catch (e) {
628
+ }
629
+ }())
630
+ );
631
+ store2.local = store2;
632
+ store2._ = _;
633
+ store2.area("session", function() {
634
+ try {
635
+ return sessionStorage;
636
+ } catch (e) {
637
+ }
638
+ }());
639
+ store2.area("page", _.storage("page"));
640
+ if (typeof define === "function" && define.amd !== void 0) {
641
+ define("store2", [], function() {
642
+ return store2;
643
+ });
644
+ } else if (typeof module2 !== "undefined" && module2.exports) {
645
+ module2.exports = store2;
646
+ } else {
647
+ if (window.store) {
648
+ _.conflict = window.store;
649
+ }
650
+ window.store = store2;
651
+ }
652
+ })(exports, exports && exports.define);
653
+ }
654
+ });
655
+
656
+ // ../../node_modules/@storybook/types/dist/index.js
657
+ var require_dist = __commonJS({
658
+ "../../node_modules/@storybook/types/dist/index.js"(exports, module2) {
659
+ "use strict";
660
+ var __defProp2 = Object.defineProperty;
661
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
662
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
663
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
664
+ var __export2 = (target, all) => {
665
+ for (var name in all)
666
+ __defProp2(target, name, { get: all[name], enumerable: true });
667
+ };
668
+ var __copyProps2 = (to, from, except, desc) => {
669
+ if (from && typeof from == "object" || typeof from == "function")
670
+ for (let key of __getOwnPropNames2(from))
671
+ !__hasOwnProp2.call(to, key) && key !== except && __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
672
+ return to;
673
+ };
674
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
675
+ var src_exports2 = {};
676
+ __export2(src_exports2, { Addon_TypesEnum: () => Addon_TypesEnum2 });
677
+ module2.exports = __toCommonJS2(src_exports2);
678
+ var Addon_TypesEnum2 = ((Addon_TypesEnum22) => (Addon_TypesEnum22.TAB = "tab", Addon_TypesEnum22.PANEL = "panel", Addon_TypesEnum22.TOOL = "tool", Addon_TypesEnum22.TOOLEXTRA = "toolextra", Addon_TypesEnum22.PREVIEW = "preview", Addon_TypesEnum22.experimental_PAGE = "page", Addon_TypesEnum22.experimental_SIDEBAR_BOTTOM = "sidebar-bottom", Addon_TypesEnum22.experimental_SIDEBAR_TOP = "sidebar-top", Addon_TypesEnum22))(Addon_TypesEnum2 || {});
679
+ }
680
+ });
681
+
682
+ // src/index.tsx
683
+ var src_exports = {};
684
+ __export(src_exports, {
685
+ Button: () => Button,
686
+ ButtonIcon: () => ButtonIcon,
687
+ ButtonText: () => ButtonText,
688
+ ComponentNode: () => ComponentNode,
689
+ Explorer: () => Explorer,
690
+ GroupNode: () => GroupNode,
691
+ IconButton: () => IconButton,
692
+ Layout: () => Layout,
693
+ LayoutProvider: () => LayoutProvider,
694
+ LeafNodeStyleWrapper: () => LeafNodeStyleWrapper,
695
+ Node: () => Node,
696
+ RootNode: () => RootNode,
697
+ RootNodeText: () => RootNodeText,
698
+ Sidebar: () => Sidebar,
699
+ StoryNode: () => StoryNode,
700
+ Tree: () => Tree,
701
+ isExpandType: () => isExpandType,
702
+ useCombination: () => useCombination,
703
+ useLayout: () => useLayout
704
+ });
705
+ module.exports = __toCommonJS(src_exports);
706
+
707
+ // src/TreeNode.tsx
708
+ var import_react_native_theming2 = require("@storybook/react-native-theming");
709
+
710
+ // src/icon/ComponentIcon.tsx
711
+ var import_react_native_svg = __toESM(require("react-native-svg"));
712
+ var import_jsx_runtime = require("react/jsx-runtime");
713
+ function ComponentIcon({ color = "#029CFD", ...props }) {
714
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_svg.default, { width: 12, height: 12, viewBox: "0 0 12 12", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
715
+ import_react_native_svg.Path,
716
+ {
717
+ fillRule: "evenodd",
718
+ clipRule: "evenodd",
719
+ d: "M2.5.004a2.5 2.5 0 00-2.5 2.5v7a2.5 2.5 0 002.5 2.5h7a2.5 2.5 0 002.5-2.5v-7a2.5 2.5 0 00-2.5-2.5h-7zm8.5 5.5H6.5v-4.5h3a1.5 1.5 0 011.5 1.5v3zm0 1v3a1.5 1.5 0 01-1.5 1.5h-3v-4.5H11zm-5.5 4.5v-4.5H1v3a1.5 1.5 0 001.5 1.5h3zM1 5.504h4.5v-4.5h-3a1.5 1.5 0 00-1.5 1.5v3z",
720
+ fill: color
721
+ }
722
+ ) });
723
+ }
724
+
725
+ // src/icon/GroupIcon.tsx
726
+ var import_react_native_svg2 = __toESM(require("react-native-svg"));
727
+ var import_jsx_runtime2 = require("react/jsx-runtime");
728
+ function GroupIcon({ color = "#6F2CAC", ...props }) {
729
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_svg2.default, { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
730
+ import_react_native_svg2.Path,
731
+ {
732
+ fillRule: "evenodd",
733
+ clipRule: "evenodd",
734
+ d: "M6.962 3.704L5.376 2.118H1.057v9.514h12.685V3.704h-6.78zM7.4 2.647L6.124 1.37a1.057 1.057 0 00-.748-.31H.53A.529.529 0 000 1.59v10.57c0 .292.237.529.529.529H14.27a.529.529 0 00.528-.529V3.175a.529.529 0 00-.528-.528H7.4z",
735
+ fill: color
736
+ }
737
+ ) });
738
+ }
739
+
740
+ // src/icon/StoryIcon.tsx
741
+ var import_react_native_svg3 = __toESM(require("react-native-svg"));
742
+ var import_jsx_runtime3 = require("react/jsx-runtime");
743
+ function StoryIcon({ color = "#37D5D3", ...props }) {
744
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native_svg3.default, { width: 12, height: 12, viewBox: "0 0 12 12", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
745
+ import_react_native_svg3.Path,
746
+ {
747
+ fillRule: "evenodd",
748
+ clipRule: "evenodd",
749
+ d: "M3 0h6c.237 0 .428.192.428.429V11.57c0 .224-.17.407-.389.427a.396.396 0 01-.318-.101L6 9.565l-2.721 2.332a.395.395 0 01-.325.1.429.429 0 01-.383-.426V.43C2.571.192 2.763 0 3 0zm.428 10.64l2.284-1.958.034-.028a.39.39 0 01.289-.081c.087.007.172.04.244.102L8.57 10.64V.857H3.428v9.783z",
750
+ fill: color
751
+ }
752
+ ) });
753
+ }
754
+
755
+ // src/icon/CollapseIcon.tsx
756
+ var import_react_native_theming = require("@storybook/react-native-theming");
757
+ var import_polished = require("polished");
758
+ var import_react_native_svg4 = __toESM(require("react-native-svg"));
759
+ var import_jsx_runtime4 = require("react/jsx-runtime");
760
+ var CollapseIconWrapper = import_react_native_theming.styled.View(
761
+ ({ theme, isExpanded }) => ({
762
+ width: 8,
763
+ height: 8,
764
+ display: "flex",
765
+ justifyContent: "center",
766
+ alignItems: "center",
767
+ color: (0, import_polished.transparentize)(0.4, theme.textMutedColor),
768
+ transform: isExpanded ? "rotateZ(90deg)" : "none",
769
+ transition: "transform .1s ease-out"
770
+ })
771
+ );
772
+ var CollapseIcon = ({ isExpanded }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CollapseIconWrapper, { isExpanded, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CollapseSVG, {}) });
773
+ function CollapseSVG(props) {
774
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_svg4.default, { width: 8, height: 8, fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
775
+ import_react_native_svg4.Path,
776
+ {
777
+ fill: "#73828C",
778
+ d: "M1.896 7.146a.5.5 0 10.708.708l3.5-3.5a.5.5 0 000-.708l-3.5-3.5a.5.5 0 10-.708.708L5.043 4 1.896 7.146z"
779
+ }
780
+ ) });
781
+ }
782
+
783
+ // src/TreeNode.tsx
784
+ var import_react = __toESM(require("react"));
785
+ var import_polished2 = require("polished");
786
+ var import_jsx_runtime5 = require("react/jsx-runtime");
787
+ var BranchNodeText = import_react_native_theming2.styled.Text(({ theme }) => ({
788
+ textAlign: "left",
789
+ fontSize: theme.typography.size.s2,
790
+ flexShrink: 1
791
+ }));
792
+ var BranchNode = import_react_native_theming2.styled.TouchableOpacity(({ depth = 0, isExpandable = false, theme }) => ({
793
+ width: "100%",
794
+ border: "none",
795
+ cursor: "pointer",
796
+ display: "flex",
797
+ flexDirection: "row",
798
+ alignItems: "flex-start",
799
+ alignSelf: "flex-start",
800
+ paddingLeft: (isExpandable ? 8 : 22) + depth * 18,
801
+ background: "transparent",
802
+ minHeight: 28,
803
+ borderRadius: 4,
804
+ gap: 6,
805
+ paddingTop: 5,
806
+ paddingBottom: 4,
807
+ // will this actually do anything?
808
+ "&:hover, &:focus": {
809
+ background: (0, import_polished2.transparentize)(0.93, theme.color.secondary),
810
+ outline: "none"
811
+ }
812
+ }));
813
+ var LeafNode = import_react_native_theming2.styled.TouchableOpacity(
814
+ ({ depth = 0, selected, theme }) => ({
815
+ alignSelf: "flex-start",
816
+ cursor: "pointer",
817
+ color: "inherit",
818
+ display: "flex",
819
+ gap: 6,
820
+ flexDirection: "row",
821
+ alignItems: "flex-start",
822
+ paddingLeft: 22 + depth * 18,
823
+ paddingTop: 5,
824
+ paddingBottom: 4,
825
+ backgroundColor: selected ? theme.color.secondary : void 0,
826
+ // flex: 1,
827
+ // not sure 👇
828
+ width: "100%",
829
+ borderRadius: 4,
830
+ paddingRight: 20,
831
+ minHeight: 28
832
+ })
833
+ );
834
+ var LeafNodeText = import_react_native_theming2.styled.Text(({ theme, selected }) => ({
835
+ fontSize: theme.typography.size.s2,
836
+ flexShrink: 1,
837
+ color: selected ? theme.color.lightest : theme.color.defaultText
838
+ }));
839
+ var Wrapper = import_react_native_theming2.styled.View({
840
+ display: "flex",
841
+ flexDirection: "row",
842
+ alignItems: "center",
843
+ gap: 6,
844
+ marginTop: 2
845
+ });
846
+ var GroupNode = import_react.default.memo(function GroupNode2({
847
+ children,
848
+ isExpanded = false,
849
+ isExpandable = false,
850
+ ...props
851
+ }) {
852
+ const theme = (0, import_react_native_theming2.useTheme)();
853
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(BranchNode, { isExpandable, ...props, children: [
854
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Wrapper, { children: [
855
+ isExpandable && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapseIcon, { isExpanded }),
856
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
857
+ GroupIcon,
858
+ {
859
+ width: "14",
860
+ height: "14",
861
+ color: theme.base === "dark" ? theme.color.primary : theme.color.ultraviolet
862
+ }
863
+ )
864
+ ] }),
865
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchNodeText, { children })
866
+ ] });
867
+ });
868
+ var ComponentNode = import_react.default.memo(
869
+ function ComponentNode2({ children, isExpanded, isExpandable, ...props }) {
870
+ const theme = (0, import_react_native_theming2.useTheme)();
871
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(BranchNode, { isExpandable, ...props, children: [
872
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Wrapper, { children: [
873
+ isExpandable && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CollapseIcon, { isExpanded }),
874
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ComponentIcon, { width: 12, height: 12, color: theme.color.secondary })
875
+ ] }),
876
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchNodeText, { children })
877
+ ] });
878
+ }
879
+ );
880
+ var StoryNode = import_react.default.memo(function StoryNode2({
881
+ children,
882
+ ...props
883
+ }) {
884
+ const theme = (0, import_react_native_theming2.useTheme)();
885
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(LeafNode, { ...props, children: [
886
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
887
+ StoryIcon,
888
+ {
889
+ width: 14,
890
+ height: 14,
891
+ color: props.selected ? theme.color.lightest : theme.color.seafoam
892
+ }
893
+ ) }),
894
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LeafNodeText, { selected: props.selected, children })
895
+ ] });
896
+ });
897
+
898
+ // src/Tree.tsx
899
+ var import_manager_api2 = require("@storybook/manager-api");
900
+ var import_react_native_theming5 = require("@storybook/react-native-theming");
901
+ var import_react6 = __toESM(require("react"));
902
+
903
+ // src/Button.tsx
904
+ var import_react_native_theming3 = require("@storybook/react-native-theming");
905
+ var import_react2 = require("react");
906
+ var import_jsx_runtime6 = require("react/jsx-runtime");
907
+ var Button = (0, import_react2.forwardRef)(
908
+ ({
909
+ // asChild = false,
910
+ Icon,
911
+ animation = "none",
912
+ size = "small",
913
+ variant = "outline",
914
+ padding = "medium",
915
+ disabled = false,
916
+ active = false,
917
+ onPress,
918
+ children,
919
+ text,
920
+ ...props
921
+ }, ref) => {
922
+ const [isAnimating, setIsAnimating] = (0, import_react2.useState)(false);
923
+ const handleClick = (event) => {
924
+ if (onPress)
925
+ onPress(event);
926
+ if (animation === "none")
927
+ return;
928
+ setIsAnimating(true);
929
+ };
930
+ (0, import_react2.useEffect)(() => {
931
+ const timer = setTimeout(() => {
932
+ if (isAnimating)
933
+ setIsAnimating(false);
934
+ }, 1e3);
935
+ return () => clearTimeout(timer);
936
+ }, [isAnimating]);
937
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
938
+ StyledButton,
939
+ {
940
+ ref,
941
+ variant,
942
+ size,
943
+ padding,
944
+ disabled,
945
+ active,
946
+ animating: isAnimating,
947
+ animation,
948
+ onPress: handleClick,
949
+ ...props,
950
+ children: [
951
+ Icon && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ButtonIcon, { Icon, variant, active }),
952
+ text && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ButtonText, { variant, active, children: text }),
953
+ children
954
+ ]
955
+ }
956
+ );
957
+ }
958
+ );
959
+ Button.displayName = "Button";
960
+ var StyledButton = import_react_native_theming3.styled.TouchableOpacity(({
961
+ theme,
962
+ variant,
963
+ size,
964
+ disabled,
965
+ active,
966
+ /* animating, animation, */
967
+ padding
968
+ }) => ({
969
+ border: 0,
970
+ cursor: disabled ? "not-allowed" : "pointer",
971
+ display: "flex",
972
+ flexDirection: "row",
973
+ gap: 6,
974
+ alignItems: "center",
975
+ justifyContent: "center",
976
+ overflow: "hidden",
977
+ paddingHorizontal: (() => {
978
+ if (padding === "small" && size === "small")
979
+ return 7;
980
+ if (padding === "small" && size === "medium")
981
+ return 9;
982
+ if (size === "small")
983
+ return 10;
984
+ if (size === "medium")
985
+ return 12;
986
+ return 0;
987
+ })(),
988
+ paddingVertical: 0,
989
+ height: size === "small" ? 28 : 32,
990
+ position: "relative",
991
+ // textDecoration: 'none',
992
+ transitionProperty: "background, box-shadow",
993
+ transitionDuration: "150ms",
994
+ transitionTimingFunction: "ease-out",
995
+ // verticalAlign: 'top',
996
+ whiteSpace: "nowrap",
997
+ userSelect: "none",
998
+ opacity: disabled ? 0.5 : 1,
999
+ margin: 0,
1000
+ backgroundColor: (() => {
1001
+ if (variant === "solid")
1002
+ return theme.color.secondary;
1003
+ if (variant === "outline")
1004
+ return theme.button$.background;
1005
+ if (variant === "ghost" && active)
1006
+ return theme.background.hoverable;
1007
+ return "transparent";
1008
+ })(),
1009
+ boxShadow: variant === "outline" ? `${theme.button$.border} 0 0 0 1px inset` : "none",
1010
+ borderRadius: theme.input.borderRadius,
1011
+ // Making sure that the button never shrinks below its minimum size
1012
+ flexShrink: 0
1013
+ // '&:hover': {
1014
+ // color: variant === 'ghost' ? theme.color.secondary : null,
1015
+ // background: (() => {
1016
+ // let bgColor = theme.color.secondary;
1017
+ // if (variant === 'solid') bgColor = theme.color.secondary;
1018
+ // if (variant === 'outline') bgColor = theme.button.background;
1019
+ // if (variant === 'ghost') return transparentize(0.86, theme.color.secondary);
1020
+ // return theme.base === 'light' ? darken(0.02, bgColor) : lighten(0.03, bgColor);
1021
+ // })(),
1022
+ // },
1023
+ // '&:active': {
1024
+ // color: variant === 'ghost' ? theme.color.secondary : null,
1025
+ // background: (() => {
1026
+ // let bgColor = theme.color.secondary;
1027
+ // if (variant === 'solid') bgColor = theme.color.secondary;
1028
+ // if (variant === 'outline') bgColor = theme.button.background;
1029
+ // if (variant === 'ghost') return theme.background.hoverable;
1030
+ // return theme.base === 'light' ? darken(0.02, bgColor) : lighten(0.03, bgColor);
1031
+ // })(),
1032
+ // },
1033
+ // '&:focus': {
1034
+ // boxShadow: `${rgba(theme.color.secondary, 1)} 0 0 0 1px inset`,
1035
+ // outline: 'none',
1036
+ // },
1037
+ // '> svg': {
1038
+ // animation:
1039
+ // animating && animation !== 'none' ? `${theme.animation[animation]} 1000ms ease-out` : '',
1040
+ // },
1041
+ }));
1042
+ var ButtonText = import_react_native_theming3.styled.Text(({ theme, variant, active }) => ({
1043
+ color: (() => {
1044
+ if (variant === "solid")
1045
+ return theme.color.lightest;
1046
+ if (variant === "outline")
1047
+ return theme.input.color;
1048
+ if (variant === "ghost" && active)
1049
+ return theme.color.secondary;
1050
+ if (variant === "ghost")
1051
+ return theme.color.mediumdark;
1052
+ return theme.input.color;
1053
+ })(),
1054
+ flexDirection: "row",
1055
+ gap: 6,
1056
+ textAlign: "center",
1057
+ // lineHeight: theme.typography.size.s1,
1058
+ fontSize: theme.typography.size.s1,
1059
+ fontWeight: theme.typography.weight.bold
1060
+ }));
1061
+ var ButtonIcon = ({
1062
+ Icon,
1063
+ active,
1064
+ variant
1065
+ }) => {
1066
+ const theme = (0, import_react_native_theming3.useTheme)();
1067
+ const color = (0, import_react2.useMemo)(() => {
1068
+ if (variant === "solid")
1069
+ return theme.color.lightest;
1070
+ if (variant === "outline")
1071
+ return theme.input.color;
1072
+ if (variant === "ghost" && active)
1073
+ return theme.color.secondary;
1074
+ if (variant === "ghost")
1075
+ return theme.color.mediumdark;
1076
+ return theme.input.color;
1077
+ }, [
1078
+ active,
1079
+ theme.color.lightest,
1080
+ theme.color.mediumdark,
1081
+ theme.color.secondary,
1082
+ theme.input.color,
1083
+ variant
1084
+ ]);
1085
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { color });
1086
+ };
1087
+
1088
+ // src/IconButton.tsx
1089
+ var import_react3 = require("react");
1090
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1091
+ var IconButton = (0, import_react3.forwardRef)(
1092
+ ({ padding = "small", variant = "ghost", ...props }, ref) => {
1093
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Button, { padding, variant, ref, ...props });
1094
+ }
1095
+ );
1096
+ IconButton.displayName = "IconButton";
1097
+
1098
+ // src/useExpanded.ts
1099
+ var import_manager_api = require("@storybook/manager-api");
1100
+ var import_core_events = require("@storybook/core-events");
1101
+ var import_react4 = require("react");
1102
+
1103
+ // src/util/tree.ts
1104
+ var import_memoizerific = __toESM(require("memoizerific"));
1105
+
1106
+ // src/constants.ts
1107
+ var BREAKPOINT = 600;
1108
+ var MEDIA_DESKTOP_BREAKPOINT = `@media (min-width: ${BREAKPOINT}px)`;
1109
+ var DEFAULT_REF_ID = "storybook_internal";
1110
+
1111
+ // src/util/tree.ts
1112
+ var createId = (itemId, refId) => !refId || refId === DEFAULT_REF_ID ? itemId : `${refId}_${itemId}`;
1113
+ var get = (0, import_memoizerific.default)(1e3)((id, dataset) => dataset[id]);
1114
+ var getParent = (0, import_memoizerific.default)(1e3)((id, dataset) => {
1115
+ const item = get(id, dataset);
1116
+ return item && item.type !== "root" ? get(item.parent, dataset) : void 0;
1117
+ });
1118
+ var getParents = (0, import_memoizerific.default)(1e3)((id, dataset) => {
1119
+ const parent = getParent(id, dataset);
1120
+ return parent ? [parent, ...getParents(parent.id, dataset)] : [];
1121
+ });
1122
+ var getAncestorIds = (0, import_memoizerific.default)(1e3)(
1123
+ (data, id) => getParents(id, data).map((item) => item.id)
1124
+ );
1125
+ var getDescendantIds = (0, import_memoizerific.default)(1e3)(
1126
+ (data, id, skipLeafs) => {
1127
+ const entry = data[id];
1128
+ const children = entry.type === "story" || entry.type === "docs" ? [] : entry.children;
1129
+ return children.reduce((acc, childId) => {
1130
+ const child = data[childId];
1131
+ if (!child || skipLeafs && (child.type === "story" || child.type === "docs"))
1132
+ return acc;
1133
+ acc.push(childId, ...getDescendantIds(data, childId, skipLeafs));
1134
+ return acc;
1135
+ }, []);
1136
+ }
1137
+ );
1138
+ function getPath(item, ref) {
1139
+ const parent = item.type !== "root" && item.parent ? ref.index[item.parent] : null;
1140
+ if (parent)
1141
+ return [...getPath(parent, ref), parent.name];
1142
+ return ref.id === DEFAULT_REF_ID ? [] : [ref.title || ref.id];
1143
+ }
1144
+ var searchItem = (item, ref) => {
1145
+ return { ...item, refId: ref.id, path: getPath(item, ref) };
1146
+ };
1147
+ var getStateType = (isLoading, isAuthRequired, isError, isEmpty) => {
1148
+ switch (true) {
1149
+ case isAuthRequired:
1150
+ return "auth";
1151
+ case isError:
1152
+ return "error";
1153
+ case isLoading:
1154
+ return "loading";
1155
+ case isEmpty:
1156
+ return "empty";
1157
+ default:
1158
+ return "ready";
1159
+ }
1160
+ };
1161
+ var removeNoiseFromName = (storyName) => storyName.replaceAll(/(\s|-|_)/gi, "");
1162
+ var isStoryHoistable = (storyName, componentName) => removeNoiseFromName(storyName) === removeNoiseFromName(componentName);
1163
+
1164
+ // src/useExpanded.ts
1165
+ var initializeExpanded = ({
1166
+ // refId,
1167
+ // data,
1168
+ initialExpanded,
1169
+ // highlightedRef,
1170
+ rootIds
1171
+ }) => {
1172
+ const highlightedAncestors = [];
1173
+ return [...rootIds, ...highlightedAncestors].reduce(
1174
+ (acc, id) => Object.assign(acc, { [id]: id in initialExpanded ? initialExpanded[id] : true }),
1175
+ {}
1176
+ );
1177
+ };
1178
+ var noop = () => {
1179
+ };
1180
+ var useExpanded = ({
1181
+ // containerRef,
1182
+ // isBrowsing,
1183
+ refId,
1184
+ data,
1185
+ initialExpanded,
1186
+ rootIds,
1187
+ // highlightedRef,
1188
+ // setHighlightedItemId,
1189
+ // onSelectStoryId,
1190
+ selectedStoryId
1191
+ }) => {
1192
+ const api = (0, import_manager_api.useStorybookApi)();
1193
+ const [expanded, setExpanded] = (0, import_react4.useReducer)(
1194
+ (state, { ids, value }) => ids.reduce((acc, id) => Object.assign(acc, { [id]: value }), { ...state }),
1195
+ {
1196
+ refId,
1197
+ data,
1198
+ /* highlightedRef */
1199
+ rootIds,
1200
+ initialExpanded
1201
+ },
1202
+ initializeExpanded
1203
+ );
1204
+ const updateExpanded = (0, import_react4.useCallback)(({ ids, value }) => {
1205
+ setExpanded({ ids, value });
1206
+ }, []);
1207
+ (0, import_react4.useEffect)(() => {
1208
+ setExpanded({ ids: getAncestorIds(data, selectedStoryId), value: true });
1209
+ }, [data, selectedStoryId]);
1210
+ const collapseAll = (0, import_react4.useCallback)(() => {
1211
+ const ids = Object.keys(data).filter((id) => !rootIds.includes(id));
1212
+ setExpanded({ ids, value: false });
1213
+ }, [data, rootIds]);
1214
+ const expandAll = (0, import_react4.useCallback)(() => {
1215
+ setExpanded({ ids: Object.keys(data), value: true });
1216
+ }, [data]);
1217
+ (0, import_react4.useEffect)(() => {
1218
+ if (!api)
1219
+ return noop;
1220
+ api.on(import_core_events.STORIES_COLLAPSE_ALL, collapseAll);
1221
+ api.on(import_core_events.STORIES_EXPAND_ALL, expandAll);
1222
+ return () => {
1223
+ api.off(import_core_events.STORIES_COLLAPSE_ALL, collapseAll);
1224
+ api.off(import_core_events.STORIES_EXPAND_ALL, expandAll);
1225
+ };
1226
+ }, [api, collapseAll, expandAll]);
1227
+ return [expanded, updateExpanded];
1228
+ };
1229
+
1230
+ // src/util/status.tsx
1231
+ var import_react_native_theming4 = require("@storybook/react-native-theming");
1232
+ var import_react_native_svg5 = __toESM(require("react-native-svg"));
1233
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1234
+ function CircleIcon({ height = 14, width = 14, color, ...props }) {
1235
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native_svg5.default, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_native_svg5.Path, { d: "M14 7A7 7 0 110 7a7 7 0 0114 0z", fill: color }) });
1236
+ }
1237
+ function SmallIcons(props) {
1238
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CircleIcon, { width: 6, height: 6, ...props });
1239
+ }
1240
+ function LoadingIcons(props) {
1241
+ const theme = (0, import_react_native_theming4.useTheme)();
1242
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1243
+ SmallIcons,
1244
+ {
1245
+ color: theme.base === "light" ? theme.color.mediumdark : theme.color.darker,
1246
+ ...props
1247
+ }
1248
+ );
1249
+ }
1250
+ var statusPriority = ["unknown", "pending", "success", "warn", "error"];
1251
+ var statusMapping = {
1252
+ unknown: [null, null],
1253
+ pending: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LoadingIcons, {}, "icon"), "currentColor"],
1254
+ success: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SmallIcons, { color: "green" }, "icon"), "currentColor"],
1255
+ warn: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SmallIcons, { color: "orange" }, "icon"), "#A15C20"],
1256
+ error: [/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SmallIcons, { color: "red" }, "icon"), "brown"]
1257
+ };
1258
+ var getHighestStatus = (statuses) => {
1259
+ return statusPriority.reduce(
1260
+ (acc, status) => statuses.includes(status) ? status : acc,
1261
+ "unknown"
1262
+ );
1263
+ };
1264
+ function getGroupStatus(collapsedData, status) {
1265
+ return Object.values(collapsedData).reduce((acc, item) => {
1266
+ if (item.type === "group" || item.type === "component") {
1267
+ const leafs = getDescendantIds(collapsedData, item.id, false).map((id) => collapsedData[id]).filter((i) => i.type === "story");
1268
+ const combinedStatus = getHighestStatus(
1269
+ leafs.flatMap((story) => Object.values(status?.[story.id] || {})).map((s) => s.status)
1270
+ );
1271
+ if (combinedStatus) {
1272
+ acc[item.id] = combinedStatus;
1273
+ }
1274
+ }
1275
+ return acc;
1276
+ }, {});
1277
+ }
1278
+
1279
+ // src/Tree.tsx
1280
+ var import_react_native2 = require("react-native");
1281
+
1282
+ // src/icon/ExpandAllIcon.tsx
1283
+ var import_react_native_svg6 = require("react-native-svg");
1284
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1285
+ var ExpandAllIcon = ({
1286
+ color = "#2E3438",
1287
+ width = 14,
1288
+ height = 14,
1289
+ ...props
1290
+ }) => {
1291
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native_svg6.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1292
+ import_react_native_svg6.Path,
1293
+ {
1294
+ d: "M7.354.146l4 4a.5.5 0 01-.708.708L7 1.207 3.354 4.854a.5.5 0 11-.708-.708l4-4a.5.5 0 01.708 0zM11.354 9.146a.5.5 0 010 .708l-4 4a.5.5 0 01-.708 0l-4-4a.5.5 0 11.708-.708L7 12.793l3.646-3.647a.5.5 0 01.708 0z",
1295
+ fill: color
1296
+ }
1297
+ ) });
1298
+ };
1299
+
1300
+ // src/icon/CollapseAllIcon.tsx
1301
+ var import_react_native_svg7 = require("react-native-svg");
1302
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1303
+ var CollapseAllIcon = ({
1304
+ color = "#2E3438",
1305
+ width = 14,
1306
+ height = 14,
1307
+ ...props
1308
+ }) => {
1309
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native_svg7.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1310
+ import_react_native_svg7.Path,
1311
+ {
1312
+ d: "M3.354.146a.5.5 0 10-.708.708l4 4a.5.5 0 00.708 0l4-4a.5.5 0 00-.708-.708L7 3.793 3.354.146zM6.646 9.146a.5.5 0 01.708 0l4 4a.5.5 0 01-.708.708L7 10.207l-3.646 3.647a.5.5 0 01-.708-.708l4-4z",
1313
+ fill: color
1314
+ }
1315
+ ) });
1316
+ };
1317
+
1318
+ // src/LayoutProvider.tsx
1319
+ var import_react5 = require("react");
1320
+ var import_react_native = require("react-native");
1321
+ var import_jsx_runtime11 = (
1322
+ // <BottomSheetModalProvider>
1323
+ require("react/jsx-runtime")
1324
+ );
1325
+ var LayoutContext = (0, import_react5.createContext)({
1326
+ // isMobileMenuOpen: false,
1327
+ openMobileMenu: () => {
1328
+ },
1329
+ closeMobileMenu: () => {
1330
+ },
1331
+ // isMobileAboutOpen: false,
1332
+ // setMobileAboutOpen: () => {},
1333
+ // isMobilePanelOpen: false,
1334
+ // setMobilePanelOpen: () => {},
1335
+ isDesktop: false,
1336
+ isMobile: false
1337
+ });
1338
+ var LayoutProvider = ({ children }) => {
1339
+ const { width } = (0, import_react_native.useWindowDimensions)();
1340
+ const isDesktop = width >= BREAKPOINT;
1341
+ const isMobile = !isDesktop;
1342
+ const openMobileMenu = (0, import_react5.useCallback)(() => {
1343
+ }, []);
1344
+ const closeMobileMenu = (0, import_react5.useCallback)(() => {
1345
+ }, []);
1346
+ const contextValue = (0, import_react5.useMemo)(
1347
+ () => ({
1348
+ // isMobileMenuOpen,
1349
+ openMobileMenu,
1350
+ closeMobileMenu,
1351
+ // isMobileAboutOpen,
1352
+ // setMobileAboutOpen,
1353
+ // isMobilePanelOpen,
1354
+ // setMobilePanelOpen,
1355
+ isDesktop,
1356
+ isMobile
1357
+ }),
1358
+ [
1359
+ // isMobileMenuOpen,
1360
+ openMobileMenu,
1361
+ closeMobileMenu,
1362
+ // // isMobileAboutOpen,
1363
+ // setMobileAboutOpen,
1364
+ // isMobilePanelOpen,
1365
+ // setMobilePanelOpen,
1366
+ isDesktop,
1367
+ isMobile
1368
+ ]
1369
+ );
1370
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(LayoutContext.Provider, { value: contextValue, children }) });
1371
+ };
1372
+ var useLayout = () => (0, import_react5.useContext)(LayoutContext);
1373
+
1374
+ // src/Tree.tsx
1375
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1376
+ var Node = import_react6.default.memo(function Node2({
1377
+ item,
1378
+ // status,
1379
+ refId,
1380
+ isOrphan,
1381
+ isDisplayed,
1382
+ isSelected,
1383
+ isFullyExpanded,
1384
+ color: _2,
1385
+ setFullyExpanded,
1386
+ isExpanded,
1387
+ setExpanded,
1388
+ onSelectStoryId,
1389
+ api: _1
1390
+ }) {
1391
+ const { isDesktop, isMobile, closeMobileMenu } = useLayout();
1392
+ if (!isDisplayed) {
1393
+ return null;
1394
+ }
1395
+ const id = createId(item.id, refId);
1396
+ if (item.type === "story") {
1397
+ const LeafNode2 = StoryNode;
1398
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LeafNodeStyleWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1399
+ LeafNode2,
1400
+ {
1401
+ selected: isSelected,
1402
+ id,
1403
+ depth: isOrphan ? item.depth : item.depth - 1,
1404
+ onPress: () => {
1405
+ onSelectStoryId(item.id);
1406
+ if (isMobile)
1407
+ closeMobileMenu();
1408
+ },
1409
+ children: item.renderLabel?.(item) || item.name
1410
+ },
1411
+ id
1412
+ ) });
1413
+ }
1414
+ if (item.type === "root") {
1415
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1416
+ RootNode,
1417
+ {
1418
+ id,
1419
+ children: [
1420
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1421
+ CollapseButton,
1422
+ {
1423
+ "data-action": "collapse-root",
1424
+ onPress: (event) => {
1425
+ event.preventDefault();
1426
+ setExpanded({ ids: [item.id], value: !isExpanded });
1427
+ },
1428
+ "aria-expanded": isExpanded,
1429
+ children: [
1430
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CollapseIcon, { isExpanded }),
1431
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react_native2.Text, { children: item.renderLabel?.(item) || item.name })
1432
+ ]
1433
+ }
1434
+ ),
1435
+ isExpanded && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1436
+ IconButton,
1437
+ {
1438
+ "aria-label": isFullyExpanded ? "Expand" : "Collapse",
1439
+ "data-action": "expand-all",
1440
+ "data-expanded": isFullyExpanded,
1441
+ onPress: (event) => {
1442
+ event.preventDefault();
1443
+ setFullyExpanded();
1444
+ },
1445
+ children: isFullyExpanded ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CollapseAllIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ExpandAllIcon, {})
1446
+ }
1447
+ )
1448
+ ]
1449
+ },
1450
+ id
1451
+ );
1452
+ }
1453
+ if (item.type === "component" || item.type === "group") {
1454
+ const BranchNode2 = item.type === "component" ? ComponentNode : GroupNode;
1455
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1456
+ BranchNode2,
1457
+ {
1458
+ id,
1459
+ "aria-controls": item.children && item.children[0],
1460
+ "aria-expanded": isExpanded,
1461
+ depth: isOrphan ? item.depth : item.depth - 1,
1462
+ isComponent: item.type === "component",
1463
+ isExpandable: item.children && item.children.length > 0,
1464
+ isExpanded,
1465
+ onPress: (event) => {
1466
+ event.preventDefault();
1467
+ setExpanded({ ids: [item.id], value: !isExpanded });
1468
+ if (item.type === "component" && !isExpanded && isDesktop)
1469
+ onSelectStoryId(item.id);
1470
+ },
1471
+ children: item.renderLabel?.(item) || item.name
1472
+ },
1473
+ id
1474
+ );
1475
+ }
1476
+ return null;
1477
+ });
1478
+ var LeafNodeStyleWrapper = import_react_native_theming5.styled.View(({ theme }) => ({
1479
+ position: "relative",
1480
+ display: "flex",
1481
+ flexDirection: "row",
1482
+ justifyContent: "space-between",
1483
+ alignItems: "center",
1484
+ paddingRight: 20,
1485
+ color: theme.color.defaultText,
1486
+ background: "transparent",
1487
+ minHeight: 28,
1488
+ borderRadius: 4
1489
+ }));
1490
+ var RootNode = import_react_native_theming5.styled.View(({}) => ({
1491
+ display: "flex",
1492
+ flexDirection: "row",
1493
+ alignItems: "center",
1494
+ justifyContent: "space-between",
1495
+ marginTop: 16,
1496
+ marginBottom: 4,
1497
+ minHeight: 28
1498
+ }));
1499
+ var RootNodeText = import_react_native_theming5.styled.Text(({ theme }) => ({
1500
+ fontSize: theme.typography.size.s1 - 1,
1501
+ fontWeight: theme.typography.weight.bold,
1502
+ color: theme.textMutedColor,
1503
+ lineHeight: 16,
1504
+ letterSpacing: 2.5,
1505
+ // letterSpacing: '0.16em',
1506
+ textTransform: "uppercase"
1507
+ }));
1508
+ var CollapseButton = import_react_native_theming5.styled.TouchableOpacity(({}) => ({
1509
+ display: "flex",
1510
+ flexDirection: "row",
1511
+ paddingVertical: 0,
1512
+ paddingHorizontal: 8,
1513
+ borderRadius: 4,
1514
+ // transition: 'color 150ms, box-shadow 150ms',
1515
+ gap: 6,
1516
+ alignItems: "center",
1517
+ cursor: "pointer",
1518
+ height: 28
1519
+ }));
1520
+ var Tree = import_react6.default.memo(function Tree2({
1521
+ // isBrowsing,
1522
+ isMain,
1523
+ refId,
1524
+ data,
1525
+ status,
1526
+ docsMode,
1527
+ selectedStoryId,
1528
+ onSelectStoryId
1529
+ }) {
1530
+ const containerRef = (0, import_react6.useRef)(null);
1531
+ const api = (0, import_manager_api2.useStorybookApi)();
1532
+ const [rootIds, orphanIds, initialExpanded] = (0, import_react6.useMemo)(
1533
+ () => Object.keys(data).reduce(
1534
+ (acc, id) => {
1535
+ const item = data[id];
1536
+ if (item.type === "root")
1537
+ acc[0].push(id);
1538
+ else if (!item.parent)
1539
+ acc[1].push(id);
1540
+ if (item.type === "root" && item.startCollapsed)
1541
+ acc[2][id] = false;
1542
+ return acc;
1543
+ },
1544
+ [[], [], {}]
1545
+ ),
1546
+ [data]
1547
+ );
1548
+ const { expandableDescendants } = (0, import_react6.useMemo)(() => {
1549
+ return [...orphanIds, ...rootIds].reduce(
1550
+ (acc, nodeId) => {
1551
+ acc.expandableDescendants[nodeId] = getDescendantIds(data, nodeId, false).filter(
1552
+ (d) => !["story", "docs"].includes(data[d].type)
1553
+ );
1554
+ return acc;
1555
+ },
1556
+ { orphansFirst: [], expandableDescendants: {} }
1557
+ );
1558
+ }, [data, rootIds, orphanIds]);
1559
+ const singleStoryComponentIds = (0, import_react6.useMemo)(() => {
1560
+ return Object.keys(data).filter((id) => {
1561
+ const entry = data[id];
1562
+ if (entry.type !== "component")
1563
+ return false;
1564
+ const { children = [], name } = entry;
1565
+ if (children.length !== 1)
1566
+ return false;
1567
+ const onlyChild = data[children[0]];
1568
+ if (onlyChild.type === "docs")
1569
+ return true;
1570
+ if (onlyChild.type === "story")
1571
+ return isStoryHoistable(onlyChild.name, name);
1572
+ return false;
1573
+ });
1574
+ }, [data]);
1575
+ const collapsedItems = (0, import_react6.useMemo)(
1576
+ () => Object.keys(data).filter((id) => !singleStoryComponentIds.includes(id)),
1577
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1578
+ [singleStoryComponentIds]
1579
+ );
1580
+ const collapsedData = (0, import_react6.useMemo)(() => {
1581
+ return singleStoryComponentIds.reduce(
1582
+ (acc, id) => {
1583
+ const { children, parent, name } = data[id];
1584
+ const [childId] = children;
1585
+ if (parent) {
1586
+ const siblings = [...data[parent].children];
1587
+ siblings[siblings.indexOf(id)] = childId;
1588
+ acc[parent] = { ...data[parent], children: siblings };
1589
+ }
1590
+ acc[childId] = {
1591
+ ...data[childId],
1592
+ name,
1593
+ parent,
1594
+ depth: data[childId].depth - 1
1595
+ };
1596
+ return acc;
1597
+ },
1598
+ { ...data }
1599
+ );
1600
+ }, [data]);
1601
+ const ancestry = (0, import_react6.useMemo)(() => {
1602
+ return collapsedItems.reduce(
1603
+ (acc, id) => Object.assign(acc, { [id]: getAncestorIds(collapsedData, id) }),
1604
+ {}
1605
+ );
1606
+ }, [collapsedItems, collapsedData]);
1607
+ const [expanded, setExpanded] = useExpanded({
1608
+ // containerRef,
1609
+ // isBrowsing,
1610
+ refId,
1611
+ data: collapsedData,
1612
+ initialExpanded,
1613
+ rootIds,
1614
+ // highlightedRef,
1615
+ // setHighlightedItemId,
1616
+ selectedStoryId,
1617
+ onSelectStoryId
1618
+ });
1619
+ const groupStatus = (0, import_react6.useMemo)(() => getGroupStatus(collapsedData, status), [collapsedData, status]);
1620
+ const treeItems = (0, import_react6.useMemo)(() => {
1621
+ return collapsedItems.map((itemId) => {
1622
+ const item = collapsedData[itemId];
1623
+ const id = createId(itemId, refId);
1624
+ if (item.type === "root") {
1625
+ const descendants = expandableDescendants[item.id];
1626
+ const isFullyExpanded = descendants.every((d) => expanded[d]);
1627
+ return (
1628
+ // @ts-expect-error (TODO)
1629
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1630
+ Root,
1631
+ {
1632
+ item,
1633
+ refId,
1634
+ isOrphan: false,
1635
+ isDisplayed: true,
1636
+ isSelected: selectedStoryId === itemId,
1637
+ isExpanded: !!expanded[itemId],
1638
+ setExpanded,
1639
+ isFullyExpanded,
1640
+ expandableDescendants: descendants,
1641
+ onSelectStoryId
1642
+ },
1643
+ id
1644
+ )
1645
+ );
1646
+ }
1647
+ const isDisplayed = !item.parent || ancestry[itemId].every((a) => expanded[a]);
1648
+ const color = groupStatus[itemId] ? statusMapping[groupStatus[itemId]][1] : null;
1649
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1650
+ Node,
1651
+ {
1652
+ api,
1653
+ item,
1654
+ status: status?.[itemId],
1655
+ refId,
1656
+ color,
1657
+ docsMode,
1658
+ isOrphan: orphanIds.some((oid) => itemId === oid || itemId.startsWith(`${oid}-`)),
1659
+ isDisplayed,
1660
+ isSelected: selectedStoryId === itemId,
1661
+ isExpanded: !!expanded[itemId],
1662
+ setExpanded,
1663
+ onSelectStoryId
1664
+ },
1665
+ id
1666
+ );
1667
+ });
1668
+ }, [
1669
+ ancestry,
1670
+ api,
1671
+ collapsedData,
1672
+ collapsedItems,
1673
+ docsMode,
1674
+ expandableDescendants,
1675
+ expanded,
1676
+ groupStatus,
1677
+ onSelectStoryId,
1678
+ orphanIds,
1679
+ refId,
1680
+ selectedStoryId,
1681
+ setExpanded,
1682
+ status
1683
+ ]);
1684
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Container, { ref: containerRef, hasOrphans: isMain && orphanIds.length > 0, children: treeItems });
1685
+ });
1686
+ var Container = import_react_native_theming5.styled.View((props) => ({
1687
+ marginTop: props.hasOrphans ? 20 : 0,
1688
+ marginBottom: 20
1689
+ }));
1690
+ var Root = import_react6.default.memo(function Root2({
1691
+ setExpanded,
1692
+ isFullyExpanded,
1693
+ expandableDescendants,
1694
+ ...props
1695
+ }) {
1696
+ const setFullyExpanded = (0, import_react6.useCallback)(
1697
+ () => setExpanded({ ids: expandableDescendants, value: !isFullyExpanded }),
1698
+ [setExpanded, isFullyExpanded, expandableDescendants]
1699
+ );
1700
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1701
+ Node,
1702
+ {
1703
+ ...props,
1704
+ setExpanded,
1705
+ isFullyExpanded,
1706
+ setFullyExpanded
1707
+ }
1708
+ );
1709
+ });
1710
+
1711
+ // src/Explorer.tsx
1712
+ var import_react8 = __toESM(require("react"));
1713
+
1714
+ // src/Refs.tsx
1715
+ var import_react7 = __toESM(require("react"));
1716
+ var import_manager_api3 = require("@storybook/manager-api");
1717
+ var import_react_native_theming6 = require("@storybook/react-native-theming");
1718
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1719
+ var Wrapper2 = import_react_native_theming6.styled.View(({}) => ({
1720
+ position: "relative"
1721
+ }));
1722
+ var Ref = import_react7.default.memo(function Ref2(props) {
1723
+ const { docsOptions } = (0, import_manager_api3.useStorybookState)();
1724
+ const api = (0, import_manager_api3.useStorybookApi)();
1725
+ const {
1726
+ index,
1727
+ id: refId,
1728
+ title = refId,
1729
+ isLoading: isLoadingMain,
1730
+ isBrowsing,
1731
+ selectedStoryId,
1732
+ // highlightedRef,
1733
+ // setHighlighted,
1734
+ loginUrl,
1735
+ type,
1736
+ expanded = true,
1737
+ indexError,
1738
+ previewInitialized,
1739
+ setSelection
1740
+ } = props;
1741
+ const length = (0, import_react7.useMemo)(() => index ? Object.keys(index).length : 0, [index]);
1742
+ const isLoadingInjected = type === "auto-inject" && !previewInitialized || type === "server-checked";
1743
+ const isLoading = isLoadingMain || isLoadingInjected || type === "unknown";
1744
+ const isError = !!indexError;
1745
+ const isEmpty = !isLoading && length === 0;
1746
+ const isAuthRequired = !!loginUrl && length === 0;
1747
+ const state = getStateType(isLoading, isAuthRequired, isError, isEmpty);
1748
+ const [isExpanded, setExpanded] = (0, import_react7.useState)(expanded);
1749
+ (0, import_react7.useEffect)(() => {
1750
+ if (index && selectedStoryId && index[selectedStoryId]) {
1751
+ setExpanded(true);
1752
+ }
1753
+ }, [setExpanded, index, selectedStoryId]);
1754
+ const onSelectStoryId = (0, import_react7.useCallback)(
1755
+ (storyId) => {
1756
+ setSelection({ refId, storyId });
1757
+ return api && api.selectStory(storyId, DEFAULT_REF_ID);
1758
+ },
1759
+ [api, refId, setSelection]
1760
+ );
1761
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: isExpanded && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Wrapper2, { "data-title": title, isMain: true, children: state === "ready" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1762
+ Tree,
1763
+ {
1764
+ status: props.status,
1765
+ isBrowsing,
1766
+ isMain: true,
1767
+ refId,
1768
+ data: index,
1769
+ docsMode: docsOptions?.docsMode,
1770
+ selectedStoryId,
1771
+ onSelectStoryId
1772
+ }
1773
+ ) }) });
1774
+ });
1775
+
1776
+ // src/Explorer.tsx
1777
+ var import_react_native3 = require("react-native");
1778
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1779
+ var import_react9 = require("react");
1780
+ var Explorer = import_react8.default.memo(function Explorer2({
1781
+ isLoading,
1782
+ isBrowsing,
1783
+ dataset,
1784
+ selected,
1785
+ setSelection
1786
+ }) {
1787
+ const containerRef = (0, import_react8.useRef)(null);
1788
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native3.View, { ref: containerRef, id: "storybook-explorer-tree", children: dataset.entries.map(([refId, ref]) => /* @__PURE__ */ (0, import_react9.createElement)(
1789
+ Ref,
1790
+ {
1791
+ ...ref,
1792
+ key: refId,
1793
+ isLoading,
1794
+ isBrowsing,
1795
+ selectedStoryId: selected?.refId === ref.id ? selected.storyId : null,
1796
+ setSelection
1797
+ }
1798
+ )) });
1799
+ });
1800
+
1801
+ // src/Sidebar.tsx
1802
+ var import_react14 = __toESM(require("react"));
1803
+ var import_react_native_theming9 = require("@storybook/react-native-theming");
1804
+
1805
+ // src/Search.tsx
1806
+ var import_manager_api4 = require("@storybook/manager-api");
1807
+ var import_react_native_theming7 = require("@storybook/react-native-theming");
1808
+ var import_fuse = __toESM(require("fuse.js"));
1809
+ var import_react10 = __toESM(require("react"));
1810
+
1811
+ // src/types.ts
1812
+ function isExpandType(x) {
1813
+ return !!(x && x.showAll);
1814
+ }
1815
+
1816
+ // src/icon/SearchIcon.tsx
1817
+ var import_react_native_svg8 = require("react-native-svg");
1818
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1819
+ var SearchIcon = ({ color = "currentColor", width = 14, height = 14, ...props }) => {
1820
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native_svg8.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1821
+ import_react_native_svg8.Path,
1822
+ {
1823
+ fillRule: "evenodd",
1824
+ clipRule: "evenodd",
1825
+ d: "M9.544 10.206a5.5 5.5 0 11.662-.662.5.5 0 01.148.102l3 3a.5.5 0 01-.708.708l-3-3a.5.5 0 01-.102-.148zM10.5 6a4.5 4.5 0 11-9 0 4.5 4.5 0 019 0z",
1826
+ fill: color
1827
+ }
1828
+ ) });
1829
+ };
1830
+
1831
+ // src/icon/CloseIcon.tsx
1832
+ var import_react_native_svg9 = require("react-native-svg");
1833
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1834
+ var CloseIcon = ({ color = "currentColor", width = 14, height = 14, ...props }) => {
1835
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_react_native_svg9.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: [
1836
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1837
+ import_react_native_svg9.Path,
1838
+ {
1839
+ d: "M9.854 4.146a.5.5 0 010 .708L7.707 7l2.147 2.146a.5.5 0 01-.708.708L7 7.707 4.854 9.854a.5.5 0 01-.708-.708L6.293 7 4.146 4.854a.5.5 0 11.708-.708L7 6.293l2.146-2.147a.5.5 0 01.708 0z",
1840
+ fill: color
1841
+ }
1842
+ ),
1843
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1844
+ import_react_native_svg9.Path,
1845
+ {
1846
+ fillRule: "evenodd",
1847
+ clipRule: "evenodd",
1848
+ d: "M7 14A7 7 0 107 0a7 7 0 000 14zm0-1A6 6 0 107 1a6 6 0 000 12z",
1849
+ fill: color
1850
+ }
1851
+ )
1852
+ ] });
1853
+ };
1854
+
1855
+ // src/Search.tsx
1856
+ var import_react_native4 = require("react-native");
1857
+ var import_bottom_sheet = require("@gorhom/bottom-sheet");
1858
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1859
+ var DEFAULT_MAX_SEARCH_RESULTS = 50;
1860
+ var options = {
1861
+ shouldSort: true,
1862
+ tokenize: true,
1863
+ findAllMatches: true,
1864
+ includeScore: true,
1865
+ includeMatches: true,
1866
+ threshold: 0.2,
1867
+ location: 0,
1868
+ distance: 100,
1869
+ maxPatternLength: 32,
1870
+ minMatchCharLength: 1,
1871
+ keys: [
1872
+ { name: "name", weight: 0.7 },
1873
+ { name: "path", weight: 0.3 }
1874
+ ]
1875
+ };
1876
+ var SearchIconWrapper = import_react_native_theming7.styled.View(({ theme }) => ({
1877
+ position: "absolute",
1878
+ top: 0,
1879
+ left: 8,
1880
+ zIndex: 1,
1881
+ pointerEvents: "none",
1882
+ color: theme.textMutedColor,
1883
+ display: "flex",
1884
+ flexDirection: "row",
1885
+ alignItems: "center",
1886
+ height: "100%"
1887
+ }));
1888
+ var SearchField = import_react_native_theming7.styled.View({
1889
+ display: "flex",
1890
+ flexDirection: "column",
1891
+ position: "relative"
1892
+ // marginBottom: 16,
1893
+ });
1894
+ var Input = (0, import_react_native_theming7.styled)(import_bottom_sheet.BottomSheetTextInput)(({ theme }) => ({
1895
+ // appearance: 'none',
1896
+ height: 32,
1897
+ paddingLeft: 28,
1898
+ paddingRight: 28,
1899
+ borderWidth: 1,
1900
+ borderColor: theme.appBorderColor,
1901
+ backgroundColor: "transparent",
1902
+ borderRadius: 4,
1903
+ fontSize: theme.typography.size.s1 + 1,
1904
+ // transition: 'all 150ms',
1905
+ color: theme.color.defaultText,
1906
+ width: "100%"
1907
+ // '&:focus, &:active': {
1908
+ // outline: 0,
1909
+ // borderColor: theme.color.secondary,
1910
+ // background: theme.background.app,
1911
+ // },
1912
+ // '&::placeholder': {
1913
+ // color: theme.textMutedColor,
1914
+ // opacity: 1,
1915
+ // },
1916
+ // '&:valid ~ code, &:focus ~ code': {
1917
+ // display: 'none',
1918
+ // },
1919
+ // '&:invalid ~ svg': {
1920
+ // display: 'none',
1921
+ // },
1922
+ // '&:valid ~ svg': {
1923
+ // display: 'block',
1924
+ // },
1925
+ // '&::-ms-clear': {
1926
+ // display: 'none',
1927
+ // },
1928
+ // '&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration':
1929
+ // {
1930
+ // display: 'none',
1931
+ // },
1932
+ }));
1933
+ var ClearIcon = import_react_native_theming7.styled.TouchableOpacity(({ theme }) => ({
1934
+ position: "absolute",
1935
+ top: 0,
1936
+ bottom: 0,
1937
+ right: 8,
1938
+ zIndex: 1,
1939
+ color: theme.textMutedColor,
1940
+ cursor: "pointer",
1941
+ display: "flex",
1942
+ alignItems: "center",
1943
+ justifyContent: "center",
1944
+ height: "100%"
1945
+ }));
1946
+ var Search = import_react10.default.memo(function Search2({
1947
+ children,
1948
+ dataset,
1949
+ setSelection,
1950
+ // enableShortcuts = true,
1951
+ getLastViewed,
1952
+ initialQuery = ""
1953
+ }) {
1954
+ const api = (0, import_manager_api4.useStorybookApi)();
1955
+ const inputRef = (0, import_react10.useRef)(null);
1956
+ const [inputValue, setInputValue] = (0, import_react10.useState)(initialQuery);
1957
+ const [isOpen, setIsOpen] = (0, import_react10.useState)(false);
1958
+ const [allComponents, showAllComponents] = (0, import_react10.useState)(false);
1959
+ const selectStory = (0, import_react10.useCallback)(
1960
+ (id, refId) => {
1961
+ if (api) {
1962
+ api.selectStory(id, void 0, { ref: refId !== DEFAULT_REF_ID && refId });
1963
+ }
1964
+ setSelection({ storyId: id, refId });
1965
+ inputRef.current?.blur();
1966
+ showAllComponents(false);
1967
+ },
1968
+ [api, setSelection]
1969
+ );
1970
+ const getItemProps = (0, import_react10.useCallback)(
1971
+ ({ item: result }) => {
1972
+ return {
1973
+ icon: result?.item?.type === "component" ? "component" : "story",
1974
+ // isHighlighted:
1975
+ result,
1976
+ onPress: () => {
1977
+ if (result?.item?.type === "story") {
1978
+ selectStory(result.item.id, result.item.refId);
1979
+ } else if (result?.item?.type === "component") {
1980
+ selectStory(result.item.children[0], result.item.refId);
1981
+ } else if (isExpandType(result) && result.showAll) {
1982
+ result.showAll();
1983
+ }
1984
+ },
1985
+ score: result.score,
1986
+ refIndex: result.refIndex,
1987
+ item: result.item,
1988
+ matches: result.matches,
1989
+ isHighlighted: false
1990
+ // isHighlighted: searchItem.
1991
+ // isHighlighted: searchItem.item.
1992
+ };
1993
+ },
1994
+ [selectStory]
1995
+ );
1996
+ const makeFuse = (0, import_react10.useCallback)(() => {
1997
+ const list = dataset.entries.reduce((acc, [refId, { index, status }]) => {
1998
+ const groupStatus = getGroupStatus(index || {}, status);
1999
+ if (index) {
2000
+ acc.push(
2001
+ ...Object.values(index).map((item) => {
2002
+ const statusValue = status && status[item.id] ? getHighestStatus(Object.values(status[item.id] || {}).map((s) => s.status)) : null;
2003
+ return {
2004
+ ...searchItem(item, dataset.hash[refId]),
2005
+ status: statusValue || groupStatus[item.id] || null
2006
+ };
2007
+ })
2008
+ );
2009
+ }
2010
+ return acc;
2011
+ }, []);
2012
+ return new import_fuse.default(list, options);
2013
+ }, [dataset]);
2014
+ const getResults = (0, import_react10.useCallback)(
2015
+ (input2) => {
2016
+ const fuse = makeFuse();
2017
+ if (!input2)
2018
+ return [];
2019
+ let results2 = [];
2020
+ const resultIds = /* @__PURE__ */ new Set();
2021
+ const distinctResults = fuse.search(input2).filter(({ item }) => {
2022
+ if (!(item.type === "component" || item.type === "docs" || item.type === "story") || resultIds.has(item.parent)) {
2023
+ return false;
2024
+ }
2025
+ resultIds.add(item.id);
2026
+ return true;
2027
+ });
2028
+ if (distinctResults.length) {
2029
+ results2 = distinctResults.slice(0, allComponents ? 1e3 : DEFAULT_MAX_SEARCH_RESULTS);
2030
+ if (distinctResults.length > DEFAULT_MAX_SEARCH_RESULTS && !allComponents) {
2031
+ results2.push({
2032
+ showAll: () => showAllComponents(true),
2033
+ totalCount: distinctResults.length,
2034
+ moreCount: distinctResults.length - DEFAULT_MAX_SEARCH_RESULTS
2035
+ });
2036
+ }
2037
+ }
2038
+ const lastViewed = !input2 && getLastViewed();
2039
+ if (lastViewed && lastViewed.length) {
2040
+ results2 = lastViewed.reduce((acc, { storyId, refId }) => {
2041
+ const data = dataset.hash[refId];
2042
+ if (data && data.index && data.index[storyId]) {
2043
+ const story = data.index[storyId];
2044
+ const item = story.type === "story" ? data.index[story.parent] : story;
2045
+ if (!acc.some((res) => res.item.refId === refId && res.item.id === item.id)) {
2046
+ acc.push({ item: searchItem(item, dataset.hash[refId]), matches: [], score: 0 });
2047
+ }
2048
+ }
2049
+ return acc;
2050
+ }, []);
2051
+ }
2052
+ return results2;
2053
+ },
2054
+ [allComponents, dataset.hash, getLastViewed, makeFuse]
2055
+ );
2056
+ const input = inputValue ? inputValue.trim() : "";
2057
+ const results = input ? getResults(input) : [];
2058
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react_native4.View, { style: { flex: 1 }, children: [
2059
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2060
+ SearchField,
2061
+ {
2062
+ children: [
2063
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SearchIconWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SearchIcon, {}) }),
2064
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2065
+ Input,
2066
+ {
2067
+ ref: inputRef,
2068
+ onChangeText: setInputValue,
2069
+ onFocus: () => setIsOpen(true),
2070
+ onBlur: () => setIsOpen(false)
2071
+ }
2072
+ ),
2073
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2074
+ ClearIcon,
2075
+ {
2076
+ onPress: () => {
2077
+ setInputValue("");
2078
+ inputRef.current.clear();
2079
+ },
2080
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CloseIcon, {})
2081
+ }
2082
+ )
2083
+ ]
2084
+ }
2085
+ ),
2086
+ children({
2087
+ query: input,
2088
+ results,
2089
+ isBrowsing: !isOpen || !inputValue.length,
2090
+ closeMenu: () => {
2091
+ },
2092
+ // getMenuProps,
2093
+ getItemProps,
2094
+ highlightedIndex: null
2095
+ })
2096
+ ] });
2097
+ });
2098
+
2099
+ // src/SearchResults.tsx
2100
+ var import_react_native_theming8 = require("@storybook/react-native-theming");
2101
+ var import_react11 = __toESM(require("react"));
2102
+ var import_polished3 = require("polished");
2103
+ var import_react_native5 = require("react-native");
2104
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2105
+ var import_react12 = require("react");
2106
+ var ResultsList = import_react_native_theming8.styled.View({
2107
+ margin: 0,
2108
+ padding: 0,
2109
+ marginTop: 8
2110
+ });
2111
+ var ResultRow = import_react_native_theming8.styled.TouchableOpacity(
2112
+ ({ theme, isHighlighted }) => ({
2113
+ width: "100%",
2114
+ border: "none",
2115
+ cursor: "pointer",
2116
+ display: "flex",
2117
+ flexDirection: "row",
2118
+ alignItems: "flex-start",
2119
+ textAlign: "left",
2120
+ color: "inherit",
2121
+ fontSize: theme.typography.size.s2,
2122
+ backgroundColor: isHighlighted ? theme.background.hoverable : "transparent",
2123
+ minHeight: 28,
2124
+ borderRadius: 4,
2125
+ gap: 6,
2126
+ paddingTop: 7,
2127
+ paddingBottom: 7,
2128
+ paddingLeft: 8,
2129
+ paddingRight: 8,
2130
+ "&:hover, &:focus": {
2131
+ backgroundColor: (0, import_polished3.transparentize)(0.93, theme.color.secondary),
2132
+ outline: "none"
2133
+ }
2134
+ })
2135
+ );
2136
+ var IconWrapper = import_react_native_theming8.styled.View({
2137
+ marginTop: 2
2138
+ });
2139
+ var ResultRowContent = import_react_native_theming8.styled.View(() => ({
2140
+ display: "flex",
2141
+ flexDirection: "column"
2142
+ }));
2143
+ var NoResults = import_react_native_theming8.styled.View(({ theme }) => ({
2144
+ marginTop: 20,
2145
+ textAlign: "center",
2146
+ fontSize: theme.typography.size.s2,
2147
+ lineHeight: 18,
2148
+ color: theme.color.defaultText
2149
+ // small: {
2150
+ // color: theme.barTextColor,
2151
+ // fontSize: theme.typography.size.s1,
2152
+ // },
2153
+ }));
2154
+ var Mark = import_react_native_theming8.styled.Text(({ theme }) => ({
2155
+ backgroundColor: "transparent",
2156
+ // fontSize: theme.typography.size.s1 - 1,
2157
+ color: theme.color.secondary
2158
+ }));
2159
+ var MoreWrapper = import_react_native_theming8.styled.View({
2160
+ marginTop: 8
2161
+ });
2162
+ var RecentlyOpenedTitle = import_react_native_theming8.styled.View(({ theme }) => ({
2163
+ display: "flex",
2164
+ flexDirection: "row",
2165
+ justifyContent: "space-between",
2166
+ fontSize: theme.typography.size.s1 - 1,
2167
+ fontWeight: theme.typography.weight.bold,
2168
+ minHeight: 28,
2169
+ // letterSpacing: '0.16em', <-- todo
2170
+ textTransform: "uppercase",
2171
+ color: theme.textMutedColor,
2172
+ marginTop: 16,
2173
+ marginBottom: 4,
2174
+ alignItems: "center"
2175
+ // '.search-result-recentlyOpened-clear': {
2176
+ // visibility: 'hidden',
2177
+ // },
2178
+ // '&:hover': {
2179
+ // '.search-result-recentlyOpened-clear': {
2180
+ // visibility: 'visible',
2181
+ // },
2182
+ // },
2183
+ }));
2184
+ var Highlight = import_react11.default.memo(
2185
+ function Highlight2({ children, match }) {
2186
+ if (!match)
2187
+ return children;
2188
+ const { value, indices } = match;
2189
+ const { nodes: result } = indices.reduce(
2190
+ ({ cursor, nodes }, [start, end], index, { length }) => {
2191
+ nodes.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native5.Text, { children: value.slice(cursor, start) }, `text-${index}`));
2192
+ nodes.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Mark, { children: value.slice(start, end + 1) }, `mark-${index}`));
2193
+ if (index === length - 1) {
2194
+ nodes.push(/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native5.Text, { children: value.slice(end + 1) }, `last-${index}`));
2195
+ }
2196
+ return { cursor: end + 1, nodes };
2197
+ },
2198
+ { cursor: 0, nodes: [] }
2199
+ );
2200
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native5.Text, { children: result }, `end-${match.key}`);
2201
+ }
2202
+ );
2203
+ var Title = import_react_native_theming8.styled.Text(({ theme }) => ({
2204
+ // display: 'grid',
2205
+ justifyContent: "flex-start",
2206
+ // gridAutoColumns: 'auto',
2207
+ // gridAutoFlow: 'column',
2208
+ color: theme.textMutedColor,
2209
+ fontSize: theme.typography.size.s2
2210
+ // '& > span': {
2211
+ // display: 'block',
2212
+ // whiteSpace: 'nowrap',
2213
+ // overflow: 'hidden',
2214
+ // textOverflow: 'ellipsis',
2215
+ // },
2216
+ }));
2217
+ var Path10 = import_react_native_theming8.styled.View(({ theme }) => ({
2218
+ // display: 'grid',
2219
+ justifyContent: "flex-start",
2220
+ marginVertical: 2,
2221
+ // gridAutoColumns: 'auto',
2222
+ // gridAutoFlow: 'column',
2223
+ color: theme.textMutedColor,
2224
+ fontSize: theme.typography.size.s1 - 1,
2225
+ flexDirection: "row"
2226
+ // '& > span': {
2227
+ // display: 'block',
2228
+ // whiteSpace: 'nowrap',
2229
+ // overflow: 'hidden',
2230
+ // textOverflow: 'ellipsis',
2231
+ // },
2232
+ // '& > span + span': {
2233
+ // '&:before': {
2234
+ // content: "' / '",
2235
+ // },
2236
+ // },
2237
+ }));
2238
+ var PathText = import_react_native_theming8.styled.Text(({ theme }) => ({
2239
+ fontSize: theme.typography.size.s1 - 1,
2240
+ color: theme.textMutedColor
2241
+ }));
2242
+ var Result = import_react11.default.memo(function Result2({
2243
+ item,
2244
+ matches,
2245
+ icon: _icon,
2246
+ onPress,
2247
+ ...props
2248
+ }) {
2249
+ const press = (0, import_react11.useCallback)(
2250
+ (event) => {
2251
+ event.preventDefault();
2252
+ onPress?.(event);
2253
+ },
2254
+ [onPress]
2255
+ );
2256
+ const nameMatch = matches.find((match) => match.key === "name");
2257
+ const pathMatches = matches.filter((match) => match.key === "path");
2258
+ const [i] = item.status ? statusMapping[item.status] : [];
2259
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ResultRow, { ...props, onPress: press, children: [
2260
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(IconWrapper, { children: [
2261
+ item.type === "component" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ComponentIcon, { width: "14", height: "14" }),
2262
+ item.type === "story" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(StoryIcon, { width: "14", height: "14" })
2263
+ ] }),
2264
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ResultRowContent, { testID: "search-result-item--label", children: [
2265
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Title, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Highlight, { match: nameMatch, children: item.name }, "search-result-item--label-highlight") }),
2266
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Path10, { children: item.path.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native5.View, { style: { flexShrink: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PathText, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2267
+ Highlight,
2268
+ {
2269
+ match: pathMatches.find((match) => match.refIndex === index),
2270
+ children: group
2271
+ }
2272
+ ) }) }, index)) })
2273
+ ] }),
2274
+ item.status ? i : null
2275
+ ] });
2276
+ });
2277
+ var SearchResults = import_react11.default.memo(function SearchResults2({
2278
+ query,
2279
+ results,
2280
+ closeMenu,
2281
+ // getMenuProps,
2282
+ getItemProps,
2283
+ highlightedIndex,
2284
+ // isLoading = false,
2285
+ // enableShortcuts = true,
2286
+ clearLastViewed
2287
+ }) {
2288
+ const handleClearLastViewed = () => {
2289
+ clearLastViewed();
2290
+ closeMenu();
2291
+ };
2292
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ResultsList, { children: [
2293
+ results.length > 0 && !query && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(RecentlyOpenedTitle, { children: [
2294
+ "Recently opened",
2295
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2296
+ IconButton,
2297
+ {
2298
+ onPress: handleClearLastViewed
2299
+ }
2300
+ )
2301
+ ] }),
2302
+ results.length === 0 && query && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native5.View, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(NoResults, { children: [
2303
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native5.Text, { style: { marginBottom: 8 }, children: "No components found" }),
2304
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native5.Text, { children: "Find components by name or path." })
2305
+ ] }) }),
2306
+ results.map((result, index) => {
2307
+ if (isExpandType(result)) {
2308
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MoreWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2309
+ Button,
2310
+ {
2311
+ ...result,
2312
+ ...getItemProps({ key: `${index}`, index, item: result }),
2313
+ size: "small",
2314
+ text: `Show ${result.moreCount} more results`
2315
+ }
2316
+ ) }, "search-result-expand");
2317
+ }
2318
+ const { item } = result;
2319
+ const key = `${item.refId}::${item.id}`;
2320
+ return /* @__PURE__ */ (0, import_react12.createElement)(
2321
+ Result,
2322
+ {
2323
+ ...result,
2324
+ ...getItemProps({ key, index, item: result }),
2325
+ isHighlighted: highlightedIndex === index,
2326
+ key: item.id
2327
+ }
2328
+ );
2329
+ })
2330
+ ] });
2331
+ });
2332
+
2333
+ // src/useLastViewed.ts
2334
+ var import_debounce = __toESM(require_debounce());
2335
+ var import_react13 = require("react");
2336
+ var import_store2 = __toESM(require_store2());
2337
+ var save = (0, import_debounce.default)((value) => import_store2.default.set("lastViewedStoryIds", value), 1e3);
2338
+ var useLastViewed = (selection) => {
2339
+ const initialLastViewedStoryIds = (0, import_react13.useMemo)(() => {
2340
+ const items = import_store2.default.get("lastViewedStoryIds");
2341
+ if (!items || !Array.isArray(items))
2342
+ return [];
2343
+ if (!items.some((item) => typeof item === "object" && item.storyId && item.refId))
2344
+ return [];
2345
+ return items;
2346
+ }, []);
2347
+ const lastViewedRef = (0, import_react13.useRef)(initialLastViewedStoryIds);
2348
+ const updateLastViewed = (0, import_react13.useCallback)(
2349
+ (story) => {
2350
+ const items = lastViewedRef.current;
2351
+ const index = items.findIndex(
2352
+ ({ storyId, refId }) => storyId === story.storyId && refId === story.refId
2353
+ );
2354
+ if (index === 0)
2355
+ return;
2356
+ if (index === -1) {
2357
+ lastViewedRef.current = [story, ...items];
2358
+ } else {
2359
+ lastViewedRef.current = [story, ...items.slice(0, index), ...items.slice(index + 1)];
2360
+ }
2361
+ save(lastViewedRef.current);
2362
+ },
2363
+ [lastViewedRef]
2364
+ );
2365
+ (0, import_react13.useEffect)(() => {
2366
+ if (selection)
2367
+ updateLastViewed(selection);
2368
+ }, [selection]);
2369
+ return {
2370
+ getLastViewed: (0, import_react13.useCallback)(() => lastViewedRef.current, [lastViewedRef]),
2371
+ clearLastViewed: (0, import_react13.useCallback)(() => {
2372
+ lastViewedRef.current = lastViewedRef.current.slice(0, 1);
2373
+ save(lastViewedRef.current);
2374
+ }, [lastViewedRef])
2375
+ };
2376
+ };
2377
+
2378
+ // src/Sidebar.tsx
2379
+ var import_react_native6 = require("react-native");
2380
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2381
+ var Container2 = import_react_native_theming9.styled.View(({ theme }) => ({
2382
+ // position: 'absolute',
2383
+ // zIndex: 1,
2384
+ // left: 0,
2385
+ // top: 0,
2386
+ // bottom: 0,
2387
+ // right: 0,
2388
+ width: "100%",
2389
+ height: "100%",
2390
+ display: "flex",
2391
+ flexDirection: "column",
2392
+ background: theme.background.content
2393
+ // [MEDIA_DESKTOP_BREAKPOINT]: {
2394
+ // background: theme.background.app,
2395
+ // },
2396
+ }));
2397
+ var Top = import_react_native_theming9.styled.View({
2398
+ paddingLeft: 4,
2399
+ paddingRight: 4,
2400
+ // paddingBottom: 20,
2401
+ paddingTop: 16,
2402
+ flex: 1,
2403
+ flexDirection: "row"
2404
+ });
2405
+ var Swap = import_react14.default.memo(function Swap2({
2406
+ children,
2407
+ condition
2408
+ }) {
2409
+ const [a, b] = import_react14.default.Children.toArray(children);
2410
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
2411
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native6.View, { style: { display: condition ? "flex" : "none" }, children: a }),
2412
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react_native6.View, { style: { display: condition ? "none" : "flex" }, children: b })
2413
+ ] });
2414
+ });
2415
+ var useCombination = (index, indexError, previewInitialized, status, refs) => {
2416
+ const hash = (0, import_react14.useMemo)(
2417
+ () => ({
2418
+ [DEFAULT_REF_ID]: {
2419
+ index,
2420
+ indexError,
2421
+ previewInitialized,
2422
+ status,
2423
+ title: null,
2424
+ id: DEFAULT_REF_ID,
2425
+ url: "iframe.html"
2426
+ },
2427
+ ...refs
2428
+ }),
2429
+ [refs, index, indexError, previewInitialized, status]
2430
+ );
2431
+ return (0, import_react14.useMemo)(() => ({ hash, entries: Object.entries(hash) }), [hash]);
2432
+ };
2433
+ var Sidebar = import_react14.default.memo(function Sidebar2({
2434
+ storyId = null,
2435
+ refId = DEFAULT_REF_ID,
2436
+ index,
2437
+ indexError,
2438
+ status,
2439
+ previewInitialized,
2440
+ // menu,
2441
+ // extra,
2442
+ // bottom = [],
2443
+ // menuHighlighted = false,
2444
+ // enableShortcuts = true,
2445
+ refs = {},
2446
+ setSelection
2447
+ }) {
2448
+ const selected = (0, import_react14.useMemo)(() => storyId && { storyId, refId }, [storyId, refId]);
2449
+ const dataset = useCombination(index, indexError, previewInitialized, status, refs);
2450
+ const lastViewedProps = useLastViewed(selected);
2451
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Container2, { style: { paddingHorizontal: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Top, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2452
+ Search,
2453
+ {
2454
+ dataset,
2455
+ setSelection,
2456
+ ...lastViewedProps,
2457
+ children: ({
2458
+ query,
2459
+ results,
2460
+ isBrowsing,
2461
+ closeMenu,
2462
+ // getMenuProps,
2463
+ getItemProps,
2464
+ highlightedIndex
2465
+ }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(Swap, { condition: isBrowsing, children: [
2466
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2467
+ Explorer,
2468
+ {
2469
+ dataset,
2470
+ selected,
2471
+ isLoading: false,
2472
+ isBrowsing,
2473
+ setSelection
2474
+ }
2475
+ ),
2476
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
2477
+ SearchResults,
2478
+ {
2479
+ query,
2480
+ results,
2481
+ closeMenu,
2482
+ getItemProps,
2483
+ highlightedIndex,
2484
+ isLoading: false,
2485
+ clearLastViewed: lastViewedProps.clearLastViewed
2486
+ }
2487
+ )
2488
+ ] })
2489
+ }
2490
+ ) }) });
2491
+ });
2492
+
2493
+ // src/Layout.tsx
2494
+ var import_core_events2 = require("@storybook/core-events");
2495
+ var import_manager_api6 = require("@storybook/manager-api");
2496
+ var import_react_native_theming11 = require("@storybook/react-native-theming");
2497
+ var import_react17 = require("react");
2498
+ var import_react_native9 = require("react-native");
2499
+ var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
2500
+
2501
+ // src/icon/BottomBarToggleIcon.tsx
2502
+ var import_react_native_svg10 = require("react-native-svg");
2503
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2504
+ var BottomBarToggleIcon = ({
2505
+ color = "currentColor",
2506
+ width = 14,
2507
+ height = 14,
2508
+ ...props
2509
+ }) => {
2510
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_react_native_svg10.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: [
2511
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2512
+ import_react_native_svg10.Path,
2513
+ {
2514
+ d: "M3.5 10.004a.5.5 0 000 1h1a.5.5 0 000-1h-1zM6 10.504a.5.5 0 01.5-.5h1a.5.5 0 010 1h-1a.5.5 0 01-.5-.5zM9.5 10.004a.5.5 0 000 1h1a.5.5 0 000-1h-1z",
2515
+ fill: color
2516
+ }
2517
+ ),
2518
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2519
+ import_react_native_svg10.Path,
2520
+ {
2521
+ fillRule: "evenodd",
2522
+ clipRule: "evenodd",
2523
+ d: "M1 12.504v-11a.5.5 0 01.5-.5h11a.5.5 0 01.5.5v11a.5.5 0 01-.5.5h-11a.5.5 0 01-.5-.5zm1-.5v-3h10v3H2zm4.5-4H2v-6h10v6H7.5V5.21l.646.646a.5.5 0 10.708-.707l-1.5-1.5a.5.5 0 00-.708 0l-1.5 1.5a.5.5 0 10.708.707l.646-.646v2.793z",
2524
+ fill: color
2525
+ }
2526
+ )
2527
+ ] });
2528
+ };
2529
+
2530
+ // src/icon/MenuIcon.tsx
2531
+ var import_react_native_svg11 = require("react-native-svg");
2532
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2533
+ var MenuIcon = ({
2534
+ color = "currentColor",
2535
+ width = 14,
2536
+ height = 14,
2537
+ ...props
2538
+ }) => {
2539
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_native_svg11.Svg, { width, height, viewBox: "0 0 14 14", fill: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2540
+ import_react_native_svg11.Path,
2541
+ {
2542
+ d: "M13 3.5a.5.5 0 010 1H1a.5.5 0 010-1h12zM13.5 10a.5.5 0 00-.5-.5H1a.5.5 0 000 1h12a.5.5 0 00.5-.5zM13 6.5a.5.5 0 010 1H1a.5.5 0 010-1h12z",
2543
+ fill: color
2544
+ }
2545
+ ) });
2546
+ };
2547
+
2548
+ // src/MobileMenuDrawer.tsx
2549
+ var import_bottom_sheet2 = require("@gorhom/bottom-sheet");
2550
+ var import_react15 = require("react");
2551
+ var import_react_native7 = require("react-native");
2552
+ var import_react_native_reanimated = require("react-native-reanimated");
2553
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2554
+ var BottomSheetBackdropComponent = (backdropComponentProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2555
+ import_bottom_sheet2.BottomSheetBackdrop,
2556
+ {
2557
+ ...backdropComponentProps,
2558
+ appearsOnIndex: 0,
2559
+ disappearsOnIndex: -1,
2560
+ pressBehavior: "close",
2561
+ style: [backdropComponentProps.style, { backgroundColor: "rgba(0,0,0,0.5)" }]
2562
+ }
2563
+ );
2564
+ var MobileMenuDrawer = (0, import_react15.forwardRef)(
2565
+ ({ children }, ref) => {
2566
+ const [isMobileMenuOpen, setMobileMenuOpen] = (0, import_react15.useState)(false);
2567
+ const reducedMotion = (0, import_react_native_reanimated.useReducedMotion)();
2568
+ const menuBottomSheetRef = (0, import_react15.useRef)(null);
2569
+ (0, import_react15.useImperativeHandle)(ref, () => ({
2570
+ isMobileMenuOpen,
2571
+ setMobileMenuOpen: (open) => {
2572
+ if (open) {
2573
+ setMobileMenuOpen(true);
2574
+ menuBottomSheetRef.current?.present();
2575
+ } else {
2576
+ import_react_native7.Keyboard.dismiss();
2577
+ setMobileMenuOpen(false);
2578
+ menuBottomSheetRef.current?.dismiss();
2579
+ }
2580
+ }
2581
+ }));
2582
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2583
+ import_bottom_sheet2.BottomSheetModal,
2584
+ {
2585
+ ref: menuBottomSheetRef,
2586
+ index: 1,
2587
+ animateOnMount: !reducedMotion,
2588
+ onDismiss: () => {
2589
+ setMobileMenuOpen(false);
2590
+ },
2591
+ snapPoints: ["50%", "75%"],
2592
+ enableDismissOnClose: true,
2593
+ enableHandlePanningGesture: true,
2594
+ enableContentPanningGesture: true,
2595
+ keyboardBehavior: "extend",
2596
+ keyboardBlurBehavior: "restore",
2597
+ stackBehavior: "replace",
2598
+ backdropComponent: BottomSheetBackdropComponent,
2599
+ children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_bottom_sheet2.BottomSheetScrollView, { keyboardShouldPersistTaps: "handled", children })
2600
+ }
2601
+ );
2602
+ }
2603
+ );
2604
+
2605
+ // src/MobileAddonsPanel.tsx
2606
+ var import_bottom_sheet3 = require("@gorhom/bottom-sheet");
2607
+ var import_manager_api5 = require("@storybook/manager-api");
2608
+ var import_react_native_theming10 = require("@storybook/react-native-theming");
2609
+ var import_types3 = __toESM(require_dist());
2610
+ var import_react16 = require("react");
2611
+ var import_react_native8 = require("react-native");
2612
+ var import_react_native_gesture_handler = require("react-native-gesture-handler");
2613
+ var import_react_native_reanimated2 = require("react-native-reanimated");
2614
+ var import_react_native_safe_area_context = require("react-native-safe-area-context");
2615
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2616
+ var MobileAddonsPanel = (0, import_react16.forwardRef)(
2617
+ ({ storyId }, ref) => {
2618
+ const [isAddonsPanelOpen, setAddonsPanelOpen] = (0, import_react16.useState)(false);
2619
+ const reducedMotion = (0, import_react_native_reanimated2.useReducedMotion)();
2620
+ const addonsPanelBottomSheetRef = (0, import_react16.useRef)(null);
2621
+ const insets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
2622
+ const panels = import_manager_api5.addons.getElements(import_types3.Addon_TypesEnum.PANEL);
2623
+ const [addonSelected, setAddonSelected] = (0, import_react16.useState)(Object.keys(panels)[0]);
2624
+ (0, import_react16.useImperativeHandle)(ref, () => ({
2625
+ isAddonsPanelOpen,
2626
+ setAddonsPanelOpen: (open) => {
2627
+ if (open) {
2628
+ setAddonsPanelOpen(true);
2629
+ addonsPanelBottomSheetRef.current?.present();
2630
+ } else {
2631
+ setAddonsPanelOpen(false);
2632
+ addonsPanelBottomSheetRef.current?.dismiss();
2633
+ }
2634
+ }
2635
+ }));
2636
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2637
+ import_bottom_sheet3.BottomSheetModal,
2638
+ {
2639
+ ref: addonsPanelBottomSheetRef,
2640
+ index: 1,
2641
+ animateOnMount: !reducedMotion,
2642
+ onDismiss: () => {
2643
+ setAddonsPanelOpen(false);
2644
+ },
2645
+ snapPoints: ["25%", "50%"],
2646
+ style: {
2647
+ paddingTop: 8
2648
+ },
2649
+ containerStyle: {},
2650
+ backgroundStyle: {
2651
+ borderRadius: 0,
2652
+ borderTopColor: "lightgrey",
2653
+ borderTopWidth: 1
2654
+ },
2655
+ keyboardBehavior: "interactive",
2656
+ keyboardBlurBehavior: "restore",
2657
+ enableDismissOnClose: true,
2658
+ enableHandlePanningGesture: true,
2659
+ enableContentPanningGesture: true,
2660
+ stackBehavior: "replace",
2661
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react_native8.View, { style: { flex: 1 }, children: [
2662
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react_native8.View, { style: { flexDirection: "row" }, children: [
2663
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2664
+ import_react_native_gesture_handler.ScrollView,
2665
+ {
2666
+ horizontal: true,
2667
+ showsHorizontalScrollIndicator: false,
2668
+ contentContainerStyle: {
2669
+ paddingHorizontal: 8,
2670
+ // alignItems: 'center',
2671
+ justifyContent: "center"
2672
+ },
2673
+ children: Object.values(panels).map(({ id, title }) => {
2674
+ const resolvedTitle = typeof title === "function" ? title({}) : title;
2675
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2676
+ Tab,
2677
+ {
2678
+ active: id === addonSelected,
2679
+ onPress: () => setAddonSelected(id),
2680
+ text: resolvedTitle
2681
+ },
2682
+ id
2683
+ );
2684
+ })
2685
+ }
2686
+ ),
2687
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2688
+ IconButton,
2689
+ {
2690
+ style: {
2691
+ marginRight: 4,
2692
+ marginBottom: 4,
2693
+ alignItems: "center",
2694
+ justifyContent: "center"
2695
+ },
2696
+ hitSlop: { top: 10, right: 10, bottom: 10, left: 10 },
2697
+ Icon: CloseIcon,
2698
+ onPress: () => {
2699
+ setAddonsPanelOpen(false);
2700
+ addonsPanelBottomSheetRef.current?.dismiss();
2701
+ }
2702
+ }
2703
+ )
2704
+ ] }),
2705
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2706
+ import_bottom_sheet3.BottomSheetScrollView,
2707
+ {
2708
+ keyboardShouldPersistTaps: "handled",
2709
+ contentContainerStyle: {
2710
+ paddingBottom: insets.bottom + 16,
2711
+ marginTop: 10,
2712
+ paddingHorizontal: 16
2713
+ },
2714
+ children: (() => {
2715
+ if (!storyId) {
2716
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_native8.View, { style: { alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_native8.Text, { children: "No Story Selected" }) });
2717
+ }
2718
+ if (Object.keys(panels).length === 0) {
2719
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_native8.View, { style: { alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_react_native8.Text, { children: "No addons loaded." }) });
2720
+ }
2721
+ return panels[addonSelected].render({ active: true });
2722
+ })()
2723
+ }
2724
+ )
2725
+ ] })
2726
+ }
2727
+ );
2728
+ }
2729
+ );
2730
+ var Tab = ({ active, onPress, text }) => {
2731
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TabButton, { active, onPress, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(TabText, { active, children: text }) });
2732
+ };
2733
+ var TabButton = import_react_native_theming10.styled.TouchableOpacity(({ theme, active }) => ({
2734
+ borderBottomWidth: active ? 2 : 0,
2735
+ borderBottomColor: active ? theme.barSelectedColor : void 0,
2736
+ overflow: "hidden",
2737
+ paddingHorizontal: 15,
2738
+ justifyContent: "center",
2739
+ alignItems: "center"
2740
+ }));
2741
+ var TabText = import_react_native_theming10.styled.Text(({ theme, active }) => ({
2742
+ color: active ? theme.barSelectedColor : theme.color.mediumdark,
2743
+ textAlign: "center",
2744
+ fontWeight: "bold",
2745
+ fontSize: 13,
2746
+ lineHeight: 12
2747
+ }));
2748
+
2749
+ // src/Layout.tsx
2750
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2751
+ var Layout = ({
2752
+ storyHash,
2753
+ story,
2754
+ children
2755
+ }) => {
2756
+ const theme = (0, import_react_native_theming11.useTheme)();
2757
+ const mobileMenuDrawerRef = (0, import_react17.useRef)(null);
2758
+ const addonPanelRef = (0, import_react17.useRef)(null);
2759
+ const insets = (0, import_react_native_safe_area_context2.useSafeAreaInsets)();
2760
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react_native9.View, { style: { flex: 1, paddingTop: insets.top }, children: [
2761
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react_native9.View, { style: { flex: 1 }, children }),
2762
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MobileMenuDrawer, { ref: mobileMenuDrawerRef, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2763
+ Sidebar,
2764
+ {
2765
+ extra: [],
2766
+ previewInitialized: true,
2767
+ indexError: void 0,
2768
+ refs: {},
2769
+ setSelection: ({ storyId: newStoryId }) => {
2770
+ const channel = import_manager_api6.addons.getChannel();
2771
+ channel.emit(import_core_events2.SET_CURRENT_STORY, { storyId: newStoryId });
2772
+ },
2773
+ status: {},
2774
+ index: storyHash,
2775
+ storyId: story?.id,
2776
+ refId: DEFAULT_REF_ID
2777
+ }
2778
+ ) }),
2779
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MobileAddonsPanel, { ref: addonPanelRef, storyId: story.id }),
2780
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Container3, { style: { marginBottom: insets.bottom }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(Nav, { children: [
2781
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
2782
+ Button2,
2783
+ {
2784
+ hitSlop: { bottom: 10, left: 10, right: 10, top: 10 },
2785
+ onPress: () => mobileMenuDrawerRef.current.setMobileMenuOpen(true),
2786
+ children: [
2787
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(MenuIcon, { color: theme.color.mediumdark }),
2788
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react_native9.Text, { children: [
2789
+ story.title,
2790
+ "/",
2791
+ story.name
2792
+ ] })
2793
+ ]
2794
+ }
2795
+ ),
2796
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2797
+ IconButton,
2798
+ {
2799
+ onPress: () => addonPanelRef.current.setAddonsPanelOpen(true),
2800
+ Icon: BottomBarToggleIcon
2801
+ }
2802
+ )
2803
+ ] }) })
2804
+ ] });
2805
+ };
2806
+ var Nav = import_react_native_theming11.styled.View({
2807
+ display: "flex",
2808
+ flexDirection: "row",
2809
+ alignItems: "center",
2810
+ justifyContent: "space-between",
2811
+ width: "100%",
2812
+ height: 40,
2813
+ paddingHorizontal: 12
2814
+ });
2815
+ var Container3 = import_react_native_theming11.styled.View(({ theme }) => ({
2816
+ alignSelf: "flex-end",
2817
+ width: "100%",
2818
+ zIndex: 10,
2819
+ background: theme.barBg,
2820
+ borderTopColor: theme.appBorderColor,
2821
+ borderTopWidth: 1
2822
+ }));
2823
+ var Button2 = import_react_native_theming11.styled.TouchableOpacity(({ theme }) => ({
2824
+ display: "flex",
2825
+ flexDirection: "row",
2826
+ alignItems: "center",
2827
+ gap: 10,
2828
+ color: theme.color.mediumdark,
2829
+ fontSize: theme.typography.size?.s2 - 1,
2830
+ paddingHorizontal: 7,
2831
+ fontWeight: theme.typography.weight.bold
2832
+ }));
2833
+ // Annotate the CommonJS export names for ESM import in node:
2834
+ 0 && (module.exports = {
2835
+ Button,
2836
+ ButtonIcon,
2837
+ ButtonText,
2838
+ ComponentNode,
2839
+ Explorer,
2840
+ GroupNode,
2841
+ IconButton,
2842
+ Layout,
2843
+ LayoutProvider,
2844
+ LeafNodeStyleWrapper,
2845
+ Node,
2846
+ RootNode,
2847
+ RootNodeText,
2848
+ Sidebar,
2849
+ StoryNode,
2850
+ Tree,
2851
+ isExpandType,
2852
+ useCombination,
2853
+ useLayout
2854
+ });
2855
+ /*! Bundled license information:
2856
+
2857
+ store2/dist/store2.js:
2858
+ (*! store2 - v2.14.3 - 2024-02-14
2859
+ * Copyright (c) 2024 Nathan Bubna; Licensed MIT *)
2860
+ */