@activecollab/components 2.0.564 → 2.0.565

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.
@@ -21,6 +21,13 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
21
21
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
22
22
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
23
23
  var CONFIRMATION_CHECKBOX_ID = "confirm-dialog-confirmation";
24
+
25
+ // Enter held down in the field that opened the confirmation repeats on the confirm button once it has the focus.
26
+ var ignoreHeldEnter = function ignoreHeldEnter(event) {
27
+ if (event.key === "Enter" && event.repeat) {
28
+ event.preventDefault();
29
+ }
30
+ };
24
31
  var ConfirmDialog = exports.ConfirmDialog = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
25
32
  var _ref$open = _ref.open,
26
33
  open = _ref$open === void 0 ? false : _ref$open,
@@ -41,7 +48,7 @@ var ConfirmDialog = exports.ConfirmDialog = /*#__PURE__*/(0, _react.forwardRef)(
41
48
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
42
49
  confirmationLabel = _ref.confirmationLabel,
43
50
  _ref$initialFocus = _ref.initialFocus,
44
- initialFocus = _ref$initialFocus === void 0 ? "cancel" : _ref$initialFocus,
51
+ initialFocus = _ref$initialFocus === void 0 ? "confirm" : _ref$initialFocus,
45
52
  size = _ref.size,
46
53
  height = _ref.height,
47
54
  native = _ref.native;
@@ -78,7 +85,8 @@ var ConfirmDialog = exports.ConfirmDialog = /*#__PURE__*/(0, _react.forwardRef)(
78
85
  id: CONFIRMATION_CHECKBOX_ID,
79
86
  checked: confirmed,
80
87
  onChange: handleToggleConfirmed,
81
- disabled: isLoading
88
+ disabled: isLoading,
89
+ autoFocus: initialFocus === "confirm"
82
90
  }), /*#__PURE__*/_react.default.createElement("label", {
83
91
  htmlFor: CONFIRMATION_CHECKBOX_ID
84
92
  }, /*#__PURE__*/_react.default.createElement(_Body.Body2, {
@@ -86,6 +94,7 @@ var ConfirmDialog = exports.ConfirmDialog = /*#__PURE__*/(0, _react.forwardRef)(
86
94
  }, confirmationLabel))) : null), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.ContentDivider, null), /*#__PURE__*/_react.default.createElement(_Dialog.Dialog.Actions, null, /*#__PURE__*/_react.default.createElement(_Button.Button, {
87
95
  variant: "primary",
88
96
  onClick: onConfirm,
97
+ onKeyDown: ignoreHeldEnter,
89
98
  disabled: isLoading || isConfirmBlocked,
90
99
  autoFocus: initialFocus === "confirm" || !shouldShowCancelButton
91
100
  }, confirmBtnText), shouldShowCancelButton ? /*#__PURE__*/_react.default.createElement(_Button.Button, {
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmDialog.js","names":["_react","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_Button","_Checkbox","_Dialog","_Styles","_usePropWarning","_Body","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","length","l","Symbol","iterator","u","next","done","push","value","return","isArray","CONFIRMATION_CHECKBOX_ID","ConfirmDialog","exports","forwardRef","_ref","ref","_ref$open","open","onCancel","onConfirm","className","_ref$dialogTitle","dialogTitle","_ref$dialogContent","dialogContent","_ref$confirmBtnText","confirmBtnText","_ref$cancelBtnText","cancelBtnText","_ref$shouldShowCancel","shouldShowCancelButton","_ref$isLoading","isLoading","confirmationLabel","_ref$initialFocus","initialFocus","size","height","native","_useState","useState","_useState2","confirmed","setConfirmed","usePropWarning","isConfirmBlocked","Boolean","handleToggleConfirmed","useCallback","event","target","checked","useEffect","createElement","Dialog","onClose","classnames","disableCloseOnEsc","role","Title","ContentDivider","Content","Body2","lineHeight","color","whitespace","StyledConfirmation","Checkbox","id","onChange","disabled","htmlFor","Actions","Button","variant","onClick","autoFocus","type","displayName"],"sources":["../../../../src/components/ConfirmDialog/ConfirmDialog.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useState } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { Button } from \"../Button/Button\";\nimport { Checkbox } from \"../Checkbox\";\nimport { Dialog } from \"../Dialog\";\nimport { StyledConfirmation } from \"./Styles\";\nimport { DialogSize } from \"../Dialog/Styles\";\nimport { usePropWarning } from \"../Dialog/usePropWarning\";\nimport { Body2 } from \"../Typography/Variants/Body2\";\n\nconst CONFIRMATION_CHECKBOX_ID = \"confirm-dialog-confirmation\";\n\nexport interface ConfirmDialogProps {\n open?: boolean;\n onCancel?: () => void;\n onConfirm?: () => void;\n className?: string;\n dialogTitle?: string;\n dialogContent?: React.ReactNode;\n confirmBtnText?: string;\n cancelBtnText?: string;\n shouldShowCancelButton?: boolean;\n isLoading?: boolean;\n confirmationLabel?: string;\n /**\n * The button that has the focus when the confirmation opens. Cancel by default, so that a confirmation of a\n * destructive action is never one Enter away; a confirmation without Cancel focuses its confirm button.\n */\n initialFocus?: \"cancel\" | \"confirm\";\n size?: DialogSize;\n height?: string;\n /**\n * @deprecated Every confirmation is a native modal alert dialog now. The prop is ignored, with a warning in\n * development, and will be removed.\n */\n native?: boolean;\n}\n\nexport const ConfirmDialog = forwardRef<HTMLDialogElement, ConfirmDialogProps>(\n (\n {\n open = false,\n onCancel,\n onConfirm,\n className,\n dialogTitle = \"Discard Changes\",\n dialogContent = \"All unsaved changes will be lost.\",\n confirmBtnText = \"OK\",\n cancelBtnText = \"Cancel\",\n shouldShowCancelButton = true,\n isLoading = false,\n confirmationLabel,\n initialFocus = \"cancel\",\n size,\n height,\n native,\n },\n ref\n ) => {\n const [confirmed, setConfirmed] = useState(false);\n\n usePropWarning(\n \"ConfirmDialog\",\n \"native\",\n native,\n \"removed\",\n \"Every confirmation is a native modal now, so remove it.\"\n );\n const isConfirmBlocked = Boolean(confirmationLabel) && !confirmed;\n\n const handleToggleConfirmed = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) =>\n setConfirmed(event.target.checked),\n []\n );\n\n useEffect(() => {\n if (!open) {\n setConfirmed(false);\n }\n }, [open]);\n\n return (\n <Dialog\n ref={ref}\n open={open}\n onClose={onCancel}\n className={classnames(\"c-confirm-dialog\", className)}\n disableCloseOnEsc={isLoading}\n size={size}\n height={height}\n role=\"alertdialog\"\n >\n <Dialog.Title>{dialogTitle}</Dialog.Title>\n <Dialog.ContentDivider />\n <Dialog.Content>\n <Body2 lineHeight=\"loose\" color=\"secondary\" whitespace=\"pre-line\">\n {dialogContent}\n </Body2>\n {confirmationLabel ? (\n <StyledConfirmation className=\"c-confirm-dialog--confirmation\">\n <Checkbox\n id={CONFIRMATION_CHECKBOX_ID}\n checked={confirmed}\n onChange={handleToggleConfirmed}\n disabled={isLoading}\n />\n <label htmlFor={CONFIRMATION_CHECKBOX_ID}>\n <Body2 color=\"secondary\">{confirmationLabel}</Body2>\n </label>\n </StyledConfirmation>\n ) : null}\n </Dialog.Content>\n <Dialog.ContentDivider />\n <Dialog.Actions>\n <Button\n variant=\"primary\"\n onClick={onConfirm}\n disabled={isLoading || isConfirmBlocked}\n autoFocus={initialFocus === \"confirm\" || !shouldShowCancelButton}\n >\n {confirmBtnText}\n </Button>\n {shouldShowCancelButton ? (\n <Button\n variant=\"secondary\"\n data-action=\"cancel\"\n onClick={onCancel}\n type=\"button\"\n disabled={isLoading}\n autoFocus={initialFocus === \"cancel\"}\n >\n {cancelBtnText}\n </Button>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AAEtB,qBAAsB;IAChCuB,QAAQ,EAAEtC;EAAU,CACrB,CAAC,eACF/E,MAAA,CAAAa,OAAA,CAAAuF,aAAA;IAAOkB,OAAO,EAAE7D;EAAyB,gBACvCzD,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAAC1F,KAAA,CAAAmG,KAAK;IAACE,KAAK,EAAC;EAAW,GAAE/B,iBAAyB,CAC9C,CACW,CAAC,GACnB,IACU,CAAC,eACjBhF,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAAC7F,OAAA,CAAA8F,MAAM,CAACM,cAAc,MAAE,CAAC,eACzB3G,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAAC7F,OAAA,CAAA8F,MAAM,CAACkB,OAAO,qBACbvH,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAAC/F,OAAA,CAAAmH,MAAM;IACLC,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAExD,SAAU;IACnBmD,QAAQ,EAAEtC,SAAS,IAAIa,gBAAiB;IACxC+B,SAAS,EAAEzC,YAAY,KAAK,SAAS,IAAI,CAACL;EAAuB,GAEhEJ,cACK,CAAC,EACRI,sBAAsB,gBACrB7E,MAAA,CAAAa,OAAA,CAAAuF,aAAA,CAAC/F,OAAA,CAAAmH,MAAM;IACLC,OAAO,EAAC,WAAW;IACnB,eAAY,QAAQ;IACpBC,OAAO,EAAEzD,QAAS;IAClB2D,IAAI,EAAC,QAAQ;IACbP,QAAQ,EAAEtC,SAAU;IACpB4C,SAAS,EAAEzC,YAAY,KAAK;EAAS,GAEpCP,aACK,CAAC,GACP,IACU,CACV,CAAC;AAEb,CACF,CAAC;AAEDjB,aAAa,CAACmE,WAAW,GAAG,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"ConfirmDialog.js","names":["_react","_interopRequireWildcard","require","_classnames","_interopRequireDefault","_Button","_Checkbox","_Dialog","_Styles","_usePropWarning","_Body","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","a","_arrayLikeToArray","toString","slice","constructor","name","Array","from","test","length","l","Symbol","iterator","u","next","done","push","value","return","isArray","CONFIRMATION_CHECKBOX_ID","ignoreHeldEnter","event","key","repeat","preventDefault","ConfirmDialog","exports","forwardRef","_ref","ref","_ref$open","open","onCancel","onConfirm","className","_ref$dialogTitle","dialogTitle","_ref$dialogContent","dialogContent","_ref$confirmBtnText","confirmBtnText","_ref$cancelBtnText","cancelBtnText","_ref$shouldShowCancel","shouldShowCancelButton","_ref$isLoading","isLoading","confirmationLabel","_ref$initialFocus","initialFocus","size","height","native","_useState","useState","_useState2","confirmed","setConfirmed","usePropWarning","isConfirmBlocked","Boolean","handleToggleConfirmed","useCallback","target","checked","useEffect","createElement","Dialog","onClose","classnames","disableCloseOnEsc","role","Title","ContentDivider","Content","Body2","lineHeight","color","whitespace","StyledConfirmation","Checkbox","id","onChange","disabled","autoFocus","htmlFor","Actions","Button","variant","onClick","onKeyDown","type","displayName"],"sources":["../../../../src/components/ConfirmDialog/ConfirmDialog.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useState } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { Button } from \"../Button/Button\";\nimport { Checkbox } from \"../Checkbox\";\nimport { Dialog } from \"../Dialog\";\nimport { StyledConfirmation } from \"./Styles\";\nimport { DialogSize } from \"../Dialog/Styles\";\nimport { usePropWarning } from \"../Dialog/usePropWarning\";\nimport { Body2 } from \"../Typography/Variants/Body2\";\n\nconst CONFIRMATION_CHECKBOX_ID = \"confirm-dialog-confirmation\";\n\n// Enter held down in the field that opened the confirmation repeats on the confirm button once it has the focus.\nconst ignoreHeldEnter = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Enter\" && event.repeat) {\n event.preventDefault();\n }\n};\n\nexport interface ConfirmDialogProps {\n open?: boolean;\n onCancel?: () => void;\n onConfirm?: () => void;\n className?: string;\n dialogTitle?: string;\n dialogContent?: React.ReactNode;\n confirmBtnText?: string;\n cancelBtnText?: string;\n shouldShowCancelButton?: boolean;\n isLoading?: boolean;\n confirmationLabel?: string;\n /**\n * The button that has the focus when the confirmation opens. The confirm button by default, so Enter confirms; Enter\n * acts only on the focused button, never on the key press that opened the confirmation. While the confirmationLabel\n * checkbox blocks the confirm button, the checkbox has the focus instead.\n */\n initialFocus?: \"cancel\" | \"confirm\";\n size?: DialogSize;\n height?: string;\n /**\n * @deprecated Every confirmation is a native modal alert dialog now. The prop is ignored, with a warning in\n * development, and will be removed.\n */\n native?: boolean;\n}\n\nexport const ConfirmDialog = forwardRef<HTMLDialogElement, ConfirmDialogProps>(\n (\n {\n open = false,\n onCancel,\n onConfirm,\n className,\n dialogTitle = \"Discard Changes\",\n dialogContent = \"All unsaved changes will be lost.\",\n confirmBtnText = \"OK\",\n cancelBtnText = \"Cancel\",\n shouldShowCancelButton = true,\n isLoading = false,\n confirmationLabel,\n initialFocus = \"confirm\",\n size,\n height,\n native,\n },\n ref\n ) => {\n const [confirmed, setConfirmed] = useState(false);\n\n usePropWarning(\n \"ConfirmDialog\",\n \"native\",\n native,\n \"removed\",\n \"Every confirmation is a native modal now, so remove it.\"\n );\n const isConfirmBlocked = Boolean(confirmationLabel) && !confirmed;\n\n const handleToggleConfirmed = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) =>\n setConfirmed(event.target.checked),\n []\n );\n\n useEffect(() => {\n if (!open) {\n setConfirmed(false);\n }\n }, [open]);\n\n return (\n <Dialog\n ref={ref}\n open={open}\n onClose={onCancel}\n className={classnames(\"c-confirm-dialog\", className)}\n disableCloseOnEsc={isLoading}\n size={size}\n height={height}\n role=\"alertdialog\"\n >\n <Dialog.Title>{dialogTitle}</Dialog.Title>\n <Dialog.ContentDivider />\n <Dialog.Content>\n <Body2 lineHeight=\"loose\" color=\"secondary\" whitespace=\"pre-line\">\n {dialogContent}\n </Body2>\n {confirmationLabel ? (\n <StyledConfirmation className=\"c-confirm-dialog--confirmation\">\n <Checkbox\n id={CONFIRMATION_CHECKBOX_ID}\n checked={confirmed}\n onChange={handleToggleConfirmed}\n disabled={isLoading}\n autoFocus={initialFocus === \"confirm\"}\n />\n <label htmlFor={CONFIRMATION_CHECKBOX_ID}>\n <Body2 color=\"secondary\">{confirmationLabel}</Body2>\n </label>\n </StyledConfirmation>\n ) : null}\n </Dialog.Content>\n <Dialog.ContentDivider />\n <Dialog.Actions>\n <Button\n variant=\"primary\"\n onClick={onConfirm}\n onKeyDown={ignoreHeldEnter}\n disabled={isLoading || isConfirmBlocked}\n autoFocus={initialFocus === \"confirm\" || !shouldShowCancelButton}\n >\n {confirmBtnText}\n </Button>\n {shouldShowCancelButton ? (\n <Button\n variant=\"secondary\"\n data-action=\"cancel\"\n onClick={onCancel}\n type=\"button\"\n disabled={isLoading}\n autoFocus={initialFocus === \"cancel\"}\n >\n {cancelBtnText}\n </Button>\n ) : null}\n </Dialog.Actions>\n </Dialog>\n );\n }\n);\n\nConfirmDialog.displayName = \"ConfirmDialog\";\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAEA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAAqD,SAAAE,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAd,uBAAA,YAA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AAAa,OAAA,CAAA2F,aAAA,CAACjG,OAAA,CAAAkG,MAAM,CAACmB,OAAO,qBACb5H,MAAA,CAAAa,OAAA,CAAA2F,aAAA,CAACnG,OAAA,CAAAwH,MAAM;IACLC,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAExD,SAAU;IACnByD,SAAS,EAAEtE,eAAgB;IAC3B+D,QAAQ,EAAErC,SAAS,IAAIa,gBAAiB;IACxCyB,SAAS,EAAEnC,YAAY,KAAK,SAAS,IAAI,CAACL;EAAuB,GAEhEJ,cACK,CAAC,EACRI,sBAAsB,gBACrBlF,MAAA,CAAAa,OAAA,CAAA2F,aAAA,CAACnG,OAAA,CAAAwH,MAAM;IACLC,OAAO,EAAC,WAAW;IACnB,eAAY,QAAQ;IACpBC,OAAO,EAAEzD,QAAS;IAClB2D,IAAI,EAAC,QAAQ;IACbR,QAAQ,EAAErC,SAAU;IACpBsC,SAAS,EAAEnC,YAAY,KAAK;EAAS,GAEpCP,aACK,CAAC,GACP,IACU,CACV,CAAC;AAEb,CACF,CAAC;AAEDjB,aAAa,CAACmE,WAAW,GAAG,eAAe","ignoreList":[]}
@@ -13,8 +13,9 @@ export interface ConfirmDialogProps {
13
13
  isLoading?: boolean;
14
14
  confirmationLabel?: string;
15
15
  /**
16
- * The button that has the focus when the confirmation opens. Cancel by default, so that a confirmation of a
17
- * destructive action is never one Enter away; a confirmation without Cancel focuses its confirm button.
16
+ * The button that has the focus when the confirmation opens. The confirm button by default, so Enter confirms; Enter
17
+ * acts only on the focused button, never on the key press that opened the confirmation. While the confirmationLabel
18
+ * checkbox blocks the confirm button, the checkbox has the focus instead.
18
19
  */
19
20
  initialFocus?: "cancel" | "confirm";
20
21
  size?: DialogSize;
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/ConfirmDialog/ConfirmDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAC;AAQ5E,OAAO,EA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C,EAAE,MAAM,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACpC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,aAAa,8FAuGzB,CAAC"}
@@ -7,6 +7,13 @@ import { StyledConfirmation } from "./Styles";
7
7
  import { usePropWarning } from "../Dialog/usePropWarning";
8
8
  import { Body2 } from "../Typography/Variants/Body2";
9
9
  const CONFIRMATION_CHECKBOX_ID = "confirm-dialog-confirmation";
10
+
11
+ // Enter held down in the field that opened the confirmation repeats on the confirm button once it has the focus.
12
+ const ignoreHeldEnter = event => {
13
+ if (event.key === "Enter" && event.repeat) {
14
+ event.preventDefault();
15
+ }
16
+ };
10
17
  export const ConfirmDialog = /*#__PURE__*/forwardRef((_ref, ref) => {
11
18
  let _ref$open = _ref.open,
12
19
  open = _ref$open === void 0 ? false : _ref$open,
@@ -27,7 +34,7 @@ export const ConfirmDialog = /*#__PURE__*/forwardRef((_ref, ref) => {
27
34
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
28
35
  confirmationLabel = _ref.confirmationLabel,
29
36
  _ref$initialFocus = _ref.initialFocus,
30
- initialFocus = _ref$initialFocus === void 0 ? "cancel" : _ref$initialFocus,
37
+ initialFocus = _ref$initialFocus === void 0 ? "confirm" : _ref$initialFocus,
31
38
  size = _ref.size,
32
39
  height = _ref.height,
33
40
  native = _ref.native;
@@ -61,7 +68,8 @@ export const ConfirmDialog = /*#__PURE__*/forwardRef((_ref, ref) => {
61
68
  id: CONFIRMATION_CHECKBOX_ID,
62
69
  checked: confirmed,
63
70
  onChange: handleToggleConfirmed,
64
- disabled: isLoading
71
+ disabled: isLoading,
72
+ autoFocus: initialFocus === "confirm"
65
73
  }), /*#__PURE__*/React.createElement("label", {
66
74
  htmlFor: CONFIRMATION_CHECKBOX_ID
67
75
  }, /*#__PURE__*/React.createElement(Body2, {
@@ -69,6 +77,7 @@ export const ConfirmDialog = /*#__PURE__*/forwardRef((_ref, ref) => {
69
77
  }, confirmationLabel))) : null), /*#__PURE__*/React.createElement(Dialog.ContentDivider, null), /*#__PURE__*/React.createElement(Dialog.Actions, null, /*#__PURE__*/React.createElement(Button, {
70
78
  variant: "primary",
71
79
  onClick: onConfirm,
80
+ onKeyDown: ignoreHeldEnter,
72
81
  disabled: isLoading || isConfirmBlocked,
73
82
  autoFocus: initialFocus === "confirm" || !shouldShowCancelButton
74
83
  }, confirmBtnText), shouldShowCancelButton ? /*#__PURE__*/React.createElement(Button, {
@@ -1 +1 @@
1
- {"version":3,"file":"ConfirmDialog.js","names":["React","forwardRef","useCallback","useEffect","useState","classnames","Button","Checkbox","Dialog","StyledConfirmation","usePropWarning","Body2","CONFIRMATION_CHECKBOX_ID","ConfirmDialog","_ref","ref","_ref$open","open","onCancel","onConfirm","className","_ref$dialogTitle","dialogTitle","_ref$dialogContent","dialogContent","_ref$confirmBtnText","confirmBtnText","_ref$cancelBtnText","cancelBtnText","_ref$shouldShowCancel","shouldShowCancelButton","_ref$isLoading","isLoading","confirmationLabel","_ref$initialFocus","initialFocus","size","height","native","_useState","confirmed","setConfirmed","isConfirmBlocked","Boolean","handleToggleConfirmed","event","target","checked","createElement","onClose","disableCloseOnEsc","role","Title","ContentDivider","Content","lineHeight","color","whitespace","id","onChange","disabled","htmlFor","Actions","variant","onClick","autoFocus","type","displayName"],"sources":["../../../../src/components/ConfirmDialog/ConfirmDialog.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useState } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { Button } from \"../Button/Button\";\nimport { Checkbox } from \"../Checkbox\";\nimport { Dialog } from \"../Dialog\";\nimport { StyledConfirmation } from \"./Styles\";\nimport { DialogSize } from \"../Dialog/Styles\";\nimport { usePropWarning } from \"../Dialog/usePropWarning\";\nimport { Body2 } from \"../Typography/Variants/Body2\";\n\nconst CONFIRMATION_CHECKBOX_ID = \"confirm-dialog-confirmation\";\n\nexport interface ConfirmDialogProps {\n open?: boolean;\n onCancel?: () => void;\n onConfirm?: () => void;\n className?: string;\n dialogTitle?: string;\n dialogContent?: React.ReactNode;\n confirmBtnText?: string;\n cancelBtnText?: string;\n shouldShowCancelButton?: boolean;\n isLoading?: boolean;\n confirmationLabel?: string;\n /**\n * The button that has the focus when the confirmation opens. Cancel by default, so that a confirmation of a\n * destructive action is never one Enter away; a confirmation without Cancel focuses its confirm button.\n */\n initialFocus?: \"cancel\" | \"confirm\";\n size?: DialogSize;\n height?: string;\n /**\n * @deprecated Every confirmation is a native modal alert dialog now. The prop is ignored, with a warning in\n * development, and will be removed.\n */\n native?: boolean;\n}\n\nexport const ConfirmDialog = forwardRef<HTMLDialogElement, ConfirmDialogProps>(\n (\n {\n open = false,\n onCancel,\n onConfirm,\n className,\n dialogTitle = \"Discard Changes\",\n dialogContent = \"All unsaved changes will be lost.\",\n confirmBtnText = \"OK\",\n cancelBtnText = \"Cancel\",\n shouldShowCancelButton = true,\n isLoading = false,\n confirmationLabel,\n initialFocus = \"cancel\",\n size,\n height,\n native,\n },\n ref\n ) => {\n const [confirmed, setConfirmed] = useState(false);\n\n usePropWarning(\n \"ConfirmDialog\",\n \"native\",\n native,\n \"removed\",\n \"Every confirmation is a native modal now, so remove it.\"\n );\n const isConfirmBlocked = Boolean(confirmationLabel) && !confirmed;\n\n const handleToggleConfirmed = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) =>\n setConfirmed(event.target.checked),\n []\n );\n\n useEffect(() => {\n if (!open) {\n setConfirmed(false);\n }\n }, [open]);\n\n return (\n <Dialog\n ref={ref}\n open={open}\n onClose={onCancel}\n className={classnames(\"c-confirm-dialog\", className)}\n disableCloseOnEsc={isLoading}\n size={size}\n height={height}\n role=\"alertdialog\"\n >\n <Dialog.Title>{dialogTitle}</Dialog.Title>\n <Dialog.ContentDivider />\n <Dialog.Content>\n <Body2 lineHeight=\"loose\" color=\"secondary\" whitespace=\"pre-line\">\n {dialogContent}\n </Body2>\n {confirmationLabel ? (\n <StyledConfirmation className=\"c-confirm-dialog--confirmation\">\n <Checkbox\n id={CONFIRMATION_CHECKBOX_ID}\n checked={confirmed}\n onChange={handleToggleConfirmed}\n disabled={isLoading}\n />\n <label htmlFor={CONFIRMATION_CHECKBOX_ID}>\n <Body2 color=\"secondary\">{confirmationLabel}</Body2>\n </label>\n </StyledConfirmation>\n ) : null}\n </Dialog.Content>\n <Dialog.ContentDivider />\n <Dialog.Actions>\n <Button\n variant=\"primary\"\n onClick={onConfirm}\n disabled={isLoading || isConfirmBlocked}\n autoFocus={initialFocus === \"confirm\" || !shouldShowCancelButton}\n >\n {confirmBtnText}\n </Button>\n {shouldShowCancelButton ? (\n <Button\n variant=\"secondary\"\n data-action=\"cancel\"\n onClick={onCancel}\n type=\"button\"\n disabled={isLoading}\n autoFocus={initialFocus === \"cancel\"}\n >\n {cancelBtnText}\n </Button>\n ) : null}\n </Dialog.Actions>\n </Dialog>\n );\n }\n);\n\nConfirmDialog.displayName = \"ConfirmDialog\";\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3E,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,kBAAkB,QAAQ,UAAU;AAE7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,8BAA8B;AAEpD,MAAMC,wBAAwB,GAAG,6BAA6B;AA4B9D,OAAO,MAAMC,aAAa,gBAAGZ,UA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QAAQ,EAAEf,qBAAsB;IAChCgB,QAAQ,EAAE5B;EAAU,CACrB,CAAC,eACFhC,KAAA,CAAAgD,aAAA;IAAOa,OAAO,EAAEjD;EAAyB,gBACvCZ,KAAA,CAAAgD,aAAA,CAACrC,KAAK;IAAC6C,KAAK,EAAC;EAAW,GAAEvB,iBAAyB,CAC9C,CACW,CAAC,GACnB,IACU,CAAC,eACjBjC,KAAA,CAAAgD,aAAA,CAACxC,MAAM,CAAC6C,cAAc,MAAE,CAAC,eACzBrD,KAAA,CAAAgD,aAAA,CAACxC,MAAM,CAACsD,OAAO,qBACb9D,KAAA,CAAAgD,aAAA,CAAC1C,MAAM;IACLyD,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAE7C,SAAU;IACnByC,QAAQ,EAAE5B,SAAS,IAAIU,gBAAiB;IACxCuB,SAAS,EAAE9B,YAAY,KAAK,SAAS,IAAI,CAACL;EAAuB,GAEhEJ,cACK,CAAC,EACRI,sBAAsB,gBACrB9B,KAAA,CAAAgD,aAAA,CAAC1C,MAAM;IACLyD,OAAO,EAAC,WAAW;IACnB,eAAY,QAAQ;IACpBC,OAAO,EAAE9C,QAAS;IAClBgD,IAAI,EAAC,QAAQ;IACbN,QAAQ,EAAE5B,SAAU;IACpBiC,SAAS,EAAE9B,YAAY,KAAK;EAAS,GAEpCP,aACK,CAAC,GACP,IACU,CACV,CAAC;AAEb,CACF,CAAC;AAEDf,aAAa,CAACsD,WAAW,GAAG,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"ConfirmDialog.js","names":["React","forwardRef","useCallback","useEffect","useState","classnames","Button","Checkbox","Dialog","StyledConfirmation","usePropWarning","Body2","CONFIRMATION_CHECKBOX_ID","ignoreHeldEnter","event","key","repeat","preventDefault","ConfirmDialog","_ref","ref","_ref$open","open","onCancel","onConfirm","className","_ref$dialogTitle","dialogTitle","_ref$dialogContent","dialogContent","_ref$confirmBtnText","confirmBtnText","_ref$cancelBtnText","cancelBtnText","_ref$shouldShowCancel","shouldShowCancelButton","_ref$isLoading","isLoading","confirmationLabel","_ref$initialFocus","initialFocus","size","height","native","_useState","confirmed","setConfirmed","isConfirmBlocked","Boolean","handleToggleConfirmed","target","checked","createElement","onClose","disableCloseOnEsc","role","Title","ContentDivider","Content","lineHeight","color","whitespace","id","onChange","disabled","autoFocus","htmlFor","Actions","variant","onClick","onKeyDown","type","displayName"],"sources":["../../../../src/components/ConfirmDialog/ConfirmDialog.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useState } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { Button } from \"../Button/Button\";\nimport { Checkbox } from \"../Checkbox\";\nimport { Dialog } from \"../Dialog\";\nimport { StyledConfirmation } from \"./Styles\";\nimport { DialogSize } from \"../Dialog/Styles\";\nimport { usePropWarning } from \"../Dialog/usePropWarning\";\nimport { Body2 } from \"../Typography/Variants/Body2\";\n\nconst CONFIRMATION_CHECKBOX_ID = \"confirm-dialog-confirmation\";\n\n// Enter held down in the field that opened the confirmation repeats on the confirm button once it has the focus.\nconst ignoreHeldEnter = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Enter\" && event.repeat) {\n event.preventDefault();\n }\n};\n\nexport interface ConfirmDialogProps {\n open?: boolean;\n onCancel?: () => void;\n onConfirm?: () => void;\n className?: string;\n dialogTitle?: string;\n dialogContent?: React.ReactNode;\n confirmBtnText?: string;\n cancelBtnText?: string;\n shouldShowCancelButton?: boolean;\n isLoading?: boolean;\n confirmationLabel?: string;\n /**\n * The button that has the focus when the confirmation opens. The confirm button by default, so Enter confirms; Enter\n * acts only on the focused button, never on the key press that opened the confirmation. While the confirmationLabel\n * checkbox blocks the confirm button, the checkbox has the focus instead.\n */\n initialFocus?: \"cancel\" | \"confirm\";\n size?: DialogSize;\n height?: string;\n /**\n * @deprecated Every confirmation is a native modal alert dialog now. The prop is ignored, with a warning in\n * development, and will be removed.\n */\n native?: boolean;\n}\n\nexport const ConfirmDialog = forwardRef<HTMLDialogElement, ConfirmDialogProps>(\n (\n {\n open = false,\n onCancel,\n onConfirm,\n className,\n dialogTitle = \"Discard Changes\",\n dialogContent = \"All unsaved changes will be lost.\",\n confirmBtnText = \"OK\",\n cancelBtnText = \"Cancel\",\n shouldShowCancelButton = true,\n isLoading = false,\n confirmationLabel,\n initialFocus = \"confirm\",\n size,\n height,\n native,\n },\n ref\n ) => {\n const [confirmed, setConfirmed] = useState(false);\n\n usePropWarning(\n \"ConfirmDialog\",\n \"native\",\n native,\n \"removed\",\n \"Every confirmation is a native modal now, so remove it.\"\n );\n const isConfirmBlocked = Boolean(confirmationLabel) && !confirmed;\n\n const handleToggleConfirmed = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) =>\n setConfirmed(event.target.checked),\n []\n );\n\n useEffect(() => {\n if (!open) {\n setConfirmed(false);\n }\n }, [open]);\n\n return (\n <Dialog\n ref={ref}\n open={open}\n onClose={onCancel}\n className={classnames(\"c-confirm-dialog\", className)}\n disableCloseOnEsc={isLoading}\n size={size}\n height={height}\n role=\"alertdialog\"\n >\n <Dialog.Title>{dialogTitle}</Dialog.Title>\n <Dialog.ContentDivider />\n <Dialog.Content>\n <Body2 lineHeight=\"loose\" color=\"secondary\" whitespace=\"pre-line\">\n {dialogContent}\n </Body2>\n {confirmationLabel ? (\n <StyledConfirmation className=\"c-confirm-dialog--confirmation\">\n <Checkbox\n id={CONFIRMATION_CHECKBOX_ID}\n checked={confirmed}\n onChange={handleToggleConfirmed}\n disabled={isLoading}\n autoFocus={initialFocus === \"confirm\"}\n />\n <label htmlFor={CONFIRMATION_CHECKBOX_ID}>\n <Body2 color=\"secondary\">{confirmationLabel}</Body2>\n </label>\n </StyledConfirmation>\n ) : null}\n </Dialog.Content>\n <Dialog.ContentDivider />\n <Dialog.Actions>\n <Button\n variant=\"primary\"\n onClick={onConfirm}\n onKeyDown={ignoreHeldEnter}\n disabled={isLoading || isConfirmBlocked}\n autoFocus={initialFocus === \"confirm\" || !shouldShowCancelButton}\n >\n {confirmBtnText}\n </Button>\n {shouldShowCancelButton ? (\n <Button\n variant=\"secondary\"\n data-action=\"cancel\"\n onClick={onCancel}\n type=\"button\"\n disabled={isLoading}\n autoFocus={initialFocus === \"cancel\"}\n >\n {cancelBtnText}\n </Button>\n ) : null}\n </Dialog.Actions>\n </Dialog>\n );\n }\n);\n\nConfirmDialog.displayName = \"ConfirmDialog\";\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3E,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,kBAAkB,QAAQ,UAAU;AAE7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,KAAK,QAAQ,8BAA8B;AAEpD,MAAMC,wBAAwB,GAAG,6BAA6B;;AAE9D;AACA,MAAMC,eAAe,GAAIC,KAA6C,IAAK;EACzE,IAAIA,KAAK,CAACC,GAAG,KAAK,OAAO,IAAID,KAAK,CAACE,MAAM,EAAE;IACzCF,KAAK,CAACG,cAAc,CAAC,CAAC;EACxB;AACF,CAAC;AA6BD,OAAO,MAAMC,aAAa,gBAAGjB,UAAU,CACrC,CAAAkB,IAAA,EAkBEC,GAAG,KACA;EAAA,IAAAC,SAAA,GAAAF,IAAA,CAjBDG,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAG,KAAK,GAAAA,SAAA;IACZE,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRC,SAAS,GAAAL,IAAA,CAATK,SAAS;IACTC,SAAS,GAAAN,IAAA,CAATM,SAAS;IAAAC,gBAAA,GAAAP,IAAA,CACTQ,WAAW;IAAXA,WAAW,GAAAD,gBAAA,cAAG,iBAAiB,GAAAA,gBAAA;IAAAE,kBAAA,GAAAT,IAAA,CAC/BU,aAAa;IAAbA,aAAa,GAAAD,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qBACbnE,KAAA,CAAAoD,aAAA,CAAC9C,MAAM;IACL8D,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAE7C,SAAU;IACnB8C,SAAS,EAAEzD,eAAgB;IAC3BmD,QAAQ,EAAE3B,SAAS,IAAIU,gBAAiB;IACxCkB,SAAS,EAAEzB,YAAY,KAAK,SAAS,IAAI,CAACL;EAAuB,GAEhEJ,cACK,CAAC,EACRI,sBAAsB,gBACrBnC,KAAA,CAAAoD,aAAA,CAAC9C,MAAM;IACL8D,OAAO,EAAC,WAAW;IACnB,eAAY,QAAQ;IACpBC,OAAO,EAAE9C,QAAS;IAClBgD,IAAI,EAAC,QAAQ;IACbP,QAAQ,EAAE3B,SAAU;IACpB4B,SAAS,EAAEzB,YAAY,KAAK;EAAS,GAEpCP,aACK,CAAC,GACP,IACU,CACV,CAAC;AAEb,CACF,CAAC;AAEDf,aAAa,CAACsD,WAAW,GAAG,eAAe","ignoreList":[]}
package/dist/index.js CHANGED
@@ -20262,6 +20262,13 @@
20262
20262
  StyledConfirmation.displayName = "StyledConfirmation";
20263
20263
 
20264
20264
  var CONFIRMATION_CHECKBOX_ID = "confirm-dialog-confirmation";
20265
+
20266
+ // Enter held down in the field that opened the confirmation repeats on the confirm button once it has the focus.
20267
+ var ignoreHeldEnter = function ignoreHeldEnter(event) {
20268
+ if (event.key === "Enter" && event.repeat) {
20269
+ event.preventDefault();
20270
+ }
20271
+ };
20265
20272
  var ConfirmDialog = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
20266
20273
  var _ref$open = _ref.open,
20267
20274
  open = _ref$open === void 0 ? false : _ref$open,
@@ -20282,7 +20289,7 @@
20282
20289
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
20283
20290
  confirmationLabel = _ref.confirmationLabel,
20284
20291
  _ref$initialFocus = _ref.initialFocus,
20285
- initialFocus = _ref$initialFocus === void 0 ? "cancel" : _ref$initialFocus,
20292
+ initialFocus = _ref$initialFocus === void 0 ? "confirm" : _ref$initialFocus,
20286
20293
  size = _ref.size,
20287
20294
  height = _ref.height,
20288
20295
  native = _ref.native;
@@ -20319,7 +20326,8 @@
20319
20326
  id: CONFIRMATION_CHECKBOX_ID,
20320
20327
  checked: confirmed,
20321
20328
  onChange: handleToggleConfirmed,
20322
- disabled: isLoading
20329
+ disabled: isLoading,
20330
+ autoFocus: initialFocus === "confirm"
20323
20331
  }), /*#__PURE__*/React__default["default"].createElement("label", {
20324
20332
  htmlFor: CONFIRMATION_CHECKBOX_ID
20325
20333
  }, /*#__PURE__*/React__default["default"].createElement(Body2, {
@@ -20327,6 +20335,7 @@
20327
20335
  }, confirmationLabel))) : null), /*#__PURE__*/React__default["default"].createElement(Dialog.ContentDivider, null), /*#__PURE__*/React__default["default"].createElement(Dialog.Actions, null, /*#__PURE__*/React__default["default"].createElement(Button, {
20328
20336
  variant: "primary",
20329
20337
  onClick: onConfirm,
20338
+ onKeyDown: ignoreHeldEnter,
20330
20339
  disabled: isLoading || isConfirmBlocked,
20331
20340
  autoFocus: initialFocus === "confirm" || !shouldShowCancelButton
20332
20341
  }, confirmBtnText), shouldShowCancelButton ? /*#__PURE__*/React__default["default"].createElement(Button, {