@propellerads/select 8.0.0 → 9.0.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/README.md CHANGED
@@ -34,11 +34,20 @@ import '@propellerads/tokens/propellerads.css'; // or monetag / propush / zeydoo
34
34
  ```tsx
35
35
  import Select from '@propellerads/select';
36
36
 
37
- <Select id="brand" options={brands} value={brand} onChange={setBrand} />
38
- <Select id="brand" options={brands} value={brand} onChange={setBrand} errors={['Choose a brand']} />
39
- <Select id="countries" isMulti options={countries} value={picked} onChange={setPicked} />
40
- <Select id="cities" isMulti isAsync loadOptions={searchCities} minSearchLength={2} />
41
- <Select id="folder" isCreatable options={folders} onCreateOption={createFolder} />
37
+ <Select label="Brand" options={brands} value={brand} onChange={setBrand} />
38
+ <Select
39
+ label="Countries"
40
+ isMulti
41
+ options={countries}
42
+ value={picked}
43
+ onChange={setPicked}
44
+ description="Where the campaign runs."
45
+ error={picked.length > 0 ? undefined : 'Choose at least one country'}
46
+ isRequired
47
+ />
48
+ <Select label="Cities" isMulti isAsync loadOptions={searchCities} minSearchLength={2} />
49
+ <Select label="Folder" isCreatable options={folders} onCreateOption={createFolder} />
50
+ <Select label="Group by" labelPosition="hidden" options={dimensions} />
42
51
  ```
43
52
 
44
53
  **Every react-select prop is accepted and passed on** — `isMulti`,
@@ -48,14 +57,74 @@ and creatable ones. A product's `styles` is written inline by react-select, so
48
57
  it wins over the library's classes, as before. Its `components` replace the
49
58
  library's, part by part. Its `classNames` are added to the library's.
50
59
 
60
+ ## Label and messages
61
+
62
+ Select draws its field with [`Field` from `@propellerads/label`](../Label/README.md),
63
+ the one every form control of the library builds on, the way
64
+ [Input](../Input/README.md) does.
65
+
66
+ - **`label`** names the field; a click on it focuses the select. `labelPosition`
67
+ puts it on top (the default), on the left — one column for the whole form, in
68
+ a `FieldGroup` — or hides it for a filter or a table cell, where a screen
69
+ reader still reads it. `optional` adds a quiet "(Optional)"; `isRequired`
70
+ sets react-select's `required` with no mark: the input says `aria-required`,
71
+ and an empty select stops the browser's form check, as a required input does.
72
+ With no label on screen, `aria-label` names the select.
73
+ - **One message:** `error`, else `warning`, else `description`. An error draws
74
+ the contour red and sets `aria-invalid`; a warning draws it yellow. The label
75
+ keeps its colour.
76
+ - **`messageDisplay`**: `compact` by default — the message waits behind a mark
77
+ among the indicators, where the `!` always stood: the `!` of
78
+ [ErrorLabel](../ErrorLabel/README.md) for an error or a warning, a quiet «i»
79
+ for the description. Its click does not open the menu. `line` writes it under
80
+ the field.
81
+ - The input is described by the message either way, single or multi, and
82
+ with a product's own `components.Control` too, so a screen reader reads it
83
+ with the field's name.
84
+ - A disabled select fades with its label and its message.
85
+
86
+ Whether the field is drawn is decided by the props being passed, not by their
87
+ values: write `error={isValid ? undefined : '…'}`, so the select stays put while
88
+ the error comes and goes.
89
+
90
+ ### The id goes to the input
91
+
92
+ `id` names react-select's input — the element that takes the focus — and no
93
+ longer its wrapper. A `Label` pointed at it by id, the way older forms do it,
94
+ now focuses the select on a click and names it for a screen reader:
95
+
96
+ ```tsx
97
+ <Label label="Brand" for="brand" />
98
+ <Select id="brand" options={brands} />
99
+ ```
100
+
101
+ react-select's own `inputId` still wins when passed; the wrapper then keeps the
102
+ `id`. The `!` mark (`error-label-${id}`) and the clear cross (`${id}-clear`) keep
103
+ their ids.
104
+
105
+ ### Inside another control's field
106
+
107
+ A select is a field of its own. Put inside the field of another control — as an
108
+ addon of an `Input` with a `label` — it would take that field's label and turn
109
+ red with its error. Give it its own `label` (or `labelPosition="hidden"`).
110
+
111
+ ### The old `errors`
112
+
113
+ `errors`, `tone`, `showErrors` and TagsInput's `isErrorLabelVisible` still work
114
+ and are deprecated. With a field of its own the select takes `errors` as
115
+ `error`, or as `warning` with `tone="warning"`. Without one — no `label`,
116
+ `description`, `error` or `warning` — they keep the old look: the `!` mark among
117
+ the indicators, `showErrors={false}` to hide it.
118
+
51
119
  ## What the library adds
52
120
 
53
121
  | Prop | Default | What it does |
54
122
  |---------------------------|-------------|---------------------------------------------------------------------|
