wimui 0.49.0 → 0.50.1

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.
@@ -71,120 +71,93 @@ export interface QueryBuilderProps {
71
71
  }
72
72
  /**
73
73
  * 演算子の語彙。**利用者が `QueryRule.operator` に渡すのは `value`(記号)**で、
74
- * `key` は翻訳の引き当てにしか使わない。以前は `operator: string` だったため
74
+ * `key` は翻訳の引き当てにしか使わない(文言は `components:query.builder.operators.<key>`。en / ja / pt)。以前は `operator: string` だったため
75
75
  * `"greater_equal"` のような語を渡すと**空の Select が黙って描画された**(T124)。
76
76
  * 型はこの表から導くので、値を足せば型も追随する(T38 と同じ形)。
77
77
  */
78
78
  declare const DEFAULT_OPERATORS: {
79
79
  readonly string: readonly [{
80
- readonly label: "Equals";
81
80
  readonly value: "=";
82
81
  readonly key: "equal";
83
82
  }, {
84
- readonly label: "Does not equal";
85
83
  readonly value: "!=";
86
84
  readonly key: "not_equal";
87
85
  }, {
88
- readonly label: "Contains";
89
86
  readonly value: "contains";
90
87
  readonly key: "contains";
91
88
  }, {
92
- readonly label: "Starts with";
93
89
  readonly value: "starts_with";
94
90
  readonly key: "starts_with";
95
91
  }, {
96
- readonly label: "Ends with";
97
92
  readonly value: "ends_with";
98
93
  readonly key: "ends_with";
99
94
  }, {
100
- readonly label: "Is null";
101
95
  readonly value: "is_null";
102
96
  readonly key: "is_null";
103
97
  }, {
104
- readonly label: "Is not null";
105
98
  readonly value: "is_not_null";
106
99
  readonly key: "is_not_null";
107
100
  }];
108
101
  readonly number: readonly [{
109
- readonly label: "Equals";
110
102
  readonly value: "=";
111
103
  readonly key: "equal";
112
104
  }, {
113
- readonly label: "Does not equal";
114
105
  readonly value: "!=";
115
106
  readonly key: "not_equal";
116
107
  }, {
117
- readonly label: "Greater than";
118
108
  readonly value: ">";
119
109
  readonly key: "greater_than";
120
110
  }, {
121
- readonly label: "Less than";
122
111
  readonly value: "<";
123
112
  readonly key: "less_than";
124
113
  }, {
125
- readonly label: "Greater than or equal";
126
114
  readonly value: ">=";
127
115
  readonly key: "greater_than_or_equal";
128
116
  }, {
129
- readonly label: "Less than or equal";
130
117
  readonly value: "<=";
131
118
  readonly key: "less_than_or_equal";
132
119
  }, {
133
- readonly label: "Is null";
134
120
  readonly value: "is_null";
135
121
  readonly key: "is_null";
136
122
  }, {
137
- readonly label: "Is not null";
138
123
  readonly value: "is_not_null";
139
124
  readonly key: "is_not_null";
140
125
  }];
141
126
  readonly date: readonly [{
142
- readonly label: "Equals";
143
127
  readonly value: "=";
144
128
  readonly key: "equal";
145
129
  }, {
146
- readonly label: "Does not equal";
147
130
  readonly value: "!=";
148
131
  readonly key: "not_equal";
149
132
  }, {
150
- readonly label: "After";
151
133
  readonly value: ">";
152
134
  readonly key: "after";
153
135
  }, {
154
- readonly label: "Before";
155
136
  readonly value: "<";
156
137
  readonly key: "before";
157
138
  }, {
158
- readonly label: "After or on";
159
139
  readonly value: ">=";
160
140
  readonly key: "after_or_on";
161
141
  }, {
162
- readonly label: "Before or on";
163
142
  readonly value: "<=";
164
143
  readonly key: "before_or_on";
165
144
  }, {
166
- readonly label: "Is null";
167
145
  readonly value: "is_null";
168
146
  readonly key: "is_null";
169
147
  }, {
170
- readonly label: "Is not null";
171
148
  readonly value: "is_not_null";
172
149
  readonly key: "is_not_null";
173
150
  }];
174
151
  readonly boolean: readonly [{
175
- readonly label: "Equals";
176
152
  readonly value: "=";
177
153
  readonly key: "equal";
178
154
  }, {
179
- readonly label: "Does not equal";
180
155
  readonly value: "!=";
181
156
  readonly key: "not_equal";
182
157
  }, {
183
- readonly label: "Is null";
184
158
  readonly value: "is_null";
185
159
  readonly key: "is_null";
186
160
  }, {
187
- readonly label: "Is not null";
188
161
  readonly value: "is_not_null";
189
162
  readonly key: "is_not_null";
190
163
  }];
@@ -17,143 +17,116 @@ import { jsx as g, jsxs as _ } from "react/jsx-runtime";
17
17
  var v = 0, y = () => typeof window < "u" && window.__VRT__ ? (v += 1, `vrt-id-${v}`) : Math.random().toString(36).substring(2, 11), b = {
18
18
  string: [
19
19
  {
20
- label: "Equals",
21
20
  value: "=",
22
21
  key: "equal"
23
22
  },
24
23
  {
25
- label: "Does not equal",
26
24
  value: "!=",
27
25
  key: "not_equal"
28
26
  },
29
27
  {
30
- label: "Contains",
31
28
  value: "contains",
32
29
  key: "contains"
33
30
  },
34
31
  {
35
- label: "Starts with",
36
32
  value: "starts_with",
37
33
  key: "starts_with"
38
34
  },
39
35
  {
40
- label: "Ends with",
41
36
  value: "ends_with",
42
37
  key: "ends_with"
43
38
  },
44
39
  {
45
- label: "Is null",
46
40
  value: "is_null",
47
41
  key: "is_null"
48
42
  },
49
43
  {
50
- label: "Is not null",
51
44
  value: "is_not_null",
52
45
  key: "is_not_null"
53
46
  }
54
47
  ],
55
48
  number: [
56
49
  {
57
- label: "Equals",
58
50
  value: "=",
59
51
  key: "equal"
60
52
  },
61
53
  {
62
- label: "Does not equal",
63
54
  value: "!=",
64
55
  key: "not_equal"
65
56
  },
66
57
  {
67
- label: "Greater than",
68
58
  value: ">",
69
59
  key: "greater_than"
70
60
  },
71
61
  {
72
- label: "Less than",
73
62
  value: "<",
74
63
  key: "less_than"
75
64
  },
76
65
  {
77
- label: "Greater than or equal",
78
66
  value: ">=",
79
67
  key: "greater_than_or_equal"
80
68
  },
81
69
  {
82
- label: "Less than or equal",
83
70
  value: "<=",
84
71
  key: "less_than_or_equal"
85
72
  },
86
73
  {
87
- label: "Is null",
88
74
  value: "is_null",
89
75
  key: "is_null"
90
76
  },
91
77
  {
92
- label: "Is not null",
93
78
  value: "is_not_null",
94
79
  key: "is_not_null"
95
80
  }
96
81
  ],
97
82
  date: [
98
83
  {
99
- label: "Equals",
100
84
  value: "=",
101
85
  key: "equal"
102
86
  },
103
87
  {
104
- label: "Does not equal",
105
88
  value: "!=",
106
89
  key: "not_equal"
107
90
  },
108
91
  {
109
- label: "After",
110
92
  value: ">",
111
93
  key: "after"
112
94
  },
113
95
  {
114
- label: "Before",
115
96
  value: "<",
116
97
  key: "before"
117
98
  },
118
99
  {
119
- label: "After or on",
120
100
  value: ">=",
121
101
  key: "after_or_on"
122
102
  },
123
103
  {
124
- label: "Before or on",
125
104
  value: "<=",
126
105
  key: "before_or_on"
127
106
  },
128
107
  {
129
- label: "Is null",
130
108
  value: "is_null",
131
109
  key: "is_null"
132
110
  },
133
111
  {
134
- label: "Is not null",
135
112
  value: "is_not_null",
136
113
  key: "is_not_null"
137
114
  }
138
115
  ],
139
116
  boolean: [
140
117
  {
141
- label: "Equals",
142
118
  value: "=",
143
119
  key: "equal"
144
120
  },
145
121
  {
146
- label: "Does not equal",
147
122
  value: "!=",
148
123
  key: "not_equal"
149
124
  },
150
125
  {
151
- label: "Is null",
152
126
  value: "is_null",
153
127
  key: "is_null"
154
128
  },
155
129
  {
156
- label: "Is not null",
157
130
  value: "is_not_null",
158
131
  key: "is_not_null"
159
132
  }
@@ -285,7 +258,7 @@ var v = 0, y = () => typeof window < "u" && window.__VRT__ ? (v += 1, `vrt-id-${
285
258
  }, ie = (e) => {
286
259
  let t = v.find((t) => t.name === e.field)?.type || "string", a = b[t].map((e) => ({
287
260
  ...e,
288
- label: H[e.key] || e.label
261
+ label: H[e.key] || E(`query.builder.operators.${e.key}`)
289
262
  })), s = (t) => {
290
263
  let n = v.find((e) => e.name === t);
291
264
  Z(e.id, {
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- let e=require("react");function t({options:t,value:n,onChange:r,defaultValue:i,searchable:a,grouped:o,disabled:s,filterOption:c}){let[l,u]=(0,e.useState)(!1),[d,f]=(0,e.useState)(i||``),[p,m]=(0,e.useState)(``),[h,g]=(0,e.useState)(-1),[_,v]=(0,e.useState)(!1),y=(0,e.useRef)(null),b=(0,e.useRef)(null),x=(0,e.useRef)(null),S=(0,e.useRef)([]),C=n!==void 0,w=C?n:d,T=(0,e.useMemo)(()=>o&&t.length>0&&`options`in t[0]?t.flatMap(e=>e.options):t,[t,o]),E=(0,e.useMemo)(()=>{if(!p)return T;let e=c||((e,t)=>{if(e.type===`separator`)return!1;let n=typeof e.label==`string`?e.label:``,r=typeof e.value==`string`?e.value:``,i=t.toLowerCase();return n.toLowerCase().includes(i)||r.toLowerCase().includes(i)});return T.filter(t=>e(t,p))},[T,p,c]),D=T.find(e=>e.value===w);(0,e.useEffect)(()=>{let e=e=>{y.current&&!y.current.contains(e.target)&&(u(!1),m(``),g(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,e.useEffect)(()=>{l&&a&&x.current&&x.current.focus()},[l,a]),(0,e.useEffect)(()=>{h>=0&&S.current[h]&&S.current[h]?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[h]);let O=()=>{s||(u(!l),l||(m(``),g(-1)))},k=e=>{e.type===`separator`||e.disabled||(!C&&e.value!==void 0&&f(e.value),r&&e.value!==void 0&&r(e.value),u(!1),m(``),g(-1),b.current?.focus())};return{isOpen:l,searchValue:p,setSearchValue:m,focusedIndex:h,setFocusedIndex:g,isKeyboardNavigating:_,setIsKeyboardNavigating:v,containerRef:y,triggerRef:b,searchInputRef:x,listItemsRef:S,currentValue:w,flatOptions:T,filteredOptions:E,selectedOption:D,focusedOption:h>=0?E[h]:null,handleToggle:O,handleSelect:k,handleClear:()=>{s||(C||f(``),r?.(``))},handleKeyDown:e=>{if(v(!0),!s)switch(e.key){case`Enter`:case` `:l?h>=0&&E[h]&&k(E[h]):u(!0),e.preventDefault();break;case`Escape`:u(!1),m(``),g(-1),b.current?.focus(),e.preventDefault();break;case`ArrowDown`:e.preventDefault(),l?g(e=>{let t=e+1;for(t>=E.length&&(t=0);t<E.length&&(E[t]?.disabled||E[t]?.type===`separator`);)t++;if(t>=E.length)for(t=0;t<e&&(E[t]?.disabled||E[t]?.type===`separator`);)t++;return t<E.length?t:e}):u(!0);break;case`ArrowUp`:e.preventDefault(),l&&g(e=>{let t=e-1;for(t<0&&(t=E.length-1);t>=0&&(E[t]?.disabled||E[t]?.type===`separator`);)t--;if(t<0)for(t=E.length-1;t>e&&(E[t]?.disabled||E[t]?.type===`separator`);)t--;return t>=0?t:e});break;case`Home`:l&&(e.preventDefault(),g(0));break;case`End`:l&&(e.preventDefault(),g(E.length-1))}}}}exports.useSelect=t;
2
+ let e=require("react");function t({options:t,value:n,onChange:r,defaultValue:i,searchable:a,grouped:o,disabled:s,filterOption:c}){let[l,u]=(0,e.useState)(!1),[d,f]=(0,e.useState)(i||``),[p,m]=(0,e.useState)(``),[h,g]=(0,e.useState)(-1),[_,v]=(0,e.useState)(!1),y=(0,e.useRef)(null),b=(0,e.useRef)(null),x=(0,e.useRef)(null),S=(0,e.useRef)([]),C=n!==void 0,w=C?n:d,T=(0,e.useMemo)(()=>o&&t.length>0&&`options`in t[0]?t.flatMap(e=>e.options):t,[t,o]),E=(0,e.useMemo)(()=>{if(!p)return T;let e=c||((e,t)=>{if(e.type===`separator`)return!1;let n=typeof e.label==`string`?e.label:``,r=typeof e.value==`string`?e.value:``,i=t.toLowerCase();return n.toLowerCase().includes(i)||r.toLowerCase().includes(i)});return T.filter(t=>e(t,p))},[T,p,c]),D=T.find(e=>e.value===w);(0,e.useEffect)(()=>{let e=e=>{y.current&&!y.current.contains(e.target)&&(u(!1),m(``),g(-1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,e.useEffect)(()=>{l&&a&&x.current&&x.current.focus()},[l,a]),(0,e.useEffect)(()=>{h>=0&&S.current[h]&&S.current[h]?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[h]);let O=()=>{s||(u(!l),l||(m(``),g(-1)))},k=e=>{e.type===`separator`||e.disabled||(!C&&e.value!==void 0&&f(e.value),r&&e.value!==void 0&&r(e.value),u(!1),m(``),g(-1),b.current?.focus())};return{isOpen:l,searchValue:p,setSearchValue:m,focusedIndex:h,setFocusedIndex:g,isKeyboardNavigating:_,setIsKeyboardNavigating:v,containerRef:y,triggerRef:b,searchInputRef:x,listItemsRef:S,currentValue:w,flatOptions:T,filteredOptions:E,selectedOption:D,focusedOption:h>=0?E[h]:null,handleToggle:O,handleSelect:k,handleClear:()=>{s||(C||f(``),r?.(``))},handleKeyDown:e=>{if(v(!0),!s)switch(e.key){case`Enter`:case` `:l?h>=0&&E[h]&&k(E[h]):u(!0),e.preventDefault();break;case`Escape`:u(!1),m(``),g(-1),b.current?.focus(),e.preventDefault();break;case`Tab`:l&&(u(!1),m(``),g(-1));break;case`ArrowDown`:e.preventDefault(),l?g(e=>{let t=e+1;for(t>=E.length&&(t=0);t<E.length&&(E[t]?.disabled||E[t]?.type===`separator`);)t++;if(t>=E.length)for(t=0;t<e&&(E[t]?.disabled||E[t]?.type===`separator`);)t++;return t<E.length?t:e}):u(!0);break;case`ArrowUp`:e.preventDefault(),l&&g(e=>{let t=e-1;for(t<0&&(t=E.length-1);t>=0&&(E[t]?.disabled||E[t]?.type===`separator`);)t--;if(t<0)for(t=E.length-1;t>e&&(E[t]?.disabled||E[t]?.type===`separator`);)t--;return t>=0?t:e});break;case`Home`:l&&(e.preventDefault(),g(0));break;case`End`:l&&(e.preventDefault(),g(E.length-1))}}}}exports.useSelect=t;
@@ -64,6 +64,9 @@ function i({ options: i, value: a, onChange: o, defaultValue: s, searchable: c,
64
64
  case "Escape":
65
65
  p(!1), _(""), y(-1), C.current?.focus(), e.preventDefault();
66
66
  break;
67
+ case "Tab":
68
+ f && (p(!1), _(""), y(-1));
69
+ break;
67
70
  case "ArrowDown":
68
71
  e.preventDefault(), f ? y((e) => {
69
72
  let t = e + 1;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./focus-trap.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({children:e,active:a=!0,initialFocus:o=!0,className:s})=>{let c=(0,n.useRef)(null),l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!a)return;l.current=document.activeElement;let e=c.current;if(!e)return;let t=()=>Array.from(e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)).filter(e=>{let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`&&!e.disabled});if(o){let e=t();e.length>0&&e[0].focus()}let n=e=>{if(e.key!==`Tab`)return;let n=t();if(n.length===0){e.preventDefault();return}let r=n[0],i=n[n.length-1];e.shiftKey?document.activeElement===r&&(e.preventDefault(),i.focus()):document.activeElement===i&&(e.preventDefault(),r.focus())};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),l.current&&l.current.focus()}},[a,o]),(0,i.jsx)(`div`,{ref:c,className:(0,r.default)(`wim-focus-trap`,t.default.root,s),children:e})};exports.FocusTrap=a;
