@uncinc/uncinc-react-kitchen-sink 2.20.9 → 2.20.10

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,11 +1,20 @@
1
1
  import { type RefObject } from 'react';
2
- export interface UseDialogHelpersOptions<T extends HTMLElement> {
2
+ export type UseDialogHelpersOptions<T extends HTMLElement> = {
3
3
  id?: string;
4
4
  wrapperElement: RefObject<T>;
5
5
  closeFunction: () => void;
6
6
  isOpen: boolean;
7
7
  disableClosers: boolean;
8
- }
8
+ } & ({
9
+ ariaLabel: string;
10
+ ariaLabelledBy?: never;
11
+ } | {
12
+ ariaLabel?: never;
13
+ ariaLabelledBy: string;
14
+ } | {
15
+ ariaLabel?: never;
16
+ ariaLabelledBy?: never;
17
+ });
9
18
  /**
10
19
  * Hook to allow you to implement your own Dialog component.
11
20
  * This takes care of focus, and closing the Dialog by
@@ -15,7 +24,8 @@ export default function useDialogHelpers<T extends HTMLElement>(options: UseDial
15
24
  readonly id: string;
16
25
  readonly labelId: string;
17
26
  readonly dialogHelpersProps: {
27
+ 'aria-labelledby'?: string | undefined;
28
+ 'aria-label'?: string | undefined;
18
29
  role: string;
19
- 'aria-labelledby': string;
20
30
  };
21
31
  };
@@ -1,3 +1,9 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1
7
  import { useEffect } from 'react';
2
8
  import { v4 as uuidv4 } from 'uuid';
3
9
  import useClickOutside from './useClickOutside';
@@ -14,7 +20,9 @@ export default function useDialogHelpers(options) {
14
20
  wrapperElement = options.wrapperElement,
15
21
  closeFunction = options.closeFunction,
16
22
  isOpen = options.isOpen,
17
- disableClosers = options.disableClosers;
23
+ disableClosers = options.disableClosers,
24
+ ariaLabel = options.ariaLabel,
25
+ ariaLabelledBy = options.ariaLabelledBy;
18
26
 
19
27
  /**
20
28
  * Allows you to disable these two hooks.
@@ -72,10 +80,13 @@ export default function useDialogHelpers(options) {
72
80
  * Create a labelId for A11Y
73
81
  */
74
82
  var labelId = "".concat(id, "-label");
75
- var dialogHelpersProps = {
76
- role: 'dialog',
77
- 'aria-labelledby': labelId
78
- };
83
+ var dialogHelpersProps = _objectSpread(_objectSpread({
84
+ role: 'dialog'
85
+ }, ariaLabel && {
86
+ 'aria-label': ariaLabel
87
+ }), ariaLabelledBy && {
88
+ 'aria-labelledby': ariaLabelledBy
89
+ });
79
90
  return {
80
91
  id: id,
81
92
  labelId: labelId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.20.9",
3
+ "version": "2.20.10",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",