@propellerads/select 5.0.0 → 6.0.1

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 ADDED
@@ -0,0 +1,125 @@
1
+ # Select
2
+
3
+ One select for one value, several values as chips, a list that loads as the
4
+ user types, and values the user creates. It is
5
+ [react-select](https://react-select.com) 5 with the library's look: react-select
6
+ renders unstyled and every part takes a class from one stylesheet, where every
7
+ colour, gap, corner and duration comes from
8
+ [@propellerads/tokens](../Tokens/README.md). The field matches
9
+ [Input](../Input/README.md) and [Button](../Button/README.md); the menu and its
10
+ items follow [shadcn's Select](https://ui.shadcn.com/docs/components/select).
11
+
12
+ It replaces `@propellerads/tags-input`: a multi select does everything it did.
13
+
14
+ ![](https://img.shields.io/npm/v/@propellerads/select.svg?style=flat-square)
15
+
16
+ [NPM](https://www.npmjs.com/package/@propellerads/select) |
17
+ [Github](https://github.com/propellerads/ui-components/tree/master/Components/Select)
18
+
19
+ ## Installation
20
+
21
+ ```sh
22
+ bun add @propellerads/select
23
+ ```
24
+
25
+ The built entry imports its own stylesheet. The tokens are the app's:
26
+
27
+ ```ts
28
+ import '@propellerads/tokens/common.css';
29
+ import '@propellerads/tokens/propellerads.css'; // or monetag / propush / zeydoo
30
+ ```
31
+
32
+ ## Use
33
+
34
+ ```tsx
35
+ import Select from '@propellerads/select';
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} />
42
+ ```
43
+
44
+ **Every react-select prop is accepted and passed on** — `isMulti`,
45
+ `filterOption`, `formatOptionLabel`, `getOptionLabel`, `menuPortalTarget`,
46
+ `closeMenuOnSelect`, `classNamePrefix`, `name`, and the rest, with the async
47
+ and creatable ones. A product's `styles` is written inline by react-select, so
48
+ it wins over the library's classes, as before. Its `components` replace the
49
+ library's, part by part. Its `classNames` are added to the library's.
50
+
51
+ ## What the library adds
52
+
53
+ | Prop | Default | What it does |
54
+ |---------------------------|-------------|---------------------------------------------------------------------|
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 |
59
+ | `isCreatable` | `false` | Adds a `Create "…"` row. A promise from `onCreateOption` shows the spinner and locks the field |
60
+ | `createOptionPlaceholder` | `'Create '` | What the create row starts with |
61
+ | `isAsync` | `false` | Loads the options with `loadOptions` |
62
+ | `minSearchLength` | `0` | An async search waits for this many characters and says so |
63
+ | `searchableKeys` | `['label']` | Pasting a list into a multi select picks every option whose key equals one of its parts |
64
+
65
+ An option flagged `isException` shows its chip in the danger colours.
66
+
67
+ The defaults of v5 stay: a single select is not searchable, the placeholder is
68
+ "Select", the menu opens where there is room, and `isDisabled` on an option is
69
+ ignored unless `isOptionDisabled` is passed. A multi select is searchable, and
70
+ reads `isDisabled` on its options, as react-select does.
71
+
72
+ ## Moving from TagsInput
73
+
74
+ ```tsx
75
+ // before
76
+ <TagsInput elementId="geo" isMulti options={countries} value={value} onChange={setValue} />
77
+
78
+ // after
79
+ <Select id="geo" isMulti options={countries} value={value} onChange={setValue} />
80
+ ```
81
+
82
+ TagsInput's own props still work on Select and are deprecated, so a first move
83
+ can be the import alone:
84
+
85
+ | TagsInput | Select |
86
+ |-----------------------|-----------------------------------------------------------|
87
+ | `elementId` | `id` |
88
+ | `isErrorLabelVisible` | `showErrors` |
89
+ | `customStyles` | `styles` — all of it, not only `control` |
90
+ | `promiseOptions` | `loadOptions` with `minSearchLength={2}` — the alias keeps the two characters |
91
+ | `actionColor` | `--select-chip-bg` on an ancestor |
92
+ | `minHeightInput` | ignored: the field grows with its chips |
93
+
94
+ Paste-to-select, `isException` chips, the `${id}-clear` cross, async and
95
+ creatable work as they did.
96
+
97
+ ## Parts and overrides
98
+
99
+ The parts take `select__*` classes: `select__control`, `select__menu`,
100
+ `select__option`, `select__multi-value` and the rest, with state modifiers such
101
+ as `select__control--focused` and `select__option--selected`. The custom
102
+ properties are the override API:
103
+
104
+ ```css
105
+ .filters .select {
106
+ --select-menu-max-height: 240px;
107
+ --select-chip-bg: var(--color-quiet-bg);
108
+ --select-chip-text: var(--color-dark-inversion);
109
+ }
110
+ ```
111
+
112
+ `--select-menu-z-index` (2500 by default) lifts the menu above a modal that
113
+ stands higher.
114
+
115
+ ## Tokens
116
+
117
+ | What | Token |
118
+ |-------------------|----------------------------------------------------------------|
119
+ | Field | 36px, `--radius-8`, contour `--color-rich`, hover `--color-quiet` |
120
+ | Focus ring | `--color-rich`, as the contour; with errors, the tone's `--color-danger` or `--color-warning`. 2px, offset 1px — the button's |
121
+ | Menu | `--color-light-inversion`, contour `--color-rich`, `--shadow-middle`, `--radius-8` |
122
+ | Item under pointer| `--color-action` at `--opacity-tint`; the check `--color-action` |
123
+ | Chips | `--color-action-bg` / `--color-action-text`; exceptions `--color-danger-bg` / `--color-danger-text` |
124
+ | Group heading | `--font-description`, `--color-quiet-text` |
125
+ | Motion | the menu appears from 95% in `--duration-200` |
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .select{--select-height:36px;--select-contour:var(--color-rich);--select-ring:var(--color-rich);--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;min-height:var(--select-height);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{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:var(--space-4)}.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}}
package/dist/index.d.ts CHANGED
@@ -1,29 +1,78 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
- import { Props, GroupBase, StylesConfig } from 'react-select';
2
+ import { GroupBase, SelectInstance, StylesConfig } from 'react-select';
3
+ export { components } from 'react-select';
4
+ import { ReactNode, Ref } from 'react';
5
+ import { AsyncProps } from 'react-select/async';
6
+ import { CreatableProps } from 'react-select/creatable';
4
7
 
5
8
  type Option = {
6
9
  value: number | string;
7
- label: number | string;
10
+ label: ReactNode;
11
+ /** Read by `isOptionDisabled` when the caller passes one. */
8
12
  isOptionDisabled?: boolean;
13
+ /** A chosen value the product flags: its chip takes the danger colours. */
14
+ isException?: boolean;
9
15
  };
10
- type OptionGroup = GroupBase<Option>;
11
- type BaseSelectProps = Pick<Props<Option, false, OptionGroup>, 'id' | 'isClearable' | 'isDisabled' | 'isOptionDisabled' | 'isSearchable' | 'menuIsOpen' | 'onChange' | 'onMenuOpen' | 'options' | 'placeholder' | 'value' | 'menuPlacement' | 'components' | 'menuPortalTarget'>;
12
- type SelectProps = Omit<BaseSelectProps, 'id' | 'onChange' | 'options'> & {
13
- errors?: string[];
14
- id: NonNullable<BaseSelectProps['id']>;
15
- onChange: NonNullable<BaseSelectProps['onChange']>;
16
- options: NonNullable<BaseSelectProps['options']>;
16
+ type OptionGroup<O = Option> = GroupBase<O>;
17
+ /** Which colour the errors are shown in. */
18
+ declare const SelectTone: {
19
+ readonly Danger: "danger";
20
+ readonly Warning: "warning";
21
+ };
22
+ type SelectTone = (typeof SelectTone)[keyof typeof SelectTone];
23
+ type OwnProps<O, M extends boolean, G extends GroupBase<O>> = {
24
+ /** Names the select, its `!` mark (`error-label-${id}`) and its clear cross (`${id}-clear`). */
25
+ id?: string;
26
+ /** The `!` mark in the field and the red contour. */
27
+ errors?: ReadonlyArray<string>;
28
+ /** Hides the mark and keeps the contour. @default true */
29
+ showErrors?: boolean;
30
+ /** @default 'danger' */
31
+ tone?: SelectTone;
32
+ /** An icon at the start of the field. */
17
33
  icon?: ReactNode;
18
- onCreateOption?: (newValue: string) => void | Promise<void>;
34
+ /** Lets the user add an option that is not in the list. */
19
35
  isCreatable?: boolean;
36
+ /** Loads the options with `loadOptions` as the user types. */
37
+ isAsync?: boolean;
38
+ /** Called with the text of a new option. A promise shows the spinner until it settles. */
39
+ onCreateOption?: (inputValue: string) => void | Promise<void>;
40
+ /** What the create row starts with: `Create "…"`. @default 'Create ' */
20
41
  createOptionPlaceholder?: string;
42
+ /** How many characters an async search waits for; it says so until then. @default 0 */
43
+ minSearchLength?: number;
44
+ /**
45
+ * The option keys a pasted list is matched against. Pasting "a, b, c" into a
46
+ * multi select picks every option whose key equals one of the parts.
47
+ * @default ['label']
48
+ */
49
+ searchableKeys?: Array<keyof O>;
50
+ ref?: Ref<SelectInstance<O, M, G>>;
51
+ /** @deprecated TagsInput's name for `id`. */
52
+ elementId?: string;
53
+ /** @deprecated TagsInput's name for `showErrors`. */
54
+ isErrorLabelVisible?: boolean;
55
+ /** @deprecated TagsInput's name for `styles`. */
56
+ customStyles?: StylesConfig<O, M, G>;
57
+ /** @deprecated TagsInput's async loader: `loadOptions` with a two-character minimum. */
58
+ promiseOptions?: (inputValue: string) => Promise<ReadonlyArray<O | G>>;
59
+ /** @deprecated TagsInput's chip colour. Set `--select-chip-bg` on an ancestor instead. */
60
+ actionColor?: string;
61
+ /** @deprecated The field grows with its chips. Accepted and ignored. */
21
62
  minHeightInput?: number;
22
- styles?: StylesConfig<Option, false, OptionGroup>;
23
- menuPortalTarget?: HTMLElement;
24
63
  };
64
+ /**
65
+ * Every prop of react-select, of its async and creatable flavours, and the
66
+ * library's own. Nothing is dropped on the way to react-select.
67
+ */
68
+ type SelectProps<O = Option, M extends boolean = boolean, G extends GroupBase<O> = GroupBase<O>> = Omit<Partial<AsyncProps<O, M, G> & CreatableProps<O, M, G>>, 'id' | 'onCreateOption'> & OwnProps<O, M, G>;
25
69
 
26
- declare const Select: (props: SelectProps) => react_jsx_runtime.JSX.Element;
70
+ /**
71
+ * A select on react-select with the library's look: one field for a single
72
+ * value, several as chips, a list that loads as the user types, and new values
73
+ * the user creates. Every react-select prop is accepted and passed on.
74
+ */
75
+ declare const Select: <O = Option, M extends boolean = false, G extends GroupBase<O> = OptionGroup<O>>(props: SelectProps<O, M, G>) => react_jsx_runtime.JSX.Element;
27
76
 
28
- export { Select as default };
29
- export type { Option, SelectProps };
77
+ export { Select, SelectTone, Select as default };
78
+ export type { Option, OptionGroup, SelectProps };
package/dist/index.js CHANGED
@@ -1,125 +1,237 @@
1
- import { jsxs as C, jsx as i } from "react/jsx-runtime";
2
- import { useState as k, useRef as E, useEffect as M } from "react";
3
- import B, { components as F } from "react-select";
4
- import T from "react-select/creatable";
5
- import W from "@propellerads/error-label";
6
- import s from "styled-components";
7
- import { lineHeight as y, spacing as l, white as q, borderRadius as z, gray80 as A } from "@propellerads/stylevariables";
8
- const G = s.div`
9
- position: relative;
10
- `, J = s.div`
11
- position: absolute;
12
- right: 1px;
13
- top: 1px;
14
- display: flex;
15
- flex-direction: row;
16
- line-height: ${y}px;
17
- height: ${y}px;
18
- align-items: center;
19
- pointer-events: none;
20
- `, K = s.div`
21
- margin: 0 0 0 ${l * 2}px;
22
- display: inline-flex;
23
- align-items: center;
24
- `, N = (o = {}, n, t) => ({
25
- container: (e) => ({
26
- ...e,
27
- padding: 0
28
- }),
29
- control: () => ({
30
- border: t.length ? "1px solid red" : `1px solid ${A};`,
31
- height: 36,
32
- display: "flex",
33
- borderRadius: z,
34
- background: q
35
- }),
36
- indicatorSeparator: () => ({
37
- display: "none"
38
- }),
39
- dropdownIndicator: (e, r) => ({
40
- ...e,
41
- color: r.isFocused ? "black" : "grey",
42
- paddingRight: t.length ? l * 7 : l * 2
43
- }),
44
- valueContainer: (e) => ({
45
- ...e,
46
- paddingLeft: n ? l : l * 2
47
- }),
48
- ...o
49
- }), Q = (o) => ({ children: n, ...t }) => /* @__PURE__ */ C(F.Control, { ...t, children: [
50
- o && /* @__PURE__ */ i(K, { children: o }),
51
- n
52
- ] }), te = (o) => {
53
- const {
54
- options: n,
55
- id: t,
56
- isClearable: e,
57
- isSearchable: r = !1,
58
- isDisabled: c = !1,
59
- menuIsOpen: d,
60
- errors: p = [],
61
- placeholder: v = "Select",
62
- value: f,
63
- onChange: S,
64
- isOptionDisabled: O = () => !1,
65
- menuPlacement: L = "auto",
66
- icon: m = null,
67
- onCreateOption: $ = () => null,
68
- onMenuOpen: I = () => null,
69
- isCreatable: w = !1,
70
- createOptionPlaceholder: P = "Create ",
71
- components: R = {},
72
- styles: D = {},
73
- menuPortalTarget: u
74
- } = o, [g, h] = k(!1), b = E(!0);
75
- M(
76
- () => () => {
77
- b.current = !1;
78
- },
79
- []
80
- );
81
- const x = {
82
- id: t,
83
- onChange: S,
84
- onMenuOpen: I,
85
- options: n,
86
- placeholder: v,
87
- menuPlacement: L,
88
- isOptionDisabled: O,
89
- isSearchable: r,
90
- styles: N(D, !!m, p),
91
- isDisabled: g || c,
92
- components: {
93
- Control: Q(m),
94
- ...R
95
- },
96
- ...e !== void 0 && { isClearable: e },
97
- ...d !== void 0 && { menuIsOpen: d },
98
- ...f !== void 0 && { value: f },
99
- ...u !== void 0 && { menuPortalTarget: u }
100
- };
101
- async function H(a) {
102
- try {
103
- h(!0), await $(a);
104
- } finally {
105
- b.current && h(!1);
106
- }
107
- }
108
- const j = w ? /* @__PURE__ */ i(
109
- T,
110
- {
111
- formatCreateLabel: (a) => `${P}"${a}"`,
112
- isLoading: g,
113
- onCreateOption: H,
114
- ...x
115
- }
116
- ) : /* @__PURE__ */ i(B, { ...x });
117
- return /* @__PURE__ */ C(G, { "data-is-disabled": c, children: [
118
- j,
119
- /* @__PURE__ */ i(J, { children: /* @__PURE__ */ i(W, { elementId: t, errors: p }) })
120
- ] });
1
+ import e from "@propellerads/error-label";
2
+ import { useEffect as t, useId as n, useRef as r, useState as i } from "react";
3
+ import a, { components as o } from "react-select";
4
+ import s from "react-select/async";
5
+ import ee 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";
9
+ import './index.css';//#region src/cn.ts
10
+ var f = (...e) => l(e), p = {
11
+ Danger: "danger",
12
+ Warning: "warning"
13
+ }, m = (e) => e.selectProps.library, h = () => /* @__PURE__ */ u("svg", {
14
+ viewBox: "0 0 16 16",
15
+ width: "16",
16
+ height: "16",
17
+ fill: "none",
18
+ "aria-hidden": "true",
19
+ children: /* @__PURE__ */ u("path", {
20
+ d: "M4 6l4 4 4-4",
21
+ stroke: "currentColor",
22
+ strokeWidth: "1.5",
23
+ strokeLinecap: "round",
24
+ strokeLinejoin: "round"
25
+ })
26
+ }), g = ({ size: e = 16 }) => /* @__PURE__ */ u("svg", {
27
+ viewBox: "0 0 16 16",
28
+ width: e,
29
+ height: e,
30
+ fill: "none",
31
+ "aria-hidden": "true",
32
+ children: /* @__PURE__ */ u("path", {
33
+ d: "M4.5 4.5l7 7M11.5 4.5l-7 7",
34
+ stroke: "currentColor",
35
+ strokeWidth: "1.5",
36
+ strokeLinecap: "round"
37
+ })
38
+ }), _ = () => /* @__PURE__ */ u("svg", {
39
+ viewBox: "0 0 16 16",
40
+ width: "16",
41
+ height: "16",
42
+ fill: "none",
43
+ "aria-hidden": "true",
44
+ children: /* @__PURE__ */ u("path", {
45
+ d: "M3 8.5l3 3 7-7",
46
+ stroke: "currentColor",
47
+ strokeWidth: "1.5",
48
+ strokeLinecap: "round",
49
+ strokeLinejoin: "round"
50
+ })
51
+ }), te = ({ children: e, ...t }) => {
52
+ let { icon: n } = m(t);
53
+ return /* @__PURE__ */ d(o.Control, {
54
+ ...t,
55
+ children: [n && /* @__PURE__ */ u("span", {
56
+ className: "select__icon",
57
+ children: n
58
+ }), e]
59
+ });
60
+ }, ne = ({ children: t, ...n }) => {
61
+ let { id: r, errors: i, showErrors: a, tone: s } = m(n);
62
+ return /* @__PURE__ */ d(o.IndicatorsContainer, {
63
+ ...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: s === p.Warning ? "var(--color-warning)" : void 0
71
+ })
72
+ }), t]
73
+ });
74
+ }, re = (e) => /* @__PURE__ */ u(o.DropdownIndicator, {
75
+ ...e,
76
+ children: /* @__PURE__ */ u(h, {})
77
+ }), ie = (e) => {
78
+ let { id: t } = m(e);
79
+ return /* @__PURE__ */ u(o.ClearIndicator, {
80
+ ...e,
81
+ innerProps: {
82
+ ...e.innerProps,
83
+ id: `${t}-clear`
84
+ },
85
+ children: /* @__PURE__ */ u(g, {})
86
+ });
87
+ }, v = (e) => /* @__PURE__ */ u(o.MultiValueRemove, {
88
+ ...e,
89
+ children: /* @__PURE__ */ u(g, { size: 12 })
90
+ }), ae = ({ children: e, ...t }) => /* @__PURE__ */ d(o.Option, {
91
+ ...t,
92
+ children: [e, t.isSelected && !t.isMulti && /* @__PURE__ */ u("span", {
93
+ className: "select__option-check",
94
+ children: /* @__PURE__ */ u(_, {})
95
+ })]
96
+ }), y = ({ innerProps: e }) => /* @__PURE__ */ u("span", {
97
+ ...e,
98
+ className: "select__indicator select__loading-indicator",
99
+ role: "status",
100
+ "aria-label": "Loading"
101
+ }), oe = (e = {}) => {
102
+ 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"),
105
+ placeholder: () => "select__placeholder",
106
+ singleValue: () => "select__single-value",
107
+ input: () => "select__input-container",
108
+ indicatorsContainer: () => "select__indicators",
109
+ indicatorSeparator: () => "select__indicator-separator",
110
+ dropdownIndicator: () => "select__indicator select__dropdown-indicator",
111
+ clearIndicator: () => "select__indicator select__clear-indicator",
112
+ loadingIndicator: () => "select__indicator select__loading-indicator",
113
+ multiValue: (e) => f("select__multi-value", e.data.isException && "select__multi-value--exception"),
114
+ multiValueLabel: () => "select__multi-value-label",
115
+ multiValueRemove: () => "select__multi-value-remove",
116
+ menu: (e) => f("select__menu", e.placement === "top" && "select__menu--top"),
117
+ menuPortal: () => "select__menu-portal",
118
+ 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"),
120
+ group: () => "select__group",
121
+ groupHeading: () => "select__group-heading",
122
+ noOptionsMessage: () => "select__menu-notice",
123
+ loadingMessage: () => "select__menu-notice"
124
+ }, n = { ...t };
125
+ for (let r of Object.keys(e)) {
126
+ let i = t[r], a = e[r];
127
+ n[r] = (e) => f(i?.(e), a?.(e));
128
+ }
129
+ return n;
130
+ }, se = ["label"], ce = (e) => {
131
+ for (let t of [
132
+ /\n+/,
133
+ /,\s/,
134
+ /,+/
135
+ ]) {
136
+ let n = e.split(t);
137
+ if (n.length > 1) return n;
138
+ }
139
+ return e.split(/\s+/);
140
+ }, b = (e) => e.flatMap((e) => e && typeof e == "object" && "options" in e ? [...e.options] : [e]), x = (e) => {
141
+ let { id: o, elementId: l, errors: d = [], showErrors: m, isErrorLabelVisible: h, tone: g = p.Danger, icon: _ = null, isCreatable: x = !1, isAsync: S = !1, onCreateOption: C, createOptionPlaceholder: le = "Create ", minSearchLength: ue, searchableKeys: de = se, promiseOptions: w, customStyles: fe, actionColor: T, minHeightInput: pe, styles: E, classNames: D, components: O, className: k, ref: 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 = n(), W = o ?? l ?? he, ge = d.length > 0, [G, K] = i(!1), q = r(!0), J = r(null);
142
+ t(() => () => {
143
+ q.current = !1;
144
+ }, []);
145
+ let _e = (e) => {
146
+ J.current = e, typeof A == "function" ? A(e) : A && (A.current = e);
147
+ }, Y = ue ?? (w ? 2 : 0), X = R ?? w, ve = async (e) => {
148
+ if (C) try {
149
+ K(!0), await C(e);
150
+ } finally {
151
+ q.current && K(!1);
152
+ }
153
+ }, ye = (e) => {
154
+ if (!j || !V || !U) return;
155
+ let t = ce(e.clipboardData.getData("text/plain")).map((e) => e.trim().toLowerCase()).filter(Boolean);
156
+ if (t.length < 2) return;
157
+ let n = b(V).filter((e) => de.some((n) => t.includes(String(e[n]).toLowerCase())));
158
+ 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, {
161
+ action: "select-option",
162
+ option: n[0]
163
+ }), 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: te,
172
+ IndicatorsContainer: ne,
173
+ IndicatorSeparator: null,
174
+ DropdownIndicator: re,
175
+ ClearIndicator: ie,
176
+ MultiValueRemove: v,
177
+ Option: ae,
178
+ LoadingIndicator: y,
179
+ ...O
180
+ }, Z = {
181
+ ...me,
182
+ id: W,
183
+ library: be,
184
+ 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,
195
+ styles: {
196
+ ...fe,
197
+ ...E
198
+ },
199
+ classNames: oe(D),
200
+ components: xe,
201
+ noOptionsMessage: (e) => e.inputValue.length < Y ? `Enter ${Y} or more characters` : z?.(e) ?? "No options",
202
+ ref: _e
203
+ }, Q = {
204
+ formatCreateLabel: B ?? ((e) => `${le}"${e}"`),
205
+ ...C && { onCreateOption: ve }
206
+ }, $ = { loadOptions: (e, t) => {
207
+ if (e.length < Y || !X) {
208
+ t([]);
209
+ return;
210
+ }
211
+ return X(e, t);
212
+ } }, Se = S && x ? /* @__PURE__ */ u(ee, {
213
+ ...Z,
214
+ ...Q,
215
+ ...$
216
+ }) : S ? /* @__PURE__ */ u(s, {
217
+ ...Z,
218
+ ...$
219
+ }) : x ? /* @__PURE__ */ u(c, {
220
+ ...Z,
221
+ ...Q
222
+ }) : /* @__PURE__ */ u(a, { ...Z }), Ce = T ? {
223
+ "--select-chip-bg": T,
224
+ "--select-chip-text": "var(--color-light)"
225
+ } : void 0;
226
+ return /* @__PURE__ */ u("div", {
227
+ className: f("select", ge && "select--invalid", g === p.Warning && "select--warning", k),
228
+ "data-is-disabled": M,
229
+ style: Ce,
230
+ onPaste: ye,
231
+ children: Se
232
+ });
121
233
  };