55
- | `errors` | `[]` | The `!` mark among the indicators and the red contour. The mark's click does not open the menu |
56
- | `showErrors` | `true` | `false` keeps the contour and hides the mark |
57
- | `tone` | `'danger'` | `'warning'` for a value that is allowed but worth a second look |
58
- | `icon` | — | An icon at the start of the field |
123
+ | `label`, `labelPosition`, `labelWidth`, `optional`, `optionalText`, `isRequired`, `description`, `error`, `warning`, `messageDisplay`, `hintLabel` | | The field: see [Label and messages](#label-and-messages) |
124
+ | `errors` | `[]` | Deprecated: use `error`. The `!` mark among the indicators and the red contour |
125
+ | `showErrors` | `true` | Deprecated. `false` keeps the contour and hides the mark |
126
+ | `tone` | `'danger'` | Deprecated: use `warning`. `'warning'` paints `errors` yellow |
127
+ | `icon` | — | An icon at the start of the field, inside its box |
59
128
  | `isCreatable` | `false` | Adds a `Create "…"` row. A promise from `onCreateOption` shows the spinner and locks the field |
60
129
  | `createOptionPlaceholder` | `'Create '` | What the create row starts with |
61
130
  | `isAsync` | `false` | Loads the options with `loadOptions` |
package/dist/index.css CHANGED
@@ -1 +1 @@
1
- .select{--select-height:36px;--select-contour:var(--color-rich);--select-ring:var(--color-action);--select-accent:var(--color-danger);color:var(--color-dark-inversion);font:var(--font-text);font-family:var(--font-family);position:relative}.select__control{box-sizing:border-box;border-radius:var(--radius-8);background-color:var(--color-light-inversion);box-shadow:inset 0 0 0 var(--space-1) var(--select-contour);outline-offset:var(--space-1);cursor:pointer;transition:box-shadow var(--duration-200) var(--ease-flat), outline-color var(--duration-200) var(--ease-flat);align-items:center;display:flex}.select__control:hover{--select-contour:var(--color-quiet)}.select--warning{--select-accent:var(--color-warning)}.select--invalid .select__control{--select-contour:var(--select-accent);--select-ring:var(--select-accent)}.select__control.select__control{min-height:var(--select-height);outline:var(--space-2) solid transparent!important}.select__control--focused.select__control--focused{outline-color:var(--select-ring)!important}.select__control--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.select__icon{color:var(--color-quiet-text);flex:none;align-items:center;padding-inline-start:var(--space-12);display:inline-flex}.select__value-container{gap:var(--space-4);padding:var(--space-0) var(--space-8) var(--space-0) var(--space-12)}.select__icon+.select__value-container{padding-inline-start:var(--space-8)}.select__value-container--is-multi.select__value-container--has-value{padding-block:var(--space-4);padding-inline-start:calc(var(--space-4) + var(--space-2))}.select__placeholder{color:var(--color-quiet-text)}.select__single-value,.select__input-container{color:inherit}.select__errors{align-items:center;display:inline-flex}.select__indicators{gap:var(--space-2);padding-inline-end:var(--space-8)}.select__indicator.select__indicator{border-radius:var(--radius-4);width:24px;height:24px;color:var(--color-quiet-text);transition:color var(--duration-200) var(--ease-flat), background-color var(--duration-200) var(--ease-flat), transform var(--duration-200) var(--ease-enter);justify-content:center;align-items:center;display:inline-flex}.select__clear-indicator:hover{background-color:color-mix(in srgb, var(--color-action) var(--opacity-tint), transparent);color:var(--color-action)}.select__dropdown-indicator:hover,.select__control--focused .select__dropdown-indicator{color:var(--color-dark-inversion)}.select__control--menu-is-open .select__dropdown-indicator{transform:rotate(180deg)}.select__loading-indicator.select__loading-indicator{width:16px;height:16px;margin-inline:var(--space-4);box-sizing:border-box;border:var(--space-2) solid var(--color-rich);border-block-start-color:var(--color-quiet-text);border-radius:50%;animation:.6s linear infinite select-spin}.select__loading-indicator>*{display:none}@keyframes select-spin{to{transform:rotate(360deg)}}.select__multi-value{border-radius:var(--radius-4);background-color:var(--select-chip-bg,var(--color-action-bg));min-width:0;height:24px;color:var(--select-chip-text,var(--color-action-text));font:var(--font-description);font-family:var(--font-family);align-items:center;display:inline-flex}.select__multi-value--exception{background-color:var(--color-danger-bg);color:var(--color-danger-text)}.select__multi-value-label{padding-inline:var(--space-8) var(--space-2);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select__multi-value-remove{width:20px;height:20px;border-radius:var(--radius-2);cursor:pointer;transition:background-color var(--duration-200) var(--ease-flat);justify-content:center;align-items:center;margin-inline-end:var(--space-2);display:inline-flex}.select__multi-value-remove:hover{background-color:color-mix(in srgb, currentColor var(--opacity-tint), transparent)}.select__menu.select__menu{--select-menu-shift:calc(-1 * var(--space-4));box-sizing:border-box;margin-block:var(--space-4);border-radius:var(--radius-8);background-color:var(--color-light-inversion);box-shadow:var(--shadow-middle), inset 0 0 0 var(--space-1) var(--color-rich);z-index:var(--select-menu-z-index,2500);animation:select-menu-in var(--duration-200) var(--ease-enter);overflow:hidden}.select__menu--top{--select-menu-shift:var(--space-4)}@keyframes select-menu-in{0%{opacity:0;transform:translateY(var(--select-menu-shift)) scale(.95)}}.select__menu-portal.select__menu-portal{z-index:var(--select-menu-z-index,2500)}.select__menu-list{max-height:var(--select-menu-max-height,300px);padding:var(--space-4)}.select__option.select__option{box-sizing:border-box;align-items:center;gap:var(--space-8);min-height:32px;padding:var(--space-4) var(--space-32) var(--space-4) var(--space-8);border-radius:var(--radius-4);cursor:pointer;transition:background-color var(--duration-200) var(--ease-flat);display:flex;position:relative}.select__option--focused{background-color:color-mix(in srgb, var(--color-action) var(--opacity-tint), transparent)}.select__option--disabled.select__option--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.select__option-check{color:var(--color-action);display:inline-flex;position:absolute;inset-inline-end:var(--space-8)}.select__group{padding-block:var(--space-4)}.select__group+.select__group{box-shadow:inset 0 var(--space-1) 0 var(--color-formal)}.select__group-heading{padding:var(--space-4) var(--space-8);color:var(--color-quiet-text);font:var(--font-description);font-family:var(--font-family)}.select__menu-notice{padding:var(--space-8) var(--space-12);color:var(--color-quiet-text);text-align:center}@media (prefers-reduced-motion:reduce){.select__loading-indicator{animation-duration:2s}}
1
+ .select{--select-height:36px;--select-contour:var(--color-rich);--select-ring:var(--color-action);--select-accent:var(--color-danger);color:var(--color-dark-inversion);font:var(--font-text);font-family:var(--font-family);position:relative}.select__control{box-sizing:border-box;border-radius:var(--radius-8);background-color:var(--color-light-inversion);box-shadow:inset 0 0 0 var(--space-1) var(--select-contour);outline-offset:var(--space-1);cursor:pointer;transition:box-shadow var(--duration-200) var(--ease-flat), outline-color var(--duration-200) var(--ease-flat);align-items:center;display:flex}.select__control:hover{--select-contour:var(--color-quiet)}.select--warning{--select-accent:var(--color-warning)}.select--invalid .select__control{--select-contour:var(--select-accent);--select-ring:var(--select-accent)}.select__control.select__control{min-height:var(--select-height);outline:var(--space-2) solid transparent!important}.select__control--focused.select__control--focused{outline-color:var(--select-ring)!important}.select__control--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.select__icon{color:var(--color-quiet-text);flex:none;align-items:center;padding-inline-start:var(--space-12);display:inline-flex}.select__value-container{gap:var(--space-4);padding:var(--space-0) var(--space-8) var(--space-0) var(--space-12)}.select__icon+.select__value-container{padding-inline-start:var(--space-8)}.select__value-container--is-multi.select__value-container--has-value{padding-block:var(--space-4);padding-inline-start:calc(var(--space-4) + var(--space-2))}.select__placeholder{color:var(--color-quiet-text)}.select__single-value,.select__input-container{color:inherit}.select__errors,.select__mark{align-items:center;display:inline-flex}.select__indicators{gap:var(--space-2);padding-inline-end:var(--space-8)}.select__indicator.select__indicator{border-radius:var(--radius-4);width:24px;height:24px;color:var(--color-quiet-text);transition:color var(--duration-200) var(--ease-flat), background-color var(--duration-200) var(--ease-flat), transform var(--duration-200) var(--ease-enter);justify-content:center;align-items:center;display:inline-flex}.select__clear-indicator:hover{background-color:color-mix(in srgb, var(--color-action) var(--opacity-tint), transparent);color:var(--color-action)}.select__dropdown-indicator:hover,.select__control--focused .select__dropdown-indicator{color:var(--color-dark-inversion)}.select__control--menu-is-open .select__dropdown-indicator{transform:rotate(180deg)}.select__loading-indicator.select__loading-indicator{width:16px;height:16px;margin-inline:var(--space-4);box-sizing:border-box;border:var(--space-2) solid var(--color-rich);border-block-start-color:var(--color-quiet-text);border-radius:50%;animation:.6s linear infinite select-spin}.select__loading-indicator>*{display:none}@keyframes select-spin{to{transform:rotate(360deg)}}.select__multi-value{border-radius:var(--radius-4);background-color:var(--select-chip-bg,var(--color-action-bg));min-width:0;height:24px;color:var(--select-chip-text,var(--color-action-text));font:var(--font-description);font-family:var(--font-family);align-items:center;display:inline-flex}.select__multi-value--exception{background-color:var(--color-danger-bg);color:var(--color-danger-text)}.select__multi-value-label{padding-inline:var(--space-8) var(--space-2);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.select__multi-value-remove{width:20px;height:20px;border-radius:var(--radius-2);cursor:pointer;transition:background-color var(--duration-200) var(--ease-flat);justify-content:center;align-items:center;margin-inline-end:var(--space-2);display:inline-flex}.select__multi-value-remove:hover{background-color:color-mix(in srgb, currentColor var(--opacity-tint), transparent)}.select__menu.select__menu{--select-menu-shift:calc(-1 * var(--space-4));box-sizing:border-box;margin-block:var(--space-4);border-radius:var(--radius-8);background-color:var(--color-light-inversion);box-shadow:var(--shadow-middle), inset 0 0 0 var(--space-1) var(--color-rich);z-index:var(--select-menu-z-index,2500);animation:select-menu-in var(--duration-200) var(--ease-enter);overflow:hidden}.select__menu--top{--select-menu-shift:var(--space-4)}@keyframes select-menu-in{0%{opacity:0;transform:translateY(var(--select-menu-shift)) scale(.95)}}.select__menu-portal.select__menu-portal{z-index:var(--select-menu-z-index,2500)}.select__menu-list{max-height:var(--select-menu-max-height,300px);padding:var(--space-4)}.select__option.select__option{box-sizing:border-box;align-items:center;gap:var(--space-8);min-height:32px;padding:var(--space-4) var(--space-32) var(--space-4) var(--space-8);border-radius:var(--radius-4);cursor:pointer;transition:background-color var(--duration-200) var(--ease-flat);display:flex;position:relative}.select__option--focused{background-color:color-mix(in srgb, var(--color-action) var(--opacity-tint), transparent)}.select__option--disabled.select__option--disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.select__option-check{color:var(--color-action);display:inline-flex;position:absolute;inset-inline-end:var(--space-8)}.select__group{padding-block:var(--space-4)}.select__group+.select__group{box-shadow:inset 0 var(--space-1) 0 var(--color-formal)}.select__group-heading{padding:var(--space-4) var(--space-8);color:var(--color-quiet-text);font:var(--font-description);font-family:var(--font-family)}.select__menu-notice{padding:var(--space-8) var(--space-12);color:var(--color-quiet-text);text-align:center}@media (prefers-reduced-motion:reduce){.select__loading-indicator{animation-duration:2s}}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ReactNode, Ref, ReactElement } from 'react';
2
2
  import { GroupBase, SelectInstance, StylesConfig } from 'react-select';
3
3
  export { components } from 'react-select';
4
+ import { FieldOwnProps as FieldOwnProps$1 } from '@propellerads/label';
4
5
  import { AsyncProps } from 'react-select/async';
5
6
  import { CreatableProps } from 'react-select/creatable';
6
7
 
@@ -13,20 +14,37 @@ type Option = {
13
14
  isException?: boolean;
14
15
  };
15
16
  type OptionGroup<O = Option> = GroupBase<O>;
16
- /** Which colour the errors are shown in. */
17
+ /** Which colour the old `errors` are shown in. */
17
18
  declare const SelectTone: {
18
19
  readonly Danger: "danger";
19
20
  readonly Warning: "warning";
20
21
  };
21
22
  type SelectTone = (typeof SelectTone)[keyof typeof SelectTone];
22
- type OwnProps<O, M extends boolean, G extends GroupBase<O>> = {
23
- /** Names the select, its `!` mark (`error-label-${id}`) and its clear cross (`${id}-clear`). */
23
+ /**
24
+ * The field around the select: its label and its message, laid out by Label's
25
+ * `Field`. Given any of `label`, `description`, `error` or `warning`, the
26
+ * select draws the field itself, with the message behind a mark among the
27
+ * indicators by default.
28
+ */
29
+ type FieldOwnProps = FieldOwnProps$1 & {
30
+ /** Sets `required`, which the input says with `aria-required`. No mark: the optional fields are the ones marked. */
31
+ isRequired?: boolean;
32
+ };
33
+ type OwnProps<O, M extends boolean, G extends GroupBase<O>> = FieldOwnProps & {
34
+ /**
35
+ * Names the select's input, so `<Label for={id}>` and a click on it find the
36
+ * select; also its `!` mark (`error-label-${id}`) and its clear cross
37
+ * (`${id}-clear`). react-select's `inputId`, when passed, names the input instead.
38
+ */
24
39
  id?: string;
25
- /** The `!` mark in the field and the red contour. */
40
+ /**
41
+ * @deprecated Use `error`, or `warning` for the warning tone. The `!` mark
42
+ * among the indicators and the contour in the tone.
43
+ */
26
44
  errors?: ReadonlyArray<string>;
27
- /** Hides the mark and keeps the contour. @default true */
45
+ /** @deprecated Hides the `!` mark of `errors` and keeps the contour. Use `error` with `messageDisplay`. @default true */
28
46
  showErrors?: boolean;
29
- /** @default 'danger' */
47
+ /** @deprecated Use `warning` instead of `errors` with `tone="warning"`. @default 'danger' */
30
48
  tone?: SelectTone;
31
49
  /** An icon at the start of the field. */
32
50
  icon?: ReactNode;
@@ -49,7 +67,7 @@ type OwnProps<O, M extends boolean, G extends GroupBase<O>> = {
49
67
  ref?: Ref<SelectInstance<O, M, G>>;
50
68
  /** @deprecated TagsInput's name for `id`. */
51
69
  elementId?: string;
52
- /** @deprecated TagsInput's name for `showErrors`. */
70
+ /** @deprecated TagsInput's name for `showErrors`. Use `error` with `messageDisplay`. */
53
71
  isErrorLabelVisible?: boolean;
54
72
  /** @deprecated TagsInput's name for `styles`. */
55
73
  customStyles?: StylesConfig<O, M, G>;
package/dist/index.js CHANGED
@@ -1,107 +1,131 @@
1
- import e from "@propellerads/error-label";
2
- import { forwardRef as t, useEffect as n, useId as r, useRef as i, useState as a } from "react";
3
- import o, { components as s } from "react-select";
4
- import ee from "react-select/async";
5
- import te from "react-select/async-creatable";
6
- import c from "react-select/creatable";
7
- import { clsx as l } from "clsx";
8
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
1
+ import { Field as e } from "@base-ui-components/react/field";
2
+ import t from "@propellerads/error-label";
3
+ import { ControlField as n, FieldMark as r, MessageDisplay as i, hasFieldProps as a, splitFieldProps as o, useFieldIds as s, useFieldMessage as c, useFieldTone as l } from "@propellerads/label";
4
+ import { forwardRef as u, useEffect as d, useId as ee, useLayoutEffect as f, useRef as p, useState as te } from "react";
5
+ import m, { components as h } from "react-select";
6
+ import ne from "react-select/async";
7
+ import re from "react-select/async-creatable";
8
+ import ie from "react-select/creatable";
9
+ import { clsx as g } from "clsx";
10
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
9
11
  import './index.css';//#region src/cn.ts
10
- var f = (...e) => l(e), p = {
12
+ var b = (...e) => g(e), x = {
11
13
  Danger: "danger",
12
14
  Warning: "warning"
13
- }, m = (e) => e.selectProps.library, h = () => /* @__PURE__ */ u("svg", {
15
+ }, S = (e) => e.selectProps.library, C = () => /* @__PURE__ */ v("svg", {
14
16
  viewBox: "0 0 16 16",
15
17
  width: "16",
16
18
  height: "16",
17
19
  fill: "none",
18
20
  "aria-hidden": "true",
19
- children: /* @__PURE__ */ u("path", {
21
+ children: /* @__PURE__ */ v("path", {
20
22
  d: "M4 6l4 4 4-4",
21
23
  stroke: "currentColor",
22
24
  strokeWidth: "1.5",
23
25
  strokeLinecap: "round",
24
26
  strokeLinejoin: "round"
25
27
  })
26
- }), g = ({ size: e = 16 }) => /* @__PURE__ */ u("svg", {
28
+ }), w = ({ size: e = 16 }) => /* @__PURE__ */ v("svg", {
27
29
  viewBox: "0 0 16 16",
28
30
  width: e,
29
31
  height: e,
30
32
  fill: "none",
31
33
  "aria-hidden": "true",
32
- children: /* @__PURE__ */ u("path", {
34
+ children: /* @__PURE__ */ v("path", {
33
35
  d: "M4.5 4.5l7 7M11.5 4.5l-7 7",
34
36
  stroke: "currentColor",
35
37
  strokeWidth: "1.5",
36
38
  strokeLinecap: "round"
37
39
  })
38
- }), _ = () => /* @__PURE__ */ u("svg", {
40
+ }), T = () => /* @__PURE__ */ v("svg", {
39
41
  viewBox: "0 0 16 16",
40
42
  width: "16",
41
43
  height: "16",
42
44
  fill: "none",
43
45
  "aria-hidden": "true",
44
- children: /* @__PURE__ */ u("path", {
46
+ children: /* @__PURE__ */ v("path", {
45
47
  d: "M3 8.5l3 3 7-7",
46
48
  stroke: "currentColor",
47
49
  strokeWidth: "1.5",
48
50
  strokeLinecap: "round",
49
51
  strokeLinejoin: "round"
50
52
  })
51
- }), ne = ({ children: e, ...t }) => {
52
- let { icon: n } = m(t);
53
- return /* @__PURE__ */ d(s.Control, {
53
+ }), E = typeof document > "u" ? d : f, D = (e) => (e ?? "").split(" ").filter(Boolean), O = (e, t) => {
54
+ let n = p([]);
55
+ E(() => {
56
+ let r = t || n.current.length > 0 ? document.getElementById(e) : null;
57
+ if (!r) return;
58
+ let i = D(t), a = [...D(r.getAttribute("aria-describedby")).filter((e) => !n.current.includes(e) && !i.includes(e)), ...i].join(" ");
59
+ n.current = i, a === "" ? r.removeAttribute("aria-describedby") : r.getAttribute("aria-describedby") !== a && r.setAttribute("aria-describedby", a);
60
+ });
61
+ }, ae = ({ children: e, ...t }) => {
62
+ let { icon: n } = S(t);
63
+ return /* @__PURE__ */ y(h.Control, {
54
64
  ...t,
55
- children: [n && /* @__PURE__ */ u("span", {
65
+ children: [n && /* @__PURE__ */ v("span", {
56
66
  className: "select__icon",
57
67
  children: n
58
68
  }), e]
59
69
  });
60
- }, re = ({ children: t, ...n }) => {
61
- let { id: r, errors: i, showErrors: a, tone: o } = m(n);
62
- return /* @__PURE__ */ d(s.IndicatorsContainer, {
70
+ }, oe = (e) => {
71
+ let { inputId: t, describedBy: n, control: r } = S(e);
72
+ return O(t, n), /* @__PURE__ */ v(r, { ...e });
73
+ }, k = (e) => e.stopPropagation(), A = (e) => {
74
+ e.key === " " && e.stopPropagation();
75
+ }, se = ({ children: e, ...n }) => {
76
+ let { id: i, errors: a, showErrors: o, tone: s, hasFieldMark: c } = S(n);
77
+ return /* @__PURE__ */ y(h.IndicatorsContainer, {
63
78
  ...n,
64
- children: [a && i.length > 0 && /* @__PURE__ */ u("span", {
65
- className: "select__errors",
66
- onMouseDown: (e) => e.stopPropagation(),
67
- children: /* @__PURE__ */ u(e, {
68
- elementId: r,
69
- errors: [...i],
70
- errorColor: o === p.Warning ? "var(--color-warning)" : void 0
71
- })
72
- }), t]
79
+ children: [
80
+ c && /* @__PURE__ */ v("span", {
81
+ className: "select__mark",
82
+ onMouseDown: k,
83
+ onKeyDown: A,
84
+ children: /* @__PURE__ */ v(r, {})
85
+ }),
86
+ o && a.length > 0 && /* @__PURE__ */ v("span", {
87
+ className: "select__errors",
88
+ onMouseDown: (e) => e.stopPropagation(),
89
+ children: /* @__PURE__ */ v(t, {
90
+ elementId: i,
91
+ errors: [...a],
92
+ errorColor: s === x.Warning ? "var(--color-warning)" : void 0
93
+ })
94
+ }),
95
+ e
96
+ ]
73
97
  });
74
- }, v = (e) => /* @__PURE__ */ u(s.DropdownIndicator, {
98
+ }, ce = (e) => /* @__PURE__ */ v(h.DropdownIndicator, {
75
99
  ...e,
76
- children: /* @__PURE__ */ u(h, {})
77
- }), ie = (e) => {
78
- let { id: t } = m(e);
79
- return /* @__PURE__ */ u(s.ClearIndicator, {
100
+ children: /* @__PURE__ */ v(C, {})
101
+ }), le = (e) => {
102
+ let { id: t } = S(e);
103
+ return /* @__PURE__ */ v(h.ClearIndicator, {
80
104
  ...e,
81
105
  innerProps: {
82
106
  ...e.innerProps,
83
107
  id: `${t}-clear`
84
108
  },
85
- children: /* @__PURE__ */ u(g, {})
109
+ children: /* @__PURE__ */ v(w, {})
86
110
  });
87
- }, ae = (e) => /* @__PURE__ */ u(s.MultiValueRemove, {
111
+ }, ue = (e) => /* @__PURE__ */ v(h.MultiValueRemove, {
88
112
  ...e,
89
- children: /* @__PURE__ */ u(g, { size: 12 })
90
- }), oe = ({ children: e, ...t }) => /* @__PURE__ */ d(s.Option, {
113
+ children: /* @__PURE__ */ v(w, { size: 12 })
114
+ }), de = ({ children: e, ...t }) => /* @__PURE__ */ y(h.Option, {
91
115
  ...t,
92
- children: [e, t.isSelected && !t.isMulti && /* @__PURE__ */ u("span", {
116
+ children: [e, t.isSelected && !t.isMulti && /* @__PURE__ */ v("span", {
93
117
  className: "select__option-check",
94
- children: /* @__PURE__ */ u(_, {})
118
+ children: /* @__PURE__ */ v(T, {})
95
119
  })]
96
- }), y = ({ innerProps: e }) => /* @__PURE__ */ u("span", {
120
+ }), fe = ({ innerProps: e }) => /* @__PURE__ */ v("span", {
97
121
  ...e,
98
122
  className: "select__indicator select__loading-indicator",
99
123
  role: "status",
100
124
  "aria-label": "Loading"
101
- }), b = (e = {}) => {
125
+ }), pe = () => /* @__PURE__ */ v(_, {}), me = (e = {}) => {
102
126
  let t = {
103
- control: (e) => f("select__control", e.isFocused && "select__control--focused", e.isDisabled && "select__control--disabled", e.menuIsOpen && "select__control--menu-is-open"),
104
- valueContainer: (e) => f("select__value-container", e.isMulti && "select__value-container--is-multi", e.hasValue && "select__value-container--has-value"),
127
+ control: (e) => b("select__control", e.isFocused && "select__control--focused", e.isDisabled && "select__control--disabled", e.menuIsOpen && "select__control--menu-is-open"),
128
+ valueContainer: (e) => b("select__value-container", e.isMulti && "select__value-container--is-multi", e.hasValue && "select__value-container--has-value"),
105
129
  placeholder: () => "select__placeholder",
106
130
  singleValue: () => "select__single-value",
107
131
  input: () => "select__input-container",
@@ -110,13 +134,13 @@ var f = (...e) => l(e), p = {
110
134
  dropdownIndicator: () => "select__indicator select__dropdown-indicator",
111
135
  clearIndicator: () => "select__indicator select__clear-indicator",
112
136
  loadingIndicator: () => "select__indicator select__loading-indicator",
113
- multiValue: (e) => f("select__multi-value", e.data.isException && "select__multi-value--exception"),
137
+ multiValue: (e) => b("select__multi-value", e.data.isException && "select__multi-value--exception"),
114
138
  multiValueLabel: () => "select__multi-value-label",
115
139
  multiValueRemove: () => "select__multi-value-remove",
116
- menu: (e) => f("select__menu", e.placement === "top" && "select__menu--top"),
140
+ menu: (e) => b("select__menu", e.placement === "top" && "select__menu--top"),
117
141
  menuPortal: () => "select__menu-portal",
118
142
  menuList: () => "select__menu-list",
119
- option: (e) => f("select__option", e.isFocused && "select__option--focused", e.isSelected && "select__option--selected", e.isDisabled && "select__option--disabled"),
143
+ option: (e) => b("select__option", e.isFocused && "select__option--focused", e.isSelected && "select__option--selected", e.isDisabled && "select__option--disabled"),
120
144
  group: () => "select__group",
121
145
  groupHeading: () => "select__group-heading",
122
146
  noOptionsMessage: () => "select__menu-notice",
@@ -124,10 +148,10 @@ var f = (...e) => l(e), p = {
124
148
  }, n = { ...t };
125
149
  for (let r of Object.keys(e)) {
126
150
  let i = t[r], a = e[r];
127
- n[r] = (e) => f(i?.(e), a?.(e));
151
+ n[r] = (e) => b(i?.(e), a?.(e));
128
152
  }
129
153
  return n;
130
- }, x = ["label"], se = (e) => {
154
+ }, he = ["label"], ge = (e) => {
131
155
  for (let t of [
132
156
  /\n+/,
133
157
  /,\s/,
@@ -137,102 +161,130 @@ var f = (...e) => l(e), p = {
137
161
  if (n.length > 1) return n;
138
162
  }
139
163
  return e.split(/\s+/);
140
- }, ce = (e) => e.flatMap((e) => e && typeof e == "object" && "options" in e ? [...e.options] : [e]), S = t((e, t) => {
141
- let { id: s, elementId: l, errors: d = [], showErrors: m, isErrorLabelVisible: h, tone: g = p.Danger, icon: _ = null, isCreatable: S = !1, isAsync: C = !1, onCreateOption: w, createOptionPlaceholder: le = "Create ", minSearchLength: ue, searchableKeys: de = x, promiseOptions: T, customStyles: fe, actionColor: E, minHeightInput: pe, styles: D, classNames: O, components: k, className: A, isMulti: j, isDisabled: M = !1, isLoading: N, isSearchable: P, isOptionDisabled: F, placeholder: I = "Select", menuPlacement: L = "auto", loadOptions: R, noOptionsMessage: z, formatCreateLabel: B, options: V, value: H, onChange: U, ...me } = e, he = r(), W = s ?? l ?? he, ge = d.length > 0, [G, K] = a(!1), q = i(!0), J = i(null);
142
- n(() => () => {
164
+ }, _e = (e) => e.flatMap((e) => e && typeof e == "object" && "options" in e ? [...e.options] : [e]), j = u((t, n) => {
165
+ let { id: r, inputId: a, elementId: o, errors: u = [], showErrors: f, isErrorLabelVisible: h, tone: g = x.Danger, icon: _ = null, isCreatable: S = !1, isAsync: C = !1, onCreateOption: w, createOptionPlaceholder: T = "Create ", minSearchLength: E, searchableKeys: D = he, promiseOptions: O, customStyles: k, actionColor: A, minHeightInput: j, styles: M, classNames: ve, components: N, className: ye, isMulti: P, isDisabled: F = !1, isLoading: be, isSearchable: xe, isOptionDisabled: Se, placeholder: Ce = "Select", menuPlacement: we = "auto", loadOptions: Te, noOptionsMessage: I, formatCreateLabel: Ee, options: L, value: R, onChange: z, ...B } = t, V = ee(), De = r ?? o ?? V, H = a ?? r ?? o ?? V, U = s(), Oe = c(), W = l(), ke = u.length > 0 || W !== void 0, Ae = W ?? g, [G, K] = te(!1), q = p(!0), J = p(null);
166
+ d(() => () => {
143
167
  q.current = !1;
144
168
  }, []);
145
- let _e = (e) => {
146
- J.current = e, typeof t == "function" ? t(e) : t && (t.current = e);
147
- }, Y = ue ?? (T ? 2 : 0), X = R ?? T, ve = async (e) => {
169
+ let je = (e) => {
170
+ J.current = e, typeof n == "function" ? n(e) : n && (n.current = e);
171
+ }, Y = E ?? (O ? 2 : 0), X = Te ?? O, Me = async (e) => {
148
172
  if (w) try {
149
173
  K(!0), await w(e);
150
174
  } finally {
151
175
  q.current && K(!1);
152
176
  }
153
- }, ye = (e) => {
154
- if (!j || !V || !U) return;
155
- let t = se(e.clipboardData.getData("text/plain")).map((e) => e.trim().toLowerCase()).filter(Boolean);
177
+ }, Ne = (e) => {
178
+ if (!P || !L || !z) return;
179
+ let t = ge(e.clipboardData.getData("text/plain")).map((e) => e.trim().toLowerCase()).filter(Boolean);
156
180
  if (t.length < 2) return;
157
- let n = ce(V).filter((e) => de.some((n) => t.includes(String(e[n]).toLowerCase())));
181
+ let n = _e(L).filter((e) => D.some((n) => t.includes(String(e[n]).toLowerCase())));
158
182
  if (n.length === 0) return;
159
- let r = Array.isArray(H) ? H : [], i = [...r, ...n.filter((e) => !r.includes(e))];
160
- e.preventDefault(), U(i, {
183
+ let r = Array.isArray(R) ? R : [], i = [...r, ...n.filter((e) => !r.includes(e))];
184
+ e.preventDefault(), z(i, {
161
185
  action: "select-option",
162
186
  option: n[0]
163
187
  }), setTimeout(() => J.current?.blur(), 0);
164
- }, be = {
165
- id: W,
166
- errors: d,
167
- showErrors: m ?? h ?? !0,
168
- tone: g,
169
- icon: _
170
- }, xe = {
171
- Control: ne,
172
- IndicatorsContainer: re,
188
+ }, Pe = {
189
+ IndicatorsContainer: se,
173
190
  IndicatorSeparator: null,
174
- DropdownIndicator: v,
175
- ClearIndicator: ie,
176
- MultiValueRemove: ae,
177
- Option: oe,
178
- LoadingIndicator: y,
179
- ...k
191
+ DropdownIndicator: ce,
192
+ ClearIndicator: le,
193
+ MultiValueRemove: ue,
194
+ Option: de,
195
+ LoadingIndicator: fe,
196
+ ...N,
197
+ Control: oe
180
198
  }, Z = {
181
- ...me,
182
- id: W,
183
- library: be,
199
+ ...B,
200
+ id: a === void 0 ? void 0 : r ?? o,
201
+ inputId: H,
202
+ "aria-invalid": B["aria-invalid"] ?? (U?.isInvalid || void 0),
203
+ library: {
204
+ id: De,
205
+ inputId: H,
206
+ errors: u,
207
+ showErrors: f ?? h ?? !0,
208
+ tone: g,
209
+ icon: _,
210
+ hasFieldMark: Oe?.display === i.Compact,
211
+ describedBy: U?.describedBy,
212
+ control: N?.Control ?? ae
213
+ },
184
214
  unstyled: !0,
185
- options: V,
186
- value: H,
187
- onChange: U,
188
- isMulti: j,
189
- placeholder: I,
190
- menuPlacement: L,
191
- isSearchable: P ?? !!j,
192
- isOptionDisabled: F ?? (j ? void 0 : () => !1),
193
- isDisabled: M || G,
194
- isLoading: N || G,
215
+ options: L,
216
+ value: R,
217
+ onChange: z,
218
+ isMulti: P,
219
+ placeholder: Ce,
220
+ menuPlacement: we,
221
+ isSearchable: xe ?? !!P,
222
+ isOptionDisabled: Se ?? (P ? void 0 : () => !1),
223
+ isDisabled: F || G,
224
+ isLoading: be || G,
195
225
  styles: {
196
- ...fe,
197
- ...D
226
+ ...k,
227
+ ...M
198
228
  },
199
- classNames: b(O),
200
- components: xe,
201
- noOptionsMessage: (e) => e.inputValue.length < Y ? `Enter ${Y} or more characters` : z?.(e) ?? "No options",
202
- ref: _e
229
+ classNames: me(ve),
230
+ components: Pe,
231
+ noOptionsMessage: (e) => e.inputValue.length < Y ? `Enter ${Y} or more characters` : I?.(e) ?? "No options",
232
+ ref: je
203
233
  }, Q = {
204
- formatCreateLabel: B ?? ((e) => `${le}"${e}"`),
205
- ...w && { onCreateOption: ve }
234
+ formatCreateLabel: Ee ?? ((e) => `${T}"${e}"`),
235
+ ...w && { onCreateOption: Me }
206
236
  }, $ = { loadOptions: (e, t) => {
207
237
  if (e.length < Y || !X) {
208
238
  t([]);
209
239
  return;
210
240
  }
211
241
  return X(e, t);
212
- } }, Se = C && S ? /* @__PURE__ */ u(te, {
242
+ } }, Fe = () => C && S ? /* @__PURE__ */ v(re, {
213
243
  ...Z,
214
244
  ...Q,
215
245
  ...$
216
- }) : C ? /* @__PURE__ */ u(ee, {
246
+ }) : C ? /* @__PURE__ */ v(ne, {
217
247
  ...Z,
218
248
  ...$
219
- }) : S ? /* @__PURE__ */ u(c, {
249
+ }) : S ? /* @__PURE__ */ v(ie, {
220
250
  ...Z,
221
251
  ...Q
222
- }) : /* @__PURE__ */ u(o, { ...Z }), Ce = E ? {
223
- "--select-chip-bg": E,
252
+ }) : /* @__PURE__ */ v(m, { ...Z }), Ie = U && /* @__PURE__ */ v(e.Control, {
253
+ id: H,
254
+ render: pe
255
+ }), Le = A ? {
256
+ "--select-chip-bg": A,
224
257
  "--select-chip-text": "var(--color-light)"
225
258
  } : void 0;
226
- return /* @__PURE__ */ u("div", {
227
- className: f("select", ge && "select--invalid", g === p.Warning && "select--warning", A),
228
- "data-is-disabled": M,
229
- style: Ce,
230
- onPaste: ye,
231
- children: Se
259
+ return /* @__PURE__ */ y("div", {
260
+ className: b("select", ke && "select--invalid", Ae === x.Warning && "select--warning", ye),
261
+ "data-is-disabled": F,
262
+ style: Le,
263
+ onPaste: Ne,
264
+ children: [Ie, Fe()]
265
+ });
266
+ }), M = u((e, t) => {
267
+ let { field: r, rest: i } = o(e), { isRequired: s, ...c } = i, l = s || c.required;
268
+ return a(e) ? /* @__PURE__ */ v(n, {
269
+ field: r,
270
+ errors: c.errors,
271
+ tone: c.tone,
272
+ isDisabled: c.isDisabled,
273
+ className: "select-field",
274
+ children: /* @__PURE__ */ v(j, {
275
+ ...c,
276
+ errors: void 0,
277
+ ref: t,
278
+ required: l
279
+ })
280
+ }) : /* @__PURE__ */ v(j, {
281
+ ...c,
282
+ ref: t,
283
+ required: l
232
284
  });
233
285
  });
234
- S.displayName = "Select";
286
+ M.displayName = "Select";
235
287
  //#endregion
236
- export { S as Select, S as default, p as SelectTone, s as components };
288
+ export { M as Select, M as default, x as SelectTone, h as components };
237
289
 
238
290
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/cn.ts","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the select\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import type {ReactNode, Ref} from 'react';\nimport type {GroupBase, SelectInstance, StylesConfig} from 'react-select';\nimport type {AsyncProps} from 'react-select/async';\nimport type {CreatableProps} from 'react-select/creatable';\n\nexport type Option = {\n value: number | string;\n label: ReactNode;\n /** Read by `isOptionDisabled` when the caller passes one. */\n isOptionDisabled?: boolean;\n /** A chosen value the product flags: its chip takes the danger colours. */\n isException?: boolean;\n};\n\nexport type OptionGroup<O = Option> = GroupBase<O>;\n\n/** Which colour the errors are shown in. */\nexport const SelectTone = {\n Danger: 'danger',\n Warning: 'warning',\n} as const;\nexport type SelectTone = (typeof SelectTone)[keyof typeof SelectTone];\n\ntype OwnProps<O, M extends boolean, G extends GroupBase<O>> = {\n /** Names the select, its `!` mark (`error-label-${id}`) and its clear cross (`${id}-clear`). */\n id?: string;\n /** The `!` mark in the field and the red contour. */\n errors?: ReadonlyArray<string>;\n /** Hides the mark and keeps the contour. @default true */\n showErrors?: boolean;\n /** @default 'danger' */\n tone?: SelectTone;\n /** An icon at the start of the field. */\n icon?: ReactNode;\n /** Lets the user add an option that is not in the list. */\n isCreatable?: boolean;\n /** Loads the options with `loadOptions` as the user types. */\n isAsync?: boolean;\n /** Called with the text of a new option. A promise shows the spinner until it settles. */\n onCreateOption?: (inputValue: string) => void | Promise<void>;\n /** What the create row starts with: `Create \"…\"`. @default 'Create ' */\n createOptionPlaceholder?: string;\n /** How many characters an async search waits for; it says so until then. @default 0 */\n minSearchLength?: number;\n /**\n * The option keys a pasted list is matched against. Pasting \"a, b, c\" into a\n * multi select picks every option whose key equals one of the parts.\n * @default ['label']\n */\n searchableKeys?: Array<keyof O>;\n ref?: Ref<SelectInstance<O, M, G>>;\n\n /** @deprecated TagsInput's name for `id`. */\n elementId?: string;\n /** @deprecated TagsInput's name for `showErrors`. */\n isErrorLabelVisible?: boolean;\n /** @deprecated TagsInput's name for `styles`. */\n customStyles?: StylesConfig<O, M, G>;\n /** @deprecated TagsInput's async loader: `loadOptions` with a two-character minimum. */\n promiseOptions?: (inputValue: string) => Promise<ReadonlyArray<O | G>>;\n /** @deprecated TagsInput's chip colour. Set `--select-chip-bg` on an ancestor instead. */\n actionColor?: string;\n /** @deprecated The field grows with its chips. Accepted and ignored. */\n minHeightInput?: number;\n};\n\n/**\n * Every prop of react-select, of its async and creatable flavours, and the\n * library's own. Nothing is dropped on the way to react-select.\n */\nexport type SelectProps<O = Option, M extends boolean = boolean, G extends GroupBase<O> = GroupBase<O>> = Omit<\n Partial<AsyncProps<O, M, G> & CreatableProps<O, M, G>>,\n 'id' | 'onCreateOption'\n> &\n OwnProps<O, M, G>;\n","import ErrorLabel from '@propellerads/error-label';\nimport {\n type ClipboardEvent,\n type CSSProperties,\n type ForwardedRef,\n forwardRef,\n type ReactElement,\n type ReactNode,\n useEffect,\n useId,\n useRef,\n useState,\n} from 'react';\nimport ReactSelect, {\n type ActionMeta,\n type ClassNamesConfig,\n type ClearIndicatorProps,\n type ControlProps,\n type DropdownIndicatorProps,\n type GroupBase,\n type IndicatorsContainerProps,\n type LoadingIndicatorProps,\n type MultiValueRemoveProps,\n type OnChangeValue,\n type OptionProps,\n components as reactSelectComponents,\n type SelectComponentsConfig,\n type SelectInstance,\n type StylesConfig,\n} from 'react-select';\nimport AsyncSelect from 'react-select/async';\nimport AsyncCreatableSelect from 'react-select/async-creatable';\nimport CreatableSelect from 'react-select/creatable';\nimport './select.css';\nimport {cn} from './cn';\nimport {type Option, type OptionGroup, type SelectProps, SelectTone} from './types';\n\n/*\n * react-select, unstyled, with every part given a class from select.css. The\n * behaviour — keyboard, search, async, creatable, multi, portals — is\n * react-select's own, and every prop it takes reaches it. What the library adds\n * rides on `selectProps.library`, so the parts below can stay the same\n * components across renders: a part created inside a render would remount the\n * menu on every keystroke.\n */\n\ntype Library = {\n id: string;\n errors: ReadonlyArray<string>;\n showErrors: boolean;\n tone: SelectTone;\n icon: ReactNode;\n};\n\ntype AnyProps = {selectProps: unknown};\n\nconst libraryOf = (props: AnyProps): Library => (props.selectProps as {library: Library}).library;\n\nconst ChevronIcon = () => (\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M4 6l4 4 4-4\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n);\n\nconst CrossIcon = ({size = 16}: {size?: number}) => (\n <svg viewBox=\"0 0 16 16\" width={size} height={size} fill=\"none\" aria-hidden=\"true\">\n <path d=\"M4.5 4.5l7 7M11.5 4.5l-7 7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n);\n\nconst CheckIcon = () => (\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M3 8.5l3 3 7-7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n);\n\nconst Control = <O, M extends boolean, G extends GroupBase<O>>({children, ...props}: ControlProps<O, M, G>) => {\n const {icon} = libraryOf(props);\n\n return (\n <reactSelectComponents.Control {...props}>\n {icon && <span className=\"select__icon\">{icon}</span>}\n {children}\n </reactSelectComponents.Control>\n );\n};\n\n/** The `!` mark stands with the other indicators, before the clear cross and the chevron. */\nconst IndicatorsContainer = <O, M extends boolean, G extends GroupBase<O>>({\n children,\n ...props\n}: IndicatorsContainerProps<O, M, G>) => {\n const {id, errors, showErrors, tone} = libraryOf(props);\n\n return (\n <reactSelectComponents.IndicatorsContainer {...props}>\n {showErrors && errors.length > 0 && (\n // The field opens its menu on mousedown; the mark keeps its own click.\n <span className=\"select__errors\" onMouseDown={(event) => event.stopPropagation()}>\n <ErrorLabel\n elementId={id}\n errors={[...errors]}\n errorColor={tone === SelectTone.Warning ? 'var(--color-warning)' : undefined}\n />\n </span>\n )}\n {children}\n </reactSelectComponents.IndicatorsContainer>\n );\n};\n\nconst DropdownIndicator = <O, M extends boolean, G extends GroupBase<O>>(props: DropdownIndicatorProps<O, M, G>) => (\n <reactSelectComponents.DropdownIndicator {...props}>\n <ChevronIcon />\n </reactSelectComponents.DropdownIndicator>\n);\n\n/** The clear cross keeps TagsInput's `${id}-clear`, which products and tests find it by. */\nconst ClearIndicator = <O, M extends boolean, G extends GroupBase<O>>(props: ClearIndicatorProps<O, M, G>) => {\n const {id} = libraryOf(props);\n\n return (\n <reactSelectComponents.ClearIndicator {...props} innerProps={{...props.innerProps, id: `${id}-clear`}}>\n <CrossIcon />\n </reactSelectComponents.ClearIndicator>\n );\n};\n\nconst MultiValueRemove = <O, M extends boolean, G extends GroupBase<O>>(props: MultiValueRemoveProps<O, M, G>) => (\n <reactSelectComponents.MultiValueRemove {...props}>\n <CrossIcon size={12} />\n </reactSelectComponents.MultiValueRemove>\n);\n\n/** A single select marks the chosen item with a check, as shadcn's does. */\nconst OptionWithCheck = <O, M extends boolean, G extends GroupBase<O>>({children, ...props}: OptionProps<O, M, G>) => (\n <reactSelectComponents.Option {...props}>\n {children}\n {props.isSelected && !props.isMulti && (\n <span className=\"select__option-check\">\n <CheckIcon />\n </span>\n )}\n </reactSelectComponents.Option>\n);\n\nconst LoadingIndicator = <O, M extends boolean, G extends GroupBase<O>>({\n innerProps,\n}: LoadingIndicatorProps<O, M, G>) => (\n <span {...innerProps} className=\"select__indicator select__loading-indicator\" role=\"status\" aria-label=\"Loading\" />\n);\n\n/** The class every part takes. A product's own `classNames` is added after ours. */\nconst partClassNames = <O, M extends boolean, G extends GroupBase<O>>(\n own: ClassNamesConfig<O, M, G> = {},\n): ClassNamesConfig<O, M, G> => {\n const ours: ClassNamesConfig<O, M, G> = {\n control: (state) =>\n cn(\n 'select__control',\n state.isFocused && 'select__control--focused',\n state.isDisabled && 'select__control--disabled',\n state.menuIsOpen && 'select__control--menu-is-open',\n ),\n valueContainer: (state) =>\n cn(\n 'select__value-container',\n state.isMulti && 'select__value-container--is-multi',\n state.hasValue && 'select__value-container--has-value',\n ),\n placeholder: () => 'select__placeholder',\n singleValue: () => 'select__single-value',\n input: () => 'select__input-container',\n indicatorsContainer: () => 'select__indicators',\n indicatorSeparator: () => 'select__indicator-separator',\n dropdownIndicator: () => 'select__indicator select__dropdown-indicator',\n clearIndicator: () => 'select__indicator select__clear-indicator',\n loadingIndicator: () => 'select__indicator select__loading-indicator',\n multiValue: (state) =>\n cn('select__multi-value', (state.data as Option).isException && 'select__multi-value--exception'),\n multiValueLabel: () => 'select__multi-value-label',\n multiValueRemove: () => 'select__multi-value-remove',\n menu: (state) => cn('select__menu', state.placement === 'top' && 'select__menu--top'),\n menuPortal: () => 'select__menu-portal',\n menuList: () => 'select__menu-list',\n option: (state) =>\n cn(\n 'select__option',\n state.isFocused && 'select__option--focused',\n state.isSelected && 'select__option--selected',\n state.isDisabled && 'select__option--disabled',\n ),\n group: () => 'select__group',\n groupHeading: () => 'select__group-heading',\n noOptionsMessage: () => 'select__menu-notice',\n loadingMessage: () => 'select__menu-notice',\n };\n\n const merged: ClassNamesConfig<O, M, G> = {...ours};\n\n for (const key of Object.keys(own) as Array<keyof ClassNamesConfig<O, M, G>>) {\n const mine = ours[key] as ((state: unknown) => string) | undefined;\n const theirs = own[key] as ((state: unknown) => string) | undefined;\n (merged as Record<string, (state: unknown) => string>)[key] = (state) => cn(mine?.(state), theirs?.(state));\n }\n\n return merged;\n};\n\nconst DEFAULT_KEYS = ['label'];\n\n/** The parts of a pasted list, split the way TagsInput did: by lines, by \", \", by \",\", or by spaces. */\nconst splitPasted = (text: string): string[] => {\n for (const separator of [/\\n+/, /,\\s/, /,+/]) {\n const parts = text.split(separator);\n if (parts.length > 1) {\n return parts;\n }\n }\n\n return text.split(/\\s+/);\n};\n\nconst flatten = <O, G extends GroupBase<O>>(options: ReadonlyArray<O | G>): O[] =>\n options.flatMap((item) =>\n item && typeof item === 'object' && 'options' in item ? [...(item as G).options] : [item as O],\n );\n\n/**\n * A select on react-select with the library's look: one field for a single\n * value, several as chips, a list that loads as the user types, and new values\n * the user creates. Every react-select prop is accepted and passed on.\n */\nconst SelectInner = <O = Option, M extends boolean = false, G extends GroupBase<O> = OptionGroup<O>>(\n props: SelectProps<O, M, G>,\n ref: ForwardedRef<SelectInstance<O, M, G>>,\n) => {\n const {\n id: idProp,\n elementId,\n errors = [],\n showErrors,\n isErrorLabelVisible,\n tone = SelectTone.Danger,\n icon = null,\n isCreatable = false,\n isAsync = false,\n onCreateOption,\n createOptionPlaceholder = 'Create ',\n minSearchLength,\n searchableKeys = DEFAULT_KEYS as Array<keyof O>,\n promiseOptions,\n customStyles,\n actionColor,\n minHeightInput: _minHeightInput,\n styles,\n classNames,\n components,\n className,\n isMulti,\n isDisabled = false,\n isLoading,\n isSearchable,\n isOptionDisabled,\n placeholder = 'Select',\n menuPlacement = 'auto',\n loadOptions,\n noOptionsMessage,\n formatCreateLabel,\n options,\n value,\n onChange,\n ...rest\n } = props;\n\n const fallbackId = useId();\n const id = idProp ?? elementId ?? fallbackId;\n const isInvalid = errors.length > 0;\n\n const [isCreating, setCreating] = useState(false);\n const isMounted = useRef(true);\n const selectRef = useRef<SelectInstance<O, M, G> | null>(null);\n\n useEffect(\n () => () => {\n isMounted.current = false;\n },\n [],\n );\n\n const setRef = (instance: SelectInstance<O, M, G> | null): void => {\n selectRef.current = instance;\n if (typeof ref === 'function') {\n ref(instance);\n } else if (ref) {\n ref.current = instance;\n }\n };\n\n // TagsInput waited for two characters before it asked the server.\n const minimum = minSearchLength ?? (promiseOptions ? 2 : 0);\n const loader = loadOptions ?? promiseOptions;\n\n const handleCreateOption = async (inputValue: string): Promise<void> => {\n if (!onCreateOption) {\n return;\n }\n\n try {\n setCreating(true);\n await onCreateOption(inputValue);\n } finally {\n if (isMounted.current) {\n setCreating(false);\n }\n }\n };\n\n // Pasting a list into a multi select picks the options it names.\n const handlePaste = (event: ClipboardEvent<HTMLDivElement>): void => {\n if (!isMulti || !options || !onChange) {\n return;\n }\n\n const parts = splitPasted(event.clipboardData.getData('text/plain'))\n .map((part) => part.trim().toLowerCase())\n .filter(Boolean);\n\n if (parts.length < 2) {\n return;\n }\n\n const found = flatten<O, G>(options).filter((option) =>\n searchableKeys.some((key: keyof O) => parts.includes(String(option[key]).toLowerCase())),\n );\n\n if (found.length === 0) {\n return;\n }\n\n const current = (Array.isArray(value) ? value : []) as O[];\n const next = [...current, ...found.filter((option) => !current.includes(option))];\n\n event.preventDefault();\n onChange(next as unknown as OnChangeValue<O, M>, {action: 'select-option', option: found[0]} as ActionMeta<O>);\n setTimeout(() => selectRef.current?.blur(), 0);\n };\n\n const library: Library = {\n id,\n errors,\n showErrors: showErrors ?? isErrorLabelVisible ?? true,\n tone,\n icon,\n };\n\n const parts: Partial<SelectComponentsConfig<O, M, G>> = {\n Control,\n IndicatorsContainer,\n IndicatorSeparator: null,\n DropdownIndicator,\n ClearIndicator,\n MultiValueRemove,\n Option: OptionWithCheck,\n LoadingIndicator,\n ...components,\n };\n\n const selectProps = {\n ...rest,\n id,\n library,\n unstyled: true,\n options,\n value,\n onChange,\n isMulti,\n placeholder,\n menuPlacement,\n // v5 of the single select was not searchable by default; TagsInput was.\n isSearchable: isSearchable ?? Boolean(isMulti),\n // v5 of the single select ignored `isDisabled` on options unless told otherwise.\n isOptionDisabled: isOptionDisabled ?? (isMulti ? undefined : () => false),\n isDisabled: isDisabled || isCreating,\n isLoading: isLoading || isCreating,\n styles: {...customStyles, ...styles} as StylesConfig<O, M, G>,\n classNames: partClassNames(classNames),\n components: parts,\n noOptionsMessage: (input: {inputValue: string}) =>\n input.inputValue.length < minimum\n ? `Enter ${minimum} or more characters`\n : (noOptionsMessage?.(input) ?? 'No options'),\n ref: setRef,\n };\n\n const creatableProps = {\n formatCreateLabel: formatCreateLabel ?? ((inputValue: string) => `${createOptionPlaceholder}\"${inputValue}\"`),\n ...(onCreateOption && {onCreateOption: handleCreateOption}),\n };\n\n const asyncProps = {\n loadOptions: (inputValue: string, callback: (options: ReadonlyArray<O | G>) => void) => {\n if (inputValue.length < minimum || !loader) {\n callback([]);\n return undefined;\n }\n\n return loader(inputValue, callback);\n },\n };\n\n // The four flavours of react-select share one set of props; the casts only\n // tell TypeScript which flavour it is looking at.\n const field = (() => {\n if (isAsync && isCreatable) {\n return <AsyncCreatableSelect {...(selectProps as object)} {...creatableProps} {...asyncProps} />;\n }\n if (isAsync) {\n return <AsyncSelect {...(selectProps as object)} {...asyncProps} />;\n }\n if (isCreatable) {\n return <CreatableSelect {...(selectProps as object)} {...creatableProps} />;\n }\n return <ReactSelect {...(selectProps as object)} />;\n })();\n\n const style = actionColor\n ? ({'--select-chip-bg': actionColor, '--select-chip-text': 'var(--color-light)'} as CSSProperties)\n : undefined;\n\n return (\n <div\n className={cn(\n 'select',\n isInvalid && 'select--invalid',\n tone === SelectTone.Warning && 'select--warning',\n className,\n )}\n data-is-disabled={isDisabled}\n style={style}\n onPaste={handlePaste}\n >\n {field}\n </div>\n );\n};\n\n// `forwardRef` does not keep the generics, so the type is written out by hand.\nconst Select = forwardRef(SelectInner) as unknown as (<\n O = Option,\n M extends boolean = false,\n G extends GroupBase<O> = OptionGroup<O>,\n>(\n props: SelectProps<O, M, G>,\n) => ReactElement) & {displayName?: string};\nSelect.displayName = 'Select';\n\nexport default Select;\n\nexport type {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EK,IAAc;EAClB,GAAG;EACH;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EAEA,cAAc,KAAgB,EAAQ;EAEtC,kBAAkB,MAAqB,IAAU,KAAA,UAAkB;EACnE,YAAY,KAAc;EAC1B,WAAW,KAAa;EACxB,QAAQ;GAAC,GAAG;GAAc,GAAG;GAAO;EACpC,YAAY,EAAe,EAAW;EACtC,YAAY;EACZ,mBAAmB,MACjB,EAAM,WAAW,SAAS,IACtB,SAAS,EAAQ,uBAChB,IAAmB,EAAM,IAAI;EACpC,KAAK;EACN,EAEK,IAAiB;EACrB,mBAAmB,OAAuB,MAAuB,GAAG,GAAwB,GAAG,EAAW;EAC1G,GAAI,KAAkB,EAAC,gBAAgB,IAAmB;EAC3D,EAEK,IAAa,EACjB,cAAc,GAAoB,MAAsD;EACtF,IAAI,EAAW,SAAS,KAAW,CAAC,GAAQ;GAC1C,EAAS,EAAE,CAAC;GACZ;;EAGF,OAAO,EAAO,GAAY,EAAS;IAEtC,EAIK,KACA,KAAW,IACN,kBAAC,IAAD;EAAsB,GAAK;EAAwB,GAAI;EAAgB,GAAI;EAAc,CAAA,GAE9F,IACK,kBAAC,IAAD;EAAa,GAAK;EAAwB,GAAI;EAAc,CAAA,GAEjE,IACK,kBAAC,GAAD;EAAiB,GAAK;EAAwB,GAAI;EAAkB,CAAA,GAEtE,kBAAC,GAAD,EAAa,GAAK,GAA0B,CAAA,EAG/C,KAAQ,IACT;EAAC,oBAAoB;EAAa,sBAAsB;EAAqB,GAC9E,KAAA;CAEJ,OACE,kBAAC,OAAD;EACE,WAAW,EACT,UACA,MAAa,mBACb,MAAS,EAAW,WAAW,mBAC/B,EACD;EACD,oBAAkB;EACX;EACP,SAAS;YAER;EACG,CAAA;EAK4B;AAOtC,EAAO,cAAc"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/cn.ts","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the select\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import type {FieldOwnProps as LabelFieldOwnProps} from '@propellerads/label';\nimport type {ReactNode, Ref} from 'react';\nimport type {GroupBase, SelectInstance, StylesConfig} from 'react-select';\nimport type {AsyncProps} from 'react-select/async';\nimport type {CreatableProps} from 'react-select/creatable';\n\nexport type Option = {\n value: number | string;\n label: ReactNode;\n /** Read by `isOptionDisabled` when the caller passes one. */\n isOptionDisabled?: boolean;\n /** A chosen value the product flags: its chip takes the danger colours. */\n isException?: boolean;\n};\n\nexport type OptionGroup<O = Option> = GroupBase<O>;\n\n/** Which colour the old `errors` are shown in. */\nexport const SelectTone = {\n Danger: 'danger',\n Warning: 'warning',\n} as const;\nexport type SelectTone = (typeof SelectTone)[keyof typeof SelectTone];\n\n/**\n * The field around the select: its label and its message, laid out by Label's\n * `Field`. Given any of `label`, `description`, `error` or `warning`, the\n * select draws the field itself, with the message behind a mark among the\n * indicators by default.\n */\ntype FieldOwnProps = LabelFieldOwnProps & {\n /** Sets `required`, which the input says with `aria-required`. No mark: the optional fields are the ones marked. */\n isRequired?: boolean;\n};\n\ntype OwnProps<O, M extends boolean, G extends GroupBase<O>> = FieldOwnProps & {\n /**\n * Names the select's input, so `<Label for={id}>` and a click on it find the\n * select; also its `!` mark (`error-label-${id}`) and its clear cross\n * (`${id}-clear`). react-select's `inputId`, when passed, names the input instead.\n */\n id?: string;\n /**\n * @deprecated Use `error`, or `warning` for the warning tone. The `!` mark\n * among the indicators and the contour in the tone.\n */\n errors?: ReadonlyArray<string>;\n /** @deprecated Hides the `!` mark of `errors` and keeps the contour. Use `error` with `messageDisplay`. @default true */\n showErrors?: boolean;\n /** @deprecated Use `warning` instead of `errors` with `tone=\"warning\"`. @default 'danger' */\n tone?: SelectTone;\n /** An icon at the start of the field. */\n icon?: ReactNode;\n /** Lets the user add an option that is not in the list. */\n isCreatable?: boolean;\n /** Loads the options with `loadOptions` as the user types. */\n isAsync?: boolean;\n /** Called with the text of a new option. A promise shows the spinner until it settles. */\n onCreateOption?: (inputValue: string) => void | Promise<void>;\n /** What the create row starts with: `Create \"…\"`. @default 'Create ' */\n createOptionPlaceholder?: string;\n /** How many characters an async search waits for; it says so until then. @default 0 */\n minSearchLength?: number;\n /**\n * The option keys a pasted list is matched against. Pasting \"a, b, c\" into a\n * multi select picks every option whose key equals one of the parts.\n * @default ['label']\n */\n searchableKeys?: Array<keyof O>;\n ref?: Ref<SelectInstance<O, M, G>>;\n\n /** @deprecated TagsInput's name for `id`. */\n elementId?: string;\n /** @deprecated TagsInput's name for `showErrors`. Use `error` with `messageDisplay`. */\n isErrorLabelVisible?: boolean;\n /** @deprecated TagsInput's name for `styles`. */\n customStyles?: StylesConfig<O, M, G>;\n /** @deprecated TagsInput's async loader: `loadOptions` with a two-character minimum. */\n promiseOptions?: (inputValue: string) => Promise<ReadonlyArray<O | G>>;\n /** @deprecated TagsInput's chip colour. Set `--select-chip-bg` on an ancestor instead. */\n actionColor?: string;\n /** @deprecated The field grows with its chips. Accepted and ignored. */\n minHeightInput?: number;\n};\n\n/**\n * Every prop of react-select, of its async and creatable flavours, and the\n * library's own. Nothing is dropped on the way to react-select.\n */\nexport type SelectProps<O = Option, M extends boolean = boolean, G extends GroupBase<O> = GroupBase<O>> = Omit<\n Partial<AsyncProps<O, M, G> & CreatableProps<O, M, G>>,\n 'id' | 'onCreateOption'\n> &\n OwnProps<O, M, G>;\n","import {Field as BaseField} from '@base-ui-components/react/field';\nimport ErrorLabel from '@propellerads/error-label';\nimport {\n ControlField,\n FieldMark,\n hasFieldProps,\n MessageDisplay,\n splitFieldProps,\n useFieldIds,\n useFieldMessage,\n useFieldTone,\n} from '@propellerads/label';\nimport {\n type ClipboardEvent,\n type ComponentType,\n type CSSProperties,\n type ForwardedRef,\n forwardRef,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport ReactSelect, {\n type ActionMeta,\n type ClassNamesConfig,\n type ClearIndicatorProps,\n type ControlProps,\n type DropdownIndicatorProps,\n type GroupBase,\n type IndicatorsContainerProps,\n type LoadingIndicatorProps,\n type MultiValueRemoveProps,\n type OnChangeValue,\n type OptionProps,\n components as reactSelectComponents,\n type SelectComponentsConfig,\n type SelectInstance,\n type StylesConfig,\n} from 'react-select';\nimport AsyncSelect from 'react-select/async';\nimport AsyncCreatableSelect from 'react-select/async-creatable';\nimport CreatableSelect from 'react-select/creatable';\nimport './select.css';\nimport {cn} from './cn';\nimport {type Option, type OptionGroup, type SelectProps, SelectTone} from './types';\n\n/*\n * react-select, unstyled, with every part given a class from select.css. The\n * behaviour — keyboard, search, async, creatable, multi, portals — is\n * react-select's own, and every prop it takes reaches it. What the library adds\n * rides on `selectProps.library`, so the parts below can stay the same\n * components across renders: a part created inside a render would remount the\n * menu on every keystroke.\n */\n\ntype Library = {\n id: string;\n inputId: string;\n errors: ReadonlyArray<string>;\n showErrors: boolean;\n tone: SelectTone;\n icon: ReactNode;\n /** The field's mark stands with the indicators in the compact display. */\n hasFieldMark: boolean;\n /** The ids of the field's message, which the input is described by. */\n describedBy: string | undefined;\n /** The control that draws the box: ours, or the one a product passed in `components`. */\n control: ComponentType<ControlProps<unknown, boolean, GroupBase<unknown>>>;\n};\n\ntype AnyProps = {selectProps: unknown};\n\nconst libraryOf = (props: AnyProps): Library => (props.selectProps as {library: Library}).library;\n\nconst ChevronIcon = () => (\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M4 6l4 4 4-4\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n);\n\nconst CrossIcon = ({size = 16}: {size?: number}) => (\n <svg viewBox=\"0 0 16 16\" width={size} height={size} fill=\"none\" aria-hidden=\"true\">\n <path d=\"M4.5 4.5l7 7M11.5 4.5l-7 7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n </svg>\n);\n\nconst CheckIcon = () => (\n <svg viewBox=\"0 0 16 16\" width=\"16\" height=\"16\" fill=\"none\" aria-hidden=\"true\">\n <path d=\"M3 8.5l3 3 7-7\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n);\n\n// A layout effect, so the ids are back before the browser paints or a screen\n// reader looks; on a server there is no DOM to fix, and React warns about one.\nconst useIsoLayoutEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;\n\n/** The ids in an `aria-describedby`. */\nconst idsOf = (value: string | null | undefined): string[] => (value ?? '').split(' ').filter(Boolean);\n\n/**\n * Describes the input by the field's message. react-select writes the input's\n * `aria-describedby` itself — the placeholder, the live region — and takes none\n * from outside, and the input of a select that is not searchable cannot be\n * replaced. So the ids are added to whatever react-select wrote, after every\n * render of react-select: React rewrites the attribute only when react-select's\n * own value changes, and then the ids go back on. `added` remembers what was\n * added last, so a message that is gone leaves no id behind.\n */\nconst useDescribedBy = (inputId: string, describedBy: string | undefined) => {\n const added = useRef<string[]>([]);\n\n useIsoLayoutEffect(() => {\n // Outside a field there is nothing to add.\n const input = describedBy || added.current.length > 0 ? document.getElementById(inputId) : null;\n if (!input) {\n return;\n }\n const next = idsOf(describedBy);\n const own = idsOf(input.getAttribute('aria-describedby')).filter(\n (id) => !added.current.includes(id) && !next.includes(id),\n );\n const value = [...own, ...next].join(' ');\n added.current = next;\n if (value === '') {\n input.removeAttribute('aria-describedby');\n } else if (input.getAttribute('aria-describedby') !== value) {\n input.setAttribute('aria-describedby', value);\n }\n });\n};\n\nconst Control = <O, M extends boolean, G extends GroupBase<O>>({children, ...props}: ControlProps<O, M, G>) => {\n const {icon} = libraryOf(props);\n\n return (\n <reactSelectComponents.Control {...props}>\n {icon && <span className=\"select__icon\">{icon}</span>}\n {children}\n </reactSelectComponents.Control>\n );\n};\n\n/**\n * Whichever control draws the box — ours, or a product's from `components` —\n * goes inside this one, which describes the input by the field's message. It\n * renders with every render of react-select, the moment react-select may have\n * rewritten the input's `aria-describedby`, so the ids go back on even when a\n * product replaces the control.\n */\nconst DescribedControl = <O, M extends boolean, G extends GroupBase<O>>(props: ControlProps<O, M, G>) => {\n const {inputId, describedBy, control: Own} = libraryOf(props);\n useDescribedBy(inputId, describedBy);\n\n return <Own {...(props as unknown as ControlProps<unknown, boolean, GroupBase<unknown>>)} />;\n};\n\n// The field opens its menu on mousedown, and on Space, which it then cancels:\n// a mark keeps both for itself, so a click or Space opens its bubble. Escape\n// goes on, for the bubble to close on.\nconst keepMouseDown = (event: MouseEvent) => event.stopPropagation();\nconst keepSpace = (event: KeyboardEvent) => {\n if (event.key === ' ') {\n event.stopPropagation();\n }\n};\n\n/** The `!` mark stands with the other indicators, before the clear cross and the chevron. */\nconst IndicatorsContainer = <O, M extends boolean, G extends GroupBase<O>>({\n children,\n ...props\n}: IndicatorsContainerProps<O, M, G>) => {\n const {id, errors, showErrors, tone, hasFieldMark} = libraryOf(props);\n\n return (\n <reactSelectComponents.IndicatorsContainer {...props}>\n {hasFieldMark && (\n <span className=\"select__mark\" onMouseDown={keepMouseDown} onKeyDown={keepSpace}>\n <FieldMark />\n </span>\n )}\n {showErrors && errors.length > 0 && (\n // The field opens its menu on mousedown; the mark keeps its own click.\n <span className=\"select__errors\" onMouseDown={(event) => event.stopPropagation()}>\n <ErrorLabel\n elementId={id}\n errors={[...errors]}\n errorColor={tone === SelectTone.Warning ? 'var(--color-warning)' : undefined}\n />\n </span>\n )}\n {children}\n </reactSelectComponents.IndicatorsContainer>\n );\n};\n\nconst DropdownIndicator = <O, M extends boolean, G extends GroupBase<O>>(props: DropdownIndicatorProps<O, M, G>) => (\n <reactSelectComponents.DropdownIndicator {...props}>\n <ChevronIcon />\n </reactSelectComponents.DropdownIndicator>\n);\n\n/** The clear cross keeps TagsInput's `${id}-clear`, which products and tests find it by. */\nconst ClearIndicator = <O, M extends boolean, G extends GroupBase<O>>(props: ClearIndicatorProps<O, M, G>) => {\n const {id} = libraryOf(props);\n\n return (\n <reactSelectComponents.ClearIndicator {...props} innerProps={{...props.innerProps, id: `${id}-clear`}}>\n <CrossIcon />\n </reactSelectComponents.ClearIndicator>\n );\n};\n\nconst MultiValueRemove = <O, M extends boolean, G extends GroupBase<O>>(props: MultiValueRemoveProps<O, M, G>) => (\n <reactSelectComponents.MultiValueRemove {...props}>\n <CrossIcon size={12} />\n </reactSelectComponents.MultiValueRemove>\n);\n\n/** A single select marks the chosen item with a check, as shadcn's does. */\nconst OptionWithCheck = <O, M extends boolean, G extends GroupBase<O>>({children, ...props}: OptionProps<O, M, G>) => (\n <reactSelectComponents.Option {...props}>\n {children}\n {props.isSelected && !props.isMulti && (\n <span className=\"select__option-check\">\n <CheckIcon />\n </span>\n )}\n </reactSelectComponents.Option>\n);\n\nconst LoadingIndicator = <O, M extends boolean, G extends GroupBase<O>>({\n innerProps,\n}: LoadingIndicatorProps<O, M, G>) => (\n <span {...innerProps} className=\"select__indicator select__loading-indicator\" role=\"status\" aria-label=\"Loading\" />\n);\n\n// What the field's control renders: nothing, see `registration` below.\nconst renderNothing = () => <></>;\n\n/** The class every part takes. A product's own `classNames` is added after ours. */\nconst partClassNames = <O, M extends boolean, G extends GroupBase<O>>(\n own: ClassNamesConfig<O, M, G> = {},\n): ClassNamesConfig<O, M, G> => {\n const ours: ClassNamesConfig<O, M, G> = {\n control: (state) =>\n cn(\n 'select__control',\n state.isFocused && 'select__control--focused',\n state.isDisabled && 'select__control--disabled',\n state.menuIsOpen && 'select__control--menu-is-open',\n ),\n valueContainer: (state) =>\n cn(\n 'select__value-container',\n state.isMulti && 'select__value-container--is-multi',\n state.hasValue && 'select__value-container--has-value',\n ),\n placeholder: () => 'select__placeholder',\n singleValue: () => 'select__single-value',\n input: () => 'select__input-container',\n indicatorsContainer: () => 'select__indicators',\n indicatorSeparator: () => 'select__indicator-separator',\n dropdownIndicator: () => 'select__indicator select__dropdown-indicator',\n clearIndicator: () => 'select__indicator select__clear-indicator',\n loadingIndicator: () => 'select__indicator select__loading-indicator',\n multiValue: (state) =>\n cn('select__multi-value', (state.data as Option).isException && 'select__multi-value--exception'),\n multiValueLabel: () => 'select__multi-value-label',\n multiValueRemove: () => 'select__multi-value-remove',\n menu: (state) => cn('select__menu', state.placement === 'top' && 'select__menu--top'),\n menuPortal: () => 'select__menu-portal',\n menuList: () => 'select__menu-list',\n option: (state) =>\n cn(\n 'select__option',\n state.isFocused && 'select__option--focused',\n state.isSelected && 'select__option--selected',\n state.isDisabled && 'select__option--disabled',\n ),\n group: () => 'select__group',\n groupHeading: () => 'select__group-heading',\n noOptionsMessage: () => 'select__menu-notice',\n loadingMessage: () => 'select__menu-notice',\n };\n\n const merged: ClassNamesConfig<O, M, G> = {...ours};\n\n for (const key of Object.keys(own) as Array<keyof ClassNamesConfig<O, M, G>>) {\n const mine = ours[key] as ((state: unknown) => string) | undefined;\n const theirs = own[key] as ((state: unknown) => string) | undefined;\n (merged as Record<string, (state: unknown) => string>)[key] = (state) => cn(mine?.(state), theirs?.(state));\n }\n\n return merged;\n};\n\nconst DEFAULT_KEYS = ['label'];\n\n/** The parts of a pasted list, split the way TagsInput did: by lines, by \", \", by \",\", or by spaces. */\nconst splitPasted = (text: string): string[] => {\n for (const separator of [/\\n+/, /,\\s/, /,+/]) {\n const parts = text.split(separator);\n if (parts.length > 1) {\n return parts;\n }\n }\n\n return text.split(/\\s+/);\n};\n\nconst flatten = <O, G extends GroupBase<O>>(options: ReadonlyArray<O | G>): O[] =>\n options.flatMap((item) =>\n item && typeof item === 'object' && 'options' in item ? [...(item as G).options] : [item as O],\n );\n\n/** The select in its box: the contour, the indicators and the old `errors` mark. */\nconst SelectBoxInner = <O = Option, M extends boolean = false, G extends GroupBase<O> = OptionGroup<O>>(\n props: SelectProps<O, M, G>,\n ref: ForwardedRef<SelectInstance<O, M, G>>,\n) => {\n const {\n id: idProp,\n inputId: inputIdProp,\n elementId,\n errors = [],\n showErrors,\n isErrorLabelVisible,\n tone = SelectTone.Danger,\n icon = null,\n isCreatable = false,\n isAsync = false,\n onCreateOption,\n createOptionPlaceholder = 'Create ',\n minSearchLength,\n searchableKeys = DEFAULT_KEYS as Array<keyof O>,\n promiseOptions,\n customStyles,\n actionColor,\n minHeightInput: _minHeightInput,\n styles,\n classNames,\n components,\n className,\n isMulti,\n isDisabled = false,\n isLoading,\n isSearchable,\n isOptionDisabled,\n placeholder = 'Select',\n menuPlacement = 'auto',\n loadOptions,\n noOptionsMessage,\n formatCreateLabel,\n options,\n value,\n onChange,\n ...rest\n } = props;\n\n const fallbackId = useId();\n const id = idProp ?? elementId ?? fallbackId;\n // The id goes to the input, where `<Label for>` and a click on the label find\n // it; react-select would give it to its wrapper and name the input itself.\n const inputId = inputIdProp ?? idProp ?? elementId ?? fallbackId;\n // The ids of the field the select stands in: react-select's input is not a\n // Base UI control, so it is described and marked invalid by hand.\n const fieldIds = useFieldIds();\n const fieldMessage = useFieldMessage();\n // The field's error or warning draws the contour in its tone.\n const fieldTone = useFieldTone();\n const isInvalid = errors.length > 0 || fieldTone !== undefined;\n const shownTone = fieldTone ?? tone;\n\n const [isCreating, setCreating] = useState(false);\n const isMounted = useRef(true);\n const selectRef = useRef<SelectInstance<O, M, G> | null>(null);\n\n useEffect(\n () => () => {\n isMounted.current = false;\n },\n [],\n );\n\n const setRef = (instance: SelectInstance<O, M, G> | null): void => {\n selectRef.current = instance;\n if (typeof ref === 'function') {\n ref(instance);\n } else if (ref) {\n ref.current = instance;\n }\n };\n\n // TagsInput waited for two characters before it asked the server.\n const minimum = minSearchLength ?? (promiseOptions ? 2 : 0);\n const loader = loadOptions ?? promiseOptions;\n\n const handleCreateOption = async (inputValue: string): Promise<void> => {\n if (!onCreateOption) {\n return;\n }\n\n try {\n setCreating(true);\n await onCreateOption(inputValue);\n } finally {\n if (isMounted.current) {\n setCreating(false);\n }\n }\n };\n\n // Pasting a list into a multi select picks the options it names.\n const handlePaste = (event: ClipboardEvent<HTMLDivElement>): void => {\n if (!isMulti || !options || !onChange) {\n return;\n }\n\n const parts = splitPasted(event.clipboardData.getData('text/plain'))\n .map((part) => part.trim().toLowerCase())\n .filter(Boolean);\n\n if (parts.length < 2) {\n return;\n }\n\n const found = flatten<O, G>(options).filter((option) =>\n searchableKeys.some((key: keyof O) => parts.includes(String(option[key]).toLowerCase())),\n );\n\n if (found.length === 0) {\n return;\n }\n\n const current = (Array.isArray(value) ? value : []) as O[];\n const next = [...current, ...found.filter((option) => !current.includes(option))];\n\n event.preventDefault();\n onChange(next as unknown as OnChangeValue<O, M>, {action: 'select-option', option: found[0]} as ActionMeta<O>);\n setTimeout(() => selectRef.current?.blur(), 0);\n };\n\n const parts: Partial<SelectComponentsConfig<O, M, G>> = {\n IndicatorsContainer,\n IndicatorSeparator: null,\n DropdownIndicator,\n ClearIndicator,\n MultiValueRemove,\n Option: OptionWithCheck,\n LoadingIndicator,\n ...components,\n // A product's control goes inside ours, which keeps the input described.\n Control: DescribedControl,\n };\n\n const selectProps = {\n ...rest,\n // The wrapper keeps the id only when the input has a name of its own.\n id: inputIdProp === undefined ? undefined : (idProp ?? elementId),\n inputId,\n 'aria-invalid': rest['aria-invalid'] ?? (fieldIds?.isInvalid || undefined),\n library: {\n id,\n inputId,\n errors,\n showErrors: showErrors ?? isErrorLabelVisible ?? true,\n tone,\n icon,\n hasFieldMark: fieldMessage?.display === MessageDisplay.Compact,\n describedBy: fieldIds?.describedBy,\n control: (components?.Control ?? Control) as Library['control'],\n } satisfies Library,\n unstyled: true,\n options,\n value,\n onChange,\n isMulti,\n placeholder,\n menuPlacement,\n // v5 of the single select was not searchable by default; TagsInput was.\n isSearchable: isSearchable ?? Boolean(isMulti),\n // v5 of the single select ignored `isDisabled` on options unless told otherwise.\n isOptionDisabled: isOptionDisabled ?? (isMulti ? undefined : () => false),\n isDisabled: isDisabled || isCreating,\n isLoading: isLoading || isCreating,\n styles: {...customStyles, ...styles} as StylesConfig<O, M, G>,\n classNames: partClassNames(classNames),\n components: parts,\n noOptionsMessage: (input: {inputValue: string}) =>\n input.inputValue.length < minimum\n ? `Enter ${minimum} or more characters`\n : (noOptionsMessage?.(input) ?? 'No options'),\n ref: setRef,\n };\n\n const creatableProps = {\n formatCreateLabel: formatCreateLabel ?? ((inputValue: string) => `${createOptionPlaceholder}\"${inputValue}\"`),\n ...(onCreateOption && {onCreateOption: handleCreateOption}),\n };\n\n const asyncProps = {\n loadOptions: (inputValue: string, callback: (options: ReadonlyArray<O | G>) => void) => {\n if (inputValue.length < minimum || !loader) {\n callback([]);\n return undefined;\n }\n\n return loader(inputValue, callback);\n },\n };\n\n // The four flavours of react-select share one set of props; the casts only\n // tell TypeScript which flavour it is looking at.\n const renderSelect = () => {\n if (isAsync && isCreatable) {\n return <AsyncCreatableSelect {...(selectProps as object)} {...creatableProps} {...asyncProps} />;\n }\n if (isAsync) {\n return <AsyncSelect {...(selectProps as object)} {...asyncProps} />;\n }\n if (isCreatable) {\n return <CreatableSelect {...(selectProps as object)} {...creatableProps} />;\n }\n return <ReactSelect {...(selectProps as object)} />;\n };\n\n // Base UI points the field's label at the control registered with the field\n // and keeps that registry to itself: `Field.Control` is the one way in. So it\n // registers the input's id and renders nothing — the input is react-select's,\n // named by the same id, and the label's `for` finds it.\n const registration = fieldIds && <BaseField.Control id={inputId} render={renderNothing} />;\n\n const style = actionColor\n ? ({'--select-chip-bg': actionColor, '--select-chip-text': 'var(--color-light)'} as CSSProperties)\n : undefined;\n\n return (\n <div\n className={cn(\n 'select',\n isInvalid && 'select--invalid',\n shownTone === SelectTone.Warning && 'select--warning',\n className,\n )}\n data-is-disabled={isDisabled}\n style={style}\n onPaste={handlePaste}\n >\n {registration}\n {renderSelect()}\n </div>\n );\n};\n\n// `forwardRef` does not keep the generics, so the types are written out by hand.\nconst SelectBox = forwardRef(SelectBoxInner) as unknown as <\n O = Option,\n M extends boolean = false,\n G extends GroupBase<O> = OptionGroup<O>,\n>(\n props: SelectProps<O, M, G> & {ref?: ForwardedRef<SelectInstance<O, M, G>>},\n) => ReactElement;\n\n/**\n * A select on react-select with the library's look: one field for a single\n * value, several as chips, a list that loads as the user types, and new values\n * the user creates. Every react-select prop is accepted and passed on.\n *\n * With a `label`, a `description`, an `error` or a `warning` it draws its\n * field: the label on top, on the left or hidden, and the message behind a mark\n * among the indicators or, with `messageDisplay=\"line\"`, under it.\n */\nconst SelectInner = <O = Option, M extends boolean = false, G extends GroupBase<O> = OptionGroup<O>>(\n props: SelectProps<O, M, G>,\n ref: ForwardedRef<SelectInstance<O, M, G>>,\n) => {\n const {field, rest} = splitFieldProps(props);\n const {isRequired, ...control} = rest;\n const required = isRequired || control.required;\n\n if (!hasFieldProps(props)) {\n return <SelectBox<O, M, G> {...control} ref={ref} required={required} />;\n }\n\n return (\n <ControlField\n field={field}\n errors={control.errors}\n tone={control.tone}\n isDisabled={control.isDisabled}\n className=\"select-field\"\n >\n {/* The errors are the field's now, written by it. */}\n <SelectBox<O, M, G> {...control} errors={undefined} ref={ref} required={required} />\n </ControlField>\n );\n};\n\nconst Select = forwardRef(SelectInner) as unknown as (<\n O = Option,\n M extends boolean = false,\n G extends GroupBase<O> = OptionGroup<O>,\n>(\n props: SelectProps<O, M, G>,\n) => ReactElement) & {displayName?: string};\nSelect.displayName = 'Select';\n\nexport default Select;\n\nexport type {Option, OptionGroup, SelectProps};\nexport {reactSelectComponents as components, Select, SelectTone};\n"],"mappings":";;;;;;;;;;;AAOA,IAAM,KAAM,GAAG,MAAiC,EAAK,EAAO,ECW/C,IAAa;CACxB,QAAQ;CACR,SAAS;CACV,ECyDK,KAAa,MAA8B,EAAM,YAAmC,SAEpF,UACJ,kBAAC,OAAD;CAAK,SAAQ;CAAY,OAAM;CAAK,QAAO;CAAK,MAAK;CAAO,eAAY;WACtE,kBAAC,QAAD;EAAM,GAAE;EAAe,QAAO;EAAe,aAAY;EAAM,eAAc;EA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AI;GAAS,QAAQ,KAAA;GAAgB;GAAe;GAAY,CAAA;EACvE,CAAA,GAbR,kBAAC,GAAD;EAAoB,GAAI;EAAc;EAAe;EAAY,CAAA;EAiBtC;AAOtC,EAAO,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@propellerads/select",
3
- "version": "8.0.0",
3
+ "version": "9.0.0",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/index.css",
@@ -29,7 +29,9 @@
29
29
  "homepage": "https://github.com/propellerads/ui-components#readme",
30
30
  "private": false,
31
31
  "dependencies": {
32
- "@propellerads/error-label": "^8.0.0",
32
+ "@base-ui-components/react": "1.0.0-rc.0",
33
+ "@propellerads/error-label": "^8.0.1",
34
+ "@propellerads/label": "^6.1.0",
33
35
  "clsx": "^2.1.1",
34
36
  "react-select": "^5.10.2"
35
37
  },