@panneau/ui 5.0.0-alpha.12 → 5.0.0-alpha.14

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.
@@ -66,6 +66,12 @@
66
66
  color: var(--panneau-color-text-muted);
67
67
  }
68
68
 
69
+ /* Decorative content before a label: a flag. */
70
+ .panneau-list-box-prefix {
71
+ flex: 0 0 auto;
72
+ line-height: 1;
73
+ }
74
+
69
75
  .panneau-list-box-check {
70
76
  flex: 0 0 auto;
71
77
  width: 1rem;
@@ -118,6 +124,52 @@
118
124
  white-space: nowrap;
119
125
  }
120
126
 
127
+ /* A flex box rather than an inline one: inside the block of the value, an inline box sits on a
128
+ line of text, whose strut pushed the label below the middle of the trigger. */
129
+ .panneau-list-box-value-text {
130
+ display: flex;
131
+ align-items: center;
132
+ gap: var(--panneau-space-2);
133
+ max-width: 100%;
134
+ }
135
+
136
+ /* The check marks the chosen option in the list: the trigger shows the option without it. */
137
+ .panneau-list-box-value .panneau-list-box-check {
138
+ display: none;
139
+ }
140
+
141
+ /* A select inside another control: the button alone, the height of the control, with a line
142
+ between it and the rest of the control. */
143
+ .panneau-list-box-bare-trigger {
144
+ display: flex;
145
+ align-items: center;
146
+ align-self: stretch;
147
+ min-width: 0;
148
+ padding: 0 var(--panneau-space-2) 0 0;
149
+ font: inherit;
150
+ color: var(--panneau-color-text);
151
+ cursor: pointer;
152
+ background: transparent;
153
+ border: 0;
154
+ border-inline-end: var(--panneau-border-width) solid var(--panneau-color-border);
155
+ border-radius: 0;
156
+ outline: none;
157
+ }
158
+
159
+ .panneau-list-box-bare-trigger[data-focus-visible] {
160
+ outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
161
+ outline-offset: 2px;
162
+ }
163
+
164
+ .panneau-list-box-bare-trigger[data-disabled] {
165
+ cursor: default;
166
+ }
167
+
168
+ /* A select that can't be changed, inside a control that can't either: its value alone. */
169
+ .panneau-list-box-bare-trigger[data-disabled] .panneau-list-box-chevron {
170
+ display: none;
171
+ }
172
+
121
173
  .panneau-list-box-value[data-placeholder] {
122
174
  color: var(--panneau-color-text-muted);
123
175
  }
@@ -5,12 +5,15 @@ var item = "panneau-list-box-item";
5
5
  var itemText = "panneau-list-box-item-text";
6
6
  var itemDescription = "panneau-list-box-item-description";
7
7
  var itemLabel = "panneau-list-box-item-label";
8
+ var prefix = "panneau-list-box-prefix";
8
9
  var check = "panneau-list-box-check";
9
10
  var placeholder = "panneau-list-box-placeholder";
10
11
  var empty = "panneau-list-box-empty";
11
12
  var separator = "panneau-list-box-separator";
12
13
  var trigger = "panneau-list-box-trigger";
13
14
  var value = "panneau-list-box-value";
15
+ var valueText = "panneau-list-box-value-text";
16
+ var bareTrigger = "panneau-list-box-bare-trigger";
14
17
  var chevron = "panneau-list-box-chevron";
