@progress/kendo-react-layout 8.1.0-develop.13 → 8.1.0-develop.15

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.
@@ -6,134 +6,152 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  "use client";
9
- import * as a from "react";
10
- import r from "prop-types";
11
- import { StepperContext as ee } from "./context/StepperContext.mjs";
12
- import { validatePackage as te, focusFirstFocusableChild as se, useRtl as ae, dispatchEvent as P, Keys as u, classNames as A, svgIconPropType as F } from "@progress/kendo-react-common";
13
- import { Step as oe } from "./Step.mjs";
9
+ import * as n from "react";
10
+ import c from "prop-types";
11
+ import { StepperContext as $ } from "./context/StepperContext.mjs";
12
+ import { validatePackage as ee, focusFirstFocusableChild as te, useDir as oe, dispatchEvent as O, Navigation as se, classNames as P, svgIconPropType as A } from "@progress/kendo-react-common";
13
+ import { Step as ne } from "./Step.mjs";
14
14
  import { ProgressBar as re } from "@progress/kendo-react-progressbars";
15
- import { DEFAULT_ANIMATION_DURATION as ne, NO_ANIMATION as le } from "./contants.mjs";
16
- import { packageMetadata as ie } from "../package-metadata.mjs";
15
+ import { DEFAULT_ANIMATION_DURATION as ie, NO_ANIMATION as le } from "./contants.mjs";
16
+ import { packageMetadata as ae } from "../package-metadata.mjs";
17
17
  import { useLocalization as ce } from "@progress/kendo-react-intl";
