@cloudscape-design/components 3.0.362 → 3.0.363

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.
Files changed (52) hide show
  1. package/alert/index.d.ts.map +1 -1
  2. package/alert/index.js +21 -16
  3. package/alert/index.js.map +1 -1
  4. package/area-chart/model/use-chart-model.js +1 -1
  5. package/area-chart/model/use-chart-model.js.map +1 -1
  6. package/code-editor/index.d.ts.map +1 -1
  7. package/code-editor/index.js +26 -71
  8. package/code-editor/index.js.map +1 -1
  9. package/code-editor/listeners.d.ts +1 -1
  10. package/code-editor/listeners.d.ts.map +1 -1
  11. package/code-editor/listeners.js.map +1 -1
  12. package/code-editor/setup-editor.d.ts.map +1 -1
  13. package/code-editor/setup-editor.js +39 -36
  14. package/code-editor/setup-editor.js.map +1 -1
  15. package/code-editor/use-editor.d.ts +24 -0
  16. package/code-editor/use-editor.d.ts.map +1 -0
  17. package/code-editor/use-editor.js +71 -0
  18. package/code-editor/use-editor.js.map +1 -0
  19. package/form-field/internal.d.ts.map +1 -1
  20. package/form-field/internal.js +17 -12
  21. package/form-field/internal.js.map +1 -1
  22. package/internal/components/chart-popover/index.d.ts.map +1 -1
  23. package/internal/components/chart-popover/index.js +1 -1
  24. package/internal/components/chart-popover/index.js.map +1 -1
  25. package/internal/environment.js +1 -1
  26. package/internal/environment.json +1 -1
  27. package/internal/manifest.json +1 -1
  28. package/internal/plugins/api.d.ts +21 -25
  29. package/internal/plugins/api.d.ts.map +1 -1
  30. package/internal/plugins/api.js +15 -35
  31. package/internal/plugins/api.js.map +1 -1
  32. package/internal/plugins/controllers/action-buttons.d.ts +9 -0
  33. package/internal/plugins/controllers/action-buttons.d.ts.map +1 -1
  34. package/internal/plugins/controllers/action-buttons.js +11 -0
  35. package/internal/plugins/controllers/action-buttons.js.map +1 -1
  36. package/internal/plugins/controllers/drawers.d.ts +9 -0
  37. package/internal/plugins/controllers/drawers.d.ts.map +1 -1
  38. package/internal/plugins/controllers/drawers.js +11 -0
  39. package/internal/plugins/controllers/drawers.js.map +1 -1
  40. package/internal/utils/dom.d.ts +1 -8
  41. package/internal/utils/dom.d.ts.map +1 -1
  42. package/internal/utils/dom.js +1 -22
  43. package/internal/utils/dom.js.map +1 -1
  44. package/mixed-line-bar-chart/hooks/use-mouse-hover.js +1 -1
  45. package/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
  46. package/package.json +1 -1
  47. package/pie-chart/pie-chart.d.ts.map +1 -1
  48. package/pie-chart/pie-chart.js +1 -1
  49. package/pie-chart/pie-chart.js.map +1 -1
  50. package/popover/container.d.ts.map +1 -1
  51. package/popover/container.js +3 -2
  52. package/popover/container.js.map +1 -1
@@ -1,13 +1,6 @@
1
1
  import { supportsKeyboardAccessibility } from './util';
2
2
  export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setHighlightedAnnotation, setPaneStatus) {
3
- ace.config.loadModule('ace/ext/language_tools', function () {
4
- editor.setOptions({
5
- displayIndentGuides: false,
6
- enableSnippets: true,
7
- enableBasicAutocompletion: true,
8
- });
9
- });
10
- editor.setAutoScrollEditorIntoView(true);
3
+ setEditorDefaults(ace, editor);
11
4
  // To display cursor position in status bar
12
5
  editor.session.selection.on('changeCursor', () => {
13
6
  setCursorPosition(editor.getCursorPosition());
@@ -20,28 +13,6 @@ export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setH
20
13
  }
21
14
  setAnnotations(newAnnotations);
22
15
  });
23
- if (!supportsKeyboardAccessibility(ace)) {
24
- editor.commands.addCommand({
25
- name: 'exitCodeEditor',
26
- bindKey: 'Esc',
27
- exec: () => {
28
- editor.container.focus();
29
- },
30
- });
31
- }
32
- editor.on('focus', () => {
33
- editor.textInput.getElement().setAttribute('tabindex', 0);
34
- });
35
- editor.on('blur', () => {
36
- editor.textInput.getElement().setAttribute('tabindex', -1);
37
- });
38
- // prevent users to step into editor directly by keyboard
39
- editor.textInput.getElement().setAttribute('tabindex', -1);
40
- editor.commands.removeCommand('showSettingsMenu', false);
41
- // Prevent default behavior on error/warning icon click
42
- editor.on('guttermousedown', (e) => {
43
- e.stop();
44
- });
45
16
  const moveCursorToAnnotation = (a) => {
46
17
  if (typeof a.row === 'number') {
47
18
  editor.gotoLine(a.row + 1, a.column || 0, false);
@@ -78,6 +49,44 @@ export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setH
78
49
  openAnnotation(row);
79
50
  }
80
51
  });
52
+ // HACK: Annotations aren't cleared when editor is empty.
53
+ editor.on('change', () => {
54
+ if (editor.getValue().length === 0) {
55
+ editor.session.clearAnnotations();
56
+ }
57
+ });
58
+ }
59
+ function setEditorDefaults(ace, editor) {
60
+ ace.config.loadModule('ace/ext/language_tools', function () {
61
+ editor.setOptions({
62
+ displayIndentGuides: false,
63
+ enableSnippets: true,
64
+ enableBasicAutocompletion: true,
65
+ });
66
+ });
67
+ editor.setAutoScrollEditorIntoView(true);
68
+ if (!supportsKeyboardAccessibility(ace)) {
69
+ editor.commands.addCommand({
70
+ name: 'exitCodeEditor',
71
+ bindKey: 'Esc',
72
+ exec: () => {
73
+ editor.container.focus();
74
+ },
75
+ });
76
+ }
77
+ editor.on('focus', () => {
78
+ editor.textInput.getElement().setAttribute('tabindex', 0);
79
+ });
80
+ editor.on('blur', () => {
81
+ editor.textInput.getElement().setAttribute('tabindex', -1);
82
+ });
83
+ // prevent users to step into editor directly by keyboard
84
+ editor.textInput.getElement().setAttribute('tabindex', -1);
85
+ editor.commands.removeCommand('showSettingsMenu', false);
86
+ // Prevent default behavior on error/warning icon click
87
+ editor.on('guttermousedown', (e) => {
88
+ e.stop();
89
+ });
81
90
  // HACK: Wrapped lines are highlighted individually. This is seriously the recommended fix.
82
91
  // See: https://github.com/ajaxorg/ace/issues/3067
83
92
  editor.setHighlightActiveLine(false);
@@ -109,12 +118,6 @@ export function setupEditor(ace, editor, setAnnotations, setCursorPosition, setH
109
118
  }
110
119
  };
