@apliteni/apliteni-ui 0.185.0 → 0.186.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/docs/components.md
CHANGED
|
@@ -408,8 +408,8 @@ dropdown must have a search field: [Component choice](../guidelines/component-ch
|
|
|
408
408
|
```
|
|
409
409
|
|
|
410
410
|
`items` is a list of rows. A row has `label`, and can have `value`, `description`, `icon`,
|
|
411
|
-
`avatar`, `badge`, `selected` and `disabled`. `'---'` is a separator. `sections` groups
|
|
412
|
-
captions. `header` and `footer` add content above and below the rows. `onSelect` gets the value
|
|
411
|
+
`avatar`, `badge`, `muted`, `selected` and `disabled`. `'---'` is a separator. `sections` groups
|
|
412
|
+
rows under captions, with space before each next group. `header` and `footer` add content above and below the rows. `onSelect` gets the value
|
|
413
413
|
and the row. `open`, `defaultOpen` and `onOpenChange` control the panel. `disabled` turns the
|
|
414
414
|
trigger off: no keyboard stop, no panel and the disabled paint.
|
|
415
415
|
|
|
@@ -437,9 +437,18 @@ trigger off: no keyboard stop, no panel and the disabled paint.
|
|
|
437
437
|
the field while the user is still scrolled into the room that the panel needed.
|
|
438
438
|
- The panel follows its trigger when the page moves the trigger: a new layout, a sideways scroll
|
|
439
439
|
or a transition.
|
|
440
|
+
- A row names its item in the body weight, as a native list does. A group caption is a compact
|
|
441
|
+
label in body ink.
|
|
440
442
|
- Each row answers the pointer with a fill and draws no edge. A destructive row turns `--pink` on
|
|
441
443
|
hover and focus. In forced colours a separator stays a visible line.
|
|
442
444
|
|
|
445
|
+
**Muted or disabled.** Use `muted` for a row that the user can still pick but that is no
|
|
446
|
+
longer current, such as an archived unit for a late invoice. Give it the state word:
|
|
447
|
+
`muted: 'Archived'`. The row keeps its name in body ink and shows the word in a state badge after
|
|
448
|
+
it. The row stays in the keyboard order. After a pick, the trigger shows `Cedar Studio (Archived)`.
|
|
449
|
+
Use `disabled` for a row that the user cannot pick now. A disabled row is faded, and the arrow
|
|
450
|
+
keys skip it.
|
|
451
|
+
|
|
443
452
|
**Search.** `search` adds a text field above the rows. Typing filters the rows, and the focus stays
|
|
444
453
|
in the field. The match is anywhere in the label, without case or accents. Descriptions are not
|
|
445
454
|
searched, so put the words that a user types in the label. `search={{ count, noun }}` names the
|
|
@@ -520,6 +529,11 @@ label and the value as its name, and the error gives it the invalid edge. In a f
|
|
|
520
529
|
trigger has the height of a text input and keeps the pill corner. A long value stays on one line
|
|
521
530
|
and ends with an ellipsis.
|
|
522
531
|
|
|
532
|
+
**A list of options in `SelectField`.** The browser draws the open list, so the kit does not
|
|
533
|
+
style an `<option>`. For an option that the user can still pick but that is no longer current,
|
|
534
|
+
write the state word in its text: `<option>Cedar Studio (Archived)</option>`. Do not disable it.
|
|
535
|
+
Name a group with `<optgroup label="Studios">`, not with a disabled option.
|
|
536
|
+
|
|
523
537
|
**Keyboard and screen reader.** The component makes the ids and points the label, the hint and the
|
|
524
538
|
error at the control. The error has `role="alert"`, so a new error is announced and the focus does
|
|
525
539
|
not move.
|
|
@@ -89,3 +89,17 @@
|
|
|
89
89
|
**Do:** Use the eyebrow for the period and the title for what is shown.
|
|
90
90
|
|
|
91
91
|
**Don't:** Use a label-sized eyebrow as the only title.
|
|
92
|
+
|
|
93
|
+
## Keep category labels compact
|
|
94
|
+
|
|
95
|
+
<!-- rule: category-compact -->
|
|
96
|
+
|
|
97
|
+
**Rule:** Give each category a compact, nonselectable label in body ink, with space before the next category.
|
|
98
|
+
|
|
99
|
+
**Why:** A compact label leaves the items prominent in a short list.
|
|
100
|
+
|
|
101
|
+
**Do:** Write “Studios” above the studio names.
|
|
102
|
+
|
|
103
|
+
**Don't:** Add “Studios” as a disabled item.
|
|
104
|
+
|
|
105
|
+
**Except:** A native picker keeps the spacing and label style supplied by the browser.
|
package/package.json
CHANGED
package/react/dist/index.d.ts
CHANGED
|
@@ -554,6 +554,10 @@ type DropdownItem = {
|
|
|
554
554
|
* letters, `src` a photo. `{ empty: true }` is the dashed ring of a "No one" row. */
|
|
555
555
|
avatar?: DropdownAvatar;
|
|
556
556
|
badge?: DropdownBadge;
|
|
557
|
+
/** A row that stays selectable but is no longer current, named by its state word, e.g.
|
|
558
|
+
* 'Archived'. The word takes the badge slot in state ink, and the trigger shows it after
|
|
559
|
+
* the label. Use `disabled` for a row that cannot be picked. */
|
|
560
|
+
muted?: string;
|
|
557
561
|
selected?: boolean;
|
|
558
562
|
disabled?: boolean;
|
|
559
563
|
danger?: boolean;
|
package/react/dist/index.js
CHANGED
|
@@ -3156,6 +3156,8 @@ function RowBadge({ badge }) {
|
|
|
3156
3156
|
if (!given && tone2 === "neutral" && /^(?:off|unset|disabled|archive|archived)$/i.test(text2)) tone2 = "state";
|
|
3157
3157
|
return /* @__PURE__ */ jsx26("span", { className: `ui-dropdown__badge is-${tone2}`, children: text2 });
|
|
3158
3158
|
}
|
|
3159
|
+
var mutedOf = (it) => it?.muted?.trim() || "";
|
|
3160
|
+
var shownOf = (it) => mutedOf(it) ? `${it?.label} (${mutedOf(it)})` : it?.label;
|
|
3159
3161
|
var keyOf = (it) => it.value != null ? `v:${it.value}` : `l:${it.label}`;
|
|
3160
3162
|
var itemsIn = (panel) => Array.from(panel?.querySelectorAll("[data-dd-item]") ?? []).filter((el) => el.getAttribute("aria-disabled") !== "true" && !el.hidden);
|
|
3161
3163
|
var openNow = /* @__PURE__ */ new Set();
|
|
@@ -3326,7 +3328,7 @@ function Dropdown({
|
|
|
3326
3328
|
}, [givenKey, pick]);
|
|
3327
3329
|
const picked = pickedKey != null ? rows.find((it) => keyOf(it) === pickedKey) : void 0;
|
|
3328
3330
|
const controlled = selectedValue !== void 0 ? rows.find((it) => it.value === selectedValue) : void 0;
|
|
3329
|
-
const shown = value != null ? value : isSelect ? selectedValue !== void 0 ? controlled
|
|
3331
|
+
const shown = value != null ? value : isSelect ? shownOf(selectedValue !== void 0 ? controlled : picked ?? given) : null;
|
|
3330
3332
|
const marked2 = isSelect && rows.some((it) => it.avatar);
|
|
3331
3333
|
const chosen = marked2 ? value != null ? rows.find((it) => it.label === value) : selectedValue !== void 0 ? controlled : picked ?? given : void 0;
|
|
3332
3334
|
const selectedOf = (it) => selectedValue !== void 0 ? it.value === selectedValue : pickedKey != null ? it.disabled ? !!it.selected : keyOf(it) === pickedKey : !!it.selected;
|
|
@@ -3606,7 +3608,7 @@ function Dropdown({
|
|
|
3606
3608
|
/* @__PURE__ */ jsx26("span", { className: "ui-dropdown__label", children: entry.label }),
|
|
3607
3609
|
entry.description && /* @__PURE__ */ jsx26("span", { className: "ui-dropdown__desc", children: entry.description })
|
|
3608
3610
|
] }),
|
|
3609
|
-
entry.badge ? /* @__PURE__ */ jsx26(RowBadge, { badge: entry.badge }) : null,
|
|
3611
|
+
mutedOf(entry) ? /* @__PURE__ */ jsx26(RowBadge, { badge: { text: mutedOf(entry), tone: "state" } }) : entry.badge ? /* @__PURE__ */ jsx26(RowBadge, { badge: entry.badge }) : null,
|
|
3610
3612
|
asOption && /* @__PURE__ */ jsx26(Glyph2, { name: "check", className: "ui-dropdown__tick", hidden: true })
|
|
3611
3613
|
] })
|
|
3612
3614
|
};
|
package/src/styles/dropdown.css
CHANGED
|
@@ -361,7 +361,7 @@
|
|
|
361
361
|
why: docs/foundations.md#the-focus-ring */
|
|
362
362
|
.ui-dropdown__item:focus-visible { background: var(--surface); /* code-bg: inherit — control paint; the containing surface is the ground, for a chip and for a band alike. */ outline: var(--ring-scroll); outline-offset: var(--ring-scroll-offset); }
|
|
363
363
|
.ui-dropdown__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
|
364
|
-
.ui-dropdown__label { font-family: var(--font-sans); font-size: var(--text-sm); color: var(--strong); font-weight:
|
|
364
|
+
.ui-dropdown__label { font-family: var(--font-sans); font-size: var(--text-sm); color: var(--strong); font-weight: var(--weight-normal); letter-spacing: 0.01em; }
|
|
365
365
|
.ui-dropdown__desc { font-size: var(--text-xs); color: var(--text); line-height: 1.35; }
|
|
366
366
|
.ui-dropdown__ic { display: inline-flex; flex: none; /* muted-ink: glyph — option icon */ color: var(--muted); }
|
|
367
367
|
.ui-dropdown__ic svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.1; }
|
|
@@ -427,9 +427,9 @@
|
|
|
427
427
|
.ui-dropdown__item.is-danger:hover .ui-dropdown__label,
|
|
428
428
|
.ui-dropdown__item.is-danger:focus-visible .ui-dropdown__label { color: var(--pink); }
|
|
429
429
|
|
|
430
|
-
/* Grouped sections. `~` and :not([hidden]),
|
|
431
|
-
query has hidden and
|
|
432
|
-
.ui-dropdown__section:not([hidden]) ~ .ui-dropdown__section:not([hidden]) {
|
|
430
|
+
/* Grouped sections: space, not a rule, before the next group (#852). `~` and :not([hidden]),
|
|
431
|
+
because `+` counts a group a search query has hidden and spaced the first one left showing. */
|
|
432
|
+
.ui-dropdown__section:not([hidden]) ~ .ui-dropdown__section:not([hidden]) { margin-top: var(--space-4); }
|
|
433
433
|
.ui-dropdown__group {
|
|
434
434
|
/* rank: label */
|
|
435
435
|
font-size: var(--text-sm);
|
|
@@ -543,6 +543,9 @@
|
|
|
543
543
|
/* muted-ink: state — off, unset, disabled or archived badge */
|
|
544
544
|
color: var(--muted);
|
|
545
545
|
}
|
|
546
|
+
/* On the row Enter would pick, the chip sits on --surface-2, where --muted reads 4.37:1 in
|
|
547
|
+
light. --dim keeps the state ink and clears 4.5:1 (#852). */
|
|
548
|
+
.ui-dropdown__item.is-active > .ui-dropdown__badge.is-state { /* muted-ink: state — archived badge on the search pick */ color: var(--dim); }
|
|
546
549
|
|
|
547
550
|
/* A picker of people. A mark leads the trigger and each row; with no value the trigger
|
|
548
551
|
shows the dashed ring beside the placeholder in the placeholder ink. The mark's own
|
|
@@ -109,9 +109,6 @@
|
|
|
109
109
|
Primer and Radix all tick a chosen menu row. #549
|
|
110
110
|
why: docs/components.md#filter-bar */
|
|
111
111
|
.ui-filter-bar .ui-dropdown__item.is-selected { background: var(--glow-purple); /* code-bg: inherit — a translucent wash moves the ground, not the chip on it. */ }
|
|
112
|
-
/* A chip's menu lists the values the chip prints, so its rows take the body weight and
|
|
113
|
-
not the kit's semibold menu label. #757 */
|
|
114
|
-
.ui-filter-bar__chip .ui-dropdown__label { font-weight: var(--weight-normal); }
|
|
115
112
|
/* Kit-wide a chosen label steps down to --text, which left the row in force the
|
|
116
113
|
faintest in the panel. Under the wash it holds --strong. */
|
|
117
114
|
.ui-filter-bar .ui-dropdown__item.is-selected .ui-dropdown__label { color: var(--strong); }
|