122
- export {
123
- te as default
124
- };
125
- //# sourceMappingURL=index.js.map
234
+ //#endregion
235
+ export { x as Select, x as default, p as SelectTone, o as components };
236
+
237
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/style.tsx","../src/index.tsx"],"sourcesContent":["import styled from 'styled-components';\nimport type {StylesConfig} from 'react-select';\nimport {borderRadius, gray80, spacing, lineHeight, white} from '@propellerads/stylevariables';\nimport type {Option, OptionGroup, SelectProps} from './types';\n\nconst StyledSelect = styled.div`\n position: relative;\n`;\n\nconst SelectHelper = styled.div`\n position: absolute;\n right: 1px;\n top: 1px;\n display: flex;\n flex-direction: row;\n line-height: ${lineHeight}px;\n height: ${lineHeight}px;\n align-items: center;\n pointer-events: none;\n`;\n\nconst IconHelper = styled.div`\n margin: 0 0 0 ${spacing * 2}px;\n display: inline-flex;\n align-items: center;\n`;\n\nconst customStyles = (\n styles: SelectProps['styles'] = {},\n hasIcon: boolean,\n errors: string[],\n): StylesConfig<Option, false, OptionGroup> => ({\n container: (provided) => ({\n ...provided,\n padding: 0,\n }),\n control: () => ({\n border: errors.length ? '1px solid red' : `1px solid ${gray80};`,\n height: 36,\n display: 'flex',\n borderRadius,\n background: white,\n }),\n indicatorSeparator: () => ({\n display: 'none',\n }),\n dropdownIndicator: (provided, state) => ({\n ...provided,\n color: state.isFocused ? 'black' : 'grey',\n paddingRight: errors.length ? spacing * 7 : spacing * 2,\n }),\n valueContainer: (provided) => ({\n ...provided,\n paddingLeft: hasIcon ? spacing : spacing * 2,\n }),\n ...styles,\n});\n\nexport {StyledSelect, SelectHelper, IconHelper, customStyles};\n","import {useEffect, useRef, useState} from 'react';\nimport ReactSelect, {components as comp, type ControlProps} from 'react-select';\nimport Creatable from 'react-select/creatable';\nimport ErrorLabel from '@propellerads/error-label';\nimport {StyledSelect, SelectHelper, customStyles, IconHelper} from './style';\nimport type {Option, OptionGroup, SelectProps} from './types';\n\nconst controlWithIcon =\n (icon: SelectProps['icon']) =>\n ({children, ...props}: ControlProps<Option, false, OptionGroup>) => {\n return (\n <comp.Control {...props}>\n {icon && <IconHelper>{icon}</IconHelper>}\n {children}\n </comp.Control>\n );\n };\n\nconst Select = (props: SelectProps) => {\n const {\n options,\n id,\n isClearable,\n isSearchable = false,\n isDisabled = false,\n menuIsOpen,\n errors = [],\n placeholder = 'Select',\n value,\n onChange,\n isOptionDisabled = () => false,\n menuPlacement = 'auto',\n icon = null,\n onCreateOption = () => null,\n onMenuOpen = () => null,\n isCreatable = false,\n createOptionPlaceholder = 'Create ',\n components = {},\n styles = {},\n menuPortalTarget,\n } = props;\n\n const [isLoading, changeLoadingState] = useState(false);\n const isMounted = useRef(true);\n\n useEffect(\n () => () => {\n isMounted.current = false;\n },\n [],\n );\n\n const selectProps = {\n id,\n onChange,\n onMenuOpen,\n options,\n placeholder,\n menuPlacement,\n isOptionDisabled,\n isSearchable,\n styles: customStyles(styles, Boolean(icon), errors),\n isDisabled: isLoading || isDisabled,\n components: {\n Control: controlWithIcon(icon),\n ...components,\n },\n ...(isClearable !== undefined && {isClearable}),\n ...(menuIsOpen !== undefined && {menuIsOpen}),\n ...(value !== undefined && {value}),\n ...(menuPortalTarget !== undefined && {menuPortalTarget}),\n };\n\n async function onLocalCreateOption(newValue: string) {\n try {\n changeLoadingState(true);\n await onCreateOption(newValue);\n } finally {\n if (isMounted.current) {\n changeLoadingState(false);\n }\n }\n }\n\n const select = isCreatable ? (\n <Creatable\n formatCreateLabel={(newValue) => `${createOptionPlaceholder}\"${newValue}\"`}\n isLoading={isLoading}\n onCreateOption={onLocalCreateOption}\n {...selectProps}\n />\n ) : (\n <ReactSelect {...selectProps} />\n );\n\n return (\n <StyledSelect data-is-disabled={isDisabled}>\n {select}\n <SelectHelper>\n <ErrorLabel elementId={id} errors={errors} />\n </SelectHelper>\n </StyledSelect>\n );\n};\n\nexport default Select;\nexport type {Option, SelectProps} from './types';\n"],"names":["StyledSelect","styled","SelectHelper","lineHeight","IconHelper","spacing","customStyles","styles","hasIcon","errors","provided","gray80","borderRadius","white","state","controlWithIcon","icon","children","props","jsxs","comp","jsx","Select","options","id","isClearable","isSearchable","isDisabled","menuIsOpen","placeholder","value","onChange","isOptionDisabled","menuPlacement","onCreateOption","onMenuOpen","isCreatable","createOptionPlaceholder","components","menuPortalTarget","isLoading","changeLoadingState","useState","isMounted","useRef","useEffect","selectProps","onLocalCreateOption","newValue","select","Creatable","ReactSelect","ErrorLabel"],"mappings":";;;;;;;AAKA,MAAMA,IAAeC,EAAO;AAAA;AAAA,GAItBC,IAAeD,EAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAMXE,CAAU;AAAA,YACfA,CAAU;AAAA;AAAA;AAAA,GAKhBC,IAAaH,EAAO;AAAA,kBACRI,IAAU,CAAC;AAAA;AAAA;AAAA,GAKvBC,IAAe,CACnBC,IAAgC,IAChCC,GACAC,OAC8C;AAAA,EAC9C,WAAW,CAACC,OAAc;AAAA,IACxB,GAAGA;AAAA,IACH,SAAS;AAAA,EAAA;AAAA,EAEX,SAAS,OAAO;AAAA,IACd,QAAQD,EAAO,SAAS,kBAAkB,aAAaE,CAAM;AAAA,IAC7D,QAAQ;AAAA,IACR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5B,GAAI,QAAAf,GAAgB,EAAA,CAC7C;AAAA,EAAA,GACF;AAEJ;"}
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 {type ClipboardEvent, type CSSProperties, type ReactNode, useEffect, useId, useRef, useState} 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 Select = <O = Option, M extends boolean = false, G extends GroupBase<O> = OptionGroup<O>>(\n props: SelectProps<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 ref,\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\nexport default Select;\n\nexport type {Option, OptionGroup, SelectProps};\nexport {reactSelectComponents as components, Select, SelectTone};\n"],"mappings":";;;;;;;;;AAOA,IAAM,KAAM,GAAG,MAAiC,EAAK,EAAO,ECU/C,IAAa;CACxB,QAAQ;CACR,SAAS;CACV,ECyBK,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;EAAQ,gBAAe;EAAU,CAAA;CAC1G,CAAA,EAGF,KAAa,EAAC,UAAO,SACzB,kBAAC,OAAD;CAAK,SAAQ;CAAY,O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B,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,GAAD;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"}
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@propellerads/select",
3
- "version": "5.0.0",
3
+ "version": "6.0.1",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
+ "style": "dist/index.css",
6
7
  "exports": {
7
8
  ".": {
8
9
  "types": "./dist/index.d.ts",
9
10
  "import": "./dist/index.js"
10
- }
11
+ },
12
+ "./index.css": "./dist/index.css"
11
13
  },
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
12
17
  "files": [
13
18
  "dist"
14
19
  ],
