@serendie/ui 2.3.0 → 2.4.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.
@@ -1,21 +1,23 @@
1
1
  import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
- import { SerendieSymbolChevronDown as S } from "@serendie/symbols";
3
- import { List as v } from "../List/List.js";
4
- import { ListItem as w } from "../List/ListItem.js";
5
- import { createListCollection as _ } from "../../node_modules/@ark-ui/react/dist/components/collection/list-collection.js";
6
- import { Portal as C } from "../../node_modules/@ark-ui/react/dist/components/portal/portal.js";
7
- import { sva as T } from "../../styled-system/css/sva.js";
8
- import { SelectRoot as N } from "../../node_modules/@ark-ui/react/dist/components/select/select-root.js";
9
- import { cx as z } from "../../styled-system/css/cx.js";
10
- import { SelectLabel as R } from "../../node_modules/@ark-ui/react/dist/components/select/select-label.js";
11
- import { css as d } from "../../styled-system/css/css.js";
12
- import { SelectControl as V } from "../../node_modules/@ark-ui/react/dist/components/select/select-control.js";
13
- import { SelectTrigger as L } from "../../node_modules/@ark-ui/react/dist/components/select/select-trigger.js";
14
- import { SelectValueText as P } from "../../node_modules/@ark-ui/react/dist/components/select/select-value-text.js";
15
- import { SelectPositioner as B } from "../../node_modules/@ark-ui/react/dist/components/select/select-positioner.js";
16
- import { SelectContent as I } from "../../node_modules/@ark-ui/react/dist/components/select/select-content.js";
17
- import { SelectItem as O } from "../../node_modules/@ark-ui/react/dist/components/select/select-item.js";
18
- const l = T({
2
+ import { SerendieSymbolChevronDown as C } from "@serendie/symbols";
3
+ import { List as T } from "../List/List.js";
4
+ import { ListItem as N } from "../List/ListItem.js";
5
+ import { useAutoPortalContainer as R } from "../../hooks/useAutoPortalContainer.js";
6
+ import { useTranslations as z } from "../../i18n/index.js";
7
+ import { createListCollection as P } from "../../node_modules/@ark-ui/react/dist/components/collection/list-collection.js";
8
+ import { Portal as V } from "../../node_modules/@ark-ui/react/dist/components/portal/portal.js";
9
+ import { sva as L } from "../../styled-system/css/sva.js";
10
+ import { SelectRoot as B } from "../../node_modules/@ark-ui/react/dist/components/select/select-root.js";
11
+ import { cx as I } from "../../styled-system/css/cx.js";
12
+ import { SelectLabel as A } from "../../node_modules/@ark-ui/react/dist/components/select/select-label.js";
13
+ import { css as r } from "../../styled-system/css/css.js";
14
+ import { SelectControl as O } from "../../node_modules/@ark-ui/react/dist/components/select/select-control.js";
15
+ import { SelectTrigger as j } from "../../node_modules/@ark-ui/react/dist/components/select/select-trigger.js";
16
+ import { SelectValueText as W } from "../../node_modules/@ark-ui/react/dist/components/select/select-value-text.js";
17
+ import { SelectPositioner as E } from "../../node_modules/@ark-ui/react/dist/components/select/select-positioner.js";
18
+ import { SelectContent as k } from "../../node_modules/@ark-ui/react/dist/components/select/select-content.js";
19
+ import { SelectItem as q } from "../../node_modules/@ark-ui/react/dist/components/select/select-item.js";
20
+ const c = L({
19
21
  slots: ["root", "valueText", "trigger", "content", "item", "iconBox"],
20
22
  base: {
21
23
  root: {
@@ -156,29 +158,30 @@ const l = T({
156
158
  defaultVariants: {
157
159
  size: "medium"
158
160
  }
159
- }), M = ({
160
- placeholder: c = "",
161
- label: r,
162
- required: p,
163
- requiredLabel: y,
164
- invalid: a,
161
+ }), de = ({
162
+ placeholder: p = "",
163
+ label: a,
164
+ required: y,
165
+ requiredLabel: g,
166
+ invalid: d,
165
167
  invalidMessage: m,
166
- className: g,
167
- items: u = [],
168
- ...x
168
+ className: u,
169
+ items: x = [],
170
+ portalled: n = !0,
171
+ ...h
169
172
  }) => {
170
- const [t, h] = l.splitVariantProps(x), o = l(t), { collection: j, ...b } = h, n = _({
171
- items: u,
173
+ const b = z(), [t, f] = c.splitVariantProps(h), o = c(t), { collection: D, ...S } = f, { triggerRef: v, portalContainerRef: w } = R(n), l = P({
174
+ items: x,
172
175
  itemToString: (s) => s.label,
173
176
  itemToValue: (s) => s.value
174
177
  });
175
178
  return /* @__PURE__ */ i(
176
- N,
179
+ B,
177
180
  {
178
- ...b,
179
- collection: n,
180
- invalid: a,
181
- className: z(o.root, g),
181
+ ...S,
182
+ collection: l,
183
+ invalid: d,
184
+ className: I(o.root, u),
182
185
  positioning: {
183
186
  sameWidth: !0,
184
187
  offset: {
@@ -187,45 +190,45 @@ const l = T({
187
190
  }
188
191
  },
189
192
  children: [
190
- r && t.size != "small" && // smallの場合はラベルを表示しない
193
+ a && t.size != "small" && // smallの場合はラベルを表示しない
191
194
  /* @__PURE__ */ i(
192
- R,
195
+ A,
193
196
  {
194
- className: d({
197
+ className: r({
195
198
  textStyle: {
196
199
  base: "sd.system.typography.label.medium_compact",
197
200
  expanded: "sd.system.typography.label.medium_expanded"
198
201
  }
199
202
  }),
200
203
  children: [
201
- r,
202
- p && /* @__PURE__ */ e(
204
+ a,
205
+ y && /* @__PURE__ */ e(
203
206
  "span",
204
207
  {
205
- className: d({
208
+ className: r({
206
209
  pl: "sd.system.dimension.spacing.extraSmall",
207
210
  color: "sd.system.color.impression.negative"
208
211
  }),
209
- children: y ?? "必須"
212
+ children: g ?? b("common.required")
210
213
  }
211
214
  )
212
215
  ]
213
216
  }
214
217
  ),
215
- /* @__PURE__ */ e(V, { children: /* @__PURE__ */ i(L, { className: o.trigger, children: [
218
+ /* @__PURE__ */ e(O, { children: /* @__PURE__ */ i(j, { className: o.trigger, ref: v, children: [
216
219
  /* @__PURE__ */ e(
217
- P,
220
+ W,
218
221
  {
219
- placeholder: c,
222
+ placeholder: p,
220
223
  className: o.valueText
221
224
  }
222
225
  ),
223
- /* @__PURE__ */ e(S, { className: o.iconBox })
226
+ /* @__PURE__ */ e(C, { className: o.iconBox })
224
227
  ] }) }),
225
- a && m && /* @__PURE__ */ e(
228
+ d && m && /* @__PURE__ */ e(
226
229
  "div",
227
230
  {
228
- className: d({
231
+ className: r({
229
232
  textStyle: {
230
233
  base: "sd.system.typography.body.extraSmall_compact",
231
234
  expanded: "sd.system.typography.body.extraSmall_expanded"
@@ -235,20 +238,20 @@ const l = T({
235
238
  children: m
236
239
  }
237
240
  ),
238
- /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(I, { className: o.content, children: /* @__PURE__ */ e(v, { children: n.items.map((s, f) => /* @__PURE__ */ e(O, { item: s, children: /* @__PURE__ */ e(
239
- w,
241
+ /* @__PURE__ */ e(V, { disabled: !n, container: w, children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(k, { className: o.content, children: /* @__PURE__ */ e(T, { children: l.items.map((s, _) => /* @__PURE__ */ e(q, { item: s, children: /* @__PURE__ */ e(
242
+ N,
240
243
  {
241
244
  title: s.label,
242
245
  value: s.value,
243
246
  className: o.item,
244
247
  size: t.size == "small" ? "small" : void 0
245
248
  }
246
- ) }, f)) }) }) }) })
249
+ ) }, _)) }) }) }) })
247
250
  ]
248
251
  }
249
252
  );
250
253
  };
251
254
  export {
252
- M as Select,
253
- l as SelectStyle
255
+ de as Select,
256
+ c as SelectStyle
254
257
  };
@@ -1,9 +1,10 @@
1
- import { jsxs as i, jsx as s } from "react/jsx-runtime";
2
- import _ from "../../node_modules/merge-refs/dist/esm/index.js";
3
- import c, { forwardRef as w } from "react";
4
- import { sva as C } from "../../styled-system/css/sva.js";
5
- import { cx as N } from "../../styled-system/css/cx.js";
6
- const p = C({
1
+ import { jsxs as a, jsx as s } from "react/jsx-runtime";
2
+ import w from "../../node_modules/merge-refs/dist/esm/index.js";
3
+ import c, { forwardRef as C } from "react";
4
+ import { useTranslations as N } from "../../i18n/index.js";
5
+ import { sva as R } from "../../styled-system/css/sva.js";
6
+ import { cx as T } from "../../styled-system/css/cx.js";
7
+ const p = R({
7
8
  slots: [
8
9
  "root",
9
10
  "label",
@@ -102,7 +103,7 @@ const p = C({
102
103
  }
103
104
  }
104
105
  }
105
- }), A = w(
106
+ }), I = C(
106
107
  ({
107
108
  placeholder: y,
108
109
  label: r,
@@ -110,44 +111,44 @@ const p = C({
110
111
  required: d,
111
112
  requiredLabel: u,
112
113
  invalidMessage: o,
113
- invalid: a,
114
- disabled: l,
114
+ invalid: i,
115
+ disabled: n,
115
116
  className: g,
116
- ...n
117
+ ...l
117
118
  }, h) => {
118
- const x = c.useRef(null), b = _(x, h), [f, S] = p.splitVariantProps(n), e = p(f), v = t || a && o, m = n.id || c.useId();
119
- return /* @__PURE__ */ i("div", { className: N(e.root, g), children: [
120
- r ? /* @__PURE__ */ i("label", { className: e.label, htmlFor: m, children: [
119
+ const x = N(), b = c.useRef(null), f = w(b, h), [S, v] = p.splitVariantProps(l), e = p(S), _ = t || i && o, m = l.id || c.useId();
120
+ return /* @__PURE__ */ a("div", { className: T(e.root, g), children: [
121
+ r ? /* @__PURE__ */ a("label", { className: e.label, htmlFor: m, children: [
121
122
  r,
122
- d && /* @__PURE__ */ s("span", { className: e.required, children: u ?? "必須" })
123
+ d && /* @__PURE__ */ s("span", { className: e.required, children: u ?? x("common.required") })
123
124
  ] }) : null,
124
125
  /* @__PURE__ */ s(
125
126
  "div",
126
127
  {
127
128
  className: e.wrapper,
128
- "data-invalid": a ? !0 : void 0,
129
- "data-disabled": l ? !0 : void 0,
129
+ "data-invalid": i ? !0 : void 0,
130
+ "data-disabled": n ? !0 : void 0,
130
131
  children: /* @__PURE__ */ s(
131
132
  "textarea",
132
133
  {
133
- ref: b,
134
+ ref: f,
134
135
  id: m,
135
136
  placeholder: y,
136
137
  required: d,
137
- disabled: l,
138
+ disabled: n,
138
139
  className: e.textarea,
139
- ...S
140
+ ...v
140
141
  }
141
142
  )
142
143
  }
143
144
  ),
144
- v && /* @__PURE__ */ i("div", { className: e.messageField, children: [
145
+ _ && /* @__PURE__ */ a("div", { className: e.messageField, children: [
145
146
  t && /* @__PURE__ */ s("p", { className: e.description, children: t }),
146
- a && o && /* @__PURE__ */ s("p", { className: e.invalidMessage, children: o })
147
+ i && o && /* @__PURE__ */ s("p", { className: e.invalidMessage, children: o })
147
148
  ] })
148
149
  ] });
149
150
  }
150
151
  );
151
152
  export {
152
- A as TextArea
153
+ I as TextArea
153
154
  };
@@ -2,72 +2,72 @@ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
2
  import { SerendieSymbolAlertCircle as A, SerendieSymbolClose as W } from "@serendie/symbols";
3
3
  import z from "../../node_modules/merge-refs/dist/esm/index.js";
4
4
  import m, { forwardRef as B } from "react";
5
- import { textFieldRecipe as x } from "../../recipes/textFieldRecipe.js";
5
+ import { textFieldRecipe as F } from "../../recipes/textFieldRecipe.js";
6
6
  import { useTranslations as D } from "../../i18n/index.js";
7
7
  import { cx as E } from "../../styled-system/css/cx.js";
8
- import { css as b } from "../../styled-system/css/css.js";
8
+ import { css as V } from "../../styled-system/css/css.js";
9
9
  const U = B(
10
10
  ({
11
- placeholder: F,
11
+ placeholder: b,
12
12
  label: d,
13
13
  description: i,
14
14
  required: u,
15
15
  requiredLabel: S,
16
- invalidMessage: n,
16
+ invalidMessage: c,
17
17
  invalid: r,
18
- type: V = "text",
19
- disabled: c,
18
+ type: w = "text",
19
+ disabled: n,
20
20
  onChange: h,
21
21
  value: f,
22
- className: w,
22
+ className: y,
23
23
  leftContent: N,
24
24
  rightContent: p,
25
- ...s
26
- }, y) => {
27
- const C = D(), o = m.useRef(null), P = z(o, y), [_, j] = x.splitVariantProps({
28
- ...s
29
- }), t = x(_), I = i || r && n, [T, k] = m.useState(s.defaultValue || f), v = s.id || m.useId(), q = () => {
30
- var R;
31
- const l = {
25
+ ...l
26
+ }, C) => {
27
+ const v = D(), o = m.useRef(null), P = z(o, C), [_, j] = F.splitVariantProps({
28
+ ...l
29
+ }), t = F(_), I = i || r && c, [T, k] = m.useState(l.defaultValue || f), g = l.id || m.useId(), q = () => {
30
+ var x;
31
+ const s = {
32
32
  target: { value: "" }
33
33
  };
34
- g(l), (R = s.onReset) == null || R.call(s, l), o.current && (o.current.value = "");
35
- }, g = (l) => {
36
- k(l.target.value), h && h(l);
34
+ R(s), (x = l.onReset) == null || x.call(l, s), o.current && (o.current.value = "");
35
+ }, R = (s) => {
36
+ k(s.target.value), h && h(s);
37
37
  };
38
- return /* @__PURE__ */ a("div", { className: E(t.root, w), children: [
39
- d ? /* @__PURE__ */ a("label", { className: t.label, htmlFor: v, children: [
38
+ return /* @__PURE__ */ a("div", { className: E(t.root, y), children: [
39
+ d ? /* @__PURE__ */ a("label", { className: t.label, htmlFor: g, children: [
40
40
  d,
41
- u && /* @__PURE__ */ e("span", { className: t.labelRequired, children: S ?? C("common.required") })
41
+ u && /* @__PURE__ */ e("span", { className: t.labelRequired, children: S ?? v("common.required") })
42
42
  ] }) : null,
43
43
  /* @__PURE__ */ a(
44
44
  "div",
45
45
  {
46
46
  className: t.inputWrapper,
47
47
  "data-invalid": r ? !0 : void 0,
48
- "data-disabled": c ? !0 : void 0,
48
+ "data-disabled": n ? !0 : void 0,
49
49
  children: [
50
50
  N ? /* @__PURE__ */ e("div", { className: t.leftContent, children: N }) : /* @__PURE__ */ e("div", {}),
51
51
  /* @__PURE__ */ e(
52
52
  "input",
53
53
  {
54
54
  ref: P,
55
- id: v,
56
- placeholder: F,
55
+ id: g,
56
+ placeholder: b,
57
57
  required: u,
58
- disabled: c,
58
+ disabled: n,
59
59
  value: f,
60
- type: V,
60
+ type: w,
61
61
  className: t.input,
62
- onChange: g,
62
+ onChange: R,
63
63
  ...j
64
64
  }
65
65
  ),
66
- p ? /* @__PURE__ */ e("div", { className: t.rightContent, children: p }) : /* @__PURE__ */ e("div", { className: t.icon, children: !c && /* disabledの場合はアイコンを表示しない */
66
+ p ? /* @__PURE__ */ e("div", { className: t.rightContent, children: p }) : /* @__PURE__ */ e("div", { className: t.icon, children: !n && /* disabledの場合はアイコンを表示しない */
67
67
  (r ? /* @__PURE__ */ e(
68
68
  "span",
69
69
  {
70
- className: b({
70
+ className: V({
71
71
  color: "sd.system.color.impression.negative"
72
72
  }),
73
73
  children: /* @__PURE__ */ e(A, { width: 20, height: 20 })
@@ -75,9 +75,9 @@ const U = B(
75
75
  ) : T ? /* @__PURE__ */ e(
76
76
  "button",
77
77
  {
78
- className: b({ cursor: "pointer" }),
78
+ className: V({ cursor: "pointer" }),
79
79
  onClick: q,
80
- "aria-label": "値をクリア",
80
+ "aria-label": v("textField.clearValue"),
81
81
  children: /* @__PURE__ */ e(W, { width: 20, height: 20 })
82
82
  }
83
83
  ) : null) })
@@ -86,7 +86,7 @@ const U = B(
86
86
  ),
87
87
  I && /* @__PURE__ */ a("div", { className: t.messageField, children: [
88
88
  i && /* @__PURE__ */ e("p", { className: t.description, children: i }),
89
- r && n && /* @__PURE__ */ e("p", { className: t.invalidMessage, children: n })
89
+ r && c && /* @__PURE__ */ e("p", { className: t.invalidMessage, children: c })
90
90
  ] })
91
91
  ] });
92
92
  }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * ModalDialog/Drawer内にある場合、自動的にそのコンテンツ要素をポータルコンテナとして検出するフック
3
+ *
4
+ * @param portalled - Portalを使用するかどうか
5
+ * @returns triggerRef - トリガー要素に設定するref
6
+ * @returns portalContainerRef - Portalのcontainerプロパティに渡すref
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const { triggerRef, portalContainerRef } = useAutoPortalContainer(portalled);
11
+ *
12
+ * <Trigger ref={triggerRef}>...</Trigger>
13
+ * <Portal container={portalContainerRef}>...</Portal>
14
+ * ```
15
+ */
16
+ export declare const useAutoPortalContainer: (portalled: boolean) => {
17
+ triggerRef: import('react').RefObject<HTMLElement>;
18
+ portalContainerRef: {
19
+ current: HTMLElement;
20
+ } | undefined;
21
+ };
@@ -0,0 +1,16 @@
1
+ import { useRef as a, useState as c, useEffect as s } from "react";
2
+ const l = (r) => {
3
+ const t = a(null), [e, o] = c(
4
+ null
5
+ );
6
+ return s(() => {
7
+ if (!r || !t.current) return;
8
+ const n = t.current.closest(
9
+ '[data-scope="dialog"][data-part="content"], [data-scope="drawer"][data-part="content"]'
10
+ );
11
+ n && o(n);
12
+ }, [r]), { triggerRef: t, portalContainerRef: e ? { current: e } : void 0 };
13
+ };
14
+ export {
15
+ l as useAutoPortalContainer
16
+ };
@@ -1,10 +1,34 @@
1
1
  export declare const dictionary: {
2
2
  readonly ja: {
3
3
  readonly "common.required": "必須";
4
+ readonly "textField.clearValue": "値をクリア";
5
+ readonly "passwordField.hidePassword": "パスワードを隠す";
6
+ readonly "passwordField.showPassword": "パスワードを表示";
7
+ readonly "datePicker.selectDate": "日付を選択";
8
+ readonly "datePicker.startDate": "開始日";
9
+ readonly "datePicker.endDate": "終了日";
4
10
  readonly "pagination.page": "{{page}}ページ目";
11
+ readonly "pagination.firstPage": "最初のページです";
12
+ readonly "pagination.previousPage": "前のページへ";
13
+ readonly "pagination.lastPage": "最後のページです";
14
+ readonly "pagination.nextPage": "次のページへ";
15
+ readonly "pagination.goToPage": "ページ{{page}}へ移動";
16
+ readonly "modalDialog.close": "閉じる";
5
17
  };
6
18
  readonly en: {
7
19
  readonly "common.required": "Required";
20
+ readonly "textField.clearValue": "Clear value";
21
+ readonly "passwordField.hidePassword": "Hide password";
22
+ readonly "passwordField.showPassword": "Show password";
23
+ readonly "datePicker.selectDate": "Select date";
24
+ readonly "datePicker.startDate": "Start date";
25
+ readonly "datePicker.endDate": "End date";
8
26
  readonly "pagination.page": "Page {{page}}";
27
+ readonly "pagination.firstPage": "This is the first page";
28
+ readonly "pagination.previousPage": "Go to previous page";
29
+ readonly "pagination.lastPage": "This is the last page";
30
+ readonly "pagination.nextPage": "Go to next page";
31
+ readonly "pagination.goToPage": "Go to page {{page}}";
32
+ readonly "modalDialog.close": "Close";
9
33
  };
10
34
  };
@@ -1,13 +1,37 @@
1
- const e = {
1
+ const a = {
2
2
  ja: {
3
3
  "common.required": "必須",
4
- "pagination.page": "{{page}}ページ目"
4
+ "textField.clearValue": "値をクリア",
5
+ "passwordField.hidePassword": "パスワードを隠す",
6
+ "passwordField.showPassword": "パスワードを表示",
7
+ "datePicker.selectDate": "日付を選択",
8
+ "datePicker.startDate": "開始日",
9
+ "datePicker.endDate": "終了日",
10
+ "pagination.page": "{{page}}ページ目",
11
+ "pagination.firstPage": "最初のページです",
12
+ "pagination.previousPage": "前のページへ",
13
+ "pagination.lastPage": "最後のページです",
14
+ "pagination.nextPage": "次のページへ",
15
+ "pagination.goToPage": "ページ{{page}}へ移動",
16
+ "modalDialog.close": "閉じる"
5
17
  },
6
18
  en: {
7
19
  "common.required": "Required",
8
- "pagination.page": "Page {{page}}"
20
+ "textField.clearValue": "Clear value",
21
+ "passwordField.hidePassword": "Hide password",
22
+ "passwordField.showPassword": "Show password",
23
+ "datePicker.selectDate": "Select date",
24
+ "datePicker.startDate": "Start date",
25
+ "datePicker.endDate": "End date",
26
+ "pagination.page": "Page {{page}}",
27
+ "pagination.firstPage": "This is the first page",
28
+ "pagination.previousPage": "Go to previous page",
29
+ "pagination.lastPage": "This is the last page",
30
+ "pagination.nextPage": "Go to next page",
31
+ "pagination.goToPage": "Go to page {{page}}",
32
+ "modalDialog.close": "Close"
9
33
  }
10
34
  };
11
35
  export {
12
- e as dictionary
36
+ a as dictionary
13
37
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@serendie/ui",
3
3
  "description": "Adaptive UI component library as part of Serendie Design System by Mitsubishi Electric",
4
4
  "license": "MIT",
5
- "version": "2.3.0",
5
+ "version": "2.4.0",
6
6
  "type": "module",
7
7
  "types": "./dist/index.d.ts",
8
8
  "sideEffects": [