@stackflow/plugin-basic-ui 1.10.1-canary.3 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -32,7 +32,9 @@ var IconBack = (props) => /* @__PURE__ */ jsx(
32
32
  children: /* @__PURE__ */ jsx(
33
33
  "path",
34
34
  {
35
- d: "M16.66 3.23C16.96 3.53 16.96 4.02 16.66 4.32L8.97999 12L16.66 19.68C16.96 19.98 16.96 20.47 16.66 20.77C16.36 21.07 15.87 21.07 15.57 20.77L7.33999 12.55C7.03999 12.25 7.03999 11.76 7.33999 11.46L15.56 3.23C15.86 2.93 16.35 2.93 16.65 3.23H16.66Z",
35
+ fillRule: "evenodd",
36
+ clipRule: "evenodd",
37
+ d: "M16.7241 2.76052C17.105 3.16043 17.0896 3.79341 16.6897 4.17431L8.45 12.0222L16.6896 19.8689C17.0896 20.2498 17.105 20.8827 16.7242 21.2827C16.3433 21.6826 15.7103 21.6981 15.3104 21.3172L6.31037 12.7464C6.11218 12.5576 6.00001 12.2959 6 12.0222C5.99999 11.7486 6.11215 11.4868 6.31032 11.2981L15.3103 2.72608C15.7102 2.34518 16.3432 2.3606 16.7241 2.76052Z",
36
38
  fill: "currentColor"
37
39
  }
38
40
  )
@@ -41,8 +43,8 @@ var IconBack = (props) => /* @__PURE__ */ jsx(
41
43
  var IconBack_default = IconBack;
42
44
 
43
45
  // src/assets/IconClose.tsx
44
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
45
- var IconClose = (props) => /* @__PURE__ */ jsxs(
46
+ import { jsx as jsx2 } from "react/jsx-runtime";
47
+ var IconClose = (props) => /* @__PURE__ */ jsx2(
46
48
  "svg",
47
49
  {
48
50
  className: props.className,
@@ -51,22 +53,13 @@ var IconClose = (props) => /* @__PURE__ */ jsxs(
51
53
  viewBox: "0 0 24 24",
52
54
  fill: "none",
53
55
  xmlns: "http://www.w3.org/2000/svg",
54
- children: [
55
- /* @__PURE__ */ jsx2(
56
- "path",
57
- {
58
- d: "M6.56588 5.43433C6.25346 5.12191 5.74693 5.12191 5.43451 5.43433C5.12209 5.74675 5.12209 6.25328 5.43451 6.5657L10.8688 12L5.43451 17.4343C5.12209 17.7467 5.12209 18.2533 5.43451 18.5657C5.74693 18.8781 6.25346 18.8781 6.56588 18.5657L12.0002 13.1314L17.4345 18.5657C17.7469 18.8781 18.2535 18.8781 18.5659 18.5657C18.8783 18.2533 18.8783 17.7467 18.5659 17.4343L13.1316 12L18.5659 6.5657C18.8783 6.25328 18.8783 5.74675 18.5659 5.43433C18.2535 5.12191 17.7469 5.12191 17.4345 5.43433L12.0002 10.8686L6.56588 5.43433Z",
59
- fill: "currentColor"
60
- }
61
- ),
62
- /* @__PURE__ */ jsx2(
63
- "path",
64
- {
65
- d: "M6.56588 5.43433C6.25346 5.12191 5.74693 5.12191 5.43451 5.43433C5.12209 5.74675 5.12209 6.25328 5.43451 6.5657L10.8688 12L5.43451 17.4343C5.12209 17.7467 5.12209 18.2533 5.43451 18.5657C5.74693 18.8781 6.25346 18.8781 6.56588 18.5657L12.0002 13.1314L17.4345 18.5657C17.7469 18.8781 18.2535 18.8781 18.5659 18.5657C18.8783 18.2533 18.8783 17.7467 18.5659 17.4343L13.1316 12L18.5659 6.5657C18.8783 6.25328 18.8783 5.74675 18.5659 5.43433C18.2535 5.12191 17.7469 5.12191 17.4345 5.43433L12.0002 10.8686L6.56588 5.43433Z",
66
- fill: "currentColor"
67
- }
68
- )
69
- ]
56
+ children: /* @__PURE__ */ jsx2(
57
+ "path",
58
+ {
59
+ d: "M20.7071 4.70711C21.0976 4.31658 21.0976 3.68342 20.7071 3.29289C20.3166 2.90237 19.6834 2.90237 19.2929 3.29289L12 10.5858L4.70711 3.29289C4.31658 2.90237 3.68342 2.90237 3.29289 3.29289C2.90237 3.68342 2.90237 4.31658 3.29289 4.70711L10.5858 12L3.29289 19.2929C2.90237 19.6834 2.90237 20.3166 3.29289 20.7071C3.68342 21.0976 4.31658 21.0976 4.70711 20.7071L12 13.4142L19.2929 20.7071C19.6834 21.0976 20.3166 21.0976 20.7071 20.7071C21.0976 20.3166 21.0976 19.6834 20.7071 19.2929L13.4142 12L20.7071 4.70711Z",
60
+ fill: "currentColor"
61
+ }
62
+ )
70
63
  }
71
64
  );
72
65
  var IconClose_default = IconClose;
@@ -77,7 +70,7 @@ import { createContext, useContext } from "react";
77
70
 
78
71
  // src/basicUIPlugin.css.ts
79
72
  import { createRuntimeFn as _7a468 } from "@vanilla-extract/recipes/createRuntimeFn";
80
- var globalVars = { backgroundColor: "var(--stackflow-plugin-basic-ui-background-color)", dimBackgroundColor: "var(--stackflow-plugin-basic-ui-dim-background-color)", transitionDuration: "var(--stackflow-plugin-basic-ui-transition-duration)", computedTransitionDuration: "var(--stackflow-plugin-basic-ui-computed-transition-duration)", appBar: { borderColor: "var(--stackflow-plugin-basic-ui-app-bar-border-color)", borderColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-border-color-transition-duration)", borderSize: "var(--stackflow-plugin-basic-ui-app-bar-border-size)", height: "var(--stackflow-plugin-basic-ui-app-bar-height)", heightTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-height-transition-duration)", minHeight: "var(--stackflow-plugin-basic-ui-app-bar-min-height)", iconColor: "var(--stackflow-plugin-basic-ui-app-bar-icon-color)", iconColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-icon-color-transition-duration)", textColor: "var(--stackflow-plugin-basic-ui-app-bar-text-color)", textColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-text-color-transition-duration)", backgroundColor: "var(--stackflow-plugin-basic-ui-app-bar-background-color)", backgroundColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-background-color-transition-duration)", overflow: "var(--stackflow-plugin-basic-ui-app-bar-overflow)", minSafeAreaInsetTop: "var(--stackflow-plugin-basic-ui-app-bar-min-safe-area-inset-top)" }, bottomSheet: { borderRadius: "var(--stackflow-plugin-basic-ui-bottom-sheet-border-radius)" }, modal: { borderRadius: "var(--stackflow-plugin-basic-ui-bottom-sheet-border-radius)" } };
73
+ var globalVars = { backgroundColor: "var(--stackflow-plugin-basic-ui-background-color)", dimBackgroundColor: "var(--stackflow-plugin-basic-ui-dim-background-color)", transitionDuration: "var(--stackflow-plugin-basic-ui-transition-duration)", computedTransitionDuration: "var(--stackflow-plugin-basic-ui-computed-transition-duration)", appBar: { borderColor: "var(--stackflow-plugin-basic-ui-app-bar-border-color)", borderColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-border-color-transition-duration)", borderSize: "var(--stackflow-plugin-basic-ui-app-bar-border-size)", height: "var(--stackflow-plugin-basic-ui-app-bar-height)", heightTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-height-transition-duration)", minHeight: "var(--stackflow-plugin-basic-ui-app-bar-min-height)", iconColor: "var(--stackflow-plugin-basic-ui-app-bar-icon-color)", iconColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-icon-color-transition-duration)", textColor: "var(--stackflow-plugin-basic-ui-app-bar-text-color)", textColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-text-color-transition-duration)", backgroundColor: "var(--stackflow-plugin-basic-ui-app-bar-background-color)", backgroundColorTransitionDuration: "var(--stackflow-plugin-basic-ui-app-bar-background-color-transition-duration)", overflow: "var(--stackflow-plugin-basic-ui-app-bar-overflow)", minSafeAreaInsetTop: "var(--stackflow-plugin-basic-ui-app-bar-min-safe-area-inset-top)" }, bottomSheet: { borderRadius: "var(--stackflow-plugin-basic-ui-bottom-sheet-border-radius)" }, modal: { borderRadius: "var(--stackflow-plugin-basic-ui-modal-border-radius)", maxWidth: "var(--stackflow-plugin-basic-ui-modal-max-width)" } };
81
74
  var stackWrapper = _7a468({ defaultClassName: "_1q6dj2j2", variantClassNames: { theme: { android: "_1q6dj2j0", cupertino: "_1q6dj2j1" }, loading: { true: "_1q6dj2j5" } }, defaultVariants: {}, compoundVariants: [] });
82
75
 
83
76
  // src/utils/compact.ts
@@ -153,39 +146,42 @@ var basicUIPlugin = (options) => () => ({
153
146
 
154
147
  // src/components/AppScreen.tsx
155
148
  import { useActions as useActions2 } from "@stackflow/react";
156
- import { assignInlineVars as assignInlineVars3 } from "@vanilla-extract/dynamic";
157
- import { createContext as createContext2, useContext as useContext2, useMemo, useRef as useRef2 } from "react";
158
149
  import {
150
+ useActivityDataAttributes as useActivityDataAttributes2,
159
151
  useLazy,
160
- useMounted,
152
+ useMounted as useMounted2,
161
153
  useNullableActivity as useNullableActivity2,
162
154
  useStyleEffectHide,
163
155
  useStyleEffectOffset,
164
156
  useStyleEffectSwipeBack,
165
157
  useZIndexBase
166
158
  } from "@stackflow/react-ui-core";
159
+ import { assignInlineVars as assignInlineVars3 } from "@vanilla-extract/dynamic";
160
+ import { createContext as createContext2, useContext as useContext2, useMemo, useRef as useRef2 } from "react";
167
161
 
168
162
  // src/components/AppBar.tsx
169
163
  import { useActions } from "@stackflow/react";
170
- import { assignInlineVars as assignInlineVars2 } from "@vanilla-extract/dynamic";
171
- import { forwardRef, useRef } from "react";
172
164
  import {
165
+ useActivityDataAttributes,
173
166
  useAppBarTitleMaxWidth,
167
+ useMounted,
174
168
  useNullableActivity
175
169
  } from "@stackflow/react-ui-core";
170
+ import { assignInlineVars as assignInlineVars2 } from "@vanilla-extract/dynamic";
171
+ import { forwardRef, useRef } from "react";
176
172
 
177
173
  // src/components/AppBar.css.ts
178
174
  import { createRuntimeFn as _7a4682 } from "@vanilla-extract/recipes/createRuntimeFn";
179
175
  var appBar = _7a4682({ defaultClassName: "_1yk3a452 dhthxq4 dhthxq0 dhthxqh _1dlf4348 _1yk3a451", variantClassNames: { border: { true: "_1yk3a453" }, modalPresentationStyle: { fullScreen: "_1yk3a454" }, activityEnterStyle: { slideInLeft: "_1yk3a455" } }, defaultVariants: {}, compoundVariants: [] });
180
176
  var backButton = "_1yk3a459 dhthxq9 dhthxq7 dhthxqb dhthxqf dhthxqi";
181
177
  var center = "dhthxq9 dhthxq7 dhthxq8 _1yk3a450";
182
- var centerMain = _7a4682({ defaultClassName: "_1yk3a45c", variantClassNames: { hasLeft: { true: "_1yk3a45d" } }, defaultVariants: {}, compoundVariants: [] });
183
- var centerMainEdge = "_1yk3a45e dhthxqi dhthxq4 dhthxq2 dhthxqf";
184
- var centerText = "_1yk3a45f dhthxqc dhthxqd dhthxq0";
178
+ var centerMain = "_1yk3a45c";
179
+ var centerMainEdge = "_1yk3a45d dhthxqi dhthxq4 dhthxq2 dhthxqf";
180
+ var centerText = "_1yk3a45e dhthxqc dhthxqd dhthxq0";
185
181
  var closeButton = "_1yk3a459 dhthxq9 dhthxq7 dhthxqb dhthxqf dhthxqi";
186
182
  var container = "_1yk3a457 dhthxqa dhthxq7 _1yk3a451";
187
183
  var left = "_1yk3a458 dhthxq9 dhthxq7 dhthxq1 _1yk3a450";
188
- var right = "_1yk3a45g dhthxq9 dhthxq7 dhthxq1 dhthxq5 _1yk3a450";
184
+ var right = "_1yk3a45f dhthxq9 dhthxq7 dhthxq1 dhthxq5 _1yk3a450";
189
185
  var safeArea = "_1yk3a456";
190
186
 
191
187
  // src/components/AppScreen.css.ts
@@ -201,7 +197,7 @@ var paper = _7a4683({ defaultClassName: "_1dlf434k dhthxq4 dhthxq0 dhthxq1 dhthx
201
197
  var vars = { transitionDuration: "var(--_1dlf4340)", zIndexes: { dim: "var(--_1dlf4341)", paper: "var(--_1dlf4342)", edge: "var(--_1dlf4343)", appBar: "var(--_1dlf4344)" }, appBar: { topMargin: "var(--_1dlf4345)", center: { mainWidth: "var(--_1dlf4346)" } } };
202
198
 
203
199
  // src/components/AppBar.tsx
204
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
200
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
205
201
  var AppBar = forwardRef(
206
202
  ({
207
203
  title,
@@ -230,6 +226,8 @@ var AppBar = forwardRef(
230
226
  var _a, _b;
231
227
  const actions = useActions();
232
228
  const activity = useNullableActivity();
229
+ const activityDataAttributes = useActivityDataAttributes();
230
+ const mounted = useMounted();
233
231
  const globalOptions = useGlobalOptions();
234
232
  const globalCloseButton = (_a = globalOptions.appBar) == null ? void 0 : _a.closeButton;
235
233
  const globalBackButton = (_b = globalOptions.appBar) == null ? void 0 : _b.backButton;
@@ -336,10 +334,9 @@ var AppBar = forwardRef(
336
334
  }
337
335
  );
338
336
  };
339
- const hasLeft = !!(closeButtonLocation === "left" && closeButton2 || backButton2 || renderLeft);
340
- return /* @__PURE__ */ jsxs2(
337
+ return /* @__PURE__ */ jsxs(
341
338
  "div",
342
- {
339
+ __spreadProps(__spreadValues({
343
340
  ref,
344
341
  className: appBar({
345
342
  border,
@@ -363,40 +360,34 @@ var AppBar = forwardRef(
363
360
  [vars.appBar.center.mainWidth]: `${maxWidth}px`
364
361
  })
365
362
  ),
363
+ "data-part": "appBar"
364
+ }, activityDataAttributes), {
366
365
  children: [
367
366
  /* @__PURE__ */ jsx4("div", { className: safeArea }),
368
- /* @__PURE__ */ jsxs2("div", { className: container, children: [
369
- /* @__PURE__ */ jsxs2("div", { className: left, children: [
367
+ /* @__PURE__ */ jsxs("div", { className: container, children: [
368
+ /* @__PURE__ */ jsxs("div", { className: left, children: [
370
369
  closeButtonLocation === "left" && renderCloseButton(),
371
370
  renderBackButton(),
372
371
  renderLeft == null ? void 0 : renderLeft()
373
372
  ] }),
374
- /* @__PURE__ */ jsx4("div", { ref: centerRef, className: center, children: /* @__PURE__ */ jsxs2(
375
- "div",
376
- {
377
- className: centerMain({
378
- hasLeft
379
- }),
380
- children: [
381
- typeof title === "string" ? /* @__PURE__ */ jsx4("div", { className: centerText, children: title }) : title,
382
- /* @__PURE__ */ jsx4(
383
- "button",
384
- {
385
- className: centerMainEdge,
386
- type: "button",
387
- onClick: onTopClick
388
- }
389
- )
390
- ]
391
- }
392
- ) }),
393
- /* @__PURE__ */ jsxs2("div", { className: right, children: [
373
+ /* @__PURE__ */ jsx4("div", { ref: centerRef, className: center, children: /* @__PURE__ */ jsxs("div", { className: centerMain, children: [
374
+ typeof title === "string" ? /* @__PURE__ */ jsx4("div", { className: centerText, children: title }) : title,
375
+ /* @__PURE__ */ jsx4(
376
+ "button",
377
+ {
378
+ className: centerMainEdge,
379
+ type: "button",
380
+ onClick: onTopClick
381
+ }
382
+ )
383
+ ] }) }),
384
+ /* @__PURE__ */ jsxs("div", { className: right, children: [
394
385
  renderRight == null ? void 0 : renderRight(),
395
386
  closeButtonLocation === "right" && renderCloseButton()
396
387
  ] })
397
388
  ] })
398
389
  ]
399
- }
390
+ })
400
391
  );
401
392
  }
402
393
  );
@@ -404,7 +395,7 @@ AppBar.displayName = "AppBar";
404
395
  var AppBar_default = AppBar;
405
396
 
406
397
  // src/components/AppScreen.tsx
407
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
398
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
408
399
  var OFFSET_PX_ANDROID = 32;
409
400
  var OFFSET_PX_CUPERTINO = 80;
410
401
  var Context = createContext2(null);
@@ -423,7 +414,8 @@ var AppScreen = ({
423
414
  var _a;
424
415
  const globalOptions = useGlobalOptions();
425
416
  const activity = useNullableActivity2();
426
- const mounted = useMounted();
417
+ const activityDataAttributes = useActivityDataAttributes2();
418
+ const mounted = useMounted2();
427
419
  const { pop } = useActions2();
428
420
  const appScreenRef = useRef2(null);
429
421
  const dimRef = useRef2(null);
@@ -479,6 +471,7 @@ var AppScreen = ({
479
471
  dimRef,
480
472
  edgeRef,
481
473
  paperRef,
474
+ appBarRef,
482
475
  offset: OFFSET_PX_CUPERTINO,
483
476
  transitionDuration: globalVars.transitionDuration,
484
477
  preventSwipeBack: isSwipeBackPrevented || globalOptions.theme !== "cupertino",
@@ -502,8 +495,10 @@ var AppScreen = ({
502
495
  }
503
496
  return null;
504
497
  },
505
- onSwiped() {
506
- pop();
498
+ onSwipeEnd({ swiped }) {
499
+ if (swiped) {
500
+ pop();
501
+ }
507
502
  }
508
503
  });
509
504
  const onAppBarTopClick = (e) => {
@@ -537,9 +532,9 @@ var AppScreen = ({
537
532
  }),
538
533
  [paperRef, zIndexDim, zIndexPaper, zIndexEdge, zIndexAppBar]
539
534
  ),
540
- children: /* @__PURE__ */ jsxs3(
535
+ children: /* @__PURE__ */ jsxs2(
541
536
  "div",
542
- {
537
+ __spreadProps(__spreadValues({
543
538
  ref: appScreenRef,
544
539
  className: appScreen({
545
540
  transitionState: transitionState === "enter-done" || transitionState === "exit-done" ? transitionState : lazyTransitionState
@@ -557,11 +552,17 @@ var AppScreen = ({
557
552
  [vars.transitionDuration]: transitionState === "enter-active" || transitionState === "exit-active" ? globalVars.computedTransitionDuration : "0ms"
558
553
  })
559
554
  ),
560
- "data-stackflow-component-name": "AppScreen",
561
- "data-stackflow-activity-id": mounted ? activity == null ? void 0 : activity.id : void 0,
562
- "data-stackflow-activity-is-active": mounted ? activity == null ? void 0 : activity.isActive : void 0,
555
+ "data-stackflow-component-name": "AppScreen"
556
+ }, activityDataAttributes), {
563
557
  children: [
564
- activityEnterStyle !== "slideInLeft" && /* @__PURE__ */ jsx5("div", { className: dim, ref: dimRef }),
558
+ activityEnterStyle !== "slideInLeft" && /* @__PURE__ */ jsx5(
559
+ "div",
560
+ __spreadValues({
561
+ ref: dimRef,
562
+ className: dim,
563
+ "data-part": "dim"
564
+ }, activityDataAttributes)
565
+ ),
565
566
  appBar2 && /* @__PURE__ */ jsx5(
566
567
  AppBar_default,
567
568
  __spreadProps(__spreadValues({}, appBar2), {
@@ -573,20 +574,29 @@ var AppScreen = ({
573
574
  ),
574
575
  /* @__PURE__ */ jsx5(
575
576
  "div",
576
- {
577
+ __spreadProps(__spreadValues({
578
+ ref: paperRef,
577
579
  className: paper({
578
580
  hasAppBar,
579
581
  modalPresentationStyle,
580
582
  activityEnterStyle
581
583
  }),
582
- ref: paperRef,
584
+ "data-part": "paper"
585
+ }, activityDataAttributes), {
583
586
  children
584
- },
587
+ }),
585
588
  activity == null ? void 0 : activity.id
586
589
  ),
587
- !(activity == null ? void 0 : activity.isRoot) && globalOptions.theme === "cupertino" && !isSwipeBackPrevented && /* @__PURE__ */ jsx5("div", { className: edge({ hasAppBar }), ref: edgeRef })
590
+ !(activity == null ? void 0 : activity.isRoot) && globalOptions.theme === "cupertino" && !isSwipeBackPrevented && /* @__PURE__ */ jsx5(
591
+ "div",
592
+ __spreadValues({
593
+ ref: edgeRef,
594
+ className: edge({ hasAppBar }),
595
+ "data-part": "edge"
596
+ }, activityDataAttributes)
597
+ )
588
598
  ]
589
- }
599
+ })
590
600
  )
591
601
  }
592
602
  );
@@ -707,6 +717,7 @@ var Modal = ({
707
717
  backgroundColor,
708
718
  dimBackgroundColor,
709
719
  borderRadius = "1rem",
720
+ maxWidth,
710
721
  onOutsideClick,
711
722
  children
712
723
  }) => {
@@ -754,9 +765,10 @@ var Modal = ({
754
765
  ref: containerRef,
755
766
  style: assignInlineVars5(
756
767
  compactMap({
757
- [globalVars.bottomSheet.borderRadius]: borderRadius,
758
768
  [globalVars.backgroundColor]: backgroundColor,
759
769
  [globalVars.dimBackgroundColor]: dimBackgroundColor,
770
+ [globalVars.modal.borderRadius]: borderRadius,
771
+ [globalVars.modal.maxWidth]: maxWidth,
760
772
  [vars3.zIndexes.dim]: `${zIndexBase}`,
761
773
  [vars3.zIndexes.paper]: `${zIndexPaper}`,
762
774
  [vars3.transitionDuration]: transitionState === "enter-active" || transitionState === "exit-active" ? globalVars.computedTransitionDuration : "0ms"