@reapit/elements 5.0.0-beta.49 → 5.0.0-beta.50

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.
@@ -1,10 +1,12 @@
1
- import type { ChangeEventHandler, InputHTMLAttributes, ReactNode } from 'react';
2
- type AttributesToOmit = 'size' | 'type';
1
+ import type { ChangeEventHandler, MouseEventHandler, InputHTMLAttributes, ReactNode } from 'react';
2
+ type AttributesToOmit = 'onClick' | 'size' | 'type';
3
3
  export interface ChipSelectChipProps extends Omit<InputHTMLAttributes<HTMLInputElement>, AttributesToOmit> {
4
4
  /** The accessible name of the chip. Should be considered mandatory when no visual label is provided. */
5
5
  'aria-label'?: string;
6
6
  /** The visual label of the chip. */
7
7
  children?: ReactNode;
8
+ /** Whether the chip is disabled. Disabled chips, even if checked, will not be submitted. */
9
+ disabled?: boolean;
8
10
  /**
9
11
  * The icon of the chip. All chips in the same chip select should either have an icon or not.
10
12
  * If there is no visual label provided via `children`, the icon should be considered mandatory.
@@ -21,8 +23,12 @@ export interface ChipSelectChipProps extends Omit<InputHTMLAttributes<HTMLInputE
21
23
  name?: string;
22
24
  /** Callback called when the chip's checked state changes. */
23
25
  onChange?: ChangeEventHandler<HTMLInputElement>;
26
+ /** Callback called when the chip is clicked. */
27
+ onClick?: MouseEventHandler<HTMLLabelElement>;
24
28
  /** Whether the label of the chip should be truncated if it is too long */
25
29
  overflow?: 'truncate';
30
+ /** Whether the chip is read-only. */
31
+ readOnly?: boolean;
26
32
  /** The size of the chip. All chips in the same chip select should have the same size. */
27
33
  size: 'small' | 'medium' | 'large';
28
34
  /** The value of the form control. */
@@ -1 +1 @@
1
- {"version":3,"file":"chip.d.ts","sourceRoot":"/","sources":["core/chip-select/chip/chip.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAK/E,KAAK,gBAAgB,GAAG,MAAM,GAAG,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Q,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,UAAU,MAAM,EAAE,CAAA;IAC7B,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAC/C,gDAAgD;IAChD,OAAO,CAAC,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAA;IAC7C,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,yFAAyF;IACzF,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;IAClC,qCAAqC;IACrC,KAAK,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAA;CACtD;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,kHAqE1B,CAAA"}
@@ -75,7 +75,13 @@ export declare const Sizes: Story;
75
75
  */
76
76
  export declare const Selected: Story;
77
77
  /**
78
- * Chips can also be disabled. Importantly, disabled chips do not participate in form submission.
78
+ * Chips can be read-only. When they are, they will still be focusable and, if checked, will participate
79
+ * in form submission, but their checked state will not be changed when clicked or activated.
80
+ */
81
+ export declare const ReadOnly: Story;
82
+ /**
83
+ * Chips can also be disabled. While they look the same as readonly chips, disabled chips do not
84
+ * participate in form submission.
79
85
  */
80
86
  export declare const Disabled: Story;
81
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"chip.stories.d.ts","sourceRoot":"/","sources":["core/chip-select/chip/chip.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAE3D,QAAA,MAAM,IAAI;;;;;;;;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eAAO,MAAM,KAAK,EAAE,KAuBnB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,KAMtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,KAaxB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,KAOtB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,KAmB1B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAQzB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"/","sources":["core/chip-select/chip/styles.ts"],"names":[],"mappings":"AAGA,UAAU,qBAAqB;IAC7B,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;CAC1C;AAED,eAAO,MAAM,gBAAgB,6KA+D5B,CAAA;AAED,eAAO,MAAM,qBAAqB,8KAYjC,CAAA;AAED,eAAO,MAAM,6BAA6B,uKAyCzC,CAAA;AAED,UAAU,8BAA8B;IACtC,eAAe,EAAE,UAAU,GAAG,SAAS,CAAA;CACxC;AAED,eAAO,MAAM,yBAAyB,+KAyBrC,CAAA"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"/","sources":["core/chip-select/chip/styles.ts"],"names":[],"mappings":"AAGA,UAAU,qBAAqB;IAC7B,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAA;CAC1C;AAED,eAAO,MAAM,gBAAgB,6KAmE5B,CAAA;AAED,eAAO,MAAM,qBAAqB,8KAYjC,CAAA;AAED,eAAO,MAAM,6BAA6B,uKAyCzC,CAAA;AAED,UAAU,8BAA8B;IACtC,eAAe,EAAE,UAAU,GAAG,SAAS,CAAA;CACxC;AAED,eAAO,MAAM,yBAAyB,+KAyBrC,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { useChipSelectContext } from './context';
1
2
  import type { HTMLAttributes, ReactNode } from 'react';
2
3
  export interface ChipSelectProps extends HTMLAttributes<HTMLDivElement> {
3
4
  /** The chip select items. */
@@ -30,10 +31,16 @@ export interface ChipSelectProps extends HTMLAttributes<HTMLDivElement> {
30
31
  * both single-select and multi-select modes depending on the use case. Importantly, single-select
31
32
  * behaviour in controlled scenarios (that is, where the checked state of each option is controlled
32
33
  * by the consumer) must be handled by the consumers given they are responsible for the state.
34
+ *
35
+ * See [ChipSelect x Formik](https://codesandbox.io/p/sandbox/eloquent-julien-hkgfgy)
36
+ * and [ChipSelect x React Hook Form](https://codesandbox.io/p/sandbox/strange-lederberg-thzzwv)
37
+ * for integration examples with popular form state management libraries.
33
38
  */
34
39
  export declare function ChipSelect({ children, form, flow, multiple, name, overflow, size, ...rest }: ChipSelectProps): import("react/jsx-runtime").JSX.Element;
35
40
  export declare namespace ChipSelect {
36
41
  var Option: import("react").ForwardRefExoticComponent<Omit<import("./chip-select-option").ChipSelectOptionProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
37
42
  var determineNextControlledState: typeof import("./chip").determineNextControlledState;
43
+ var Context: import("react").Context<import("./context").ChipSelectContextType | null>;
44
+ var useContext: typeof useChipSelectContext;
38
45
  }
39
46
  //# sourceMappingURL=chip-select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chip-select.d.ts","sourceRoot":"/","sources":["core/chip-select/chip-select.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtD,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACrE,6BAA6B;IAC7B,QAAQ,EAAE,SAAS,CAAA;IACnB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAA;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G,IAAI,EACR,EAAE,eAAe,2CAQjB;yBAjBe,UAAU"}
@@ -43,10 +43,12 @@ export declare const MultiSelect: Story;
43
43
  * single-select behaviour, however, manual intervention will be required. To assist with this, the
44
44
  * `ChipSelect.determineNextControlledState` helper is provided.
45
45
  *
46
- * Whether single- or multi-select behaviour is desired, the controlled state must be an array.
47
- *
48
- * This example demonstrates a controlled usage of the `ChipSelect` via simple local component state
49
- * (`useState`) and `ChipSelect.determineNextControlledState`.
46
+ * Whether single- or multi-select behaviour is desired, the controlled state must be an array of
47
+ * string values. The example here demonstrates a controlled usage of the `ChipSelect` via simple
48
+ * local component state (`useState`) and `ChipSelect.determineNextControlledState`. Examples that
49
+ * demonstrate integration with [Formik](https://codesandbox.io/p/sandbox/eloquent-julien-hkgfgy)
50
+ * and [React Hook Form](https://codesandbox.io/p/sandbox/strange-lederberg-thzzwv)
51
+ * are also available.
50
52
  */
51
53
  export declare const Controlled: Story;
52
54
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"chip-select.stories.d.ts","sourceRoot":"/","sources":["core/chip-select/chip-select.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAK1C,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEtE,QAAA,MAAM,IAAI;;;;;;;;;;;;CAoByB,CAAA;AAEnC,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAUlC;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,EAAE,KA6BrB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,KAMzB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,EAAE,KA8BxB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAMxB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,KAMtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAwCxB,CAAA"}
1
+ {"version":3,"file":"chip-select.stories.d.ts","sourceRoot":"/","sources":["core/chip-select/chip-select.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAK1C,OAAO,KAAK,EAAmB,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEtE,QAAA,MAAM,IAAI;;;;;;;;;;;;CAoByB,CAAA;AAEnC,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAUlC;;;;;;;;;GASG;AACH,eAAO,MAAM,OAAO,EAAE,KA6BrB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,KAMzB,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,EAAE,KA8BxB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAMxB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,KAMtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,KAwCxB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  export * from './chip';
2
2
  export * from './chip-select';
3
3
  export * from './chip-select-option';
4
+ export * from './context';
4
5
  export * from './styles';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["core/chip-select/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["core/chip-select/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reapit/elements",
3
- "version": "5.0.0-beta.49",
3
+ "version": "5.0.0-beta.50",
4
4
  "description": "A collection of React components and utilities for building apps for Reapit Marketplace",
5
5
  "homepage": "https://github.com/reapit/elements#readme",
6
6
  "bugs": {
@@ -1 +0,0 @@
1
- "use strict";const c=require("react/jsx-runtime"),a=require("react"),r=require("./index-Dmlb2--K.cjs"),f=r.styled_default("label")({name:"ElChipSelectChip",class:"el-chip-select-chip",propsAsIs:!1}),x=r.styled_default("input")({name:"ElChipSelectChipInput",class:"el-chip-select-chip-input",propsAsIs:!1}),S=r.styled_default("span")({name:"ElChipSelectChipIconContainer",class:"el-chip-select-chip-icon-container",propsAsIs:!1}),m=r.styled_default("span")({name:"ElChipSelectChipLabelText",class:"el-chip-select-chip-label-text",propsAsIs:!1});function E(e){return e.dataset.exclusive==="true"}function k(e){const t=e.form,l=e.name;if(E(e)&&t&&l){const i=t.elements.namedItem(l);i instanceof RadioNodeList&&i.forEach(s=>{e!==s&&s.checked&&(s.checked=!1)})}}const C=a.forwardRef(({"aria-label":e,children:t,icon:l,isExclusive:i=!1,maxWidth:s,onChange:n,overflow:p,size:h,...j},y)=>{const N=a.useCallback(o=>{o.currentTarget.checked&&k(o.currentTarget),n?.(o)},[n]);return c.jsxs(f,{"aria-label":e,"data-size":h,style:{maxWidth:s?`var(${s})`:void 0},children:[c.jsx(x,{...j,"data-exclusive":i,onChange:N,ref:y,type:"checkbox"}),l&&c.jsx(S,{"aria-hidden":!0,children:l}),t&&c.jsx(m,{"data-overflow":p,children:t})]})});C.displayName="ChipSelectOption";function v(e,t){const l=t.value;return t.checked?E(t)?[l]:[...e,l]:t.dataset.exclusive==="true"?[]:e.filter(i=>i!==l)}const b=a.createContext(null);function w({children:e,form:t,multiple:l,name:i,size:s}){return c.jsx(b.Provider,{value:{form:t,multiple:l,name:i,size:s},children:e})}function A(){const e=a.useContext(b);if(!e)throw new Error("useChipSelectContext must be used within a ChipSelect");return e}const u=a.forwardRef((e,t)=>{const{form:l,multiple:i,name:s,size:n}=A();return c.jsx(C,{...e,isExclusive:!i,form:l,name:s,ref:t,size:n})});u.displayName="ChipSelectOption";const I=r.styled_default("div")({name:"ElChipSelect",class:"el-chip-select",propsAsIs:!1});function d({children:e,form:t,flow:l="wrap",multiple:i=!1,name:s,overflow:n="visible",size:p,...h}){return c.jsx(I,{...h,"data-flow":l,"data-overflow":n,children:c.jsx(w,{form:t,multiple:i,name:s,size:p,children:e})})}d.Option=u;d.determineNextControlledState=v;exports.ChipSelect=d;exports.ChipSelectChip=C;exports.ChipSelectOption=u;exports.ElChipSelect=I;exports.ElChipSelectChip=f;exports.ElChipSelectChipIconContainer=S;exports.ElChipSelectChipInput=x;exports.ElChipSelectChipLabelText=m;exports.determineNextControlledState=v;
@@ -1,114 +0,0 @@
1
- import { jsxs as v, jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as h, useCallback as b, createContext as I, useContext as k } from "react";
3
- import { s as n } from "./index-YtxCR-9e.js";
4
- const N = /* @__PURE__ */ n("label")({
5
- name: "ElChipSelectChip",
6
- class: "el-chip-select-chip",
7
- propsAsIs: !1
8
- }), w = /* @__PURE__ */ n("input")({
9
- name: "ElChipSelectChipInput",
10
- class: "el-chip-select-chip-input",
11
- propsAsIs: !1
12
- }), A = /* @__PURE__ */ n("span")({
13
- name: "ElChipSelectChipIconContainer",
14
- class: "el-chip-select-chip-icon-container",
15
- propsAsIs: !1
16
- }), g = /* @__PURE__ */ n("span")({
17
- name: "ElChipSelectChipLabelText",
18
- class: "el-chip-select-chip-label-text",
19
- propsAsIs: !1
20
- });
21
- function C(e) {
22
- return e.dataset.exclusive === "true";
23
- }
24
- function O(e) {
25
- const t = e.form, s = e.name;
26
- if (C(e) && t && s) {
27
- const i = t.elements.namedItem(s);
28
- i instanceof RadioNodeList && i.forEach((l) => {
29
- e !== l && l.checked && (l.checked = !1);
30
- });
31
- }
32
- }
33
- const u = h(
34
- ({ "aria-label": e, children: t, icon: s, isExclusive: i = !1, maxWidth: l, onChange: c, overflow: r, size: o, ...x }, S) => {
35
- const E = b(
36
- (p) => {
37
- p.currentTarget.checked && O(p.currentTarget), c?.(p);
38
- },
39
- [c]
40
- );
41
- return /* @__PURE__ */ v(
42
- N,
43
- {
44
- "aria-label": e,
45
- "data-size": o,
46
- style: { maxWidth: l ? `var(${l})` : void 0 },
47
- children: [
48
- /* @__PURE__ */ a(
49
- w,
50
- {
51
- ...x,
52
- "data-exclusive": i,
53
- onChange: E,
54
- ref: S,
55
- type: "checkbox"
56
- }
57
- ),
58
- s && /* @__PURE__ */ a(A, { "aria-hidden": !0, children: s }),
59
- t && /* @__PURE__ */ a(g, { "data-overflow": r, children: t })
60
- ]
61
- }
62
- );
63
- }
64
- );
65
- u.displayName = "ChipSelectOption";
66
- function T(e, t) {
67
- const s = t.value;
68
- return t.checked ? C(t) ? [s] : [...e, s] : t.dataset.exclusive === "true" ? [] : e.filter((i) => i !== s);
69
- }
70
- const f = I(null);
71
- function y({ children: e, form: t, multiple: s, name: i, size: l }) {
72
- return /* @__PURE__ */ a(f.Provider, { value: { form: t, multiple: s, name: i, size: l }, children: e });
73
- }
74
- function L() {
75
- const e = k(f);
76
- if (!e)
77
- throw new Error("useChipSelectContext must be used within a ChipSelect");
78
- return e;
79
- }
80
- const d = h((e, t) => {
81
- const { form: s, multiple: i, name: l, size: c } = L();
82
- return /* @__PURE__ */ a(u, { ...e, isExclusive: !i, form: s, name: l, ref: t, size: c });
83
- });
84
- d.displayName = "ChipSelectOption";
85
- const j = /* @__PURE__ */ n("div")({
86
- name: "ElChipSelect",
87
- class: "el-chip-select",
88
- propsAsIs: !1
89
- });
90
- function m({
91
- children: e,
92
- form: t,
93
- flow: s = "wrap",
94
- multiple: i = !1,
95
- name: l,
96
- overflow: c = "visible",
97
- size: r,
98
- ...o
99
- }) {
100
- return /* @__PURE__ */ a(j, { ...o, "data-flow": s, "data-overflow": c, children: /* @__PURE__ */ a(y, { form: t, multiple: i, name: l, size: r, children: e }) });
101
- }
102
- m.Option = d;
103
- m.determineNextControlledState = T;
104
- export {
105
- u as C,
106
- N as E,
107
- w as a,
108
- A as b,
109
- g as c,
110
- T as d,
111
- m as e,
112
- d as f,
113
- j as g
114
- };