15
18
  var ListBox_module_default = {
16
19
  listBox,
@@ -18,15 +21,18 @@ var ListBox_module_default = {
18
21
  itemText,
19
22
  itemDescription,
20
23
  itemLabel,
24
+ prefix,
21
25
  check,
22
26
  placeholder,
23
27
  empty,
24
28
  separator,
25
29
  trigger,
26
30
  value,
31
+ valueText,
32
+ bareTrigger,
27
33
  chevron
28
34
  };
29
35
  //#endregion
30
- export { check, chevron, ListBox_module_default as default, empty, item, itemDescription, itemLabel, itemText, listBox, placeholder, separator, trigger, value };
36
+ export { bareTrigger, check, chevron, ListBox_module_default as default, empty, item, itemDescription, itemLabel, itemText, listBox, placeholder, prefix, separator, trigger, value, valueText };
31
37
 
32
38
  //# sourceMappingURL=ListBox.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListBox.module.js","names":[],"sources":["../../src/select/ListBox.module.css"],"sourcesContent":["/* Options of selects, combo boxes and menus. */\n\n.listBox {\n display: flex;\n flex-direction: column;\n max-height: inherit;\n padding: var(--panneau-list-box-padding, var(--panneau-space-1));\n overflow: auto;\n outline: none;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n min-height: var(--panneau-control-height-sm);\n padding: var(--panneau-list-box-item-padding-y, calc(var(--panneau-row-padding-y) / 2))\n var(--panneau-list-box-item-padding-x, var(--panneau-space-2));\n font-size: var(--panneau-font-size-control);\n line-height: var(--panneau-line-height-tight);\n color: var(--panneau-color-text);\n cursor: default;\n border-radius: var(--panneau-list-box-item-radius, var(--panneau-radius-sm));\n outline: none;\n}\n\n.item[data-focused],\n.item[data-hovered] {\n background-color: var(--panneau-list-box-item-bg-hover, var(--panneau-color-hover));\n}\n\n.item[data-focus-visible] {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: -2px;\n}\n\n.item[data-disabled] {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.item[data-danger] {\n color: var(--panneau-color-danger);\n}\n\n.itemText {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: 0.125rem;\n min-width: 0;\n}\n\n/* An option with a description has two lines: more room above and below them. */\n.item:has(.itemDescription) {\n padding-block: var(--panneau-list-box-item-padding-y-described, var(--panneau-space-2));\n}\n\n.itemLabel {\n overflow-wrap: anywhere;\n}\n\n.itemDescription {\n font-size: var(--panneau-font-size-xs);\n line-height: var(--panneau-line-height-tight);\n color: var(--panneau-color-text-muted);\n}\n\n.check {\n flex: 0 0 auto;\n width: 1rem;\n color: var(--panneau-color-text);\n}\n\n.placeholder {\n color: var(--panneau-color-text-muted);\n}\n\n.empty {\n padding: var(--panneau-space-2);\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.separator {\n height: 1px;\n margin: var(--panneau-space-1) 0;\n background-color: var(--panneau-color-border);\n}\n\n.trigger {\n justify-content: space-between;\n gap: var(--panneau-space-2);\n text-align: start;\n cursor: pointer;\n}\n\n.value {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* The chosen option, in the trigger: its description follows its label on the same line. */\n.value .itemText {\n flex-direction: row;\n align-items: baseline;\n gap: var(--panneau-space-2);\n}\n\n.value .itemLabel,\n.value .itemDescription {\n flex: 0 1 auto;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.value[data-placeholder] {\n color: var(--panneau-color-text-muted);\n}\n\n.chevron {\n color: var(--panneau-color-text-muted);\n}\n"],"mappings":""}
1
+ {"version":3,"file":"ListBox.module.js","names":[],"sources":["../../src/select/ListBox.module.css"],"sourcesContent":["/* Options of selects, combo boxes and menus. */\n\n.listBox {\n display: flex;\n flex-direction: column;\n max-height: inherit;\n padding: var(--panneau-list-box-padding, var(--panneau-space-1));\n overflow: auto;\n outline: none;\n}\n\n.item {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n min-height: var(--panneau-control-height-sm);\n padding: var(--panneau-list-box-item-padding-y, calc(var(--panneau-row-padding-y) / 2))\n var(--panneau-list-box-item-padding-x, var(--panneau-space-2));\n font-size: var(--panneau-font-size-control);\n line-height: var(--panneau-line-height-tight);\n color: var(--panneau-color-text);\n cursor: default;\n border-radius: var(--panneau-list-box-item-radius, var(--panneau-radius-sm));\n outline: none;\n}\n\n.item[data-focused],\n.item[data-hovered] {\n background-color: var(--panneau-list-box-item-bg-hover, var(--panneau-color-hover));\n}\n\n.item[data-focus-visible] {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: -2px;\n}\n\n.item[data-disabled] {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.item[data-danger] {\n color: var(--panneau-color-danger);\n}\n\n.itemText {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: 0.125rem;\n min-width: 0;\n}\n\n/* An option with a description has two lines: more room above and below them. */\n.item:has(.itemDescription) {\n padding-block: var(--panneau-list-box-item-padding-y-described, var(--panneau-space-2));\n}\n\n.itemLabel {\n overflow-wrap: anywhere;\n}\n\n.itemDescription {\n font-size: var(--panneau-font-size-xs);\n line-height: var(--panneau-line-height-tight);\n color: var(--panneau-color-text-muted);\n}\n\n/* Decorative content before a label: a flag. */\n.prefix {\n flex: 0 0 auto;\n line-height: 1;\n}\n\n.check {\n flex: 0 0 auto;\n width: 1rem;\n color: var(--panneau-color-text);\n}\n\n.placeholder {\n color: var(--panneau-color-text-muted);\n}\n\n.empty {\n padding: var(--panneau-space-2);\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n}\n\n.separator {\n height: 1px;\n margin: var(--panneau-space-1) 0;\n background-color: var(--panneau-color-border);\n}\n\n.trigger {\n justify-content: space-between;\n gap: var(--panneau-space-2);\n text-align: start;\n cursor: pointer;\n}\n\n.value {\n flex: 1 1 auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* The chosen option, in the trigger: its description follows its label on the same line. */\n.value .itemText {\n flex-direction: row;\n align-items: baseline;\n gap: var(--panneau-space-2);\n}\n\n.value .itemLabel,\n.value .itemDescription {\n flex: 0 1 auto;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* A flex box rather than an inline one: inside the block of the value, an inline box sits on a\n line of text, whose strut pushed the label below the middle of the trigger. */\n.valueText {\n display: flex;\n align-items: center;\n gap: var(--panneau-space-2);\n max-width: 100%;\n}\n\n/* The check marks the chosen option in the list: the trigger shows the option without it. */\n.value .check {\n display: none;\n}\n\n/* A select inside another control: the button alone, the height of the control, with a line\n between it and the rest of the control. */\n.bareTrigger {\n display: flex;\n align-items: center;\n align-self: stretch;\n min-width: 0;\n padding: 0 var(--panneau-space-2) 0 0;\n font: inherit;\n color: var(--panneau-color-text);\n cursor: pointer;\n background: transparent;\n border: 0;\n border-inline-end: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: 0;\n outline: none;\n}\n\n.bareTrigger[data-focus-visible] {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 2px;\n}\n\n.bareTrigger[data-disabled] {\n cursor: default;\n}\n\n/* A select that can't be changed, inside a control that can't either: its value alone. */\n.bareTrigger[data-disabled] .chevron {\n display: none;\n}\n\n.value[data-placeholder] {\n color: var(--panneau-color-text-muted);\n}\n\n.chevron {\n color: var(--panneau-color-text-muted);\n}\n"],"mappings":""}
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from 'react';
1
2
  import { type FieldChromeProps } from '../field/FieldParts.js';
2
3
  /** The value of an option. */
3
4
  export type OptionValue = string | number | boolean;
@@ -7,6 +8,8 @@ export interface SelectOption {
7
8
  label: string;
8
9
  description?: string;
9
10
  disabled?: boolean;
11
+ /** Decorative content before the label, such as a flag. Assistive technologies skip it. */
12
+ prefix?: ReactNode;
10
13
  }
11
14
  /** Props of both single and multiple selects. */
12
15
  export interface SelectBaseProps extends FieldChromeProps {
@@ -20,6 +23,11 @@ export interface SelectBaseProps extends FieldChromeProps {
20
23
  onBlur?: () => void;
21
24
  'aria-label'?: string;
22
25
  id?: string;
26
+ /**
27
+ * `field` (default): a control with its box. `bare`: the button alone, without a box, inside
28
+ * another control (the country of a phone number).
29
+ */
30
+ appearance?: 'field' | 'bare';
23
31
  /** Class name of the button that opens the options. */
24
32
  triggerClassName?: string;
25
33
  popoverClassName?: string;
@@ -29,6 +37,11 @@ export interface SingleSelectProps extends SelectBaseProps {
29
37
  /** The selected value, or `null`. */
30
38
  value?: OptionValue | null;
31
39
  onChange?: (value: OptionValue | null) => void;
40
+ /**
41
+ * What the button shows for the selected option, instead of its label: a shorter text when
42
+ * the button is narrow. The options keep their labels.
43
+ */
44
+ renderValue?: (option: SelectOption) => ReactNode;
32
45
  }
33
46
  export interface MultipleSelectProps extends SelectBaseProps {
34
47
  /** Several values can be selected. */
@@ -1 +1 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../src/select/Select.tsx"],"names":[],"mappings":"AAWA,OAAO,EACH,KAAK,gBAAgB,EAKxB,MAAM,qBAAqB,CAAC;AAQ7B,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD,iGAAiG;AACjG,MAAM,WAAW,YAAY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