2
+ const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("./focus-trap.module.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("classnames");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a=({children:e,active:a=!0,initialFocus:o=!0,className:s})=>{let c=(0,n.useRef)(null),l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!a)return;l.current=document.activeElement;let e=c.current;if(!e)return;let t=()=>Array.from(e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`)).filter(e=>{let t=window.getComputedStyle(e);return e.tabIndex>=0&&t.display!==`none`&&t.visibility!==`hidden`&&!e.disabled});if(o){let e=t();e.length>0&&e[0].focus()}let n=n=>{if(n.key!==`Tab`)return;let r=t();if(r.length===0){n.preventDefault();return}let i=r[0],a=r[r.length-1],o=document.activeElement;if(!o||!e.contains(o))return;let s=r.indexOf(o);n.shiftKey?(s>=0?s>0:r.some(e=>e.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING))||(n.preventDefault(),a.focus()):(s>=0?s<r.length-1:r.some(e=>o.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))||(n.preventDefault(),i.focus())};return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n),l.current&&l.current.focus()}},[a,o]),(0,i.jsx)(`div`,{ref:c,className:(0,r.default)(`wim-focus-trap`,t.default.root,s),children:e})};exports.FocusTrap=a;
@@ -13,21 +13,23 @@ var a = ({ children: a, active: o = !0, initialFocus: s = !0, className: c }) =>
13
13
  if (!e) return;
14
14
  let t = () => Array.from(e.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])")).filter((e) => {
