@splunk/react-ui 5.8.0 → 5.9.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.
package/Clickable.js CHANGED
@@ -63,9 +63,9 @@
63
63
  e.d(n, {
64
64
  NavigationContext: () => /* reexport */ m,
65
65
  NavigationProvider: () => /* reexport */ y,
66
- default: () => /* reexport */ R,
67
- isInternalLink: () => /* reexport */ S,
68
- isRootRelativeLink: () => /* reexport */ P
66
+ default: () => /* reexport */ T,
67
+ isInternalLink: () => /* reexport */ j,
68
+ isRootRelativeLink: () => /* reexport */ S
69
69
  });
70
70
  // CONCATENATED MODULE: external "react"
71
71
  const r = require("react");
@@ -74,51 +74,93 @@
74
74
  const i = require("lodash/has");
75
75
  // CONCATENATED MODULE: external "lodash/isString"
76
76
  const a = require("lodash/isString");
77
- var o = e.n(a);
77
+ var l = e.n(a);
78
78
  // CONCATENATED MODULE: external "lodash/omit"
79
- const l = require("lodash/omit");
80
- var d = e.n(l);
79
+ const o = require("lodash/omit");
80
+ var d = e.n(o);
81
81
  // CONCATENATED MODULE: external "prop-types"
82
82
  const u = require("prop-types");
83
- var c = e.n(u);
83
+ var s = e.n(u);
84
84
  // CONCATENATED MODULE: external "styled-components"
85
- const s = require("styled-components");
86
- var f = e.n(s);
85
+ const f = require("styled-components");
86
+ var c = e.n(f);
87
87
  // CONCATENATED MODULE: external "@splunk/themes"
88
- const v = require("@splunk/themes");
88
+ const b = require("@splunk/themes");
89
89
  // CONCATENATED MODULE: ./src/Clickable/ClickableStyles.ts
90
- var b = f().a.withConfig({
90
+ var v = c().a.withConfig({
91
91
  displayName: "ClickableStyles__StyledA",
92
92
  componentId: "sc-7al1vw-0"
93
- })([ "", " cursor:pointer;&[disabled],&[aria-disabled='true']{cursor:not-allowed;color:", ";}&::-moz-focus-inner{border:0;padding:0;}" ], v.mixins.reset("inline"), v.variables.contentColorDisabled);
93
+ })([ "", " cursor:pointer;&[disabled],&[aria-disabled='true']{cursor:not-allowed;color:", ";}&::-moz-focus-inner{border:0;padding:0;}" ], b.mixins.reset("inline"), b.variables.contentColorDisabled);
94
94
  // CONCATENATED MODULE: ./src/Clickable/NavigationProvider.tsx
95
95
  /** @public */
96
96
  var p = {
97
- children: c().node,
98
- onClick: c().func,
99
- onLinkClick: c().func,
100
- transformUrl: c().func
97
+ children: s().node,
98
+ onClick: s().func,
99
+ onLinkClick: s().func,
100
+ transformUrl: s().func
101
101
  };
102
102
  var m = t().createContext({});
103
103
  /**
104
104
  * Used to provide an override for the `onClick` for links for single page applications so that
105
105
  * internal links can navigate without a page reload.
106
106
  */ function y(e) {
107
- var n = e.children, i = e.onClick, a = e.onLinkClick, o = e.transformUrl;
107
+ var n = e.children, i = e.onClick, a = e.onLinkClick, l = e.transformUrl;
108
108
  // @docs-props-type NavigationProviderProps
109
- var l = (0, r.useMemo)((function() {
109
+ var o = (0, r.useMemo)((function() {
110
110
  return {
111
111
  onClick: i,
112
112
  onLinkClick: a,
113
- transformUrl: o
113
+ transformUrl: l
114
114
  };
115
- }), [ i, a, o ]);
115
+ }), [ i, a, l ]);
116
116
 
117
117
  return t().createElement(m.Provider, {
118
- value: l
118
+ value: o
119
119
  }, n);
120
120
  }
