@serendie/ui 2.2.8 → 2.3.0-dev.202512051042

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,81 +1,82 @@
1
- import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
- import { SerendieSymbolAlertCircle as T, SerendieSymbolClose as W } from "@serendie/symbols";
3
- import q from "../../node_modules/merge-refs/dist/esm/index.js";
4
- import m, { forwardRef as z } from "react";
1
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
+ import { SerendieSymbolAlertCircle as A, SerendieSymbolClose as W } from "@serendie/symbols";
3
+ import z from "../../node_modules/merge-refs/dist/esm/index.js";
4
+ import m, { forwardRef as B } from "react";
5
5
  import { textFieldRecipe as x } from "../../recipes/textFieldRecipe.js";
6
- import { cx as B } from "../../styled-system/css/cx.js";
6
+ import { useTranslations as D } from "../../i18n/index.js";
7
+ import { cx as E } from "../../styled-system/css/cx.js";
7
8
  import { css as b } from "../../styled-system/css/css.js";
8
- const M = z(
9
+ const U = B(
9
10
  ({
10
11
  placeholder: F,
11
12
  label: d,
12
13
  description: i,
13
14
  required: u,
14
15
  requiredLabel: S,
15
- invalidMessage: c,
16
- invalid: a,
16
+ invalidMessage: n,
17
+ invalid: r,
17
18
  type: V = "text",
18
- disabled: n,
19
+ disabled: c,
19
20
  onChange: h,
20
21
  value: f,
21
22
  className: w,
22
23
  leftContent: N,
23
24
  rightContent: p,
24
- ...l
25
+ ...s
25
26
  }, y) => {
26
- const o = m.useRef(null), C = q(o, y), [P, _] = x.splitVariantProps({
27
- ...l
28
- }), t = x(P), j = i || a && c, [I, k] = m.useState(l.defaultValue || f), v = l.id || m.useId(), A = () => {
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 = () => {
29
30
  var R;
30
- const s = {
31
+ const l = {
31
32
  target: { value: "" }
32
33
  };
33
- g(s), (R = l.onReset) == null || R.call(l, s), o.current && (o.current.value = "");
34
- }, g = (s) => {
35
- k(s.target.value), h && h(s);
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);
36
37
  };
37
- return /* @__PURE__ */ r("div", { className: B(t.root, w), children: [
38
- d ? /* @__PURE__ */ r("label", { className: t.label, htmlFor: v, children: [
38
+ return /* @__PURE__ */ a("div", { className: E(t.root, w), children: [
39
+ d ? /* @__PURE__ */ a("label", { className: t.label, htmlFor: v, children: [
39
40
  d,
40
- u && /* @__PURE__ */ e("span", { className: t.labelRequired, children: S ?? "必須" })
41
+ u && /* @__PURE__ */ e("span", { className: t.labelRequired, children: S ?? C("common.required") })
41
42
  ] }) : null,
42
- /* @__PURE__ */ r(
43
+ /* @__PURE__ */ a(
43
44
  "div",
44
45
  {
45
46
  className: t.inputWrapper,
46
- "data-invalid": a ? !0 : void 0,
47
- "data-disabled": n ? !0 : void 0,
47
+ "data-invalid": r ? !0 : void 0,
48
+ "data-disabled": c ? !0 : void 0,
48
49
  children: [
49
50
  N ? /* @__PURE__ */ e("div", { className: t.leftContent, children: N }) : /* @__PURE__ */ e("div", {}),
50
51
  /* @__PURE__ */ e(
51
52
  "input",
52
53
  {
53
- ref: C,
54
+ ref: P,
54
55
  id: v,
55
56
  placeholder: F,
56
57
  required: u,
57
- disabled: n,
58
+ disabled: c,
58
59
  value: f,
59
60
  type: V,
60
61
  className: t.input,
61
62
  onChange: g,
62
- ..._
63
+ ...j
63
64
  }
64
65
  ),
65
- p ? /* @__PURE__ */ e("div", { className: t.rightContent, children: p }) : /* @__PURE__ */ e("div", { className: t.icon, children: !n && /* disabledの場合はアイコンを表示しない */
66
- (a ? /* @__PURE__ */ e(
66
+ p ? /* @__PURE__ */ e("div", { className: t.rightContent, children: p }) : /* @__PURE__ */ e("div", { className: t.icon, children: !c && /* disabledの場合はアイコンを表示しない */
67
+ (r ? /* @__PURE__ */ e(
67
68
  "span",
68
69
  {
69
70
  className: b({
70
71
  color: "sd.system.color.impression.negative"
71
72
  }),
72
- children: /* @__PURE__ */ e(T, { width: 20, height: 20 })
73
+ children: /* @__PURE__ */ e(A, { width: 20, height: 20 })
73
74
  }
74
- ) : I ? /* @__PURE__ */ e(
75
+ ) : T ? /* @__PURE__ */ e(
75
76
  "button",
76
77
  {
77
78
  className: b({ cursor: "pointer" }),
78
- onClick: A,
79
+ onClick: q,
79
80
  "aria-label": "値をクリア",
80
81
  children: /* @__PURE__ */ e(W, { width: 20, height: 20 })
81
82
  }
@@ -83,13 +84,13 @@ const M = z(
83
84
  ]
84
85
  }
85
86
  ),
86
- j && /* @__PURE__ */ r("div", { className: t.messageField, children: [
87
+ I && /* @__PURE__ */ a("div", { className: t.messageField, children: [
87
88
  i && /* @__PURE__ */ e("p", { className: t.description, children: i }),
88
- a && c && /* @__PURE__ */ e("p", { className: t.invalidMessage, children: c })
89
+ r && n && /* @__PURE__ */ e("p", { className: t.invalidMessage, children: n })
89
90
  ] })
90
91
  ] });
91
92
  }
92
93
  );
93
94
  export {
94
- M as TextField
95
+ U as TextField
95
96
  };
@@ -0,0 +1,10 @@
1
+ export declare const dictionary: {
2
+ readonly ja: {
3
+ readonly "common.required": "必須";
4
+ readonly "pagination.page": "{{page}}ページ目";
5
+ };
6
+ readonly en: {
7
+ readonly "common.required": "Required";
8
+ readonly "pagination.page": "Page {{page}}";
9
+ };
10
+ };
@@ -0,0 +1,13 @@
1
+ const e = {
2
+ ja: {
3
+ "common.required": "必須",
4
+ "pagination.page": "{{page}}ページ目"
5
+ },
6
+ en: {
7
+ "common.required": "Required",
8
+ "pagination.page": "Page {{page}}"
9
+ }
10
+ };
11
+ export {
12
+ e as dictionary
13
+ };
@@ -0,0 +1,20 @@
1
+ import { dictionary } from './dictionary';
2
+ import { Language } from './provider';
3
+ export { SerendieProvider, LanguageProvider, type Language } from './provider';
4
+ export type TranslationKey = keyof typeof dictionary.ja;
5
+ /**
6
+ * 翻訳関数を生成するヘルパー
7
+ * Context不要な場合や、サーバーサイドで直接使う場合に使用
8
+ */
9
+ export declare function getTranslations(lang: Language): (key: TranslationKey, params?: Record<string, string | number>) => string;
10
+ /**
11
+ * 翻訳関数を取得するReact Hook
12
+ * SerendieProviderがない場合はデフォルト言語(ja)を使用します
13
+ */
14
+ export declare function useTranslations(): (key: TranslationKey, params?: Record<string, string | number>) => string;
15
+ /**
16
+ * 言語に合わせて日付文字列をフォーマットする
17
+ * @param date ISO形式などDateが解釈できる文字列
18
+ * @param lang 言語
19
+ */
20
+ export declare function formatDateByLang(date: string, lang: Language): string;
@@ -0,0 +1,34 @@
1
+ import { useContext as l } from "react";
2
+ import { dictionary as u } from "./dictionary.js";
3
+ import { LanguageContext as s } from "./provider.js";
4
+ import { LanguageProvider as x, SerendieProvider as P } from "./provider.js";
5
+ function c(e) {
6
+ return function(r, t) {
7
+ let n = u[e][r];
8
+ return !n && e !== "ja" && (n = u.ja[r]), n ? (t && Object.entries(t).forEach(([a, f]) => {
9
+ const i = `{{${a}}}`;
10
+ n.includes(i) || console.warn(
11
+ `Placeholder "${i}" not found in translation "${n}"`
12
+ ), n = n.replace(
13
+ new RegExp(`\\{\\{${a}\\}\\}`, "g"),
14
+ String(f)
15
+ );
16
+ }), n) : (console.warn(`Translation key "${r}" not found`), r);
17
+ };
18
+ }
19
+ function m() {
20
+ const e = l(s);
21
+ return !e && process.env.NODE_ENV === "development" && console.warn(
22
+ "SerendieProvider is not found. Using default language 'ja'. Consider wrapping your app with <SerendieProvider lang='ja'>"
23
+ ), c(e || "ja");
24
+ }
25
+ function j(e, o) {
26
+ return new Date(e).toLocaleDateString(o === "en" ? "en-US" : "ja-JP");
27
+ }
28
+ export {
29
+ x as LanguageProvider,
30
+ P as SerendieProvider,
31
+ j as formatDateByLang,
32
+ c as getTranslations,
33
+ m as useTranslations
34
+ };
@@ -0,0 +1,14 @@
1
+ export type Language = "ja" | "en";
2
+ export declare const LanguageContext: import('react').Context<Language | undefined>;
3
+ /**
4
+ * Serendie UIの設定を提供するProvider
5
+ * アプリケーションのルートで使用してください
6
+ */
7
+ export declare function SerendieProvider({ lang, children, }: {
8
+ lang: Language;
9
+ children: React.ReactNode;
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ /**
12
+ * @deprecated LanguageProvider は SerendieProvider にリネームされました
13
+ */
14
+ export declare const LanguageProvider: typeof SerendieProvider;
@@ -0,0 +1,15 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { createContext as t } from "react";
3
+ const n = t(void 0);
4
+ function i({
5
+ lang: e,
6
+ children: r
7
+ }) {
8
+ return /* @__PURE__ */ o(n.Provider, { value: e, children: r });
9
+ }
10
+ const u = i;
11
+ export {
12
+ n as LanguageContext,
13
+ u as LanguageProvider,
14
+ i as SerendieProvider
15
+ };
package/dist/index.d.ts CHANGED
@@ -24,6 +24,7 @@ export * from './components/ProgressIndicator/index.ts';
24
24
  export * from './components/RadioButton/index.ts';
25
25
  export * from './components/Search/index.ts';
26
26
  export * from './components/Select/index.ts';
27
+ export * from './components/Steps/index.ts';
27
28
  export * from './components/Switch/index.ts';
28
29
  export * from './components/Tabs/index.ts';
29
30
  export * from './components/TextArea/index.ts';
package/dist/index.js CHANGED
@@ -30,16 +30,17 @@ import { RadioButton as Mo, RadioButtonStyle as wo, radioCheckedIconCss as Ao, r
30
30
  import { RadioGroup as Fo } from "./components/RadioButton/RadioGroup.js";
31
31
  import { Search as Uo, SearchStyle as Wo } from "./components/Search/Search.js";
32
32
  import { Select as qo, SelectStyle as zo } from "./components/Select/Select.js";
33
- import { Switch as Ho, SwitchStyle as Jo } from "./components/Switch/Switch.js";
34
- import { Tabs as Oo, TabsStyle as Qo } from "./components/Tabs/Tabs.js";
35
- import { TabItem as Xo, TabItemStyle as Yo } from "./components/Tabs/TabItem.js";
36
- import { TextArea as _o } from "./components/TextArea/TextArea.js";
37
- import { TextField as or } from "./components/TextField/TextField.js";
38
- import { Toast as er, ToastStyle as tr, toaster as ar } from "./components/Toast/Toast.js";
39
- import { Tooltip as mr } from "./components/Tooltip/Tooltip.js";
40
- import { TopAppBar as ir } from "./components/TopAppBar/TopAppBar.js";
41
- import { DataTableComponent as fr } from "./components/DataTable/DataTableComponent.js";
42
- import { parse as cr } from "./node_modules/@zag-js/date-picker/dist/index.js";
33
+ import { Steps as Ho } from "./components/Steps/Steps.js";
34
+ import { Switch as Ko, SwitchStyle as Oo } from "./components/Switch/Switch.js";
35
+ import { Tabs as Vo, TabsStyle as Xo } from "./components/Tabs/Tabs.js";
36
+ import { TabItem as Zo, TabItemStyle as _o } from "./components/Tabs/TabItem.js";
37
+ import { TextArea as or } from "./components/TextArea/TextArea.js";
38
+ import { TextField as er } from "./components/TextField/TextField.js";
39
+ import { Toast as ar, ToastStyle as pr, toaster as mr } from "./components/Toast/Toast.js";
40
+ import { Tooltip as ir } from "./components/Tooltip/Tooltip.js";
41
+ import { TopAppBar as fr } from "./components/TopAppBar/TopAppBar.js";
42
+ import { DataTableComponent as cr } from "./components/DataTable/DataTableComponent.js";
43
+ import { parse as lr } from "./node_modules/@zag-js/date-picker/dist/index.js";
43
44
  export {
44
45
  a as Accordion,
45
46
  m as AccordionGroup,
@@ -60,7 +61,7 @@ export {
60
61
  K as ChoiceBoxStyle,
61
62
  Q as DashboardWidget,
62
63
  X as DataTable,
63
- fr as DataTableComponent,
64
+ cr as DataTableComponent,
64
65
  Z as DatePicker,
65
66
  $ as Divider,
66
67
  oo as DividerStyle,
@@ -88,18 +89,19 @@ export {
88
89
  zo as SelectStyle,
89
90
  D as SerendieChartTheme,
90
91
  e as SerendiePreset,
91
- Ho as Switch,
92
- Jo as SwitchStyle,
93
- Xo as TabItem,
94
- Yo as TabItemStyle,
95
- Oo as Tabs,
96
- Qo as TabsStyle,
97
- _o as TextArea,
98
- or as TextField,
99
- er as Toast,
100
- tr as ToastStyle,
101
- mr as Tooltip,
102
- ir as TopAppBar,
92
+ Ho as Steps,
93
+ Ko as Switch,
94
+ Oo as SwitchStyle,
95
+ Zo as TabItem,
96
+ _o as TabItemStyle,
97
+ Vo as Tabs,
98
+ Xo as TabsStyle,
99
+ or as TextArea,
100
+ er as TextField,
101
+ ar as Toast,
102
+ pr as ToastStyle,
103
+ ir as Tooltip,
104
+ fr as TopAppBar,
103
105
  q as checkboxCheckedIconCss,
104
106
  z as checkboxIconCss,
105
107
  E as checkboxUncheckedIconCss,
@@ -108,12 +110,12 @@ export {
108
110
  M as getChartColor,
109
111
  w as getChartColors,
110
112
  A as legendChartMargin,
111
- cr as parseDate,
113
+ lr as parseDate,
112
114
  Ao as radioCheckedIconCss,
113
115
  Lo as radioIconCss,
114
116
  No as radioUncheckedIconCss,
115
117
  L as spaciousChartMargin,
116
- ar as toaster,
118
+ mr as toaster,
117
119
  N as useBarChartProps,
118
120
  R as useChartProps,
119
121
  F as useLineChartProps,