15
15
  let t = window.getComputedStyle(e);
16
- return t.display !== "none" && t.visibility !== "hidden" && !e.disabled;
16
+ return e.tabIndex >= 0 && t.display !== "none" && t.visibility !== "hidden" && !e.disabled;
17
17
  });
18
18
  if (s) {
19
19
  let e = t();
20
20
  e.length > 0 && e[0].focus();
21
21
  }
22
- let n = (e) => {
23
- if (e.key !== "Tab") return;
24
- let n = t();
25
- if (n.length === 0) {
26
- e.preventDefault();
22
+ let n = (n) => {
23
+ if (n.key !== "Tab") return;
24
+ let r = t();
25
+ if (r.length === 0) {
26
+ n.preventDefault();
27
27
  return;
28
28
  }
29
- let r = n[0], i = n[n.length - 1];
30
- e.shiftKey ? document.activeElement === r && (e.preventDefault(), i.focus()) : document.activeElement === i && (e.preventDefault(), r.focus());
29
+ let i = r[0], a = r[r.length - 1], o = document.activeElement;
30
+ if (!o || !e.contains(o)) return;
31
+ let s = r.indexOf(o);
32
+ n.shiftKey ? (s >= 0 ? s > 0 : r.some((e) => e.compareDocumentPosition(o) & Node.DOCUMENT_POSITION_FOLLOWING)) || (n.preventDefault(), a.focus()) : (s >= 0 ? s < r.length - 1 : r.some((e) => o.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING)) || (n.preventDefault(), i.focus());
31
33
  };
32
34
  return document.addEventListener("keydown", n), () => {
33
35
  document.removeEventListener("keydown", n), u.current && u.current.focus();