@fairfox/polly 0.86.0 → 0.88.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.
@@ -4,8 +4,12 @@
4
4
  * Renders as a <button> by default; switches to an <a> when given an
5
5
  * `href`. Tier sets visual importance (primary/secondary/tertiary),
6
6
  * color overlays semantic meaning (info/success/warning/danger),
7
- * size picks the padding + font scale (small/normal/large). Icon +
8
- * label are arranged with a nested inline <Layout>.
7
+ * size picks the height + padding + font scale (small/normal/large).
8
+ * The button is a flex container, so an icon and a label are its own
9
+ * children with a `gap` between them.
10
+ *
11
+ * Height comes from --polly-control-height-*, never from padding, so a
12
+ * Button is exactly as tall as a TextInput or a Select in the same row.
9
13
  *
10
14
  * A text `label` is the accessible name. An icon-only button (icon, no
11
15
  * label) has none, so the type REQUIRES `aria-label` there — an unnamed
@@ -5,7 +5,9 @@
5
5
  * and `data-action-id={tab.id}` so the event delegator resolves the
6
6
  * activated tab. The active tab gets `aria-current="page"` and a
7
7
  * bottom-border accent. The nav scrolls horizontally with a hidden
8
- * scrollbar for overflow. Internal arrangement uses <Layout>.
8
+ * scrollbar for overflow. Internal arrangement uses <Layout>, packed to
9
+ * the inline start: the grid is 100% wide, so without justifyContent the
10
+ * `auto` tracks stretch and four tabs spread across the whole container.
9
11
  */
10
12
  import type { JSX } from "preact";
