@parrot-co/parrot-ui 0.0.84 → 0.0.85

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/main.js CHANGED
@@ -205,15 +205,16 @@ $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011.displayName = "Flex";
205
205
 
206
206
 
207
207
  const $c46ecb47aa6f4da1$export$5f1af8db9871e1d6 = (props)=>{
208
- const { size: size , weight: weight , color: color = "gray" , variant: variant = "default" , highlight: highlight , align: align , lineHeight: lineHeight , underline: underline , italic: italic , as: Tag = "span" , textRef: textRef , className: className , ...rest } = props;
209
- return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)(Tag, {
208
+ const { textCase: textCase , size: size , weight: weight , color: color = "gray" , variant: variant = "default" , highlight: highlight , align: align , lineHeight: lineHeight , underline: underline , italic: italic , as: Comp = "span" , textRef: textRef , className: className , ...rest } = props;
209
+ return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)(Comp, {
210
210
  className: (0, $5d3f3512fadee416$export$a274e22fb40f762e)({
211
211
  [`text-highlight`]: !!highlight,
212
212
  "p-text": true,
213
213
  [`text-size-${size}`]: !!size,
214
214
  [`text-weight-${weight}`]: !!weight,
215
- [`text-alight-${align}`]: !!align,
215
+ [`text-align-${align}`]: !!align,
216
216
  [`text-line-height-${lineHeight}`]: !!lineHeight,
217
+ [`text-transform-${textCase}`]: !!textCase,
217
218
  [`${className}`]: !!className
218
219
  }),
219
220
  "data-underline": underline,
@@ -608,7 +609,8 @@ const $50596a59d1a82779$export$353f5b6fc5456de1 = /*#__PURE__*/ (0, ($parcel$int
608
609
  prepend,
609
610
  /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("span", {
610
611
  style: {
611
- padding: isIconButton ? undefined : "0 6px"
612
+ padding: isIconButton ? undefined : "0 6px",
613
+ lineHeight: 0
612
614
  },
613
615
  children: children
614
616
  }),
@@ -889,12 +891,12 @@ const $8e816824e7d3bbe8$export$48513f6b9f8ce62d = /*#__PURE__*/ (0, ($parcel$int
889
891
  className: "fake-checkbox",
890
892
  "data-focused": isFocusVisible,
891
893
  "aria-hidden": "true",
892
- "data-checked": isSelected,
894
+ "data-checked": isSelected && !props.isIndeterminate,
893
895
  "data-indeterminate": props.isIndeterminate,
894
896
  "data-size": resolvedSize,
895
897
  "data-appearance": resolvedAppearance,
896
898
  children: [
897
- isSelected && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("svg", {
899
+ isSelected && !props.isIndeterminate && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("svg", {
898
900
  stroke: "white",
899
901
  width: "0.75rem",
900
902
  height: "0.75rem",
@@ -912,7 +914,7 @@ const $8e816824e7d3bbe8$export$48513f6b9f8ce62d = /*#__PURE__*/ (0, ($parcel$int
912
914
  }),
913
915
  props.isIndeterminate && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $f9c6775c22423d58$export$e71c4d32a2263218), {
914
916
  style: {
915
- background: "$gray11",
917
+ background: "var(--color-12)",
916
918
  width: "70%",
917
919
  height: 2,
918
920
  borderRadius: 4
@@ -1103,7 +1105,26 @@ function $d14b866db34f150f$export$3d7d0414f6db67e7({ children: children , render
1103
1105
 
1104
1106
 
1105
1107
 
1106
- function $895088a96d07d13e$export$41f133550aa26f48({ state: state , color: color , width: width = 300 , ...props }) {
1108
+
1109
+
1110
+
1111
+ const $7815c8512dae20d4$var$ListBoxContext = /*#__PURE__*/ $4Lhmj$react.createContext(null);
1112
+ function $7815c8512dae20d4$export$1e60abce570c2b01(props) {
1113
+ return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)($7815c8512dae20d4$var$ListBoxContext.Provider, {
1114
+ value: {
1115
+ props: props
1116
+ },
1117
+ children: props.children
1118
+ });
1119
+ }
1120
+ function $7815c8512dae20d4$export$961f16f221737ce2() {
1121
+ const context = $4Lhmj$react.useContext($7815c8512dae20d4$var$ListBoxContext);
1122
+ if (!context) throw new Error("ListBox components must be rendered within the ListBoxProvider");
1123
+ return context;
1124
+ }
1125
+
1126
+
1127
+ function $895088a96d07d13e$export$41f133550aa26f48({ state: state , color: color , width: width = 300 , showSelectedMarker: showSelectedMarker = true , ...props }) {
1107
1128
  const internalState = (0, $4Lhmj$reactstately.useListState)({
1108
1129
  ...props,
1109
1130
  children: (0, $d14b866db34f150f$export$3d7d0414f6db67e7)(props)
@@ -1114,23 +1135,18 @@ function $895088a96d07d13e$export$41f133550aa26f48({ state: state , color: color
1114
1135
  const options = [
1115
1136
  ...listState.collection
1116
1137
  ];
1117
- return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1118
- "data-color": color,
1119
- style: {
1120
- width: width,
1121
- minWidth: 300
1122
- },
1123
- stack: true,
1124
- gap: "md",
1125
- children: [
1126
- props.label && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $c46ecb47aa6f4da1$export$5f1af8db9871e1d6), {
1127
- size: "sm",
1128
- variant: "light",
1129
- as: "div",
1130
- ...labelProps,
1131
- children: props.label
1132
- }),
1133
- /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1138
+ return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $7815c8512dae20d4$export$1e60abce570c2b01), {
1139
+ ...props,
1140
+ showSelectedMarker: showSelectedMarker,
1141
+ children: /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1142
+ "data-color": color,
1143
+ style: {
1144
+ width: width,
1145
+ minWidth: 300
1146
+ },
1147
+ stack: true,
1148
+ gap: "md",
1149
+ children: /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1134
1150
  as: "ul",
1135
1151
  stack: true,
1136
1152
  gap: "none",
@@ -1162,7 +1178,7 @@ function $895088a96d07d13e$export$41f133550aa26f48({ state: state , color: color
1162
1178
  })
1163
1179
  ]
1164
1180
  })
1165
- ]
1181
+ })
1166
1182
  });
1167
1183
  }
1168
1184
  function $895088a96d07d13e$var$ListOption({ state: state , item: item }) {
@@ -1170,7 +1186,8 @@ function $895088a96d07d13e$var$ListOption({ state: state , item: item }) {
1170
1186
  const { optionProps: optionProps , isDisabled: isDisabled , isFocusVisible: isFocusVisible , isFocused: isFocused , isPressed: isPressed , isSelected: isSelected } = (0, $4Lhmj$reactaria.useOption)({
1171
1187
  key: item.key
1172
1188
  }, state, optionRef);
1173
- return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("li", {
1189
+ const listBoxContext = (0, $7815c8512dae20d4$export$961f16f221737ce2)();
1190
+ return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)("li", {
1174
1191
  className: "list-option",
1175
1192
  "data-disabled": isDisabled,
1176
1193
  "data-focus-visible": isFocusVisible,
@@ -1182,7 +1199,12 @@ function $895088a96d07d13e$var$ListOption({ state: state , item: item }) {
1182
1199
  "textValue"
1183
1200
  ]),
1184
1201
  ref: optionRef,
1185
- children: item.rendered
1202
+ children: [
1203
+ item.rendered,
1204
+ isSelected && listBoxContext.props.showSelectedMarker && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $4Lhmj$reacticonshi.HiCheck), {
1205
+ className: "selected-marker"
1206
+ })
1207
+ ]
1186
1208
  });
1187
1209
  }
1188
1210
  function $895088a96d07d13e$var$ListSection({ state: state , section: section }) {
@@ -1190,40 +1212,50 @@ function $895088a96d07d13e$var$ListSection({ state: state , section: section })
1190
1212
  heading: section?.rendered,
1191
1213
  "aria-label": section["aria-label"]
1192
1214
  });
1215
+ const listBoxContext = (0, $7815c8512dae20d4$export$961f16f221737ce2)();
1193
1216
  function getChildren() {
1194
1217
  if (state.collection.getChildren) return [
1195
1218
  ...state.collection.getChildren(section.key)
1196
1219
  ];
1197
1220
  return [];
1198
1221
  }
1199
- return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1222
+ return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1200
1223
  gap: "sm",
1201
1224
  stack: true,
1202
1225
  className: "list-section",
1203
- children: /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1204
- gap: "sm",
1205
- stack: true,
1206
- as: "li",
1207
- ...itemProps,
1208
- children: [
1209
- section.rendered && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $c46ecb47aa6f4da1$export$5f1af8db9871e1d6), {
1210
- size: "sm",
1211
- as: "div",
1212
- variant: "light",
1213
- ...headingProps,
1214
- children: section.rendered
1215
- }),
1216
- /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("ul", {
1217
- ...groupProps,
1218
- children: getChildren().map((node)=>{
1219
- return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)($895088a96d07d13e$var$ListOption, {
1220
- item: node,
1221
- state: state
1222
- }, node.key);
1226
+ children: [
1227
+ section.key !== state.collection.getFirstKey() && listBoxContext.props.showSeparator && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("li", {
1228
+ className: "list-separator"
1229
+ }),
1230
+ /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
1231
+ gap: "none",
1232
+ stack: true,
1233
+ as: "li",
1234
+ ...itemProps,
1235
+ children: [
1236
+ section.rendered && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("div", {
1237
+ className: "list-section-header",
1238
+ children: /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $c46ecb47aa6f4da1$export$5f1af8db9871e1d6), {
1239
+ weight: "regular",
1240
+ size: "xs",
1241
+ as: "div",
1242
+ variant: "light",
1243
+ ...headingProps,
1244
+ children: section.rendered
1245
+ })
1246
+ }),
1247
+ /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("ul", {
1248
+ ...groupProps,
1249
+ children: getChildren().map((node)=>{
1250
+ return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)($895088a96d07d13e$var$ListOption, {
1251
+ item: node,
1252
+ state: state
1253
+ }, node.key);
1254
+ })
1223
1255
  })
1224
- })
1225
- ]
1226
- })
1256
+ ]
1257
+ })
1258
+ ]
1227
1259
  });
