@caseparts-org/caseblocks 0.0.262 → 0.0.263

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.
@@ -4,10 +4,15 @@ export interface SelectOption {
4
4
  value: string;
5
5
  label: string;
6
6
  }
7
+ export interface SelectOptionGroup {
8
+ label: string;
9
+ options: SelectOption[];
10
+ }
7
11
  export interface SelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, "children">, HideAtProps {
8
12
  label: string | null;
9
13
  placeholder?: string;
10
- options: SelectOption[];
14
+ options?: SelectOption[];
15
+ groups?: SelectOptionGroup[];
11
16
  error?: string | null;
12
17
  }
13
18
  export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
@@ -1,79 +1,81 @@
1
- import { jsxs as u, jsx as a } from "react/jsx-runtime";
2
- import w, { useState as E } from "react";
1
+ import { jsxs as D, jsx as a } from "react/jsx-runtime";
2
+ import F, { useState as V } from "react";
3
3
  import { c as f } from "../../clsx-OuTLNxxd.js";
4
- import { getHideAtStyles as M } from "../HideAt.js";
5
- import { Icon as F } from "../Icon/Icon.js";
6
- import '../../assets/Select.css';const V = "_select_kfi8n_1", j = "_icon_kfi8n_29", I = "_selectError_kfi8n_59", L = "_label_kfi8n_63", P = "_labelPlaceholder_kfi8n_78", R = "_labelDisabled_kfi8n_99", z = "_errorMessage_kfi8n_103", e = {
4
+ import { getHideAtStyles as j } from "../HideAt.js";
5
+ import { Icon as p } from "../Icon/Icon.js";
6
+ import '../../assets/Select.css';const I = "_select_kfi8n_1", L = "_icon_kfi8n_29", P = "_selectError_kfi8n_59", R = "_label_kfi8n_63", z = "_labelPlaceholder_kfi8n_78", A = "_labelDisabled_kfi8n_99", B = "_errorMessage_kfi8n_103", l = {
7
7
  "select-container": "_select-container_kfi8n_1",
8
- select: V,
9
- icon: j,
10
- selectError: I,
11
- label: L,
12
- labelPlaceholder: P,
13
- labelDisabled: R,
14
- errorMessage: z
15
- }, A = w.forwardRef(
8
+ select: I,
9
+ icon: L,
10
+ selectError: P,
11
+ label: R,
12
+ labelPlaceholder: z,
13
+ labelDisabled: A,
14
+ errorMessage: B
15
+ }, C = F.forwardRef(
16
16
  ({
17
17
  label: s,
18
- placeholder: o,
19
- options: k,
20
- value: m,
21
- defaultValue: i,
22
- hideAt: g,
23
- className: D,
24
- error: t,
18
+ placeholder: c,
19
+ options: N = [],
20
+ groups: i,
21
+ value: v,
22
+ defaultValue: t,
23
+ hideAt: S,
24
+ className: x,
25
+ error: d,
25
26
  onFocus: r,
26
- onBlur: d,
27
- ...c
28
- }, N) => {
29
- const [S, b] = E(!1), x = !!c.disabled, n = m !== void 0, v = n ? String(m ?? "") : void 0, h = !n && i !== void 0 && i !== null ? String(i) : "", _ = !!s && (S || (n ? v !== "" : h !== "")), y = !!o && !_, p = s ? "" : o ?? "";
30
- return /* @__PURE__ */ u("div", { className: f(e["select-container"], M(g)), children: [
31
- (s || y) && /* @__PURE__ */ a(
27
+ onBlur: _,
28
+ ...o
29
+ }, y) => {
30
+ const [w, h] = V(!1), E = !!o.disabled, n = v !== void 0, k = n ? String(v ?? "") : void 0, u = !n && t !== void 0 && t !== null ? String(t) : "", b = !!s && (w || (n ? k !== "" : u !== "")), M = !!c && !b, g = s ? "" : c ?? "";
31
+ return /* @__PURE__ */ D("div", { className: f(l["select-container"], j(S)), children: [
32
+ (s || M) && /* @__PURE__ */ a(
32
33
  "label",
33
34
  {
34
- htmlFor: c.name,
35
+ htmlFor: o.name,
35
36
  className: f(
36
- _ ? e.label : e.labelPlaceholder,
37
- x ? e.labelDisabled : void 0
37
+ b ? l.label : l.labelPlaceholder,
38
+ E ? l.labelDisabled : void 0
38
39
  ),
39
- children: _ ? s : o ?? s
40
+ children: b ? s : c ?? s
40
41
  }
41
42
  ),
42
- /* @__PURE__ */ u(
43
+ /* @__PURE__ */ D(
43
44
  "select",
44
45
  {
45
- ...c,
46
- ref: N,
47
- id: c.name,
48
- value: v,
49
- defaultValue: n ? void 0 : h,
50
- className: f(e.select, t ? e.selectError : void 0, D),
51
- onFocus: (l) => {
52
- b(!0), r == null || r(l);
46
+ ...o,
47
+ ref: y,
48
+ id: o.name,
49
+ value: k,
50
+ defaultValue: n ? void 0 : u,
51
+ className: f(l.select, d ? l.selectError : void 0, x),
52
+ onFocus: (e) => {
53
+ h(!0), r == null || r(e);
53
54
  },
54
- onBlur: (l) => {
55
- b(!1), d == null || d(l);
55
+ onBlur: (e) => {
56
+ h(!1), _ == null || _(e);
56
57
  },
57
58
  children: [
58
- o ? /* @__PURE__ */ a("option", { value: "", disabled: !0, hidden: !!s, children: p }) : null,
59
- k.map((l) => /* @__PURE__ */ a("option", { value: l.value, children: l.label }, l.value))
59
+ c ? /* @__PURE__ */ a("option", { value: "", disabled: !0, hidden: !!s, children: g }) : null,
60
+ N.map((e) => /* @__PURE__ */ a("option", { value: e.value, children: e.label }, e.value)),
61
+ i == null ? void 0 : i.map((e) => /* @__PURE__ */ a("optgroup", { label: e.label, children: e.options.map((m) => /* @__PURE__ */ a("option", { value: m.value, children: m.label }, m.value)) }, e.label))
60
62
  ]
61
63
  }
62
64
  ),
63
65
  /* @__PURE__ */ a(
64
- F,
66
+ p,
65
67
  {
66
- className: e.icon,
68
+ className: l.icon,
67
69
  iconKey: "fa-solid fa-chevron-down",
68
70
  size: "3xs",
69
71
  colorToken: "secondary"
70
72
  }
71
73
  ),
72
- t ? /* @__PURE__ */ a("div", { className: e.errorMessage, children: t }) : null
74
+ d ? /* @__PURE__ */ a("div", { className: l.errorMessage, children: d }) : null
73
75
  ] });
74
76
  }
75
77
  );
76
- A.displayName = "Select";
78
+ C.displayName = "Select";
77
79
  export {
78
- A as Select
80
+ C as Select
79
81
  };
@@ -5,4 +5,5 @@ export default meta;
5
5
  type Story = StoryObj<typeof Select>;
6
6
  export declare const Default: Story;
7
7
  export declare const WithSelectedValue: Story;
8
+ export declare const WithOptionGroups: Story;
8
9
  export declare const ErrorState: Story;
@@ -1,10 +1,22 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { useState as c } from "react";
2
+ import { useState as s } from "react";
3
3
  import { Select as n } from "./Select.js";
4
- const i = [
4
+ const o = [
5
5
  { value: "US", label: "United States" },
6
6
  { value: "CA", label: "Canada" },
7
7
  { value: "MX", label: "Mexico" }
8
+ ], c = [
9
+ {
10
+ label: "North America",
11
+ options: o
12
+ },
13
+ {
14
+ label: "Europe",
15
+ options: [
16
+ { value: "DE", label: "Germany" },
17
+ { value: "GB", label: "United Kingdom" }
18
+ ]
19
+ }
8
20
  ], S = {
9
21
  title: "Case Parts/Atoms/Select",
10
22
  component: n,
@@ -12,34 +24,40 @@ const i = [
12
24
  name: "country",
13
25
  label: "Country",
14
26
  placeholder: "Select country",
15
- options: i
27
+ options: o
16
28
  },
17
29
  parameters: {
18
30
  layout: "centered"
19
31
  }
20
32
  };
21
33
  function a(e) {
22
- const [o, u] = c(String(e.value ?? ""));
34
+ const [u, i] = s(String(e.value ?? ""));
23
35
  return /* @__PURE__ */ t("div", { style: { width: 320 }, children: /* @__PURE__ */ t(
24
36
  n,
25
37
  {
26
38
  ...e,
27
- value: o,
39
+ value: u,
28
40
  onChange: (r) => {
29
41
  var l;
30
- u(r.target.value), (l = e.onChange) == null || l.call(e, r);
42
+ i(r.target.value), (l = e.onChange) == null || l.call(e, r);
31
43
  }
32
44
  }
33
45
  ) });
34
46
  }
35
- const v = {
47
+ const g = {
36
48
  render: (e) => /* @__PURE__ */ t(a, { ...e })
37
- }, g = {
49
+ }, b = {
38
50
  args: {
39
51
  value: "US"
40
52
  },
41
53
  render: (e) => /* @__PURE__ */ t(a, { ...e })
42
- }, C = {
54
+ }, h = {
55
+ args: {
56
+ options: void 0,
57
+ groups: c
58
+ },
59
+ render: (e) => /* @__PURE__ */ t(a, { ...e })
60
+ }, y = {
43
61
  args: {
44
62
  value: "",
45
63
  error: "Country is required"
@@ -47,8 +65,9 @@ const v = {
47
65
  render: (e) => /* @__PURE__ */ t(a, { ...e })
48
66
  };
49
67
  export {
50
- v as Default,
51
- C as ErrorState,
52
- g as WithSelectedValue,
68
+ g as Default,
69
+ y as ErrorState,
70
+ h as WithOptionGroups,
71
+ b as WithSelectedValue,
53
72
  S as default
54
73
  };
@@ -10,7 +10,7 @@ export type { InputProps } from './atoms/Input/Input';
10
10
  export { InputEndAdornmentButton } from './atoms/InputEndAdornmentButton/InputEndAdornmentButton';
11
11
  export type { InputEndAdornmentButtonProps } from './atoms/InputEndAdornmentButton/InputEndAdornmentButton';
12
12
  export { Select } from './atoms/Select/Select';
13
- export type { SelectProps, SelectOption } from './atoms/Select/Select';
13
+ export type { SelectProps, SelectOption, SelectOptionGroup } from './atoms/Select/Select';
14
14
  export { Tooltip } from './atoms/Tooltip/Tooltip';
15
15
  export { Popover } from './atoms/Popover/Popover';
16
16
  export type { PopoverProps } from './atoms/Popover/Popover';
package/dist/main.d.ts CHANGED
@@ -16,7 +16,7 @@ export type { InputProps } from './atoms/Input/Input';
16
16
  export { InputEndAdornmentButton } from './atoms/InputEndAdornmentButton/InputEndAdornmentButton';
17
17
  export type { InputEndAdornmentButtonProps } from './atoms/InputEndAdornmentButton/InputEndAdornmentButton';
18
18
  export { Select } from './atoms/Select/Select';
19
- export type { SelectProps } from './atoms/Select/Select';
19
+ export type { SelectProps, SelectOption, SelectOptionGroup } from './atoms/Select/Select';
20
20
  export { Account } from './molecules/Account/Account';
21
21
  export type { AccountProps } from './molecules/Account/Account';
22
22
  export { Avatar } from './molecules/Avatar/Avatar';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@caseparts-org/caseblocks",
3
3
  "private": false,
4
- "version": "0.0.262",
4
+ "version": "0.0.263",
5
5
  "type": "module",
6
6
  "module": "dist/main.js",
7
7
  "types": "dist/main.d.ts",