11
13
  export type Tab = {
@@ -14,23 +14,27 @@
14
14
  @layer polly-components {
15
15
  .root_-n6UrQ {
16
16
  box-sizing: border-box;
17
- padding: var(--polly-space-sm) var(--polly-space-md);
17
+ min-block-size: var(--polly-control-height-md);
18
+ padding-block-start: 0;
19
+ padding-block-end: 0;
20
+ padding-inline: var(--polly-field-padding);
18
21
  font: inherit;
19
22
  font-family: var(--polly-font-sans);
20
23
  color: var(--polly-text);
21
24
  line-height: var(--polly-line-height-base);
22
25
  border: var(--polly-border-width-default) solid transparent;
23
- border-radius: var(--polly-radius-md);
24
- min-block-size: calc(1.5em + 2 * var(--polly-space-sm) + 2 * var(--polly-border-width-default));
26
+ border-radius: var(--polly-control-radius);
25
27
  inline-size: 100%;
26
28
  }
27
29
 
28
30
  .view_-n6UrQ {
31
+ display: flex;
29
32
  cursor: text;
30
33
  white-space: pre-wrap;
31
34
  word-break: break-word;
32
35
  transition: background var(--polly-motion-fast) ease, border-color var(--polly-motion-fast) ease;
33
36
  background: none;
37
+ align-items: center;
34
38
  }
35
39
 
36
40
  .view_-n6UrQ:hover {
@@ -49,7 +53,9 @@
49
53
  }
50
54
 
51
55
  .root_-n6UrQ[data-variant="multi"] {
56
+ display: block;
52
57
  field-sizing: content;
58
+ padding-block: calc((var(--polly-control-height-md) - 1.5em - 2 * var(--polly-border-width-default)) / 2);
53
59
  resize: vertical;
54
60
  max-block-size: 40em;
55
61
  }
@@ -63,7 +69,8 @@
63
69
  }
64
70
 
65
71
  .trigger_HX48zA {
66
- display: inline-block;
72
+ display: inline-flex;
73
+ align-items: center;
67
74
  }
68
75
 
69
76
  .menu_HX48zA {
@@ -160,10 +167,13 @@
160
167
  display: inline-flex;
161
168
  align-items: center;
162
169
  gap: var(--polly-space-sm);
170
+ min-block-size: var(--polly-control-height-md);
163
171
  max-width: min(100%, var(--polly-control-max-width));
164
- padding: var(--polly-space-sm) var(--polly-space-md);
172
+ padding-block-start: 0;
173
+ padding-block-end: 0;
174
+ padding-inline: var(--polly-field-padding);
165
175
  border: var(--polly-border-width-default) solid var(--polly-border);
166
- border-radius: var(--polly-radius-sm);
176
+ border-radius: var(--polly-control-radius);
167
177
  background-color: var(--polly-surface);
168
178
  font-family: inherit;
169
179
  font-size: var(--polly-text-md);
@@ -217,7 +227,7 @@
217
227
  }
218
228
 
219
229
  .actionBtn_daofbw {
220
- display: inline-block;
230
+ display: block;
221
231
  padding: var(--polly-space-xs) var(--polly-space-sm);
222
232
  border-radius: var(--polly-radius-sm);
223
233
  font-family: inherit;
@@ -260,6 +270,8 @@
260
270
 
261
271
  .optionCheck_daofbw {
262
272
  accent-color: var(--polly-accent);
273
+ inline-size: var(--polly-checkbox-size);
274
+ block-size: var(--polly-checkbox-size);
263
275
  vertical-align: middle;
264
276
  pointer-events: none;
265
277
  margin-inline-end: var(--polly-space-sm);
@@ -305,20 +317,26 @@
305
317
  /* src/polly-ui/Button.module.css */
306
318
  @layer polly-components {
307
319
  .btn_c4HKfA {
308
- display: inline-block;
309
- padding: var(--polly-space-sm) var(--polly-space-lg);
320
+ display: inline-flex;
321
+ justify-content: center;
322
+ align-items: center;
323
+ gap: var(--polly-space-sm);
324
+ min-block-size: var(--polly-control-height-md);
325
+ padding-block-start: 0;
326
+ padding-block-end: 0;
327
+ padding-inline: var(--polly-control-padding-md);
310
328
  border: var(--polly-border-width-default) solid transparent;
311
- border-radius: var(--polly-radius-sm);
329
+ border-radius: var(--polly-control-radius);
312
330
  font-family: inherit;
313
331
  font-size: var(--polly-text-md);
314
332
  font-weight: var(--polly-weight-medium);
333
+ line-height: var(--polly-line-height-tight);
315
334
  text-align: center;
316
335
  text-decoration: none;
317
336
  cursor: pointer;
318
337
  user-select: none;
319
338
  box-sizing: border-box;
320
339
  transition: background-color var(--polly-motion-fast), border-color var(--polly-motion-fast), color var(--polly-motion-fast);
321
- line-height: 1.2;
322
340
  }
323
341
 
324
342
  .btn_c4HKfA:disabled, .btn_c4HKfA[aria-disabled="true"] {
@@ -393,20 +411,31 @@
393
411
  }
394
412
 
395
413
  .btnSmall_c4HKfA {
396
- padding: var(--polly-space-xs) var(--polly-space-md);
414
+ min-block-size: var(--polly-control-height-sm);
415
+ padding-inline: var(--polly-control-padding-sm);
397
416
  font-size: var(--polly-text-sm);
398
417
  }
399
418
 
400
419
  .btnLarge_c4HKfA {
401
- padding: var(--polly-space-md) var(--polly-space-xl);
420
+ min-block-size: var(--polly-control-height-lg);
421
+ padding-inline: var(--polly-control-padding-lg);
402
422
  font-size: var(--polly-text-lg);
403
423
  }
404
424
 
405
425
  .btnCircle_c4HKfA {
406
426
  border-radius: var(--polly-radius-full);
407
427
  aspect-ratio: 1;
408
- width: var(--polly-control-height-md);
409
- padding: 0;
428
+ inline-size: var(--polly-control-height-md);
429
+ padding-inline-start: 0;
430
+ padding-inline-end: 0;
431
+ }
432
+
433
+ .btnSmall_c4HKfA.btnCircle_c4HKfA {
434
+ inline-size: var(--polly-control-height-sm);
435
+ }
436
+
437
+ .btnLarge_c4HKfA.btnCircle_c4HKfA {
438
+ inline-size: var(--polly-control-height-lg);
410
439
  }
411
440
 
412
441
  .btnFullWidth_c4HKfA {
@@ -419,6 +448,22 @@
419
448
  text-overflow: ellipsis;
420
449
  white-space: nowrap;
421
450
  }
451
+
452
+ .icon_c4HKfA {
453
+ display: inline-flex;
454
+ flex: none;
455
+ align-items: center;
456
+ }
457
+
458
+ .label_c4HKfA {
459
+ min-inline-size: 0;
460
+ }
461
+
462
+ .btnBounded_c4HKfA .label_c4HKfA {
463
+ overflow: hidden;
464
+ text-overflow: ellipsis;
465
+ white-space: nowrap;
466
+ }
422
467
  }
423
468
 
424
469
  /* src/polly-ui/Surface.module.css */
@@ -502,7 +547,11 @@
502
547
  /* src/polly-ui/Checkbox.module.css */
503
548
  @layer polly-components {
504
549
  .checkbox_EKE5sg {
505
- display: inline-block;
550
+ display: inline-flex;
551
+ align-items: center;
552
+ gap: var(--polly-space-sm);
553
+ box-sizing: border-box;
554
+ min-block-size: var(--polly-control-height-md);
506
555
  cursor: pointer;
507
556
  font-family: inherit;
508
557
  font-size: var(--polly-text-md);
@@ -517,14 +566,15 @@
517
566
 
518
567
  .input_EKE5sg {
519
568
  accent-color: var(--polly-accent);
520
- vertical-align: middle;
569
+ inline-size: var(--polly-checkbox-size);
570
+ block-size: var(--polly-checkbox-size);
521
571
  cursor: inherit;
572
+ flex: none;
522
573
  margin: 0;
523
574
  }
524
575
 
525
576
  .label_EKE5sg {
526
- vertical-align: middle;
527
- margin-inline-start: var(--polly-space-sm);
577
+ min-inline-size: 0;
528
578
  }
529
579
  }
530
580
 
@@ -642,13 +692,19 @@
642
692
 
643
693
  .cancel_ZfTX4A, .confirm_ZfTX4A, .confirmDanger_ZfTX4A {
644
694
  appearance: none;
645
- padding: var(--polly-space-sm) var(--polly-space-lg);
695
+ display: inline-flex;
696
+ min-block-size: var(--polly-control-height-md);
697
+ padding-block-start: 0;
698
+ padding-block-end: 0;
699
+ padding-inline: var(--polly-control-padding-md);
646
700
  font: inherit;
647
701
  font-weight: var(--polly-weight-medium);
648
702
  border: var(--polly-border-width-default) solid var(--polly-border);
649
- border-radius: var(--polly-radius-md);
703
+ border-radius: var(--polly-control-radius);
650
704
  cursor: pointer;
651
705
  transition: background var(--polly-motion-fast) ease;
706
+ justify-content: center;
707
+ align-items: center;
652
708
  }
653
709
 
654
710
  .cancel_ZfTX4A {
@@ -729,14 +785,20 @@
729
785
 
730
786
  .close_fLMrWA {
731
787
  appearance: none;
788
+ display: inline-flex;
789
+ min-block-size: var(--polly-control-height-md);
732
790
  color: var(--polly-text);
733
791
  border: var(--polly-border-width-default) solid transparent;
734
- border-radius: var(--polly-radius-md);
735
- padding: var(--polly-space-sm) var(--polly-space-md);
792
+ border-radius: var(--polly-control-radius);
793
+ padding-block-start: 0;
794
+ padding-block-end: 0;
795
+ padding-inline: var(--polly-field-padding);
736
796
  font: inherit;
737
797
  cursor: pointer;
738
798
  transition: background var(--polly-motion-fast) ease, border-color var(--polly-motion-fast) ease;
739
799
  background: none;
800
+ justify-content: center;
801
+ align-items: center;
740
802
  }
741
803
 
742
804
  .close_fLMrWA:hover {
@@ -760,10 +822,13 @@
760
822
  display: inline-flex;
761
823
  align-items: center;
762
824
  gap: var(--polly-space-sm);
825
+ box-sizing: border-box;
763
826
  min-block-size: var(--polly-control-height-md);
764
- padding: var(--polly-space-sm) var(--polly-space-md);
827
+ padding-block-start: 0;
828
+ padding-block-end: 0;
829
+ padding-inline: var(--polly-control-padding-md);
765
830
  border: var(--polly-border-width-default) solid var(--polly-border);
766
- border-radius: var(--polly-radius-sm);
831
+ border-radius: var(--polly-control-radius);
767
832
  background-color: var(--polly-surface);
768
833
  font-family: inherit;
769
834
  font-size: var(--polly-text-md);
@@ -894,8 +959,11 @@
894
959
  }
895
960
 
896
961
  .tab_xKO6GA {
897
- display: inline-block;
898
- padding: var(--polly-space-sm) var(--polly-space-lg);
962
+ display: inline-flex;
963
+ min-block-size: var(--polly-control-height-md);
964
+ padding-block-start: 0;
965
+ padding-block-end: 0;
966
+ padding-inline: var(--polly-control-padding-md);
899
967
  border: none;
900
968
  border-bottom: var(--polly-border-width-medium) solid transparent;
901
969
  font-family: inherit;
@@ -906,6 +974,8 @@
906
974
  white-space: nowrap;
907
975
  transition: color var(--polly-motion-fast), border-color var(--polly-motion-fast);
908
976
  background: none;
977
+ justify-content: center;
978
+ align-items: center;
909
979
  }
910
980
 
911
981
  .tab_xKO6GA:hover:not(:disabled) {
@@ -1003,13 +1073,16 @@
1003
1073
  @layer polly-components {
1004
1074
  .input_ez4_Vg {
1005
1075
  box-sizing: border-box;
1006
- padding: var(--polly-space-sm) var(--polly-space-md);
1076
+ min-block-size: var(--polly-control-height-md);
1077
+ padding-block-start: 0;
1078
+ padding-block-end: 0;
1079
+ padding-inline: var(--polly-field-padding);
1007
1080
  font: inherit;
1008
1081
  font-family: var(--polly-font-sans);
1009
1082
  color: var(--polly-text);
1010
1083
  background: var(--polly-surface);
1011
1084
  border: var(--polly-border-width-default) solid var(--polly-border);
1012
- border-radius: var(--polly-radius-md);
1085
+ border-radius: var(--polly-control-radius);
1013
1086
  transition: border-color var(--polly-motion-fast) ease, background var(--polly-motion-fast) ease;
1014
1087
  inline-size: 100%;
1015
1088
  }
@@ -1029,7 +1102,8 @@
1029
1102
 
1030
1103
  .input_ez4_Vg[data-polly-input-variant="multi"] {
1031
1104
  field-sizing: content;
1032
- min-block-size: calc(1.5em + 2 * var(--polly-space-sm) + 2 * var(--polly-border-width-default));
1105
+ padding-block: calc((var(--polly-control-height-md) - 1.5em - 2 * var(--polly-border-width-default)) / 2);
1106
+ min-block-size: var(--polly-control-height-md);
1033
1107
  resize: vertical;
1034
1108
  max-block-size: 40em;
1035
1109
  }
@@ -1077,13 +1151,19 @@
1077
1151
 
1078
1152
  .close_xVzRuA {
1079
1153
  appearance: none;
1154
+ display: inline-flex;
1155
+ min-block-size: var(--polly-control-height-sm);
1080
1156
  color: inherit;
1081
1157
  border: var(--polly-border-width-default) solid transparent;
1082
- border-radius: var(--polly-radius-sm);
1083
- padding: var(--polly-space-xs) var(--polly-space-sm);
1158
+ border-radius: var(--polly-control-radius);
1159
+ padding-block-start: 0;
1160
+ padding-block-end: 0;
1161
+ padding-inline: var(--polly-space-sm);
1084
1162
  font: inherit;
1085
1163
  cursor: pointer;
1086
1164
  background: none;
1165
+ justify-content: center;
1166
+ align-items: center;
1087
1167
  }
1088
1168
 
1089
1169
  .close_xVzRuA:hover {
@@ -1094,13 +1174,16 @@
1094
1174
  /* src/polly-ui/Toggle.module.css */
1095
1175
  @layer polly-components {
1096
1176
  .toggle_rnf-SQ {
1097
- display: inline-block;
1177
+ display: inline-flex;
1178
+ align-items: center;
1179
+ gap: var(--polly-space-sm);
1180
+ box-sizing: border-box;
1181
+ min-block-size: var(--polly-control-height-md);
1098
1182
  cursor: pointer;
1099
1183
  font-family: inherit;
1100
1184
  font-size: var(--polly-text-md);
1101
1185
  color: var(--polly-text);
1102
1186
  user-select: none;
1103
- vertical-align: middle;
1104
1187
  }
1105
1188
 
1106
1189
  .disabled_rnf-SQ {
@@ -1121,12 +1204,12 @@
1121
1204
  }
1122
1205
 
1123
1206
  .track_rnf-SQ {
1124
- display: inline-block;
1207
+ display: block;
1125
1208
  position: relative;
1126
1209
  border-radius: var(--polly-radius-full);
1127
1210
  background-color: var(--polly-border);
1128
- vertical-align: middle;
1129
1211
  transition: background-color var(--polly-motion-fast);
1212
+ flex: none;
1130
1213
  width: 36px;
1131
1214
  height: 20px;
1132
1215
  }
@@ -1161,7 +1244,6 @@
1161
1244
  }
1162
1245
 
1163
1246
  .label_rnf-SQ {
1164
- vertical-align: middle;
1165
- margin-inline-start: var(--polly-space-sm);
1247
+ min-inline-size: 0;
1166
1248
  }
1167
1249
  }
@@ -718,11 +718,13 @@ var Button_module_default = {
718
718
  btnLarge: "btnLarge_c4HKfA",
719
719
  btnCircle: "btnCircle_c4HKfA",
720
720
  btnFullWidth: "btnFullWidth_c4HKfA",
721
- btnBounded: "btnBounded_c4HKfA"
721
+ btnBounded: "btnBounded_c4HKfA",
722
+ icon: "icon_c4HKfA",
723
+ label: "label_c4HKfA"
722
724
  };
723
725
 
724
726
  // src/polly-ui/Button.tsx
725
- import { jsxDEV as jsxDEV6 } from "preact/jsx-dev-runtime";
727
+ import { jsxDEV as jsxDEV6, Fragment as Fragment2 } from "preact/jsx-dev-runtime";
726
728
  function tierClass(tier) {
727
729
  if (tier === "primary")
728
730
  return Button_module_default["tierPrimary"];
@@ -782,18 +784,18 @@ function Button(props) {
782
784
  if (className)
783
785
  parts.push(className);
784
786
  const buttonClass = parts.filter(Boolean).join(" ");
785
- const content = icon ? /* @__PURE__ */ jsxDEV6(Layout, {
786
- inline: true,
787
- columns: "auto auto",
788
- gap: "0.5em",
789
- alignItems: "center",
787
+ const content = /* @__PURE__ */ jsxDEV6(Fragment2, {
790
788
  children: [
791
- icon,
789
+ icon !== undefined && /* @__PURE__ */ jsxDEV6("span", {
790
+ class: Button_module_default["icon"],
791
+ children: icon
792
+ }, undefined, false, undefined, this),
792
793
  label !== undefined && /* @__PURE__ */ jsxDEV6("span", {
794
+ class: Button_module_default["label"],
793
795
  children: label
794
796
  }, undefined, false, undefined, this)
795
797
  ]
796
- }, undefined, true, undefined, this) : label;
798
+ }, undefined, true, undefined, this);
797
799
  const dataAction = props["data-action"];
798
800
  const ariaLabel = props["aria-label"];
799
801
  const resolvedTitle = title ?? (typeof label === "string" && label.length > 0 ? label : typeof ariaLabel === "string" ? ariaLabel : undefined);
@@ -1500,6 +1502,8 @@ function Root2({ when, onClose, children, "aria-label": ariaLabel }) {
1500
1502
  const mountRef = useRef4(null);
1501
1503
  const [portalNode, setPortalNode] = useState2(null);
1502
1504
  const isOpen = typeof when === "boolean" ? when : when.value;
1505
+ const onCloseRef = useRef4(onClose);
1506
+ onCloseRef.current = onClose;
1503
1507
  useEffect4(() => {
1504
1508
  if (!isOpen) {
1505
1509
  setPortalNode(null);
@@ -1510,7 +1514,7 @@ function Root2({ when, onClose, children, "aria-label": ariaLabel }) {
1510
1514
  useEffect4(() => {
1511
1515
  if (!isOpen || !portalNode)
1512
1516
  return;
1513
- const entry = { id, onClose };
1517
+ const entry = { id, onClose: () => onCloseRef.current?.() };
1514
1518
  pushOverlay(entry);
1515
1519
  const el = mountRef.current;
1516
1520
  const cleanup = el ? installFocusTrap(el) : () => {};
@@ -1518,7 +1522,7 @@ function Root2({ when, onClose, children, "aria-label": ariaLabel }) {
1518
1522
  cleanup();
1519
1523
  popOverlay(id);
1520
1524
  };
1521
- }, [isOpen, portalNode, id, onClose]);
1525
+ }, [isOpen, portalNode, id]);
1522
1526
  if (!isOpen || !portalNode)
1523
1527
  return null;
1524
1528
  const close = () => {
@@ -1820,7 +1824,7 @@ function Output(props) {
1820
1824
  }
1821
1825
  // src/polly-ui/Select.tsx
1822
1826
  import { useComputed, useSignal as useSignal2 } from "@preact/signals";
1823
- import { jsxDEV as jsxDEV17, Fragment as Fragment2 } from "preact/jsx-dev-runtime";
1827
+ import { jsxDEV as jsxDEV17, Fragment as Fragment3 } from "preact/jsx-dev-runtime";
1824
1828
  var MULTI_SELECT_LABEL_THRESHOLD = 2;
1825
1829
  function formatSelected(options, selected, multiSelect) {
1826
1830
  if (selected.size === 0)
@@ -1883,7 +1887,7 @@ function Select(props) {
1883
1887
  if (wide)
1884
1888
  triggerParts.push(Select_module_default["triggerWide"] ?? "");
1885
1889
  const triggerClass = triggerParts.filter(Boolean).join(" ");
1886
- const triggerContent = /* @__PURE__ */ jsxDEV17(Fragment2, {
1890
+ const triggerContent = /* @__PURE__ */ jsxDEV17(Fragment3, {
1887
1891
  children: [
1888
1892
  /* @__PURE__ */ jsxDEV17("span", {
1889
1893
  class: Select_module_default["triggerLabel"],
@@ -2050,6 +2054,7 @@ function Tabs(props) {
2050
2054
  columns: `repeat(${tabs.length}, auto)`,
2051
2055
  gap: "0",
2052
2056
  alignItems: "end",
2057
+ justifyContent: "start",
2053
2058
  children: tabs.map((tab) => {
2054
2059
  const isActive = activeTab === tab.id;
2055
2060
  const tabClass = isActive ? `${Tabs_module_default["tab"]} ${Tabs_module_default["active"]}` : Tabs_module_default["tab"];
@@ -2417,4 +2422,4 @@ export {
2417
2422
  getOverlayRootNode
2418
2423
  };
2419
2424
 
2420
- //# debugId=2BD418D4BB18550164756E2164756E21
2425
+ //# debugId=658A56B7B40F7FD364756E2164756E21