1228
1260
  }
1229
1261
  const $895088a96d07d13e$export$36d18380658d5d20 = (0, $4Lhmj$reactstately.Item);
@@ -1361,16 +1393,39 @@ function $8c3b8477473df88b$export$5b6b19405a83ff9d({ state: state , children: ch
1361
1393
 
1362
1394
 
1363
1395
 
1364
- function $d9e1022f7af5df7f$export$ef9b1a59e592288f({ label: label , selectionMode: selectionMode = "single" , appearance: appearance = "outline" , append: append , prepend: prepend , renderValue: renderValue , color: color = "gray" , error: error , description: description , size: size = "sm" , shape: shape = "rounded" , listBoxColor: listBoxColor , className: className , ...props }) {
1396
+
1397
+ function $d9e1022f7af5df7f$export$ef9b1a59e592288f({ label: label , selectionMode: selectionMode = "single" , appearance: appearance = "outline" , append: append , prepend: prepend , renderValue: renderValue , color: color = "gray" , error: error , description: description , size: size = "sm" , shape: shape = "rounded" , listBoxColor: listBoxColor , className: className , value: value , defaultValue: defaultValue , onChange: onChange , ...props }) {
1398
+ const isMultiple = selectionMode === "multiple";
1399
+ function getValue(value) {
1400
+ if (!value) return null;
1401
+ if (selectionMode === "single") return [
1402
+ value
1403
+ ];
1404
+ if (isMultiple && !(0, $8dceeba61e72d053$export$43bee75e5e14138e)(value)) throw new Error("Select: value must be an array when selectionMode is multiple");
1405
+ return value;
1406
+ }
1407
+ function onSelectionChange(selectedKeys) {
1408
+ onChange?.({
1409
+ target: {
1410
+ value: isMultiple ? selectedKeys : selectedKeys[0],
1411
+ name: props.name
1412
+ }
1413
+ });
1414
+ }
1365
1415
  const space = (0, $951f2dc4112308d0$export$450c36e0b0e62ccd)();
1366
1416
  const [isFocused, setIsFocused] = $4Lhmj$react.useState(false);
1367
1417
  const triggerState = (0, $4Lhmj$reactstately.useMenuTriggerState)({});
1368
1418
  const listState = (0, $4Lhmj$reactstately.useListState)({
1369
1419
  ...props,
1420
+ selectedKeys: getValue(value),
1421
+ defaultSelectedKeys: getValue(defaultValue),
1370
1422
  selectionMode: selectionMode,
1371
1423
  children: (0, $d14b866db34f150f$export$3d7d0414f6db67e7)(props),
1372
- onSelectionChange () {
1373
- if (selectionMode === "single") triggerState.close();
1424
+ onSelectionChange (keys) {
1425
+ onSelectionChange([
1426
+ ...keys
1427
+ ]);
1428
+ if (!isMultiple) triggerState.close();
1374
1429
  }
1375
1430
  });
1376
1431
  const triggerRef = $4Lhmj$react.useRef(null);
@@ -1381,7 +1436,6 @@ function $d9e1022f7af5df7f$export$ef9b1a59e592288f({ label: label , selectionMod
1381
1436
  isDisabled: false
1382
1437
  }, triggerState, triggerRef);
1383
1438
  const { pressProps: triggerProps } = (0, $4Lhmj$reactaria.usePress)(menuTriggerProps);
1384
- const isMultiple = selectionMode === "multiple";
1385
1439
  const selectedItems = [
1386
1440
  ...listState.selectionManager.selectedKeys
1387
1441
  ].map((item)=>listState.collection.getItem(item));
@@ -1480,8 +1534,11 @@ function $d9e1022f7af5df7f$export$ef9b1a59e592288f({ label: label , selectionMod
1480
1534
  triggerRef: triggerRef,
1481
1535
  state: triggerState,
1482
1536
  children: /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $895088a96d07d13e$export$41f133550aa26f48), {
1537
+ label: label,
1538
+ showSeparator: props.showSeparator,
1539
+ showSelectedMarker: props.showSelectedMarker,
1483
1540
  width: triggerRef.current?.getBoundingClientRect().width,
1484
- color: listBoxColor ?? color,
1541
+ color: listBoxColor ?? "gray",
1485
1542
  shouldFocusOnHover: true,
1486
1543
  state: listState,
1487
1544
  ...props
@@ -2647,10 +2704,14 @@ function $3dc285189c5cc5d1$export$e6a97ba2cae5bb94({ items: items , render: rend
2647
2704
 
2648
2705
 
2649
2706
 
2707
+
2650
2708
  function $61ad51d3c2a11900$export$c6fdb837b070b4ff({ state: state , children: children , ...props }) {
2651
2709
  const modalRef = $4Lhmj$react.useRef(null);
2652
2710
  const { modalProps: modalProps , underlayProps: underlayProps } = (0, $4Lhmj$reactaria.useModalOverlay)(props, state, modalRef);
2653
2711
  if (!state.isOpen) return null;
2712
+ // bring back aria-overlay when you find a way for theme provider to affect
2713
+ // portalled elements
2714
+ // aria-overlay handles the focus trap
2654
2715
  return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)("div", {
2655
2716
  className: "modal-underlay parrot-theme",
2656
2717
  ...underlayProps,
@@ -2662,10 +2723,11 @@ function $61ad51d3c2a11900$export$c6fdb837b070b4ff({ state: state , children: ch
2662
2723
  })
2663
2724
  });
2664
2725
  }
2665
- function $61ad51d3c2a11900$var$Dialog({ width: width = 400 , title: title , onCancel: onCancel , onConfirm: onConfirm , confirmLabel: confirmLabel = "Confirm" , cancelLabel: cancelLabel = "Cancel" , description: description , children: children , state: state , confirmButtonProps: confirmButtonProps , cancelButtonProps: cancelButtonProps , variant: variant = "modal" }) {
2726
+ function $61ad51d3c2a11900$var$Dialog({ width: width = 400 , title: title , onCancel: onCancel , onConfirm: onConfirm , confirmLabel: confirmLabel = "Confirm" , cancelLabel: cancelLabel = "Cancel" , description: description , children: children , state: state , confirmButtonProps: confirmButtonProps , cancelButtonProps: cancelButtonProps , variant: variant = "modal" , showCloseButton: showCloseButton = true , ...props }) {
2666
2727
  const dialogRef = $4Lhmj$react.useRef(null);
2667
2728
  const { dialogProps: dialogProps , titleProps: titleProps } = (0, $4Lhmj$reactaria.useDialog)({
2668
- role: "alertdialog"
2729
+ role: "dialog",
2730
+ ...props
2669
2731
  }, dialogRef);
2670
2732
  return /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)("div", {
2671
2733
  className: "modal-content",
@@ -2680,24 +2742,38 @@ function $61ad51d3c2a11900$var$Dialog({ width: width = 400 , title: title , onCa
2680
2742
  stack: true,
2681
2743
  children: [
2682
2744
  /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
2683
- stack: true,
2684
- gap: "3xs",
2745
+ justify: "space-between",
2746
+ gap: "2xl",
2685
2747
  className: "modal-head",
2686
2748
  children: [
2687
- title && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $c46ecb47aa6f4da1$export$5f1af8db9871e1d6), {
2688
- weight: "medium",
2689
- size: "md",
2690
- color: "gray",
2691
- ...titleProps,
2692
- as: "div",
2693
- children: title
2749
+ /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsxs)((0, $0fbc6d8e58c7ff1b$export$f51f4c4ede09e011), {
2750
+ stack: true,
2751
+ gap: "3xs",
2752
+ children: [
2753
+ title && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $c46ecb47aa6f4da1$export$5f1af8db9871e1d6), {
2754
+ weight: "medium",
2755
+ size: "md",
2756
+ color: "gray",
2757
+ ...titleProps,
2758
+ as: "div",
2759
+ children: title
2760
+ }),
2761
+ description && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $c46ecb47aa6f4da1$export$5f1af8db9871e1d6), {
2762
+ lineHeight: "base",
2763
+ size: "xs",
2764
+ variant: "light",
2765
+ as: "div",
2766
+ children: description
2767
+ })
2768
+ ]
2694
2769
  }),
2695
- description && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $c46ecb47aa6f4da1$export$5f1af8db9871e1d6), {
2696
- lineHeight: "base",
2697
- size: "xs",
2698
- variant: "light",
2699
- as: "div",
2700
- children: description
2770
+ props.isDismissable && showCloseButton && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $b3fe2d8492eca72c$export$c25acd513dcc8062), {
2771
+ onPress: state.close,
2772
+ variant: "ghost",
2773
+ size: "sm",
2774
+ children: /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $4Lhmj$reacticonshi.HiX), {
2775
+ size: 18
2776
+ })
2701
2777
  })
2702
2778
  ]
2703
2779
  }),
@@ -2714,10 +2790,10 @@ function $61ad51d3c2a11900$var$Dialog({ width: width = 400 , title: title , onCa
2714
2790
  stretchX: true,
2715
2791
  children: [
2716
2792
  onCancel && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $50596a59d1a82779$export$353f5b6fc5456de1), {
2717
- ...cancelButtonProps,
2718
2793
  onPress: state.close,
2719
2794
  variant: "outline",
2720
2795
  color: "gray",
2796
+ ...cancelButtonProps,
2721
2797
  children: cancelLabel
2722
2798
  }),
2723
2799
  onConfirm && /*#__PURE__*/ (0, $4Lhmj$reactjsxruntime.jsx)((0, $50596a59d1a82779$export$353f5b6fc5456de1), {