@expcat/tigercat-react 2.1.1 → 2.1.2

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,6 +1,6 @@
1
1
  import {
2
2
  Select
3
- } from "./chunk-KVCI2346.mjs";
3
+ } from "./chunk-S2V3HGLZ.mjs";
4
4
  import {
5
5
  Radio
6
6
  } from "./chunk-IIWUQK2P.mjs";
@@ -2,6 +2,9 @@ import {
2
2
  renderOverlayPortal,
3
3
  useAnchoredOverlay
4
4
  } from "./chunk-HKAZXG74.mjs";
5
+ import {
6
+ useTigerConfig
7
+ } from "./chunk-YSIXURBW.mjs";
5
8
 
6
9
  // src/components/ColorPicker.tsx
7
10
  import { useState, useMemo, useRef, useEffect } from "react";
@@ -17,7 +20,10 @@ import {
17
20
  formatColorString,
18
21
  parseColorInput,
19
22
  parseColorParts,
20
- classNames
23
+ classNames,
24
+ mergeTigerLocale,
25
+ getColorPickerLabels,
26
+ formatColorPickerSelectPreset
21
27
  } from "@expcat/tigercat-core";
22
28
  import { jsx, jsxs } from "react/jsx-runtime";
23
29
  function rgbFromValue(value) {
@@ -37,8 +43,19 @@ var ColorPicker = ({
37
43
  format = "hex",
38
44
  presets,
39
45
  className,
46
+ locale,
47
+ labels: labelsOverride,
40
48
  onChange
41
49
  }) => {
50
+ const config = useTigerConfig();
51
+ const mergedLocale = useMemo(
52
+ () => mergeTigerLocale(config.locale, locale),
53
+ [config.locale, locale]
54
+ );
55
+ const labels = useMemo(
56
+ () => getColorPickerLabels(mergedLocale, labelsOverride),
57
+ [mergedLocale, labelsOverride]
58
+ );
42
59
  const [isOpen, setIsOpen] = useState(false);
43
60
  const [alpha, setAlpha] = useState(() => explicitAlphaFromValue(value) ?? 1);
44
61
  const containerRef = useRef(null);
@@ -114,6 +131,9 @@ var ColorPicker = ({
114
131
  handlePresetClick(color);
115
132
  }
116
133
  }
134
+ function handleClear() {
135
+ onChange?.("");
136
+ }
117
137
  return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: classNames(colorPickerBaseClasses, className), children: [
118
138
  /* @__PURE__ */ jsx(
119
139
  "div",
@@ -122,7 +142,9 @@ var ColorPicker = ({
122
142
  className: getColorPickerTriggerClasses(size, disabled),
123
143
  style: { backgroundColor: swatchColor },
124
144
  role: "button",
125
- "aria-label": "Pick color",
145
+ "data-tiger-colorpicker-trigger": "",
146
+ "aria-label": labels.trigger,
147
+ title: labels.trigger,
126
148
  "aria-haspopup": "dialog",
127
149
  "aria-expanded": isOpen,
128
150
  "aria-disabled": disabled || void 0,
@@ -139,9 +161,25 @@ var ColorPicker = ({
139
161
  className: classNames(colorPickerPanelClasses, overlay.floatingClasses),
140
162
  style: overlay.floatingStyles,
141
163
  "data-positioned": overlay.positioned,
164
+ "data-tiger-colorpicker-panel": "",
165
+ role: "dialog",
166
+ "aria-label": labels.panelTitle,
142
167
  children: [
168
+ /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
169
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-[var(--tiger-text,#111827)]", children: labels.panelTitle }),
170
+ /* @__PURE__ */ jsx(
171
+ "button",
172
+ {
173
+ type: "button",
174
+ className: "text-xs text-[var(--tiger-primary,#2563eb)] hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--tiger-primary,#2563eb)]",
175
+ "data-tiger-colorpicker-clear": "",
176
+ onClick: handleClear,
177
+ children: labels.clear
178
+ }
179
+ )
180
+ ] }),
143
181
  /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
144
- /* @__PURE__ */ jsx("label", { className: "block text-xs text-[var(--tiger-text-muted,#6b7280)] mb-1", children: "Hue" }),
182
+ /* @__PURE__ */ jsx("label", { className: "block text-xs text-[var(--tiger-text-muted,#6b7280)] mb-1", children: labels.hue }),
145
183
  /* @__PURE__ */ jsx(
146
184
  "input",
147
185
  {
@@ -150,13 +188,13 @@ var ColorPicker = ({
150
188
  max: 360,
151
189
  value: hsv.h,
152
190
  className: "w-full h-2 rounded-full cursor-pointer accent-[var(--tiger-primary,#2563eb)]",
153
- "aria-label": "Hue",
191
+ "aria-label": labels.hue,
154
192
  onChange: handleHueChange
155
193
  }
156
194
  )
157
195
  ] }),
158
196
  showAlpha && /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
159
- /* @__PURE__ */ jsx("label", { className: "block text-xs text-[var(--tiger-text-muted,#6b7280)] mb-1", children: "Alpha" }),
197
+ /* @__PURE__ */ jsx("label", { className: "block text-xs text-[var(--tiger-text-muted,#6b7280)] mb-1", children: labels.alpha }),
160
198
  /* @__PURE__ */ jsx(
161
199
  "input",
162
200
  {
@@ -165,7 +203,7 @@ var ColorPicker = ({
165
203
  max: 100,
166
204
  value: Math.round(alpha * 100),
167
205
  className: "w-full h-2 rounded-full cursor-pointer accent-[var(--tiger-primary,#2563eb)]",
168
- "aria-label": "Alpha",
206
+ "aria-label": labels.alpha,
169
207
  onChange: handleAlphaChange
170
208
  }
171
209
  )
@@ -178,7 +216,7 @@ var ColorPicker = ({
178
216
  type: "text",
179
217
  className: colorPickerInputClasses,
180
218
  value: inputValue,
181
- "aria-label": "Color value",
219
+ "aria-label": labels.value,
182
220
  onChange: handleInputChange
183
221
  }
184
222
  )
@@ -189,7 +227,7 @@ var ColorPicker = ({
189
227
  {
190
228
  className: "w-8 h-8 rounded border border-[var(--tiger-border,#d1d5db)]",
191
229
  style: { backgroundColor: swatchColor },
192
- "aria-label": "Color preview"
230
+ "aria-label": labels.preview
193
231
  }
194
232
  ),
195
233
  /* @__PURE__ */ jsx("span", { className: "text-xs font-mono text-[var(--tiger-text,#111827)]", children: displayValue })
@@ -201,7 +239,7 @@ var ColorPicker = ({
201
239
  style: { backgroundColor: color },
202
240
  role: "button",
203
241
  tabIndex: 0,
204
- "aria-label": `Select ${color}`,
242
+ "aria-label": formatColorPickerSelectPreset(labels.selectPreset, color),
205
243
  onClick: () => handlePresetClick(color),
206
244
  onKeyDown: (e) => handlePresetKeyDown(e, color)
207
245
  },
@@ -10,7 +10,7 @@ import { useCallback, useMemo, useRef } from "react";
10
10
  import {
11
11
  applyMarkdownToolbarAction,
12
12
  classNames,
13
- defaultMarkdownToolbar,
13
+ createDefaultMarkdownToolbar,
14
14
  findMarkdownHotkeyMatch,
15
15
  getMarkdownBodyClasses,
16
16
  getMarkdownContainerClasses,
@@ -62,9 +62,17 @@ var MarkdownEditor = ({
62
62
  const textareaRef = useRef(null);
63
63
  const [currentValue, commitValue] = useControlledState(value, defaultValue, onChange);
64
64
  const [currentMode, commitMode] = useControlledState(mode, defaultMode, onModeChange);
65
+ const mergedLocale = useMemo(
66
+ () => mergeTigerLocale(config.locale, locale),
67
+ [config.locale, locale]
68
+ );
69
+ const labels = useMemo(
70
+ () => getMarkdownEditorLabels(mergedLocale, labelsOverride),
71
+ [mergedLocale, labelsOverride]
72
+ );
65
73
  const toolbarItems = useMemo(
66
- () => toolbar === false ? [] : toolbar ?? defaultMarkdownToolbar,
67
- [toolbar]
74
+ () => toolbar === false ? [] : toolbar ?? createDefaultMarkdownToolbar(labels),
75
+ [toolbar, labels]
68
76
  );
69
77
  const previewHtml = useMemo(
70
78
  () => renderMarkdownToHtml(currentValue, renderer),
@@ -74,14 +82,6 @@ var MarkdownEditor = ({
74
82
  const parsedHeight = parseMarkdownHeight(height);
75
83
  return { ...parsedHeight ? { height: parsedHeight } : {}, ...style };
76
84
  }, [height, style]);
77
- const mergedLocale = useMemo(
78
- () => mergeTigerLocale(config.locale, locale),
79
- [config.locale, locale]
80
- );
81
- const labels = useMemo(
82
- () => getMarkdownEditorLabels(mergedLocale, labelsOverride),
83
- [mergedLocale, labelsOverride]
84
- );
85
85
  const modeLabels = {
86
86
  edit: labels.editModeLabel,
87
87
  split: labels.splitModeLabel,
@@ -15,7 +15,7 @@ import {
15
15
  richTextToolbarClasses,
16
16
  richTextToolbarSeparatorClasses,
17
17
  richTextPlaceholderClasses,
18
- defaultToolbar,
18
+ createDefaultRichTextToolbar,
19
19
  isInlineFormat,
20
20
  findHotkeyMatch,
21
21
  isContentEmpty,
@@ -48,7 +48,6 @@ var RichTextEditor = ({
48
48
  const [currentContent, setContent] = useControlledState(value, defaultValue, onChange);
49
49
  const isControlled = value !== void 0;
50
50
  const [activeFormats, setActiveFormats] = useState(/* @__PURE__ */ new Set());
51
- const toolbarItems = toolbar ?? defaultToolbar;
52
51
  const empty = isContentEmpty(currentContent);
53
52
  const mergedLocale = useMemo(
54
53
  () => mergeTigerLocale(config.locale, locale),
@@ -58,6 +57,10 @@ var RichTextEditor = ({
58
57
  () => getRichTextEditorLabels(mergedLocale, labelsOverride),
59
58
  [mergedLocale, labelsOverride]
60
59
  );
60
+ const toolbarItems = useMemo(
61
+ () => toolbar ?? createDefaultRichTextToolbar(labels),
62
+ [toolbar, labels]
63
+ );
61
64
  useEffect(() => {
62
65
  if (!editorRef.current) return;
63
66
  const factory = engine ?? builtinRichTextEngine;
@@ -63,7 +63,7 @@ function useSelectState(props) {
63
63
  options = [],
64
64
  size = "md",
65
65
  disabled = false,
66
- placeholder = "Select an option",
66
+ placeholder,
67
67
  searchable = false,
68
68
  searchValue,
69
69
  defaultSearchValue = "",
@@ -95,6 +95,7 @@ function useSelectState(props) {
95
95
  () => getSelectLabels(mergedLocale, labelsOverride),
96
96
  [mergedLocale, labelsOverride]
97
97
  );
98
+ const resolvedPlaceholder = resolveLocaleText(labels.placeholder, placeholder);
98
99
  const divProps = {};
99
100
  for (const [k, v] of Object.entries(props)) {
100
101
  if (!SELECT_KEYS.has(k)) divProps[k] = v;
@@ -132,7 +133,7 @@ function useSelectState(props) {
132
133
  const displayText = useMemo(() => {
133
134
  if (isMultiple) {
134
135
  const values = Array.isArray(value) ? value : [];
135
- if (values.length === 0) return placeholder;
136
+ if (values.length === 0) return resolvedPlaceholder;
136
137
  const labels2 = [...allOptions, ...createdOptions].filter((opt) => values.includes(opt.value)).map((opt) => opt.label);
137
138
  if (maxTagCount !== void 0 && labels2.length > maxTagCount) {
138
139
  const visible = labels2.slice(0, maxTagCount);
@@ -140,9 +141,9 @@ function useSelectState(props) {
140
141
  }
141
142
  return labels2.join(", ");
142
143
  }
143
- if (value === void 0 || value === null || value === "") return placeholder;
144
- return [...allOptions, ...createdOptions].find((opt) => opt.value === value)?.label ?? placeholder;
145
- }, [isMultiple, value, allOptions, createdOptions, placeholder, maxTagCount]);
144
+ if (value === void 0 || value === null || value === "") return resolvedPlaceholder;
145
+ return [...allOptions, ...createdOptions].find((opt) => opt.value === value)?.label ?? resolvedPlaceholder;
146
+ }, [isMultiple, value, allOptions, createdOptions, resolvedPlaceholder, maxTagCount]);
146
147
  const showClearButton = useMemo(
147
148
  () => clearable && !disabled && value !== void 0 && value !== null && value !== "" && (!Array.isArray(value) || value.length > 0),
148
149
  [clearable, disabled, value]
@@ -434,10 +435,10 @@ function useSelectState(props) {
434
435
  virtual,
435
436
  listHeight,
436
437
  disabled,
437
- placeholder,
438
+ placeholder: resolvedPlaceholder,
438
439
  searchable,
439
440
  clearable,
440
- emptyText: resolveLocaleText("No options found", emptyText, mergedLocale?.common?.emptyText),
441
+ emptyText: resolveLocaleText(labels.emptyText, emptyText),
441
442
  createOptionText,
442
443
  className,
443
444
  divProps,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Table
3
- } from "./chunk-CQOLQAB5.mjs";
3
+ } from "./chunk-2XZHYYZ2.mjs";
4
4
  import {
5
5
  Select
6
- } from "./chunk-KVCI2346.mjs";
6
+ } from "./chunk-S2V3HGLZ.mjs";
7
7
  import {
8
8
  Popover
9
9
  } from "./chunk-FNK2VWPP.mjs";
@@ -1,11 +1,13 @@
1
1
  import React__default from 'react';
2
- import { ColorPickerProps as ColorPickerProps$1 } from '@expcat/tigercat-core';
2
+ import { ColorPickerProps as ColorPickerProps$1, TigerLocale, TigerLocaleColorPicker } from '@expcat/tigercat-core';
3
3
 
4
4
  interface ColorPickerProps extends ColorPickerProps$1 {
5
5
  /** Controlled color value (hex) */
6
6
  value?: string;
7
7
  /** Called when color changes */
8
8
  onChange?: (value: string) => void;
9
+ locale?: Partial<TigerLocale>;
10
+ labels?: Partial<TigerLocaleColorPicker>;
9
11
  }
10
12
  declare const ColorPicker: React__default.FC<ColorPickerProps>;
11
13
 
@@ -1,7 +1,9 @@
1
1
  import {
2
2
  ColorPicker
3
- } from "../chunk-KL6YJIZ3.mjs";
3
+ } from "../chunk-3GPGSNOQ.mjs";
4
4
  import "../chunk-HKAZXG74.mjs";
5
+ import "../chunk-YSIXURBW.mjs";
6
+ import "../chunk-TGXBCKOU.mjs";
5
7
  export {
6
8
  ColorPicker
7
9
  };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  DataTableWithToolbar,
3
3
  DataTableWithToolbar_default
4
- } from "../chunk-QXSUG7SN.mjs";
5
- import "../chunk-CQOLQAB5.mjs";
6
- import "../chunk-KVCI2346.mjs";
4
+ } from "../chunk-YH7FKFRM.mjs";
5
+ import "../chunk-2XZHYYZ2.mjs";
6
+ import "../chunk-S2V3HGLZ.mjs";
7
7
  import "../chunk-IIWUQK2P.mjs";
8
8
  import "../chunk-AKNWUI7K.mjs";
9
9
  import "../chunk-FNK2VWPP.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MarkdownEditor,
3
3
  MarkdownEditor_default
4
- } from "../chunk-MXXAJSRS.mjs";
4
+ } from "../chunk-6RMBUZZE.mjs";
5
5
  import "../chunk-MEFARVQI.mjs";
6
6
  import "../chunk-YSIXURBW.mjs";
7
7
  import "../chunk-TGXBCKOU.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RichTextEditor,
3
3
  RichTextEditor_default
4
- } from "../chunk-ASLRAZZN.mjs";
4
+ } from "../chunk-NXJMVH26.mjs";
5
5
  import "../chunk-MEFARVQI.mjs";
6
6
  import "../chunk-YSIXURBW.mjs";
7
7
  import "../chunk-TGXBCKOU.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Select
3
- } from "../chunk-KVCI2346.mjs";
3
+ } from "../chunk-S2V3HGLZ.mjs";
4
4
  import "../chunk-HKAZXG74.mjs";
5
5
  import "../chunk-YSIXURBW.mjs";
6
6
  import "../chunk-TGXBCKOU.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Table
3
- } from "../chunk-CQOLQAB5.mjs";
4
- import "../chunk-KVCI2346.mjs";
3
+ } from "../chunk-2XZHYYZ2.mjs";
4
+ import "../chunk-S2V3HGLZ.mjs";
5
5
  import "../chunk-IIWUQK2P.mjs";
6
6
  import "../chunk-AKNWUI7K.mjs";
7
7
  import "../chunk-M6ZPTGBV.mjs";
package/dist/index.d.mts CHANGED
@@ -166,6 +166,6 @@ import 'react';
166
166
  * React components for Tigercat UI library
167
167
  */
168
168
 
169
- declare const version = "2.1.1";
169
+ declare const version = "2.1.2";
170
170
 
171
171
  export { version };
package/dist/index.mjs CHANGED
@@ -19,6 +19,7 @@ export {
19
19
  DEFAULT_CHART_LABELS,
20
20
  DEFAULT_CHAT_WINDOW_LABELS,
21
21
  DEFAULT_CODE_LABELS,
22
+ DEFAULT_COLOR_PICKER_LABELS,
22
23
  DEFAULT_COMMENT_THREAD_LABELS,
23
24
  DEFAULT_CRON_EDITOR_LABELS,
24
25
  DEFAULT_DATA_EXPORT_LABELS,
@@ -162,6 +163,7 @@ export {
162
163
  ZH_CN_CHART_LABELS,
163
164
  ZH_CN_CHAT_WINDOW_LABELS,
164
165
  ZH_CN_CODE_LABELS,
166
+ ZH_CN_COLOR_PICKER_LABELS,
165
167
  ZH_CN_COMMENT_THREAD_LABELS,
166
168
  ZH_CN_CRON_EDITOR_LABELS,
167
169
  ZH_CN_DATA_EXPORT_LABELS,
@@ -504,6 +506,8 @@ export {
504
506
  createColumnDragData,
505
507
  createCountdownPayload,
506
508
  createDefaultDragSnapshot,
509
+ createDefaultMarkdownToolbar,
510
+ createDefaultRichTextToolbar,
507
511
  createDefaultTransform,
508
512
  createDocumentDragSession,
509
513
  createDragState,
@@ -744,6 +748,7 @@ export {
744
748
  formatBadgeContent,
745
749
  formatBytes,
746
750
  formatChatTime,
751
+ formatColorPickerSelectPreset,
747
752
  formatColorString,
748
753
  formatCommentTime,
749
754
  formatCountdown,
@@ -892,6 +897,7 @@ export {
892
897
  getCollapseIconClasses,
893
898
  getCollapsePanelClasses,
894
899
  getCollapsePanelHeaderClasses,
900
+ getColorPickerLabels,
895
901
  getColorPickerTriggerClasses,
896
902
  getColorSwatchButtonClasses,
897
903
  getColorSwatchCheckClasses,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expcat/tigercat-react",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "React components for Tigercat UI library",
5
5
  "license": "MIT",
6
6
  "author": "Yizhe Wang",
@@ -897,7 +897,7 @@
897
897
  "access": "public"
898
898
  },
899
899
  "dependencies": {
900
- "@expcat/tigercat-core": "2.1.1"
900
+ "@expcat/tigercat-core": "2.1.2"
901
901
  },
902
902
  "devDependencies": {
903
903
  "@types/node": "^26.1.1",