111
120
  editor.setHighlightActiveLine(true);
112
- // HACK: Annotations aren't cleared when editor is empty.
113
- editor.on('change', () => {
114
- if (editor.getValue().length === 0) {
115
- editor.session.clearAnnotations();
116
- }
117
- });
118
121
  // HACK: "disable" error tooltips by hiding them as soon as they appear.
119
122
  // See https://github.com/ajaxorg/ace/issues/4004
120
123
  editor.on('showGutterTooltip', (tooltip) => {
@@ -1 +1 @@
1
- {"version":3,"file":"setup-editor.js","sourceRoot":"lib/default/","sources":["code-editor/setup-editor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,6BAA6B,EAAE,MAAM,QAAQ,CAAC;AAEnE,MAAM,UAAU,WAAW,CACzB,GAAQ,EACR,MAAkB,EAClB,cAAsE,EACtE,iBAAkE,EAClE,wBAA0F,EAC1F,aAA+D;IAE/D,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,wBAAwB,EAAE;QAC9C,MAAM,CAAC,UAAU,CAAC;YAChB,mBAAmB,EAAE,KAAK;YAC1B,cAAc,EAAE,IAAI;YACpB,yBAAyB,EAAE,IAAI;SAChC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IAEzC,2CAA2C;IAC3C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;QAC/C,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,kBAAyB,EAAE,GAAG,EAAE;QAChD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC1D,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QACxE,IAAI,iBAAiB,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM,EAAE;YACtD,MAAM,CAAC,OAAO,CAAC,cAAc,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,EAAE,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACtE,KAAa,CAAC,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;YAC5E,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC;SACtC;aAAM,IAAI,SAAS,EAAE;YACpB,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACvD,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACrD,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9C,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;SACrC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAEpC,yDAAyD;IACzD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACvB,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;SACnC;IACH,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,mBAA0B,EAAE,CAAC,OAAY,EAAE,EAAE;QACrD,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { Ace } from 'ace-builds';\nimport { PaneStatus, supportsKeyboardAccessibility } from './util';\n\nexport function setupEditor(\n ace: any,\n editor: Ace.Editor,\n setAnnotations: React.Dispatch<React.SetStateAction<Ace.Annotation[]>>,\n setCursorPosition: React.Dispatch<React.SetStateAction<Ace.Point>>,\n setHighlightedAnnotation: React.Dispatch<React.SetStateAction<Ace.Annotation | undefined>>,\n setPaneStatus: React.Dispatch<React.SetStateAction<PaneStatus>>\n) {\n ace.config.loadModule('ace/ext/language_tools', function () {\n editor.setOptions({\n displayIndentGuides: false,\n enableSnippets: true,\n enableBasicAutocompletion: true,\n });\n });\n\n editor.setAutoScrollEditorIntoView(true);\n\n // To display cursor position in status bar\n editor.session.selection.on('changeCursor', () => {\n setCursorPosition(editor.getCursorPosition());\n });\n\n editor.session.on('changeAnnotation' as any, () => {\n const editorAnnotations = editor.session.getAnnotations();\n const newAnnotations = editorAnnotations.filter(a => a.type !== 'info');\n if (editorAnnotations.length !== newAnnotations.length) {\n editor.session.setAnnotations(newAnnotations);\n }\n setAnnotations(newAnnotations);\n });\n\n if (!supportsKeyboardAccessibility(ace)) {\n editor.commands.addCommand({\n name: 'exitCodeEditor',\n bindKey: 'Esc',\n exec: () => {\n editor.container.focus();\n },\n });\n }\n\n editor.on('focus', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', 0);\n });\n\n editor.on('blur', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n });\n\n // prevent users to step into editor directly by keyboard\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n\n editor.commands.removeCommand('showSettingsMenu', false);\n\n // Prevent default behavior on error/warning icon click\n editor.on('guttermousedown' as any, (e: any) => {\n e.stop();\n });\n\n const moveCursorToAnnotation = (a: Ace.Annotation) => {\n if (typeof a.row === 'number') {\n editor.gotoLine(a.row + 1, a.column || 0, false);\n }\n };\n\n const openAnnotation = (row: number) => {\n const currentAnnotations = editor.session.getAnnotations().filter(a => a.row === row && a.type !== 'info');\n const errors = currentAnnotations.filter(a => a.type === 'error');\n if (errors.length > 0) {\n setHighlightedAnnotation(errors[0]);\n setPaneStatus('error');\n moveCursorToAnnotation(errors[0]);\n } else if (currentAnnotations.length > 0) {\n setHighlightedAnnotation(currentAnnotations[0]);\n setPaneStatus('warning');\n moveCursorToAnnotation(currentAnnotations[0]);\n } else {\n setHighlightedAnnotation(undefined);\n setPaneStatus('hidden');\n editor.gotoLine(row + 1, 0, false);\n }\n };\n\n // open error/warning pane when user clicks on gutter icon\n editor.on('gutterclick' as any, (e: any) => {\n const { row }: Ace.Point = e.getDocumentPosition();\n openAnnotation(row);\n });\n\n // open error/warning pane when user presses space/enter on gutter icon\n editor.on('gutterkeydown', e => {\n if (e.isInAnnotationLane() && (e.getKey() === 'space' || e.getKey() === 'return')) {\n const row: number = e.getRow();\n openAnnotation(row);\n }\n });\n\n // HACK: Wrapped lines are highlighted individually. This is seriously the recommended fix.\n // See: https://github.com/ajaxorg/ace/issues/3067\n editor.setHighlightActiveLine(false);\n (editor as any).$updateHighlightActiveLine = function () {\n const session = this.getSession();\n\n let highlight;\n if (this.$highlightActiveLine) {\n if (this.$selectionStyle !== 'line' || !this.selection.isMultiLine()) {\n highlight = this.getCursorPosition();\n }\n if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1)) {\n highlight = false;\n }\n }\n\n if (session.$highlightLineMarker && !highlight) {\n session.removeMarker(session.$highlightLineMarker.id);\n session.$highlightLineMarker = null;\n } else if (!session.$highlightLineMarker && highlight) {\n const range = new ace.Range(highlight.row, 0, highlight.row, Infinity);\n (range as any).id = session.addMarker(range, 'ace_active-line', 'fullLine');\n session.$highlightLineMarker = range;\n } else if (highlight) {\n session.$highlightLineMarker.start.row = highlight.row;\n session.$highlightLineMarker.end.row = highlight.row;\n session.$highlightLineMarker.start.column = 0;\n session._signal('changeBackMarker');\n }\n };\n\n editor.setHighlightActiveLine(true);\n\n // HACK: Annotations aren't cleared when editor is empty.\n editor.on('change', () => {\n if (editor.getValue().length === 0) {\n editor.session.clearAnnotations();\n }\n });\n\n // HACK: \"disable\" error tooltips by hiding them as soon as they appear.\n // See https://github.com/ajaxorg/ace/issues/4004\n editor.on('showGutterTooltip' as any, (tooltip: any) => {\n tooltip.hide();\n });\n}\n"]}
1
+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O,CAAC,oBAAoB,IAAI,SAAS,EAAE;YACrD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACtE,KAAa,CAAC,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;YAC5E,OAAO,CAAC,oBAAoB,GAAG,KAAK,CAAC;SACtC;aAAM,IAAI,SAAS,EAAE;YACpB,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACvD,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,CAAC;YACrD,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9C,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;SACrC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAEpC,wEAAwE;IACxE,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,mBAA0B,EAAE,CAAC,OAAY,EAAE,EAAE;QACrD,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { Ace } from 'ace-builds';\nimport { PaneStatus, supportsKeyboardAccessibility } from './util';\n\nexport function setupEditor(\n ace: any,\n editor: Ace.Editor,\n setAnnotations: React.Dispatch<React.SetStateAction<Ace.Annotation[]>>,\n setCursorPosition: React.Dispatch<React.SetStateAction<Ace.Point>>,\n setHighlightedAnnotation: React.Dispatch<React.SetStateAction<Ace.Annotation | undefined>>,\n setPaneStatus: React.Dispatch<React.SetStateAction<PaneStatus>>\n) {\n setEditorDefaults(ace, editor);\n\n // To display cursor position in status bar\n editor.session.selection.on('changeCursor', () => {\n setCursorPosition(editor.getCursorPosition());\n });\n\n editor.session.on('changeAnnotation' as any, () => {\n const editorAnnotations = editor.session.getAnnotations();\n const newAnnotations = editorAnnotations.filter(a => a.type !== 'info');\n if (editorAnnotations.length !== newAnnotations.length) {\n editor.session.setAnnotations(newAnnotations);\n }\n setAnnotations(newAnnotations);\n });\n\n const moveCursorToAnnotation = (a: Ace.Annotation) => {\n if (typeof a.row === 'number') {\n editor.gotoLine(a.row + 1, a.column || 0, false);\n }\n };\n\n const openAnnotation = (row: number) => {\n const currentAnnotations = editor.session.getAnnotations().filter(a => a.row === row && a.type !== 'info');\n const errors = currentAnnotations.filter(a => a.type === 'error');\n if (errors.length > 0) {\n setHighlightedAnnotation(errors[0]);\n setPaneStatus('error');\n moveCursorToAnnotation(errors[0]);\n } else if (currentAnnotations.length > 0) {\n setHighlightedAnnotation(currentAnnotations[0]);\n setPaneStatus('warning');\n moveCursorToAnnotation(currentAnnotations[0]);\n } else {\n setHighlightedAnnotation(undefined);\n setPaneStatus('hidden');\n editor.gotoLine(row + 1, 0, false);\n }\n };\n\n // open error/warning pane when user clicks on gutter icon\n editor.on('gutterclick' as any, (e: any) => {\n const { row }: Ace.Point = e.getDocumentPosition();\n openAnnotation(row);\n });\n\n // open error/warning pane when user presses space/enter on gutter icon\n editor.on('gutterkeydown', e => {\n if (e.isInAnnotationLane() && (e.getKey() === 'space' || e.getKey() === 'return')) {\n const row: number = e.getRow();\n openAnnotation(row);\n }\n });\n\n // HACK: Annotations aren't cleared when editor is empty.\n editor.on('change', () => {\n if (editor.getValue().length === 0) {\n editor.session.clearAnnotations();\n }\n });\n}\n\nfunction setEditorDefaults(ace: any, editor: Ace.Editor) {\n ace.config.loadModule('ace/ext/language_tools', function () {\n editor.setOptions({\n displayIndentGuides: false,\n enableSnippets: true,\n enableBasicAutocompletion: true,\n });\n });\n\n editor.setAutoScrollEditorIntoView(true);\n\n if (!supportsKeyboardAccessibility(ace)) {\n editor.commands.addCommand({\n name: 'exitCodeEditor',\n bindKey: 'Esc',\n exec: () => {\n editor.container.focus();\n },\n });\n }\n\n editor.on('focus', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', 0);\n });\n\n editor.on('blur', () => {\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n });\n\n // prevent users to step into editor directly by keyboard\n (editor as any).textInput.getElement().setAttribute('tabindex', -1);\n\n editor.commands.removeCommand('showSettingsMenu', false);\n\n // Prevent default behavior on error/warning icon click\n editor.on('guttermousedown' as any, (e: any) => {\n e.stop();\n });\n\n // HACK: Wrapped lines are highlighted individually. This is seriously the recommended fix.\n // See: https://github.com/ajaxorg/ace/issues/3067\n editor.setHighlightActiveLine(false);\n (editor as any).$updateHighlightActiveLine = function () {\n const session = this.getSession();\n\n let highlight;\n if (this.$highlightActiveLine) {\n if (this.$selectionStyle !== 'line' || !this.selection.isMultiLine()) {\n highlight = this.getCursorPosition();\n }\n if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1)) {\n highlight = false;\n }\n }\n\n if (session.$highlightLineMarker && !highlight) {\n session.removeMarker(session.$highlightLineMarker.id);\n session.$highlightLineMarker = null;\n } else if (!session.$highlightLineMarker && highlight) {\n const range = new ace.Range(highlight.row, 0, highlight.row, Infinity);\n (range as any).id = session.addMarker(range, 'ace_active-line', 'fullLine');\n session.$highlightLineMarker = range;\n } else if (highlight) {\n session.$highlightLineMarker.start.row = highlight.row;\n session.$highlightLineMarker.end.row = highlight.row;\n session.$highlightLineMarker.start.column = 0;\n session._signal('changeBackMarker');\n }\n };\n\n editor.setHighlightActiveLine(true);\n\n // HACK: \"disable\" error tooltips by hiding them as soon as they appear.\n // See https://github.com/ajaxorg/ace/issues/4004\n editor.on('showGutterTooltip' as any, (tooltip: any) => {\n tooltip.hide();\n });\n}\n"]}
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import { Ace } from 'ace-builds';
3
+ import { CodeEditorProps } from './interfaces';
4
+ export declare function useEditor(ace: any, loading?: boolean): {
5
+ editorRef: import("react").RefObject<HTMLDivElement>;
6
+ editor: Ace.Editor | null;
7
+ };
8
+ export declare function useSyncEditorLabels(editor: null | Ace.Editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby, }: {
9
+ controlId?: string;
10
+ ariaLabel?: string;
11
+ ariaLabelledby?: string;
12
+ ariaDescribedby?: string;
13
+ }): void;
14
+ export declare function useSyncEditorSize(editor: null | Ace.Editor, { width, height }: {
15
+ width?: null | number;
16
+ height?: null | number;
17
+ }): {
18
+ onResize: () => void;
19
+ };
20
+ export declare function useSyncEditorValue(editor: null | Ace.Editor, value: string): void;
21
+ export declare function useSyncEditorLanguage(editor: null | Ace.Editor, language: string): void;
22
+ export declare function useSyncEditorWrapLines(editor: null | Ace.Editor, wrapLines?: boolean): void;
23
+ export declare function useSyncEditorTheme(editor: null | Ace.Editor, theme: CodeEditorProps.Theme): void;
24
+ //# sourceMappingURL=use-editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-editor.d.ts","sourceRoot":"lib/default/","sources":["code-editor/use-editor.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO;;;EAmBpD;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EACzB,EACE,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,GAChB,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,QAiBjG;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EACzB,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE;;EAWrE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,QAY1E;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,QAIhF;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,QAIpF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,QAIzF"}
@@ -0,0 +1,71 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useCallback, useEffect, useRef, useState } from 'react';
4
+ import { getAceTheme, getDefaultConfig, getDefaultTheme } from './util';
5
+ export function useEditor(ace, loading) {
6
+ const editorRef = useRef(null);
7
+ const [editor, setEditor] = useState(null);
8
+ useEffect(() => {
9
+ const elem = editorRef.current;
10
+ if (!ace || !elem) {
11
+ return;
12
+ }
13
+ const config = getDefaultConfig(ace);
14
+ setEditor(ace.edit(elem, Object.assign(Object.assign({}, config), { theme: getAceTheme(getDefaultTheme(elem)) })));
15
+ }, [ace, loading]);
16
+ return { editorRef, editor };
17
+ }
18
+ export function useSyncEditorLabels(editor, { controlId, ariaLabel, ariaLabelledby, ariaDescribedby, }) {
19
+ useEffect(() => {
20
+ if (!editor) {
21
+ return;
22
+ }
23
+ const { textarea } = editor.renderer;
24
+ if (!textarea) {
25
+ return;
26
+ }
27
+ const updateAttribute = (attribute, value) => value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);
28
+ updateAttribute('id', controlId);
29
+ updateAttribute('aria-label', ariaLabel);
30
+ updateAttribute('aria-labelledby', ariaLabelledby);
31
+ updateAttribute('aria-describedby', ariaDescribedby);
32
+ }, [ariaLabel, ariaDescribedby, ariaLabelledby, controlId, editor]);
33
+ }
34
+ export function useSyncEditorSize(editor, { width, height }) {
35
+ useEffect(() => {
36
+ editor === null || editor === void 0 ? void 0 : editor.resize();
37
+ }, [editor, width, height]);
38
+ const onResize = useCallback(() => {
39
+ editor === null || editor === void 0 ? void 0 : editor.resize();
40
+ }, [editor]);
41
+ return { onResize };
42
+ }
43
+ export function useSyncEditorValue(editor, value) {
44
+ useEffect(() => {
45
+ if (!editor) {
46
+ return;
47
+ }
48
+ if (value === editor.getValue()) {
49
+ return;
50
+ }
51
+ const pos = editor.session.selection.toJSON();
52
+ editor.setValue(value, -1);
53
+ editor.session.selection.fromJSON(pos);
54
+ }, [editor, value]);
55
+ }
56
+ export function useSyncEditorLanguage(editor, language) {
57
+ useEffect(() => {
58
+ editor === null || editor === void 0 ? void 0 : editor.session.setMode(`ace/mode/${language}`);
59
+ }, [editor, language]);
60
+ }
61
+ export function useSyncEditorWrapLines(editor, wrapLines) {
62
+ useEffect(() => {
63
+ editor === null || editor === void 0 ? void 0 : editor.session.setUseWrapMode(wrapLines !== null && wrapLines !== void 0 ? wrapLines : true);
64
+ }, [editor, wrapLines]);
65
+ }
66
+ export function useSyncEditorTheme(editor, theme) {
67
+ useEffect(() => {
68
+ editor === null || editor === void 0 ? void 0 : editor.setTheme(getAceTheme(theme));
69
+ }, [editor, theme]);
70
+ }
71
+ //# sourceMappingURL=use-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-editor.js","sourceRoot":"lib/default/","sources":["code-editor/use-editor.tsx"],"names":[],"mappings":"AAAA,qEAAqE;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,CAAC,CAAC;IACzC,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAyB,EAAE,QAAgB;IAC/E,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,OAAO,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;IAClD,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAyB,EAAE,SAAmB;IACnF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,cAAc,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,CAAC;IACpD,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAyB,EAAE,KAA4B;IACxF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACtB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Ace } from 'ace-builds';\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { getAceTheme, getDefaultConfig, getDefaultTheme } from './util';\nimport { CodeEditorProps } from './interfaces';\n\nexport function useEditor(ace: any, loading?: boolean) {\n const editorRef = useRef<HTMLDivElement>(null);\n const [editor, setEditor] = useState<null | Ace.Editor>(null);\n\n useEffect(() => {\n const elem = editorRef.current;\n if (!ace || !elem) {\n return;\n }\n const config = getDefaultConfig(ace);\n setEditor(\n ace.edit(elem, {\n ...config,\n theme: getAceTheme(getDefaultTheme(elem)),\n })\n );\n }, [ace, loading]);\n\n return { editorRef, editor };\n}\n\nexport function useSyncEditorLabels(\n editor: null | Ace.Editor,\n {\n controlId,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n }: { controlId?: string; ariaLabel?: string; ariaLabelledby?: string; ariaDescribedby?: string }\n) {\n useEffect(() => {\n if (!editor) {\n return;\n }\n const { textarea } = editor.renderer as unknown as { textarea: HTMLTextAreaElement };\n if (!textarea) {\n return;\n }\n const updateAttribute = (attribute: string, value: string | undefined) =>\n value ? textarea.setAttribute(attribute, value) : textarea.removeAttribute(attribute);\n updateAttribute('id', controlId);\n updateAttribute('aria-label', ariaLabel);\n updateAttribute('aria-labelledby', ariaLabelledby);\n updateAttribute('aria-describedby', ariaDescribedby);\n }, [ariaLabel, ariaDescribedby, ariaLabelledby, controlId, editor]);\n}\n\nexport function useSyncEditorSize(\n editor: null | Ace.Editor,\n { width, height }: { width?: null | number; height?: null | number }\n) {\n useEffect(() => {\n editor?.resize();\n }, [editor, width, height]);\n\n const onResize = useCallback(() => {\n editor?.resize();\n }, [editor]);\n\n return { onResize };\n}\n\nexport function useSyncEditorValue(editor: null | Ace.Editor, value: string) {\n useEffect(() => {\n if (!editor) {\n return;\n }\n if (value === editor.getValue()) {\n return;\n }\n const pos = editor.session.selection.toJSON();\n editor.setValue(value, -1);\n editor.session.selection.fromJSON(pos);\n }, [editor, value]);\n}\n\nexport function useSyncEditorLanguage(editor: null | Ace.Editor, language: string) {\n useEffect(() => {\n editor?.session.setMode(`ace/mode/${language}`);\n }, [editor, language]);\n}\n\nexport function useSyncEditorWrapLines(editor: null | Ace.Editor, wrapLines?: boolean) {\n useEffect(() => {\n editor?.session.setUseWrapMode(wrapLines ?? true);\n }, [editor, wrapLines]);\n}\n\nexport function useSyncEditorTheme(editor: null | Ace.Editor, theme: CodeEditorProps.Theme) {\n useEffect(() => {\n editor?.setTheme(getAceTheme(theme));\n }, [editor, theme]);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["form-field/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAazC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAetD,UAAU,mBAAmB;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,mBAAmB,eAiBvF;AAED,wBAAgB,cAAc,CAAC,EAC7B,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,eAMA;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,SAAS,EACT,OAAe,EACf,KAAK,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,SAAS,EACT,WAAW,EACX,iBAAwB,EACxB,gBAAwB,EACxB,GAAG,IAAI,EACR,EAAE,sBAAsB,eA2HxB"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"lib/default/","sources":["form-field/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAazC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAetD,UAAU,mBAAmB;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,kBAAkB,EAAE,EAAE,mBAAmB,eAiBvF;AAED,wBAAgB,cAAc,CAAC,EAC7B,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,eAMA;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,SAAS,EACT,OAAe,EACf,KAAK,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,SAAS,EACT,WAAW,EACX,iBAAwB,EACxB,gBAAwB,EACxB,GAAG,IAAI,EACR,EAAE,sBAAsB,eAgIxB"}
@@ -52,22 +52,27 @@ export default function InternalFormField(_a) {
52
52
  [DATA_ATTR_FIELD_ERROR]: slotIds.error ? getFieldSlotSeletor(slotIds.error) : undefined,
53
53
  };
