ingred-ui 31.0.5 → 31.1.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.
@@ -5,9 +5,10 @@
5
5
  * メインコンポーネントの複雑性を軽減する。
6
6
  */
7
7
  /// <reference types="react" />
8
- import { AppliedFilter, FilterType, FilterConfig } from "../types";
8
+ import { AppliedFilter, FilterType, FilterConfig, AdvancedFilterSelectionMode } from "../types";
9
9
  export type UseAdvancedFilterStateProps = {
10
10
  types: FilterType[];
11
+ selectionMode?: AdvancedFilterSelectionMode;
11
12
  onFiltersChange?: (filters: AppliedFilter[]) => void;
12
13
  initialAppliedFilters?: AppliedFilter[];
13
14
  };
@@ -34,10 +35,11 @@ export type UseAdvancedFilterStateReturn = {
34
35
  y: number;
35
36
  } | null) => void;
36
37
  handleTypeSelect: (type: string) => void;
38
+ handleSlotClick: (type: string) => void;
37
39
  handleConfigApply: (config: FilterConfig) => void;
38
40
  handleRemoveFilter: (filterId: string) => void;
39
41
  handleClearAll: () => void;
40
42
  handleConfigCancel: () => void;
41
43
  handleEditFilter: (filter: AppliedFilter) => void;
42
44
  };
43
- export declare const useAdvancedFilterState: ({ types, onFiltersChange, initialAppliedFilters, }: UseAdvancedFilterStateProps) => UseAdvancedFilterStateReturn;
45
+ export declare const useAdvancedFilterState: ({ types, selectionMode, onFiltersChange, initialAppliedFilters, }: UseAdvancedFilterStateProps) => UseAdvancedFilterStateReturn;
@@ -26,10 +26,10 @@ export { AdvancedFilterTrigger } from "./AdvancedFilterTrigger";
26
26
  export { AdvancedFilterConfigPanel } from "./AdvancedFilterConfigPanel";
27
27
  export { useAdvancedFilterState } from "./hooks/useAdvancedFilterState";
28
28
  export { useFilterMenuPosition } from "./hooks/useFilterMenuPosition";
29
- export { TEXT_OPERATORS, NUMBER_OPERATORS, DATE_OPERATORS, SELECTION_OPERATORS, PRESET_OPERATORS, getPresetOperators, createOperator, combineOperators, overrideOperatorLabels, changeOperatorLabel, getPresetOperatorsWithLabels, selectOperators, selectOperatorsByIndex, applyOperatorToValue, applyFilter, applyMultipleFilters, evaluateFilterConditions, } from "./utils/operators";
29
+ export { TEXT_OPERATORS, NUMBER_OPERATORS, DATE_OPERATORS, SELECTION_OPERATORS, PRESET_OPERATORS, getPresetOperators, createOperator, combineOperators, overrideOperatorLabels, changeOperatorLabel, getPresetOperatorsWithLabels, selectOperators, selectOperatorsByIndex, applyOperatorToValue, applyFilter, applyMultipleFilters, evaluateFilterConditions, normalizeForSearch, } from "./utils/operators";
30
30
  export { createValue, combineValues, overrideValueLabels, changeValueLabel, selectValues, selectValuesByIndex, getValueStrings, getValueLabels, getLabelsForValues, mergeValues, sortValues, } from "./utils/values";
31
31
  export type { ValueDefinition } from "./utils/values";
32
- export { isRangeOperator, isCustomOperator, isValidFilterConfig, isValidFilterType, generateTagText, generateTagTitle, getTagBoldText, getAvailableTypes, getFilterTypeLabel, } from "./utils/helpers";
32
+ export { isRangeOperator, isCustomOperator, isValidFilterConfig, isValidFilterType, generateTagText, generateTagTitle, getTagBoldText, getAvailableTypes, getFilterTypeLabel, buildFilterSlots, getPresetSlotId, isConfiguredFilter, getConfiguredFilters, } from "./utils/helpers";
33
33
  export { FilterPositionCalculator } from "./utils/positionCalculator";
34
34
  export { ADVANCED_FILTER_CONSTANTS } from "./constants";
35
- export type { AdvancedFilterProps, FilterType, FilterTypeConfig, FilterConfig, AppliedFilter, OperatorDefinition, AdvancedFilterSize, AdvancedFilterVariant, FilterOperator, FilterInputType, FilterPresetType, } from "./types";
35
+ export type { AdvancedFilterProps, FilterType, FilterTypeConfig, FilterConfig, AppliedFilter, OperatorDefinition, AdvancedFilterSize, AdvancedFilterVariant, FilterOperator, FilterInputType, FilterPresetType, AdvancedFilterSelectionMode, FilterSlotView, } from "./types";
@@ -82,6 +82,7 @@ export declare const IconArea: import("styled-components/dist/types").IStyledCom
82
82
  /**
83
83
  * 中央:タグエリア
84
84
  */