121
121
  y.propTypes = p;
122
+ // CONCATENATED MODULE: ./src/utils/disabled.ts
123
+ /**
124
+ * Normalizes the disabled prop and returns both the boolean state and normalized string value.
125
+ * Use this function to ensure consistent handling of disabled prop across components.
126
+ *
127
+ * @param disabled - The disabled prop value
128
+ * @param defaultWhenBooleanTrue - Optional normalization override for disabled={true}
129
+ * @returns Object with isDisabled boolean|undefined and disabledValue string
130
+ *
131
+ * TODO (SUI-8600): `disabled` prop should default to 'dimmed' for data entry components
132
+ */
133
+ function k(e) {
134
+ var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "dimmed";
135
+ if (e === "dimmed") {
136
+ return {
137
+ isDisabled: true,
138
+ disabledValue: "dimmed"
139
+ };
140
+ }
141
+ if (e === true) {
142
+ return {
143
+ isDisabled: true,
144
+ disabledValue: n
145
+ };
146
+ }
147
+ if (e === "disabled") {
148
+ return {
149
+ isDisabled: true,
150
+ disabledValue: "disabled"
151
+ };
152
+ }
153
+ if (e === false) {
154
+ return {
155
+ isDisabled: false,
156
+ disabledValue: undefined
157
+ };
158
+ }
159
+ return {
160
+ isDisabled: undefined,
161
+ disabledValue: undefined
162
+ };
163
+ }
122
164
  // CONCATENATED MODULE: ./src/utils/updateReactRef.ts
123
165
  /**
124
166
  * Updates a React ref. Callback refs and object refs (from `createRef` and `useRef`) are supported.
@@ -126,7 +168,7 @@
126
168
  * @param ref - The React callback or object ref. Can be `null` or `undefined`.
127
169
  * @param current - The new value of the ref.
128
170
  */