54
54
  useEffect(() => {
55
+ var _a, _b, _c;
55
56
  if (funnelInteractionId && errorText && funnelState.current !== 'complete') {
56
57
  const stepName = getNameFromSelector(stepNameSelector);
57
58
  const subStepName = getNameFromSelector(subStepNameSelector);
58
59
  errorCount.current++;
59
- FunnelMetrics.funnelSubStepError({
60
- funnelInteractionId,
61
- subStepSelector,
62
- subStepName,
63
- subStepNameSelector,
64
- stepNumber,
65
- stepName,
66
- stepNameSelector,
67
- fieldErrorSelector: getFieldSlotSeletor(slotIds.error),
68
- fieldLabelSelector: getFieldSlotSeletor(slotIds.label),
69
- subStepAllSelector: getSubStepAllSelector(),
70
- });
60
+ // We don't want to report an error if it is hidden, e.g. inside an Expandable Section.
61
+ const errorIsVisible = ((_c = (_b = (_a = __internalRootRef === null || __internalRootRef === void 0 ? void 0 : __internalRootRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0) > 0;
62
+ if (errorIsVisible) {
63
+ FunnelMetrics.funnelSubStepError({
64
+ funnelInteractionId,
65
+ subStepSelector,
66
+ subStepName,
67
+ subStepNameSelector,
68
+ stepNumber,
69
+ stepName,
70
+ stepNameSelector,
71
+ fieldErrorSelector: getFieldSlotSeletor(slotIds.error),
72
+ fieldLabelSelector: getFieldSlotSeletor(slotIds.label),
73
+ subStepAllSelector: getSubStepAllSelector(),
74
+ });
75
+ }
71
76
  return () => {
72
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
73
78
  errorCount.current--;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"lib/default/","sources":["form-field/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,aAAa,EAA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jB,oBAAC,cAAc,IAAC,EAAE,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,SAAS,IAC1D,cAAc,CACA,CAClB,CACG,CACP,CACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../i18n/context';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FIELD_ERROR,\n DATA_ATTR_FIELD_LABEL,\n getFieldSlotSeletor,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../internal/analytics/selectors';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n\n return (\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div\n role=\"img\"\n aria-label={i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel)}\n className={styles['error-icon-scale-wrapper']}\n >\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message}>{children}</span>\n </div>\n );\n}\n\nexport function ConstraintText({\n id,\n hasError,\n children,\n}: {\n id?: string;\n hasError: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasError && styles['constraint-has-error'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const { funnelInteractionId, submissionAttempt, funnelState, errorCount } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_FIELD_LABEL]: slotIds.label ? getFieldSlotSeletor(slotIds.label) : undefined,\n [DATA_ATTR_FIELD_ERROR]: slotIds.error ? getFieldSlotSeletor(slotIds.error) : undefined,\n };\n\n useEffect(() => {\n if (funnelInteractionId && errorText && funnelState.current !== 'complete') {\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepName = getNameFromSelector(subStepNameSelector);\n\n errorCount.current++;\n\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n stepNumber,\n stepName,\n stepNameSelector,\n fieldErrorSelector: getFieldSlotSeletor(slotIds.error),\n fieldLabelSelector: getFieldSlotSeletor(slotIds.label),\n subStepAllSelector: getSubStepAllSelector(),\n });\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n errorCount.current--;\n };\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, errorText, submissionAttempt, errorCount]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n ref={__internalRootRef}\n {...analyticsAttributes}\n >\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n <InfoLinkLabelContext.Provider value={slotIds.label}>\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"internal.js","source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.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../internal/base-component';\nimport { FormFieldContext, useFormFieldContext } from '../internal/context/form-field-context';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\n\nimport InternalGrid from '../grid/internal';\nimport InternalIcon from '../icon/internal';\nimport { getAriaDescribedBy, getGridDefinition, getSlotIds } from './util';\n\nimport styles from './styles.css.js';\nimport { InternalFormFieldProps } from './interfaces';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useInternalI18n } from '../i18n/context';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\n\nimport { FunnelMetrics } from '../internal/analytics';\nimport { useFunnel, useFunnelStep, useFunnelSubStep } from '../internal/analytics/hooks/use-funnel';\nimport {\n DATA_ATTR_FIELD_ERROR,\n DATA_ATTR_FIELD_LABEL,\n getFieldSlotSeletor,\n getNameFromSelector,\n getSubStepAllSelector,\n} from '../internal/analytics/selectors';\n\ninterface FormFieldErrorProps {\n id?: string;\n children?: React.ReactNode;\n errorIconAriaLabel?: string;\n}\n\nexport function FormFieldError({ id, children, errorIconAriaLabel }: FormFieldErrorProps) {\n const i18n = useInternalI18n('form-field');\n\n return (\n <div id={id} className={styles.error}>\n <div className={styles['error-icon-shake-wrapper']}>\n <div\n role=\"img\"\n aria-label={i18n('i18nStrings.errorIconAriaLabel', errorIconAriaLabel)}\n className={styles['error-icon-scale-wrapper']}\n >\n <InternalIcon name=\"status-warning\" size=\"small\" />\n </div>\n </div>\n <span className={styles.error__message}>{children}</span>\n </div>\n );\n}\n\nexport function ConstraintText({\n id,\n hasError,\n children,\n}: {\n id?: string;\n hasError: boolean;\n children: React.ReactNode;\n}) {\n return (\n <div id={id} className={clsx(styles.constraint, hasError && styles['constraint-has-error'])}>\n {children}\n </div>\n );\n}\n\nexport default function InternalFormField({\n controlId,\n stretch = false,\n label,\n info,\n i18nStrings,\n children,\n secondaryControl,\n description,\n constraintText,\n errorText,\n __hideLabel,\n __internalRootRef = null,\n __disableGutters = false,\n ...rest\n}: InternalFormFieldProps) {\n const baseProps = getBaseProps(rest);\n const isRefresh = useVisualRefresh();\n\n const instanceUniqueId = useUniqueId('formField');\n const generatedControlId = controlId || instanceUniqueId;\n const formFieldId = controlId || generatedControlId;\n\n const { funnelInteractionId, submissionAttempt, funnelState, errorCount } = useFunnel();\n const { stepNumber, stepNameSelector } = useFunnelStep();\n const { subStepSelector, subStepNameSelector } = useFunnelSubStep();\n\n const slotIds = getSlotIds(formFieldId, label, description, constraintText, errorText);\n\n const ariaDescribedBy = getAriaDescribedBy(slotIds);\n\n const gridDefinition = getGridDefinition(stretch, !!secondaryControl, isRefresh);\n\n const {\n ariaLabelledby: parentAriaLabelledby,\n ariaDescribedby: parentAriaDescribedby,\n invalid: parentInvalid,\n } = useFormFieldContext({});\n\n const contextValuesWithoutControlId = {\n ariaLabelledby: joinStrings(parentAriaLabelledby, slotIds.label) || undefined,\n ariaDescribedby: joinStrings(parentAriaDescribedby, ariaDescribedBy) || undefined,\n invalid: !!errorText || !!parentInvalid,\n };\n\n const analyticsAttributes = {\n [DATA_ATTR_FIELD_LABEL]: slotIds.label ? getFieldSlotSeletor(slotIds.label) : undefined,\n [DATA_ATTR_FIELD_ERROR]: slotIds.error ? getFieldSlotSeletor(slotIds.error) : undefined,\n };\n\n useEffect(() => {\n if (funnelInteractionId && errorText && funnelState.current !== 'complete') {\n const stepName = getNameFromSelector(stepNameSelector);\n const subStepName = getNameFromSelector(subStepNameSelector);\n\n errorCount.current++;\n\n // We don't want to report an error if it is hidden, e.g. inside an Expandable Section.\n const errorIsVisible = (__internalRootRef?.current?.getBoundingClientRect()?.width ?? 0) > 0;\n\n if (errorIsVisible) {\n FunnelMetrics.funnelSubStepError({\n funnelInteractionId,\n subStepSelector,\n subStepName,\n subStepNameSelector,\n stepNumber,\n stepName,\n stepNameSelector,\n fieldErrorSelector: getFieldSlotSeletor(slotIds.error),\n fieldLabelSelector: getFieldSlotSeletor(slotIds.label),\n subStepAllSelector: getSubStepAllSelector(),\n });\n }\n\n return () => {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n errorCount.current--;\n };\n }\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [funnelInteractionId, errorText, submissionAttempt, errorCount]);\n\n return (\n <div\n {...baseProps}\n className={clsx(baseProps.className, styles.root)}\n ref={__internalRootRef}\n {...analyticsAttributes}\n >\n <div className={clsx(__hideLabel && styles['visually-hidden'])}>\n {label && (\n <label className={styles.label} id={slotIds.label} htmlFor={generatedControlId}>\n {label}\n </label>\n )}\n <InfoLinkLabelContext.Provider value={slotIds.label}>\n {!__hideLabel && info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </div>\n\n {description && (\n <div className={styles.description} id={slotIds.description}>\n {description}\n </div>\n )}\n\n <div className={clsx(styles.controls, __hideLabel && styles['label-hidden'])}>\n <InternalGrid gridDefinition={gridDefinition} disableGutters={__disableGutters}>\n <FormFieldContext.Provider\n value={{\n controlId: generatedControlId,\n ...contextValuesWithoutControlId,\n }}\n >\n {children && <div className={styles.control}>{children}</div>}\n </FormFieldContext.Provider>\n\n {secondaryControl && (\n <FormFieldContext.Provider value={contextValuesWithoutControlId}>\n <div className={styles['secondary-control']}>{secondaryControl}</div>\n </FormFieldContext.Provider>\n )}\n </InternalGrid>\n </div>\n\n {(constraintText || errorText) && (\n <div className={styles.hints}>\n {errorText && (\n <FormFieldError id={slotIds.error} errorIconAriaLabel={i18nStrings?.errorIconAriaLabel}>\n {errorText}\n </FormFieldError>\n )}\n {constraintText && (\n <ConstraintText id={slotIds.constraint} hasError={!!errorText}>\n {constraintText}\n </ConstraintText>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["internal/components/chart-popover/index.tsx"],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GAAG,IAAI,CAAC;IAE1B,wDAAwD;IACxD,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAE5C,0EAA0E;IAC1E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEjD,0EAA0E;IAC1E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAEjD,sBAAsB;IACtB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;;AAED,wBAA8C"}
@@ -3,11 +3,11 @@ import { __rest } from "tslib";
3
3
  // SPDX-License-Identifier: Apache-2.0
4
4
  import React, { useEffect, useRef } from 'react';
5
5
  import clsx from 'clsx';
6
+ import { nodeContains } from '@cloudscape-design/component-toolkit/dom';
6
7
  import { getBaseProps } from '../../base-component';
7
8
  import PopoverContainer from '../../../popover/container';
8
9
  import PopoverBody from '../../../popover/body';
9
10
  import popoverStyles from '../../../popover/styles.css.js';
10
- import { nodeContains } from '../../utils/dom';
11
11
  import { useMergeRefs } from '../../hooks/use-merge-refs';
12
12
  import styles from './styles.css.js';
13
13
  import { nodeBelongs } from '../../utils/node-belongs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/chart-popover/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C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CAAC;QAChF,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,6CACM,SAAS,IACb,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,EACrE,GAAG,EAAE,UAAU,EACf,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY;QAE1B,oBAAC,gBAAgB,IACf,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CACjB,6BAAK,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;gBACpF,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI;gBAChD,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI,CAC5C,CACP;YAED,6BAAK,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;gBAClC,oBAAC,WAAW,IACV,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,EACpB,eAAe,EAAC,SAAS,EACzB,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAEhC,QAAQ,CACG,CACV,CACW,CACf,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { getBaseProps } from '../../base-component';\n\nimport { PopoverProps } from '../../../popover/interfaces';\nimport PopoverContainer from '../../../popover/container';\nimport PopoverBody from '../../../popover/body';\nimport popoverStyles from '../../../popover/styles.css.js';\nimport { nodeContains } from '../../utils/dom';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\n\nimport styles from './styles.css.js';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\nexport interface ChartPopoverProps extends PopoverProps {\n /** Title of the popover */\n title?: React.ReactNode;\n\n /** References the element the container is positioned against. */\n trackRef: React.RefObject<Element>;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n\n /** Optional container element that prevents any clicks in there from dismissing the popover */\n container: Element | null;\n\n /** Event that is fired when the popover is dismissed */\n onDismiss: (outsideClick?: boolean) => void;\n\n /** Fired when the pointer enters the hoverable area around the popover */\n onMouseEnter?: (event: React.MouseEvent) => void;\n\n /** Fired when the pointer leaves the hoverable area around the popover */\n onMouseLeave?: (event: React.MouseEvent) => void;\n\n /** Popover content */\n children?: React.ReactNode;\n}\n\nexport default React.forwardRef(ChartPopover);\n\nfunction ChartPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n dismissButton = false,\n dismissAriaLabel,\n\n children,\n\n title,\n trackRef,\n trackKey,\n onDismiss,\n container,\n\n onMouseEnter,\n onMouseLeave,\n\n ...restProps\n }: ChartPopoverProps,\n ref: React.Ref<HTMLElement>\n) {\n const baseProps = getBaseProps(restProps);\n const popoverObjectRef = useRef<HTMLDivElement | null>(null);\n\n const popoverRef = useMergeRefs(popoverObjectRef, ref);\n\n useEffect(() => {\n const onDocumentClick = (event: MouseEvent) => {\n if (\n event.target &&\n !nodeBelongs(popoverObjectRef.current, event.target as Element) && // click not in popover\n !nodeContains(container, event.target as Element) // click not in segment\n ) {\n onDismiss(true);\n }\n };\n\n document.addEventListener('mousedown', onDocumentClick, { capture: true });\n return () => {\n document.removeEventListener('mousedown', onDocumentClick, { capture: true });\n };\n }, [container, onDismiss]);\n\n return (\n <div\n {...baseProps}\n className={clsx(popoverStyles.root, styles.root, baseProps.className)}\n ref={popoverRef}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={trackRef}\n trackKey={trackKey}\n arrow={position => (\n <div className={clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`])}>\n <div className={popoverStyles['arrow-outer']} />\n <div className={popoverStyles['arrow-inner']} />\n </div>\n )}\n >\n <div className={styles['hover-area']}>\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={title}\n onDismiss={onDismiss}\n overflowVisible=\"content\"\n className={styles['popover-body']}\n >\n {children}\n </PopoverBody>\n </div>\n </PopoverContainer>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["internal/components/chart-popover/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAmCvD,eAAe,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AAE9C,SAAS,YAAY,CACnB,EAmBoB,EACpB,GAA2B;QApB3B,EACE,QAAQ,GAA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EAC1B,YAAY,EAAE,YAAY;QAE1B,oBAAC,gBAAgB,IACf,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC,CACjB,6BAAK,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;gBACpF,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI;gBAChD,6BAAK,SAAS,EAAE,aAAa,CAAC,aAAa,CAAC,GAAI,CAC5C,CACP;YAED,6BAAK,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;gBAClC,oBAAC,WAAW,IACV,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,KAAK,EACb,SAAS,EAAE,SAAS,EACpB,eAAe,EAAC,SAAS,EACzB,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,IAEhC,QAAQ,CACG,CACV,CACW,CACf,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\nimport clsx from 'clsx';\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport { getBaseProps } from '../../base-component';\n\nimport { PopoverProps } from '../../../popover/interfaces';\nimport PopoverContainer from '../../../popover/container';\nimport PopoverBody from '../../../popover/body';\nimport popoverStyles from '../../../popover/styles.css.js';\nimport { useMergeRefs } from '../../hooks/use-merge-refs';\n\nimport styles from './styles.css.js';\nimport { nodeBelongs } from '../../utils/node-belongs';\n\nexport interface ChartPopoverProps extends PopoverProps {\n /** Title of the popover */\n title?: React.ReactNode;\n\n /** References the element the container is positioned against. */\n trackRef: React.RefObject<Element>;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n\n /** Optional container element that prevents any clicks in there from dismissing the popover */\n container: Element | null;\n\n /** Event that is fired when the popover is dismissed */\n onDismiss: (outsideClick?: boolean) => void;\n\n /** Fired when the pointer enters the hoverable area around the popover */\n onMouseEnter?: (event: React.MouseEvent) => void;\n\n /** Fired when the pointer leaves the hoverable area around the popover */\n onMouseLeave?: (event: React.MouseEvent) => void;\n\n /** Popover content */\n children?: React.ReactNode;\n}\n\nexport default React.forwardRef(ChartPopover);\n\nfunction ChartPopover(\n {\n position = 'right',\n size = 'medium',\n fixedWidth = false,\n dismissButton = false,\n dismissAriaLabel,\n\n children,\n\n title,\n trackRef,\n trackKey,\n onDismiss,\n container,\n\n onMouseEnter,\n onMouseLeave,\n\n ...restProps\n }: ChartPopoverProps,\n ref: React.Ref<HTMLElement>\n) {\n const baseProps = getBaseProps(restProps);\n const popoverObjectRef = useRef<HTMLDivElement | null>(null);\n\n const popoverRef = useMergeRefs(popoverObjectRef, ref);\n\n useEffect(() => {\n const onDocumentClick = (event: MouseEvent) => {\n if (\n event.target &&\n !nodeBelongs(popoverObjectRef.current, event.target as Element) && // click not in popover\n !nodeContains(container, event.target as Element) // click not in segment\n ) {\n onDismiss(true);\n }\n };\n\n document.addEventListener('mousedown', onDocumentClick, { capture: true });\n return () => {\n document.removeEventListener('mousedown', onDocumentClick, { capture: true });\n };\n }, [container, onDismiss]);\n\n return (\n <div\n {...baseProps}\n className={clsx(popoverStyles.root, styles.root, baseProps.className)}\n ref={popoverRef}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n <PopoverContainer\n size={size}\n fixedWidth={fixedWidth}\n position={position}\n trackRef={trackRef}\n trackKey={trackKey}\n arrow={position => (\n <div className={clsx(popoverStyles.arrow, popoverStyles[`arrow-position-${position}`])}>\n <div className={popoverStyles['arrow-outer']} />\n <div className={popoverStyles['arrow-inner']} />\n </div>\n )}\n >\n <div className={styles['hover-area']}>\n <PopoverBody\n dismissButton={dismissButton}\n dismissAriaLabel={dismissAriaLabel}\n header={title}\n onDismiss={onDismiss}\n overflowVisible=\"content\"\n className={styles['popover-body']}\n >\n {children}\n </PopoverBody>\n </div>\n </PopoverContainer>\n </div>\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (0e1ee85b)";
2
+ export var PACKAGE_VERSION = "3.0.0 (7108c464)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (0e1ee85b)",
3
+ "PACKAGE_VERSION": "3.0.0 (7108c464)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "0e1ee85bfe26214d14d9426715de264920c0ade7"
2
+ "commit": "7108c464847229e22776be0615e176434d8819cf"
3
3
  }
@@ -1,30 +1,26 @@
1
- import { DrawerConfig, DrawersRegistrationListener } from './controllers/drawers';
2
- import { ActionConfig, ActionRegistrationListener } from './controllers/action-buttons';
3
- interface AwsuiPluginApiPublic {
4
- appLayout: {
5
- registerDrawer(config: DrawerConfig): void;
1
+ import { DrawersApiInternal, DrawersApiPublic } from './controllers/drawers';
2
+ import { ActionsApiInternal, ActionsApiPublic } from './controllers/action-buttons';
3
+ interface AwsuiApi {
4
+ awsuiPlugins: {
5
+ appLayout: DrawersApiPublic;
6
+ alert: ActionsApiPublic;
7
+ flashbar: ActionsApiPublic;
6
8
  };
7
- alert: {
8
- registerAction(config: ActionConfig): void;
9
- };
10
- flashbar: {
11
- registerAction(config: ActionConfig): void;
12
- };
13
- }
14
- interface AwsuiPluginApiInternal {
15
- appLayout: {
16
- clearRegisteredDrawers(): void;
17
- onDrawersRegistered(listener: DrawersRegistrationListener): () => void;
18
- };
19
- alert: {
20
- clearRegisteredActions: () => void;
21
- onActionRegistered(listener: ActionRegistrationListener): () => void;
22
- };
23
- flashbar: {
24
- clearRegisteredActions: () => void;
25
- onActionRegistered(listener: ActionRegistrationListener): () => void;
9
+ awsuiPluginsInternal: {
10
+ appLayout: DrawersApiInternal;
11
+ alert: ActionsApiInternal;
12
+ flashbar: ActionsApiInternal;
26
13
  };
27
14
  }
28
- export declare const awsuiPlugins: AwsuiPluginApiPublic, awsuiPluginsInternal: AwsuiPluginApiInternal;
15
+ export declare function loadApi(): AwsuiApi;
16
+ export declare const awsuiPlugins: {
17
+ appLayout: DrawersApiPublic;
18
+ alert: ActionsApiPublic;
19
+ flashbar: ActionsApiPublic;
20
+ }, awsuiPluginsInternal: {
21
+ appLayout: DrawersApiInternal;
22
+ alert: ActionsApiInternal;
23
+ flashbar: ActionsApiInternal;
24
+ };
29
25
  export {};
30
26
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"lib/default/","sources":["internal/plugins/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAqB,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACrG,OAAO,EAA2B,YAAY,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAIjH,UAAU,oBAAoB;IAC5B,SAAS,EAAE;QACT,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;KAC5C,CAAC;IACF,KAAK,EAAE;QACL,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;KAC5C,CAAC;IACF,QAAQ,EAAE;QACR,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;KAC5C,CAAC;CACH;AACD,UAAU,sBAAsB;IAC9B,SAAS,EAAE;QACT,sBAAsB,IAAI,IAAI,CAAC;QAC/B,mBAAmB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM,IAAI,CAAC;KACxE,CAAC;IACF,KAAK,EAAE;QACL,sBAAsB,EAAE,MAAM,IAAI,CAAC;QACnC,kBAAkB,CAAC,QAAQ,EAAE,0BAA0B,GAAG,MAAM,IAAI,CAAC;KACtE,CAAC;IACF,QAAQ,EAAE;QACR,sBAAsB,EAAE,MAAM,IAAI,CAAC;QACnC,kBAAkB,CAAC,QAAQ,EAAE,0BAA0B,GAAG,MAAM,IAAI,CAAC;KACtE,CAAC;CACH;AA0CD,eAAO,MAAQ,YAAY,wBAAE,oBAAoB,wBAAc,CAAC"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"lib/default/","sources":["internal/plugins/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAA2B,MAAM,8BAA8B,CAAC;AAI7G,UAAU,QAAQ;IAChB,YAAY,EAAE;QACZ,SAAS,EAAE,gBAAgB,CAAC;QAC5B,KAAK,EAAE,gBAAgB,CAAC;QACxB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,CAAC;IACF,oBAAoB,EAAE;QACpB,SAAS,EAAE,kBAAkB,CAAC;QAC9B,KAAK,EAAE,kBAAkB,CAAC;QAC1B,QAAQ,EAAE,kBAAkB,CAAC;KAC9B,CAAC;CACH;AAwBD,wBAAgB,OAAO,aAQtB;AAED,eAAO,MAAQ,YAAY;eA3CZ,gBAAgB;WACpB,gBAAgB;cACb,gBAAgB;GAyCD,oBAAoB;eAtClC,kBAAkB;WACtB,kBAAkB;cACf,kBAAkB;CAoC+B,CAAC"}
@@ -19,49 +19,29 @@ function findUpApi(currentWindow) {
19
19
  return undefined;
20
20
  }
21
21
  }
22
- function loadApi() {
22
+ export function loadApi() {
23
23
  if (typeof window === 'undefined') {
24
- return createApi();
24
+ return installApi({});
25
25
  }
26
26
  const win = window;
27
- const api = findUpApi(win);
28
- if (api) {
29
- return api;
30
- }
31
- win[storageKey] = createApi();
27
+ const existingApi = findUpApi(win);
28
+ win[storageKey] = installApi(existingApi !== null && existingApi !== void 0 ? existingApi : {});
32
29
  return win[storageKey];
33
30
  }
34
31
  export const { awsuiPlugins, awsuiPluginsInternal } = loadApi();
35
- function createApi() {
32
+ function installApi(api) {
33
+ var _a, _b;
34
+ (_a = api.awsuiPlugins) !== null && _a !== void 0 ? _a : (api.awsuiPlugins = {});
35
+ (_b = api.awsuiPluginsInternal) !== null && _b !== void 0 ? _b : (api.awsuiPluginsInternal = {});
36
36
  const appLayoutDrawers = new DrawersController();
37
+ api.awsuiPlugins.appLayout = appLayoutDrawers.installPublic(api.awsuiPlugins.appLayout);
38
+ api.awsuiPluginsInternal.appLayout = appLayoutDrawers.installInternal(api.awsuiPluginsInternal.appLayout);
37
39
  const alertActions = new ActionButtonsController();
40
+ api.awsuiPlugins.alert = alertActions.installPublic(api.awsuiPlugins.alert);
41
+ api.awsuiPluginsInternal.alert = alertActions.installInternal(api.awsuiPluginsInternal.alert);
38
42
  const flashbarActions = new ActionButtonsController();
39
- return {
40
- awsuiPlugins: {
41
- appLayout: {
42
- registerDrawer: appLayoutDrawers.registerDrawer,
43
- },
44
- alert: {
45
- registerAction: alertActions.registerAction,
46
- },
47
- flashbar: {
48
- registerAction: flashbarActions.registerAction,
49
- },
50
- },
51
- awsuiPluginsInternal: {
52
- appLayout: {
53
- clearRegisteredDrawers: appLayoutDrawers.clearRegisteredDrawers,
54
- onDrawersRegistered: appLayoutDrawers.onDrawersRegistered,
55
- },
56
- alert: {
57
- clearRegisteredActions: alertActions.clearRegisteredActions,
58
- onActionRegistered: alertActions.onActionRegistered,
59
- },
60
- flashbar: {
61
- clearRegisteredActions: flashbarActions.clearRegisteredActions,
62
- onActionRegistered: flashbarActions.onActionRegistered,
63
- },
64
- },
65
- };
43
+ api.awsuiPlugins.flashbar = flashbarActions.installPublic(api.awsuiPlugins.flashbar);
44
+ api.awsuiPluginsInternal.flashbar = flashbarActions.installInternal(api.awsuiPluginsInternal.flashbar);
45
+ return api;
66
46
  }
67
47
  //# sourceMappingURL=api.js.map