85
+ export declare const CONFIGURED_PRESET_SLOT_TAG_CLASS = "ingred-advanced-filter-configured-tag";
85
86
  export declare const TagArea: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
86
87
  /**
87
88
  * プレースホルダーテキスト
@@ -14,6 +14,7 @@
14
14
  * 注: FilterOperator, FilterInputType, FilterPresetType は src/utils/filterTypes.ts で
15
15
  * 定義され、本ファイルから re-export しています。
16
16
  */
17
+ import type { MouseEvent } from "react";
17
18
  import { Theme } from "../../themes";
18
19
  import type { FilterOperator, FilterInputType, FilterPresetType } from "../../utils/filterTypes";
19
20
  export type { FilterOperator, FilterInputType, FilterPresetType };
@@ -22,6 +23,20 @@ export type FilterType = {
22
23
  label: string;
23
24
  disabled?: boolean;
24
25
  };
26
+ /**
27
+ * フィルター選択 UI のモード
28
+ * - menu: メニューからタイプを選んで追加(default)
29
+ * - presetSlots: types 分のスロットを常時表示。未設定はタイプ名のみ、クリックで ConfigPanel を直接開く
30
+ */
31
+ export type AdvancedFilterSelectionMode = "menu" | "presetSlots";
32
+ /** presetSlots モード用の表示スロット */
33
+ export type FilterSlotView = {
34
+ type: string;
35
+ typeLabel: string;
36
+ disabled?: boolean;
37
+ slotId: string;
38
+ filter: AppliedFilter | null;
39
+ };
25
40
  export type OperatorDefinition = {
26
41
  value: FilterOperator | (string & {});
27
42
  label: string;
@@ -148,14 +163,22 @@ export type AdvancedFilterProps = {
148
163
  onFiltersChange?: (filters: AppliedFilter[]) => void;
149
164
  /** Story等で初期表示用に事前適用されたフィルターを指定する */
150
165
  initialAppliedFilters?: AppliedFilter[];
166
+ /**
167
+ * フィルター選択 UI のモード
168
+ * @default 'menu'
169
+ */
170
+ selectionMode?: AdvancedFilterSelectionMode;
151
171
  };
152
172
  export type AdvancedFilterTriggerProps = {
153
173
  placeholder?: string;
154
174
  disabled?: boolean;
155
175
  isOpen?: boolean;
156
- onClick?: () => void;
176
+ onClick?: (event?: MouseEvent) => void;
157
177
  appliedFilters?: AppliedFilter[];
178
+ selectionMode?: AdvancedFilterSelectionMode;
179
+ filterSlots?: FilterSlotView[];
158
180
  onEditFilter?: (filter: AppliedFilter) => void;
181
+ onSlotClick?: (type: string) => void;
159
182
  onRemoveFilter?: (filterId: string) => void;
160
183
  onClearAll?: () => void;
161
184
  size?: "small" | "medium" | "large";
@@ -11,7 +11,7 @@
11
11
  * - タグ表示: タグのテキスト・タイトル生成
12
12
  * - バリデーション: フィルター設定・タイプの有効性チェック
13
13
  */
14
- import { AppliedFilter, FilterConfig, FilterInputType, FilterTypeConfig, MultiFilterConditionConfig, OperatorDefinition, ValueDefinition } from "../types";
14
+ import { AppliedFilter, FilterConfig, FilterInputType, FilterSlotView, FilterTypeConfig, MultiFilterConditionConfig, OperatorDefinition, ValueDefinition } from "../types";
15
15
  /**
16
16
  * 範囲指定が必要なオペレーターかどうかを判定
17
17
  * @param operator オペレーターのvalue
@@ -159,4 +159,16 @@ type ConditionForTextFocus = {
159
159
  * 複数条件モードで最初のテキスト入力条件の ID を取得する
160
160
  */
161
161
  export declare const getFirstTextConditionId: (filterConfig: FilterTypeConfig | undefined, conditions: ConditionForTextFocus[]) => string | null;
162
+ /** 未設定スロットの安定 ID */
163
+ export declare const getPresetSlotId: (type: string) => string;
164
+ /** 設定済み(値が入っている)フィルターかどうか */
165
+ export declare const isConfiguredFilter: (filter: AppliedFilter) => boolean;
166
+ /** 設定済みフィルターのみ返す */
167
+ export declare const getConfiguredFilters: (appliedFilters: AppliedFilter[]) => AppliedFilter[];
168
+ /** types と appliedFilters から presetSlots 表示用スロットを構築 */
169
+ export declare const buildFilterSlots: (types: Array<{
170
+ type: string;
171
+ label: string;
172
+ disabled?: boolean;
173
+ }>, appliedFilters: AppliedFilter[]) => FilterSlotView[];
162
174
  export {};
@@ -69,6 +69,14 @@ export declare const selectOperators: (operators: OperatorDefinition[], values:
69
69
  * オペレーター配列から指定されたインデックスの要素のみを抽出
70
70
  */
71
71
  export declare const selectOperatorsByIndex: (operators: OperatorDefinition[], indices: number[]) => OperatorDefinition[];
72
+ /**
73
+ * フィルタリング処理用のヘルパー関数群
74
+ * 実際のデータフィルタリング処理で使用
75
+ */
76
+ /**
77
+ * 文字列比較用の正規化(大文字小文字・全角半角を区別しない)
78
+ */
79
+ export declare const normalizeForSearch: (value: string) => string;
72
80
  /**
73
81
  * 単一の値に対してオペレーターを適用
74
82
  */
@@ -27,9 +27,13 @@ export declare class FilterPositionCalculator {
27
27
  */
28
28
  private static calculateSafePosition;
29
29
  /**
30
- * ConfigPanelの座標を計算
30
+ * ConfigPanelの座標を計算(AppliedFilter 用。後方互換)
31
31
  */
32
32
  static calculateConfigPanelPosition(filter: AppliedFilter, appliedFilters: AppliedFilter[], triggerRef: React.RefObject<HTMLDivElement>): MenuPosition;
33
+ /**
34
+ * ConfigPanelの座標を計算(slotId ベース。presetSlots モード用)
35
+ */
36
+ static calculateConfigPanelPositionBySlotId(slotId: string, slotIndex: number, triggerRef: React.RefObject<HTMLDivElement>): MenuPosition;
33
37
  /**
34
38
  * 実際のDOM要素から座標を計算
35
39
  */
@@ -33,6 +33,7 @@ export declare const useDateField2: ({ date, format, disabled, onDateChange, }:
33
33
  spellCheck?: undefined;
34
34
  autoCorrect?: undefined;
35
35
  style?: undefined;
36
+ "aria-label"?: undefined;
36
37
  onFocus?: undefined;
37
38
  onBlur?: undefined;
38
39
  onKeyDown?: undefined;
@@ -52,6 +53,7 @@ export declare const useDateField2: ({ date, format, disabled, onDateChange, }:
52
53
  style: {
53
54
  caretColor: "transparent";
54
55
  };
56
+ "aria-label": "日" | "月" | "年" | undefined;
55
57
  onFocus: () => void;
56
58
  onBlur: (e: React.FocusEvent) => void;
57
59
  onKeyDown: (event: React.KeyboardEvent<HTMLSpanElement>) => void;
@@ -59,6 +59,16 @@ export type DropdownButtonProps = {
59
59
  * - アイコン + テキスト: スピナー + ローディングテキストを表示(`true`の場合はデフォルトで"Loading...")
60
60
  */
61
61
  loading?: boolean | string;
62
+ /**
63
+ * ドロップダウンメニューを開くトグルボタンに付ける accessible name。
64
+ * - split=true のときの分割トリガー(矢印のみのボタン)
65
+ * - 単一トリガーが children を持たないとき(アイコンのみ/ローディング中)
66
+ * のフォールバックとして使用されます。split モードのメインボタン (左側
67
+ * の onClick 用ボタン) には適用されないので、そちらが icon-only になる
68
+ * 場合は呼び出し側で `children` か aria-label を渡してください。
69
+ * @default "メニューを開く"
70
+ */
71
+ toggleAriaLabel?: string;
62
72
  };
63
73
  export type DropdownButtonSizeConfig = {
64
74
  arrowIconSize: number;
@@ -1,2 +1,2 @@
1
- declare const LoadingBar: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
1
+ declare const LoadingBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<any, "role" | "aria-busy" | "aria-label"> & Partial<Pick<any, "role" | "aria-busy" | "aria-label">>> & string;
2
2
  export default LoadingBar;
@@ -7,7 +7,7 @@ export declare const SelectLabel: import("styled-components/dist/types").IStyled
7
7
  export declare const SelectLabelText: import("styled-components/dist/types").IStyledComponentBase<"web", any> & string;
8
8
  export declare const SelectLabelIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<any, never> & Partial<Pick<any, never>>> & string;
9
9
  export declare const TagContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<any, never> & Partial<Pick<any, never>>> & string;
10
- export declare const StyledTag: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../Tag").TagProps, never> & Partial<Pick<import("../Tag").TagProps, never>>> & string & Omit<({ label, size, variant, onRemove, className, disabled, boldText, onClick, "aria-label": ariaLabel, "data-tag": dataTag, prepend, }: import("../Tag").TagProps) => JSX.Element, keyof import("react").Component<any, {}, any>>;
10
+ export declare const StyledTag: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../Tag").TagProps, never> & Partial<Pick<import("../Tag").TagProps, never>>> & string & Omit<({ label, size, variant, onRemove, className, disabled, boldText, onClick, onPointerDown, "aria-label": ariaLabel, "data-tag": dataTag, prepend, }: import("../Tag").TagProps) => JSX.Element, keyof import("react").Component<any, {}, any>>;
11
11
  export declare const Placeholder: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<any, never> & Partial<Pick<any, never>>> & string;
12
12
  export declare const IconArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<any, never> & Partial<Pick<any, never>>> & string;
13
13
  export declare const StyledContextMenu2TextInputItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components").FastOmit<import("styled-components").FastOmit<{
@@ -45,6 +45,10 @@ export type SliderProps = {
45
45
  * Additional inline styles.
46
46
  */
47
47
  style?: React.CSSProperties;
48
+ /**
49
+ * Accessible name for the slider. Use this when the slider has no visible label.
50
+ */
51
+ "aria-label"?: string;
48
52
  /**
49
53
  * ID of the element that labels the slider.
50
54
  */
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { TagProps } from "./types";
3
- export declare const Tag: ({ label, size, variant, onRemove, className, disabled, boldText, onClick, "aria-label": ariaLabel, "data-tag": dataTag, prepend, }: TagProps) => JSX.Element;
3
+ export declare const Tag: ({ label, size, variant, onRemove, className, disabled, boldText, onClick, onPointerDown, "aria-label": ariaLabel, "data-tag": dataTag, prepend, }: TagProps) => JSX.Element;
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from "react";
1
+ import type { PointerEventHandler, ReactNode } from "react";
2
2
  export type TagSize = "small" | "medium" | "large" | "xl";
3
3
  export type TagVariant = "light" | "dark";
4
4
  export type TagProps = {
@@ -10,6 +10,11 @@ export type TagProps = {
10
10
  disabled?: boolean;
11
11
  boldText?: string | string[];
12
12
  onClick?: () => void;
13
+ /**
14
+ * ポインター押下時(マウス・タッチ)。`preventDefault` でフォーカス移動によるスクロールを抑止する用途向け。
15
+ * タッチでは `onMouseDown` だけでは効かないことがある。
16
+ */
17
+ onPointerDown?: PointerEventHandler<HTMLDivElement>;
13
18
  "aria-label"?: string;
14
19
  "data-tag"?: string;
15
20
  prepend?: ReactNode;
@@ -32,6 +32,7 @@ export declare const useTimeField2: ({ time, disabled, onTimeChange, }: Props) =
32
32
  spellCheck?: undefined;
33
33
  autoCorrect?: undefined;
34
34
  style?: undefined;
35
+ "aria-label"?: undefined;
35
36
  onFocus?: undefined;
36
37
  onBlur?: undefined;
37
38
  onKeyDown?: undefined;
@@ -51,6 +52,7 @@ export declare const useTimeField2: ({ time, disabled, onTimeChange, }: Props) =
51
52
  style: {
52
53
  caretColor: "transparent";
53
54
  };
55
+ "aria-label": string;
54
56
  onFocus: () => void;
55
57
  onBlur: (e: React.FocusEvent) => void;
56
58
  onKeyDown: (event: React.KeyboardEvent<HTMLSpanElement>) => void;
@@ -6,6 +6,13 @@ export type WeekTimeElementProps = {
6
6
  active: boolean;
7
7
  hover: boolean;
8
8
  } & React.HTMLAttributes<HTMLButtonElement | HTMLSpanElement>>;
9
+ /**
10
+ * インタラクティブなセル(button)として描画される場合は true。
11
+ * 読み取り専用(span)として描画される場合は false。
12
+ * span に aria-label / aria-pressed を付与すると axe の aria-prohibited-attr に該当するため、
13
+ * インタラクティブな場合のみ付与する。
14
+ */
15
+ interactive?: boolean;
9
16
  isWithinHoverRange?: (weekIndex: number, timeIndex: number) => boolean;
10
17
  onMouseOver?: (weekIndex: number, timeIndex: number) => void;
11
18
  onMouseDown?: (weekIndex: number, timeIndex: number, time: string) => void;