18
- import { progBarAriaLabel as M, messages as ue } from "./messages/index.mjs";
19
- const E = a.forwardRef((k, V) => {
20
- te(ie);
18
+ import { progBarAriaLabel as T, messages as ue } from "./messages/index.mjs";
19
+ const F = n.forwardRef((x, M) => {
20
+ ee(ae);
21
21
  const {
22
- animationDuration: b,
22
+ animationDuration: v,
23
23
  children: L,
24
- className: D,
25
- disabled: m,
26
- errorIcon: z,
27
- errorSVGIcon: G,
28
- item: N,
29
- items: d,
30
- linear: p,
24
+ className: C,
25
+ disabled: f,
26
+ errorIcon: V,
27
+ errorSVGIcon: z,
28
+ item: S,
29
+ items: m,
30
+ linear: g,
31
31
  mode: K,
32
- orientation: y,
33
- style: R,
34
- successIcon: _,
35
- successSVGIcon: B,
36
- onChange: h,
37
- onFocus: C
38
- } = k, H = ce().toLanguageString(M, ue[M]), g = a.useRef(null), w = a.useCallback(
32
+ orientation: I,
33
+ style: N,
34
+ successIcon: G,
35
+ successSVGIcon: H,
36
+ value: u = 0,
37
+ onChange: k,
38
+ onFocus: y
39
+ } = x, U = ce().toLanguageString(T, ue[T]), p = n.useRef(null), w = n.useCallback(
39
40
  () => {
40
- g.current && se(g.current);
41
+ p.current && te(p.current);
41
42
  },
42
43
  []
43
- ), I = a.useCallback(
44
+ ), E = n.useCallback(
44
45
  () => ({
45
- element: g.current,
46
+ element: p.current,
46
47
  focus: w
47
48
  }),
48
49
  [w]
49
50
  );
50
- a.useImperativeHandle(V, I);
51
- const l = k.value || O.value, [f, n] = a.useState(l), c = d ? d.length : 0, o = y === "vertical", S = ae(g, k.dir), U = typeof b == "number" ? b : b !== !1 ? ne : le;
52
- a.useEffect(() => {
53
- n(l);
54
- }, [l]);
55
- const v = a.useCallback(
56
- (t, s) => {
57
- const e = s === l - 1, i = s === l, $ = s === l + 1;
58
- l !== s && h && !m && (!p || e || i || $) && (P(
59
- h,
60
- t,
61
- I(),
62
- { value: s }
63
- ), n(s));
51
+ n.useImperativeHandle(M, E);
52
+ const [_, a] = n.useState(u), d = m ? m.length : 0, o = I === "vertical", h = oe(p, x.dir), B = typeof v == "number" ? v : v !== !1 ? ie : le;
53
+ n.useEffect(() => {
54
+ a(u);
55
+ }, [u]);
56
+ const D = n.useCallback(
57
+ (r, i) => {
58
+ const e = i === u - 1, t = i === u, l = i === u + 1;
59
+ u !== i && k && !f && (!g || e || t || l) && (O(
60
+ k,
61
+ r,
62
+ E(),
63
+ { value: i }
64
+ ), a(i));
64
65
  },
65
- [l, p, h, m, n]
66
- ), j = a.useCallback(
67
- (t) => {
68
- let s = t.value, e = t.syntheticEvent;
69
- v(e, s);
66
+ [u, g, k, f, a]
67
+ ), j = n.useCallback(
68
+ (r) => {
69
+ let i = r.value, e = r.syntheticEvent;
70
+ D(e, i);
70
71
  },
71
- [v]
72
- ), q = a.useCallback(
73
- (t) => {
74
- C && !m && P(
75
- C,
76
- t.syntheticEvent,
77
- I(),
72
+ [D]
73
+ ), q = n.useCallback(
74
+ (r) => {
75
+ y && !f && O(
76
+ y,
77
+ r.syntheticEvent,
78
+ E(),
78
79
  void 0
79
80
  );
80
81
  },
81
- [C, m]
82
- ), x = a.useCallback(
83
- (t) => {
84
- v(t, f);
85
- },
86
- [v, f]
87
- ), J = a.useCallback(
88
- (t) => {
89
- const s = S === "rtl", e = f, i = d.length - 1;
90
- switch (t.keyCode) {
91
- case u.left:
92
- t.preventDefault(), !s && e > 0 && n(e - 1), s && e < i && n(e + 1);
93
- break;
94
- case u.right:
95
- t.preventDefault(), !s && e < i && n(e + 1), s && e > 0 && n(e - 1);
96
- break;
97
- case u.up:
98
- t.preventDefault(), !s && e > 0 && n(e - 1), s && e > 0 && n(e - 1);
99
- break;
100
- case u.down:
101
- t.preventDefault(), !s && e < i && n(e + 1), s && e < i && n(e + 1);
102
- break;
103
- case u.home:
104
- t.preventDefault(), n(0);
105
- break;
106
- case u.end:
107
- t.preventDefault(), n(i);
108
- break;
109
- case u.space:
110
- t.preventDefault();
111
- break;
112
- case u.enter:
113
- t.preventDefault(), d[e].disabled || x(t);
114
- break;
115
- }
82
+ [y, f]
83
+ ), b = n.useMemo(
84
+ () => {
85
+ const r = h === "rtl", i = m.length - 1;
86
+ return new se({
87
+ root: p,
88
+ selectors: ["ol.k-step-list li.k-step a.k-step-link"],
89
+ tabIndex: 0,
90
+ keyboardEvents: {
91
+ keydown: {
92
+ ArrowLeft: (e, t, l) => {
93
+ l.preventDefault();
94
+ const s = t.elements.indexOf(e);
95
+ !o && !r && s > 0 ? (t.focusPrevious(e), a(s - 1)) : !o && r && s < i && (t.focusNext(e), a(s + 1));
96
+ },
97
+ ArrowRight: (e, t, l) => {
98
+ l.preventDefault();
99
+ const s = t.elements.indexOf(e);
100
+ !o && !r && s < i ? (t.focusNext(e), a(s + 1)) : !o && r && s > 0 && (t.focusPrevious(e), a(s - 1));
101
+ },
102
+ ArrowUp: (e, t, l) => {
103
+ l.preventDefault();
104
+ const s = t.elements.indexOf(e);
105
+ o && !r && s > 0 ? (t.focusPrevious(e), a(s - 1)) : o && r && s > 0 && (t.focusPrevious(e), a(s + 1));
106
+ },
107
+ ArrowDown: (e, t, l) => {
108
+ l.preventDefault();
109
+ const s = t.elements.indexOf(e);
110
+ o && !r && s < i ? (t.focusNext(e), a(s + 1)) : o && r && s < i && (t.focusNext(e), a(s - 1));
111
+ },
112
+ Tab: (e, t, l) => {
113
+ l.preventDefault();
114
+ const s = t.elements.indexOf(e);
115
+ l.shiftKey ? !o && !r && s > 0 ? (t.focusPrevious(e), a(s - 1)) : !o && r && s < i && (t.focusNext(e), a(s + 1)) : !o && !r && s < i ? (t.focusNext(e), a(s + 1)) : !o && r && s > 0 && (t.focusPrevious(e), a(s - 1));
116
+ },
117
+ Home: (e, t, l) => {
118
+ l.preventDefault(), t.focusElement(t.first, e), a(0);
119
+ },
120
+ End: (e, t, l) => {
121
+ l.preventDefault(), t.focusElement(t.last, e), a(i);
122
+ },
123
+ Space: (e, t, l) => {
124
+ l.preventDefault(), e.children[0].click();
125
+ },
126
+ Enter: (e, t, l) => {
127
+ l.preventDefault(), e.children[0].click();
128
+ }
129
+ }
130
+ }
131
+ });
116
132
  },
117
- [d, n, f, S, x]
118
- ), Q = a.useMemo(
119
- () => A(
133
+ [h, m.length, o, a]
134
+ );
135
+ n.useEffect(() => (b.initializeRovingTab(u), () => b.removeFocusListener()), []);
136
+ const J = n.useCallback(b.triggerKeyboardEvent.bind(b), []), Q = n.useMemo(
137
+ () => P(
120
138
  "k-stepper",
121
139
  {
122
- "k-stepper-linear": p
140
+ "k-stepper-linear": g
123
141
  },
124
- D
142
+ C
125
143
  ),
126
- [p, D]
127
- ), W = a.useMemo(
144
+ [g, C]
145
+ ), W = n.useMemo(
128
146
  () => ({
129
147
  display: "grid",
130
- gridTemplateColumns: o ? void 0 : "repeat(" + c * 2 + ", 1fr)",
131
- gridTemplateRows: o ? "repeat(" + c + ", 1fr)" : void 0,
132
- ...R
148
+ gridTemplateColumns: o ? void 0 : "repeat(" + d * 2 + ", 1fr)",
149
+ gridTemplateRows: o ? "repeat(" + d + ", 1fr)" : void 0,
150
+ ...N
133
151
  }),
134
- [o, c, R]
135
- ), X = a.useMemo(
136
- () => A(
152
+ [o, d, N]
153
+ ), X = n.useMemo(
154
+ () => P(
137
155
  "k-step-list",
138
156
  {
139
157
  "k-step-list-horizontal": !o,
@@ -141,7 +159,7 @@ const E = a.forwardRef((k, V) => {
141
159
  }
142
160
  ),
143
161
  [o]
144
- ), Y = a.useMemo(
162
+ ), Y = n.useMemo(
145
163
  () => ({
146
164
  gridColumnStart: o ? void 0 : 1,
147
165
  gridColumnEnd: o ? void 0 : -1,
@@ -149,105 +167,103 @@ const E = a.forwardRef((k, V) => {
149
167
  gridRowEnd: o ? -1 : void 0
150
168
  }),
151
169
  [o]
152
- ), Z = a.useMemo(
170
+ ), Z = n.useMemo(
153
171
  () => ({
154
172
  gridColumnStart: o ? void 0 : 2,
155
- gridColumnEnd: o ? void 0 : c * 2,
173
+ gridColumnEnd: o ? void 0 : d * 2,
156
174
  gridRowStart: o ? 1 : void 0,
157
- gridRowEnd: o ? c : void 0,
175
+ gridRowEnd: o ? d : void 0,
158
176
  top: o ? 17 : void 0
159
177
  }),
160
- [o, c]
161
- ), T = d && d.map((t, s) => {
178
+ [o, d]
179
+ ), R = m && m.map((r, i) => {
162
180
  const e = {
163
- index: s,
164
- disabled: m || t.disabled,
165
- focused: s === f,
166
- current: s === l,
167
- ...t
168
- }, i = N || oe;
169
- return /* @__PURE__ */ a.createElement(i, { key: s, ...e });
181
+ index: i,
182
+ disabled: f || r.disabled,
183
+ focused: i === _,
184
+ current: i === u,
185
+ ...r
186
+ }, t = S || ne;
187
+ return /* @__PURE__ */ n.createElement(t, { key: i, ...e });
170
188
  });
171
- return /* @__PURE__ */ a.createElement(
172
- ee.Provider,
189
+ return /* @__PURE__ */ n.createElement(
190
+ $.Provider,
173
191
  {
174
192
  value: {
175
- animationDuration: b,
193
+ animationDuration: v,
176
194
  isVertical: o,
177
- item: N,
178
- linear: p,
195
+ item: S,
196
+ linear: g,
179
197
  mode: K,
180
- numOfSteps: c,
181
- value: l,
182
- successIcon: _,
183
- successSVGIcon: B,
184
- errorIcon: z,
185
- errorSVGIcon: G,
198
+ numOfSteps: d,
199
+ value: u,
200
+ successIcon: G,
201
+ successSVGIcon: H,
202
+ errorIcon: V,
203
+ errorSVGIcon: z,
186
204
  onChange: j,
187
205
  onFocus: q
188
206
  }
189
207
  },
190
- /* @__PURE__ */ a.createElement(
208
+ /* @__PURE__ */ n.createElement(
191
209
  "nav",
192
210
  {
193
211
  className: Q,
194
212
  style: W,
195
- dir: S,
213
+ dir: h,
214
+ role: "navigation",
215
+ ref: p,
196
216
  onKeyDown: J
197
217
  },
198
- /* @__PURE__ */ a.createElement(
218
+ /* @__PURE__ */ n.createElement(
199
219
  "ol",
200
220
  {
201
221
  className: X,
202
222
  style: Y
203
223
  },
204
- T || L
224
+ R || L
205
225
  ),
206
- /* @__PURE__ */ a.createElement(
226
+ /* @__PURE__ */ n.createElement(
207
227
  re,
208
228
  {
209
229
  style: Z,
210
230
  labelPlacement: "start",
211
- animation: { duration: U },
212
- ariaLabel: H,
231
+ animation: { duration: B },
232
+ ariaLabel: U,
213
233
  "aria-hidden": !0,
214
- max: c - 1,
234
+ max: d - 1,
215
235
  labelVisible: !1,
216
- orientation: y,
217
- reverse: y === "vertical",
218
- value: l,
219
- disabled: m,
236
+ orientation: I,
237
+ reverse: I === "vertical",
238
+ value: u,
239
+ disabled: f,
220
240
  tabIndex: -1
221
241
  }
222
242
  )
223
243
  )
224
244
  );
225
245
  });
226
- E.propTypes = {
227
- animationDuration: r.oneOfType([r.bool, r.number]),
228
- children: r.any,
229
- className: r.string,
230
- dir: r.string,
231
- disabled: r.bool,
232
- errorIcon: r.string,
233
- errorSVGIcon: F,
234
- item: r.any,
235
- items: r.any,
236
- linear: r.bool,
237
- mode: r.oneOf(["steps", "labels"]),
238
- orientation: r.oneOf(["horizontal", "vertical"]),
239
- style: r.object,
240
- successIcon: r.string,
241
- successSVGIcon: F,
242
- value: r.number.isRequired,
243
- onChange: r.func,
244
- onFocus: r.func
245
- };
246
- const O = {
247
- value: 0
246
+ F.propTypes = {
247
+ animationDuration: c.oneOfType([c.bool, c.number]),
248
+ children: c.any,
249
+ className: c.string,
250
+ dir: c.string,
251
+ disabled: c.bool,
252
+ errorIcon: c.string,
253
+ errorSVGIcon: A,
254
+ item: c.any,
255
+ items: c.any,
256
+ linear: c.bool,
257
+ mode: c.oneOf(["steps", "labels"]),
258
+ orientation: c.oneOf(["horizontal", "vertical"]),
259
+ style: c.object,
260
+ successIcon: c.string,
261
+ successSVGIcon: A,
262
+ value: c.number.isRequired,
263
+ onChange: c.func,
264
+ onFocus: c.func
248
265
  };
249
- E.defaultProps = O;
250
- E.displayName = "KendoStepper";
266
+ F.displayName = "KendoStepper";
251
267
  export {
252
- E as Stepper
268
+ F as Stepper
253
269
  };