@@ -19,25 +24,33 @@
19
24
  "url": "https://github.com/propellerads/ui-components/issues"
20
25
  },
21
26
  "scripts": {
22
- "build": "tsc && vite build && rollup -c rollup.dts.config.mjs"
27
+ "build": "tsc && vite build && bunx rollup -c rollup.dts.config.mjs"
23
28
  },
24
29
  "homepage": "https://github.com/propellerads/ui-components#readme",
25
30
  "private": false,
26
31
  "dependencies": {
27
- "@propellerads/error-label": "^5.0.2",
28
- "@propellerads/stylevariables": "^2.0.2",
29
- "react-select": "5.10.2"
32
+ "@propellerads/error-label": "^6.0.0",
33
+ "clsx": "^2.1.1",
34
+ "react-select": "^5.10.2"
30
35
  },
31
36
  "peerDependencies": {
37
+ "@propellerads/tokens": ">=0.2.0",
32
38
  "react": "^18.0.0 || ^19.0.0",
33
- "styled-components": "^5.1.1 || ^6.0.0"
39
+ "react-dom": "^18.0.0 || ^19.0.0"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "@propellerads/tokens": {
43
+ "optional": true
44
+ }
34
45
  },
35
46
  "devDependencies": {
47
+ "@propellerads/tokens": "workspace:^",
36
48
  "@types/react": "^19.2.14",
37
- "@vitejs/plugin-react": "^5.1.4",
38
- "rollup": "^4.58.0",
39
- "rollup-plugin-dts": "^6.3.0",
40
- "typescript": "^5.9.3",
41
- "vite": "^7.3.1"
49
+ "@vitejs/plugin-react": "^6.0.1",
50
+ "rollup": "^4.60.3",
51
+ "rollup-plugin-dts": "^6.4.1",
52
+ "typescript": "^6.0.3",
53
+ "vite": "^8.0.10",
54
+ "vite-plugin-lib-inject-css": "^2.2.2"
42
55
  }
43
56
  }