129
- function k(e, n) {
171
+ function g(e, n) {
130
172
  if (e) {
131
173
  if (typeof e === "function") {
132
174
  e(n);
@@ -150,9 +192,9 @@
150
192
  return e;
151
193
  }, C.apply(null, arguments);
152
194
  }
153
- function g(e, n) {
195
+ function O(e, n) {
154
196
  if (null == e) return {};
155
- var r, t, i = O(e, n);
197
+ var r, t, i = h(e, n);
156
198
  if (Object.getOwnPropertySymbols) {
157
199
  var a = Object.getOwnPropertySymbols(e);
158
200
  for (t = 0; t < a.length; t++) {
@@ -161,7 +203,7 @@
161
203
  }
162
204
  return i;
163
205
  }
164
- function O(e, n) {
206
+ function h(e, n) {
165
207
  if (null == e) return {};
166
208
  var r = {};
167
209
  for (var t in e) {
@@ -172,132 +214,127 @@
172
214
  }
173
215
  return r;
174
216
  }
175
- var h = /^[a-z0-9]+:/;
176
- var w = /^\/\//;
177
- var x = /^\//;
178
- var P = function e(n) {
179
- return n != null && x.test(n);
180
- };
217
+ var w = /^[a-z0-9]+:/;
218
+ var x = /^\/\//;
219
+ var P = /^\//;
181
220
  var S = function e(n) {
182
- return n != null && !h.test(n) && !w.test(n);
221
+ return n != null && P.test(n);
222
+ };
223
+ var j = function e(n) {
224
+ return n != null && !w.test(n) && !x.test(n);
183
225
  };
184
- var j = {
185
- children: c().node,
186
- disabled: c().oneOfType([ c().bool, c().oneOf([ "dimmed", "disabled" ]) ]),
187
- elementRef: c().oneOfType([ c().func, c().object ]),
188
- onClick: c().func,
189
- openInNewContext: c().bool,
190
- navigationLabel: c().string,
191
- to: c().oneOfType([ c().string, c().oneOf([ undefined ]) ])
226
+ var L = {
227
+ children: s().node,
228
+ disabled: s().oneOfType([ s().bool, s().oneOf([ "dimmed", "disabled" ]) ]),
229
+ elementRef: s().oneOfType([ s().func, s().object ]),
230
+ onClick: s().func,
231
+ openInNewContext: s().bool,
232
+ navigationLabel: s().string,
233
+ to: s().oneOfType([ s().string, s().oneOf([ undefined ]) ])
192
234
  };
193
- function L(e, n) {
235
+ function I(e, n) {
194
236
  return e !== "button" && n !== undefined;
195
237
  }
196
238
  /**
197
239
  * `Clickable` renders as a `button` element, or as an `a` element if the `to` prop is set
198
240
  * and the `disabled` prop is `false`. This is called link mode.
199
- */ var I = t().forwardRef((function(e,
241
+ */ var R = t().forwardRef((function(e,
200
242
  // SUI-7623 - needs to be specified for react-docgen versions less than 7.1.0
201
243
  n) {
202
- var i = e.children, a = e.disabled, l = e.elementRef, u = e.navigationLabel, c = e.onClick, s = e.openInNewContext, f = e.tag, v = e.to, p = g(e, [ "children", "disabled", "elementRef", "navigationLabel", "onClick", "openInNewContext", "tag", "to" ]);
244
+ var i = e.children, a = e.disabled, o = e.elementRef, u = e.navigationLabel, s = e.onClick, f = e.openInNewContext, c = e.tag, b = e.to, p = O(e, [ "children", "disabled", "elementRef", "navigationLabel", "onClick", "openInNewContext", "tag", "to" ]);
203
245
  // @docs-props-type ClickablePropsBase
204
- var y = (0, r.useContext)(m), O = y.onClick, h = y.onLinkClick, w = y.transformUrl;
246
+ var y = (0, r.useContext)(m), h = y.onClick, w = y.onLinkClick, x = y.transformUrl;
205
247
  (0, r.useEffect)((function() {
206
248
  if (false) {}
207
249
  // this effect only runs once
208
250
  // eslint-disable-next-line react-hooks/exhaustive-deps
209
251
  }), []);
210
- var x = (0, r.useCallback)((function(e) {
211
- k(l, e);
212
- k(n, e);
213
- }), [ l, n ]);
252
+ var P = (0, r.useCallback)((function(e) {
253
+ g(o, e);
254
+ g(n, e);
255
+ }), [ o, n ]);
214
256
  // memoizing this result causes TS to lose track of the type guard established by isLinkCheck
215
- var j = L(f, v);
257
+ var L = I(c, b);
216
258
  // ideally we wouldn't need to pass "to" as "toValue" here
217
259
  // but without doing that TS thinks the return value of this is
218
260
  // string | undefined which doesn't work for usages of this function
219
- var I = (0, r.useCallback)((function(e) {
220
- return w != null ? w(e, {
221
- isInternal: S(e),
222
- isRootRelative: P(e)
261
+ var R = (0, r.useCallback)((function(e) {
262
+ return x != null ? x(e, {
263
+ isInternal: j(e),
264
+ isRootRelative: S(e)
223
265
  }) : e;
224
- }), [ w ]);
225
- var R = (0, r.useCallback)((function(e) {
226
- if (j) {
266
+ }), [ x ]);
267
+ var T = (0, r.useCallback)((function(e) {
268
+ if (L) {
227
269
  // when user command-click on mac or ctrl-click on other platforms, and
228
270
  // Tag is an <a>, let the click pass through, let the <a> to achieve user's
229
271
  // intent of 'open in new context'
230
272
  // on mac, ctrl-click will be caught and open option menu even before hitting
231
273
  // the DOM, so we're safe to check both metaKey and ctrlKey here
232
274
  // without platform sniffing
233
- if ((e.metaKey || e.ctrlKey) && v) {
275
+ if ((e.metaKey || e.ctrlKey) && b) {
234
276
  return;
235
277
  }
236
278
  }
237
- c === null || c === void 0 ? void 0 : c(e);
238
- var n = c == null && O != null;
239
- if (j && (n || h != null)) {
279
+ s === null || s === void 0 ? void 0 : s(e);
280
+ var n = s == null && h != null;
281
+ if (L && (n || w != null)) {
240
282
  var r = u;
241
- if (!r && o()(i)) {
283
+ if (!r && l()(i)) {
242
284
  r = i;
243
285
  }
244
286
  var t = {
245
- to: I(v),
246
- originalTo: v,
247
- openInNewContext: s,
287
+ to: R(b),
288
+ originalTo: b,
289
+ openInNewContext: f,
248
290
  label: r
249
291
  };
250
292
  if (n) {
251
- O(e, t);
293
+ h(e, t);
252
294
  }
253
- h === null || h === void 0 ? void 0 : h(e, t);
295
+ w === null || w === void 0 ? void 0 : w(e, t);
254
296
  }
255
- }), [ i, I, j, u, c, O, h, s, v ]);
256
- if (j) {
257
- if (a) {
297
+ }), [ i, R, L, u, s, h, w, f, b ]);
298
+ var q = k(a), D = q.isDisabled, N = q.disabledValue;
299
+ if (L) {
300
+ if (D) {
258
301
 
259
- return t().createElement(b, C({
302
+ return t().createElement(v, C({
260
303
  "data-test": "clickable",
261
- "data-test-disabled": a,
262
- ref: x,
304
+ "data-test-disabled": N,
305
+ ref: P,
263
306
  role: "link",
264
307
  "aria-disabled": "true"
265
308
  }, p), i);
266
309
  }
267
- var T = s ? "_blank" : undefined;
268
- var q = s && S(v) ? "noopener noreferrer" : undefined;
310
+ var _ = f ? "_blank" : undefined;
311
+ var E = f && j(b) ? "noopener noreferrer" : undefined;
269
312
 
270
- return t().createElement(b, C({
313
+ return t().createElement(v, C({
271
314
  "data-test": "clickable",
272
- ref: x,
273
- href: I(v),
274
- target: T,
275
- rel: q,
276
- onClick: R
315
+ ref: P,
316
+ href: R(b),
317
+ target: _,
318
+ rel: E,
319
+ onClick: T
277
320
  }, d()(p)), i);
278
321
  }
279
322
  // button variant
280
- var N = a === true || a === "dimmed" || undefined;
281
- var _;
282
- if (N) {
283
- _ = "dimmed";
284
- } else if (a === "disabled") {
285
- _ = "disabled";
286
- }
323
+ var V = a === true || a === "dimmed" || undefined;
287
324
 
288
- return t().createElement(b, C({
325
+ return t().createElement(v, C({
289
326
  as: "button",
290
- "aria-disabled": N,
327
+ "aria-disabled": V,
291
328
  "data-test": "clickable",
292
- "data-test-disabled": _,
293
- ref: x,
329
+ "data-test-disabled": N,
330
+ ref: P,
294
331
  type: "button",
295
332
  disabled: a === "disabled",
296
- onClick: !a ? R : undefined
333
+ onClick: D ? undefined : T
297
334
  }, d()(p, "disabled")), i);
298
335
  }));
299
- I.propTypes = j;
300
- /* harmony default export */ const R = I;
336
+ R.propTypes = L;
337
+ /* harmony default export */ const T = R;
301
338
  // forwardRef appears to prevent TS from inferring ClickableProps in components that import Clickable
302
339
  // so we need to export it separately to prevent the TS build from failing with:
303
340
  // "... has or is using name 'ClickablePropsBase' from external module "...packages/react-ui/src/Clickable/Clickable" but cannot be named."