@wordpress/components 32.5.0 → 32.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/CHANGELOG.md +40 -0
- package/README.md +18 -4
- package/build/alignment-matrix-control/cell.cjs +3 -3
- package/build/alignment-matrix-control/cell.cjs.map +2 -2
- package/build/alignment-matrix-control/index.cjs +3 -3
- package/build/alignment-matrix-control/index.cjs.map +2 -2
- package/build/autocomplete/autocompleter-ui.cjs +75 -79
- package/build/autocomplete/autocompleter-ui.cjs.map +2 -2
- package/build/autocomplete/get-autocomplete-match.cjs +91 -0
- package/build/autocomplete/get-autocomplete-match.cjs.map +7 -0
- package/build/autocomplete/index.cjs +104 -107
- package/build/autocomplete/index.cjs.map +3 -3
- package/build/box-control/index.cjs +0 -8
- package/build/box-control/index.cjs.map +2 -2
- package/build/box-control/utils.cjs +1 -10
- package/build/box-control/utils.cjs.map +2 -2
- package/build/calendar/utils/use-localization-props.cjs +3 -2
- package/build/calendar/utils/use-localization-props.cjs.map +2 -2
- package/build/custom-gradient-picker/index.cjs.map +2 -2
- package/build/custom-select-control/index.cjs.map +3 -3
- package/build/custom-select-control-v2/custom-select.cjs +2 -2
- package/build/custom-select-control-v2/custom-select.cjs.map +2 -2
- package/build/custom-select-control-v2/index.cjs.map +3 -3
- package/build/date-time/{date → date-picker}/index.cjs +6 -6
- package/build/date-time/{date → date-picker}/index.cjs.map +2 -2
- package/build/date-time/{date → date-picker}/styles.cjs +17 -17
- package/build/date-time/{date → date-picker}/styles.cjs.map +2 -2
- package/build/date-time/{date → date-picker}/use-lilius/index.cjs +1 -1
- package/build/date-time/{date → date-picker}/use-lilius/index.cjs.map +1 -1
- package/build/date-time/date-time/index.cjs +6 -6
- package/build/date-time/date-time/index.cjs.map +2 -2
- package/build/date-time/index.cjs +4 -4
- package/build/date-time/index.cjs.map +2 -2
- package/build/date-time/{time → time-picker}/index.cjs +6 -6
- package/build/date-time/time-picker/index.cjs.map +7 -0
- package/build/date-time/{time → time-picker}/styles.cjs +21 -21
- package/build/date-time/{time → time-picker}/styles.cjs.map +2 -2
- package/build/date-time/{time → time-picker}/time-input/index.cjs +1 -1
- package/build/date-time/{time → time-picker}/time-input/index.cjs.map +1 -1
- package/build/date-time/{time → time-picker}/timezone.cjs +1 -1
- package/build/date-time/{time → time-picker}/timezone.cjs.map +1 -1
- package/build/modal/index.cjs.map +2 -2
- package/build/palette-edit/index.cjs.map +2 -2
- package/build/radio-control/index.cjs +2 -0
- package/build/radio-control/index.cjs.map +2 -2
- package/build/sandbox/index.cjs +127 -3
- package/build/sandbox/index.cjs.map +2 -2
- package/build/textarea-control/styles/textarea-control-styles.cjs +3 -3
- package/build/textarea-control/styles/textarea-control-styles.cjs.map +2 -2
- package/build/validated-form-controls/control-with-error.cjs +12 -8
- package/build/validated-form-controls/control-with-error.cjs.map +2 -2
- package/build-module/alignment-matrix-control/cell.mjs +3 -3
- package/build-module/alignment-matrix-control/cell.mjs.map +2 -2
- package/build-module/alignment-matrix-control/index.mjs +3 -3
- package/build-module/alignment-matrix-control/index.mjs.map +2 -2
- package/build-module/autocomplete/autocompleter-ui.mjs +74 -78
- package/build-module/autocomplete/autocompleter-ui.mjs.map +2 -2
- package/build-module/autocomplete/get-autocomplete-match.mjs +56 -0
- package/build-module/autocomplete/get-autocomplete-match.mjs.map +7 -0
- package/build-module/autocomplete/index.mjs +103 -107
- package/build-module/autocomplete/index.mjs.map +3 -3
- package/build-module/box-control/index.mjs +1 -9
- package/build-module/box-control/index.mjs.map +2 -2
- package/build-module/box-control/utils.mjs +1 -9
- package/build-module/box-control/utils.mjs.map +2 -2
- package/build-module/calendar/utils/use-localization-props.mjs +3 -2
- package/build-module/calendar/utils/use-localization-props.mjs.map +2 -2
- package/build-module/custom-gradient-picker/index.mjs.map +2 -2
- package/build-module/custom-select-control/index.mjs +2 -2
- package/build-module/custom-select-control/index.mjs.map +2 -2
- package/build-module/custom-select-control-v2/custom-select.mjs +2 -2
- package/build-module/custom-select-control-v2/custom-select.mjs.map +2 -2
- package/build-module/custom-select-control-v2/index.mjs +2 -2
- package/build-module/custom-select-control-v2/index.mjs.map +2 -2
- package/build-module/date-time/{date → date-picker}/index.mjs +3 -3
- package/build-module/date-time/{date → date-picker}/index.mjs.map +2 -2
- package/build-module/date-time/{date → date-picker}/styles.mjs +17 -17
- package/build-module/date-time/{date → date-picker}/styles.mjs.map +2 -2
- package/build-module/date-time/{date → date-picker}/use-lilius/index.mjs +1 -1
- package/build-module/date-time/{date → date-picker}/use-lilius/index.mjs.map +1 -1
- package/build-module/date-time/date-time/index.mjs +2 -2
- package/build-module/date-time/date-time/index.mjs.map +1 -1
- package/build-module/date-time/index.mjs +2 -2
- package/build-module/date-time/index.mjs.map +1 -1
- package/build-module/date-time/{time → time-picker}/index.mjs +3 -3
- package/build-module/date-time/time-picker/index.mjs.map +7 -0
- package/build-module/date-time/{time → time-picker}/styles.mjs +21 -21
- package/build-module/date-time/{time → time-picker}/styles.mjs.map +2 -2
- package/build-module/date-time/{time → time-picker}/time-input/index.mjs +1 -1
- package/build-module/date-time/{time → time-picker}/time-input/index.mjs.map +1 -1
- package/build-module/date-time/{time → time-picker}/timezone.mjs +1 -1
- package/build-module/date-time/{time → time-picker}/timezone.mjs.map +1 -1
- package/build-module/modal/index.mjs.map +2 -2
- package/build-module/palette-edit/index.mjs.map +2 -2
- package/build-module/radio-control/index.mjs +2 -0
- package/build-module/radio-control/index.mjs.map +2 -2
- package/build-module/sandbox/index.mjs +128 -4
- package/build-module/sandbox/index.mjs.map +2 -2
- package/build-module/textarea-control/styles/textarea-control-styles.mjs +3 -3
- package/build-module/textarea-control/styles/textarea-control-styles.mjs.map +2 -2
- package/build-module/validated-form-controls/control-with-error.mjs +12 -8
- package/build-module/validated-form-controls/control-with-error.mjs.map +2 -2
- package/build-style/style-rtl.css +83 -26
- package/build-style/style.css +83 -26
- package/build-types/autocomplete/autocompleter-ui.d.ts +2 -2
- package/build-types/autocomplete/autocompleter-ui.d.ts.map +1 -1
- package/build-types/autocomplete/get-autocomplete-match.d.ts +11 -0
- package/build-types/autocomplete/get-autocomplete-match.d.ts.map +1 -0
- package/build-types/autocomplete/index.d.ts +8 -0
- package/build-types/autocomplete/index.d.ts.map +1 -1
- package/build-types/autocomplete/test/get-autocomplete-match.d.ts +2 -0
- package/build-types/autocomplete/test/get-autocomplete-match.d.ts.map +1 -0
- package/build-types/autocomplete/types.d.ts +23 -9
- package/build-types/autocomplete/types.d.ts.map +1 -1
- package/build-types/box-control/index.d.ts.map +1 -1
- package/build-types/box-control/utils.d.ts +7 -16
- package/build-types/box-control/utils.d.ts.map +1 -1
- package/build-types/button/stories/index.story.d.ts +0 -1
- package/build-types/button/stories/index.story.d.ts.map +1 -1
- package/build-types/calendar/utils/use-localization-props.d.ts +3 -3
- package/build-types/calendar/utils/use-localization-props.d.ts.map +1 -1
- package/build-types/checkbox-control/types.d.ts +4 -0
- package/build-types/checkbox-control/types.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/constants.d.ts +2 -2
- package/build-types/custom-gradient-picker/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/custom-select.d.ts +3 -3
- package/build-types/custom-select-control-v2/custom-select.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/types.d.ts +1 -1
- package/build-types/custom-select-control-v2/types.d.ts.map +1 -1
- package/build-types/date-time/date-picker/index.d.ts.map +1 -0
- package/build-types/date-time/date-picker/styles.d.ts.map +1 -0
- package/build-types/date-time/date-picker/test/index.d.ts.map +1 -0
- package/build-types/date-time/date-picker/test/use-lilius.d.ts.map +1 -0
- package/build-types/date-time/date-picker/use-lilius/index.d.ts.map +1 -0
- package/build-types/date-time/date-time/index.d.ts +2 -2
- package/build-types/date-time/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/index.d.ts +2 -2
- package/build-types/date-time/index.d.ts.map +1 -1
- package/build-types/date-time/stories/date.story.d.ts +1 -1
- package/build-types/date-time/stories/date.story.d.ts.map +1 -1
- package/build-types/date-time/stories/time.story.d.ts +1 -1
- package/build-types/date-time/stories/time.story.d.ts.map +1 -1
- package/build-types/date-time/{time → time-picker}/index.d.ts +1 -1
- package/build-types/date-time/time-picker/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/styles.d.ts.map +1 -0
- package/build-types/date-time/time-picker/test/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/time-input/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/time-input/test/index.d.ts.map +1 -0
- package/build-types/date-time/time-picker/timezone.d.ts.map +1 -0
- package/build-types/date-time/types.d.ts +1 -1
- package/build-types/date-time/types.d.ts.map +1 -1
- package/build-types/font-size-picker/constants.d.ts +2 -2
- package/build-types/font-size-picker/constants.d.ts.map +1 -1
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/palette-edit/index.d.ts +1 -1
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/radio-control/index.d.ts.map +1 -1
- package/build-types/radio-control/types.d.ts +6 -0
- package/build-types/radio-control/types.d.ts.map +1 -1
- package/build-types/sandbox/index.d.ts +1 -1
- package/build-types/sandbox/index.d.ts.map +1 -1
- package/build-types/sandbox/types.d.ts +11 -0
- package/build-types/sandbox/types.d.ts.map +1 -1
- package/build-types/textarea-control/stories/index.story.d.ts.map +1 -1
- package/build-types/textarea-control/styles/textarea-control-styles.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts +2 -1
- package/build-types/validated-form-controls/components/checkbox-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts +2 -1
- package/build-types/validated-form-controls/components/radio-control.d.ts.map +1 -1
- package/build-types/validated-form-controls/control-with-error.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/alignment-matrix-control/README.md +1 -1
- package/src/alignment-matrix-control/style.module.scss +1 -1
- package/src/angle-picker-control/style.module.scss +1 -0
- package/src/autocomplete/README.md +2 -2
- package/src/autocomplete/autocompleter-ui.native.js +166 -173
- package/src/autocomplete/autocompleter-ui.tsx +114 -116
- package/src/autocomplete/get-autocomplete-match.ts +115 -0
- package/src/autocomplete/index.tsx +129 -208
- package/src/autocomplete/test/get-autocomplete-match.ts +338 -0
- package/src/autocomplete/test/index.tsx +112 -4
- package/src/autocomplete/types.ts +17 -10
- package/src/box-control/index.tsx +1 -19
- package/src/box-control/utils.ts +1 -19
- package/src/button/README.md +1 -1
- package/src/button/stories/index.story.tsx +0 -1
- package/src/button/style.scss +1 -7
- package/src/calendar/style.scss +3 -3
- package/src/calendar/utils/use-localization-props.ts +3 -4
- package/src/checkbox-control/style.scss +17 -5
- package/src/checkbox-control/types.ts +4 -0
- package/src/circular-option-picker/style.scss +1 -1
- package/src/color-palette/style.scss +1 -1
- package/src/css.d.ts +1 -0
- package/src/custom-gradient-picker/index.tsx +1 -0
- package/src/custom-select-control/index.tsx +3 -3
- package/src/custom-select-control-v2/custom-select.tsx +4 -4
- package/src/custom-select-control-v2/index.tsx +2 -2
- package/src/custom-select-control-v2/types.ts +1 -1
- package/src/date-time/README.md +3 -3
- package/src/date-time/date-picker/README.md +65 -0
- package/src/date-time/date-time/index.tsx +2 -2
- package/src/date-time/index.ts +2 -2
- package/src/date-time/stories/date.story.tsx +1 -1
- package/src/date-time/stories/time.story.tsx +1 -1
- package/src/date-time/time-picker/README.md +119 -0
- package/src/date-time/{time → time-picker}/index.tsx +1 -1
- package/src/date-time/types.ts +1 -1
- package/src/divider/README.md +5 -6
- package/src/dropdown-menu/style.scss +1 -1
- package/src/flex/stories/index.story.tsx +1 -1
- package/src/form-file-upload/README.md +3 -3
- package/src/form-toggle/style.scss +35 -2
- package/src/form-token-field/style.scss +12 -3
- package/src/gradient-picker/README.md +2 -2
- package/src/h-stack/README.md +10 -15
- package/src/h-stack/stories/index.story.tsx +2 -2
- package/src/heading/stories/index.story.tsx +1 -1
- package/src/higher-order/with-focus-outside/index.native.js +21 -20
- package/src/icon/README.md +1 -1
- package/src/menu/README.md +2 -2
- package/src/mobile/utils/get-px-from-css-unit.native.js +1 -1
- package/src/modal/index.tsx +1 -0
- package/src/palette-edit/index.tsx +1 -0
- package/src/radio-control/index.tsx +2 -0
- package/src/radio-control/style.scss +21 -2
- package/src/radio-control/test/index.tsx +10 -0
- package/src/radio-control/types.ts +6 -0
- package/src/sandbox/index.native.js +2 -2
- package/src/sandbox/index.tsx +191 -11
- package/src/sandbox/test/index.tsx +65 -24
- package/src/sandbox/types.ts +11 -0
- package/src/snackbar/style.scss +2 -2
- package/src/tab-panel/style.scss +1 -1
- package/src/tabs/README.md +6 -6
- package/src/text/stories/index.story.tsx +1 -1
- package/src/textarea-control/stories/index.story.tsx +3 -0
- package/src/textarea-control/styles/textarea-control-styles.ts +6 -0
- package/src/toggle-control/style.scss +1 -1
- package/src/toggle-control/test/index.tsx +8 -2
- package/src/toolbar/toolbar-button/toolbar-button-container.native.js +3 -1
- package/src/tree-select/README.md +1 -1
- package/src/v-stack/README.md +10 -15
- package/src/v-stack/stories/index.story.tsx +2 -2
- package/src/validated-form-controls/control-with-error.tsx +17 -12
- package/src/validated-form-controls/test/control-with-error.tsx +28 -1
- package/src/view/README.md +2 -5
- package/build/date-time/time/index.cjs.map +0 -7
- package/build-module/date-time/time/index.mjs.map +0 -7
- package/build-types/date-time/date/index.d.ts.map +0 -1
- package/build-types/date-time/date/styles.d.ts.map +0 -1
- package/build-types/date-time/date/test/index.d.ts.map +0 -1
- package/build-types/date-time/date/test/use-lilius.d.ts.map +0 -1
- package/build-types/date-time/date/use-lilius/index.d.ts.map +0 -1
- package/build-types/date-time/time/index.d.ts.map +0 -1
- package/build-types/date-time/time/styles.d.ts.map +0 -1
- package/build-types/date-time/time/test/index.d.ts.map +0 -1
- package/build-types/date-time/time/time-input/index.d.ts.map +0 -1
- package/build-types/date-time/time/time-input/test/index.d.ts.map +0 -1
- package/build-types/date-time/time/timezone.d.ts.map +0 -1
- package/src/button/stories/style.css +0 -8
- /package/build-types/date-time/{date → date-picker}/index.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/styles.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/test/index.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/test/use-lilius.d.ts +0 -0
- /package/build-types/date-time/{date → date-picker}/use-lilius/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/styles.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/test/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/time-input/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/time-input/test/index.d.ts +0 -0
- /package/build-types/date-time/{time → time-picker}/timezone.d.ts +0 -0
- /package/src/date-time/{date → date-picker}/index.tsx +0 -0
- /package/src/date-time/{date → date-picker}/styles.ts +0 -0
- /package/src/date-time/{date → date-picker}/test/index.tsx +0 -0
- /package/src/date-time/{date → date-picker}/test/use-lilius.ts +0 -0
- /package/src/date-time/{date → date-picker}/use-lilius/index.ts +0 -0
- /package/src/date-time/{time → time-picker}/styles.ts +0 -0
- /package/src/date-time/{time → time-picker}/test/index.tsx +0 -0
- /package/src/date-time/{time → time-picker}/time-input/index.tsx +0 -0
- /package/src/date-time/{time → time-picker}/time-input/test/index.tsx +0 -0
- /package/src/date-time/{time → time-picker}/timezone.tsx +0 -0
package/src/h-stack/README.md
CHANGED
|
@@ -11,17 +11,14 @@ This feature is still experimental. “Experimental” means this is an early im
|
|
|
11
11
|
`HStack` can render anything inside.
|
|
12
12
|
|
|
13
13
|
```jsx
|
|
14
|
-
import {
|
|
15
|
-
__experimentalHStack as HStack,
|
|
16
|
-
__experimentalText as Text,
|
|
17
|
-
} from '@wordpress/components';
|
|
14
|
+
import { __experimentalHStack as HStack } from '@wordpress/components';
|
|
18
15
|
|
|
19
16
|
function Example() {
|
|
20
17
|
return (
|
|
21
18
|
<HStack>
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
<
|
|
19
|
+
<span>Code</span>
|
|
20
|
+
<span>is</span>
|
|
21
|
+
<span>Poetry</span>
|
|
25
22
|
</HStack>
|
|
26
23
|
);
|
|
27
24
|
}
|
|
@@ -87,17 +84,16 @@ When a `Spacer` is used within an `HStack`, the `Spacer` adaptively expands to t
|
|
|
87
84
|
import {
|
|
88
85
|
__experimentalHStack as HStack,
|
|
89
86
|
__experimentalSpacer as Spacer,
|
|
90
|
-
__experimentalText as Text,
|
|
91
87
|
} from '@wordpress/components';
|
|
92
88
|
|
|
93
89
|
function Example() {
|
|
94
90
|
return (
|
|
95
91
|
<HStack>
|
|
96
|
-
<
|
|
92
|
+
<span>Code</span>
|
|
97
93
|
<Spacer>
|
|
98
|
-
<
|
|
94
|
+
<span>is</span>
|
|
99
95
|
</Spacer>
|
|
100
|
-
<
|
|
96
|
+
<span>Poetry</span>
|
|
101
97
|
</HStack>
|
|
102
98
|
);
|
|
103
99
|
}
|
|
@@ -109,16 +105,15 @@ function Example() {
|
|
|
109
105
|
import {
|
|
110
106
|
__experimentalHStack as HStack,
|
|
111
107
|
__experimentalSpacer as Spacer,
|
|
112
|
-
__experimentalText as Text,
|
|
113
108
|
} from '@wordpress/components';
|
|
114
109
|
|
|
115
110
|
function Example() {
|
|
116
111
|
return (
|
|
117
112
|
<HStack>
|
|
118
|
-
<
|
|
113
|
+
<span>Code</span>
|
|
119
114
|
<Spacer />
|
|
120
|
-
<
|
|
121
|
-
<
|
|
115
|
+
<span>is</span>
|
|
116
|
+
<span>Poetry</span>
|
|
122
117
|
</HStack>
|
|
123
118
|
);
|
|
124
119
|
}
|
|
@@ -75,9 +75,9 @@ const meta: Meta< typeof HStack > = {
|
|
|
75
75
|
controls: { expanded: true },
|
|
76
76
|
docs: { canvas: { sourceState: 'shown' } },
|
|
77
77
|
componentStatus: {
|
|
78
|
-
status: '
|
|
78
|
+
status: 'not-recommended',
|
|
79
79
|
whereUsed: 'global',
|
|
80
|
-
notes: '
|
|
80
|
+
notes: 'Use `Stack` from `@wordpress/ui` instead.',
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
83
|
};
|
|
@@ -32,7 +32,7 @@ const meta: Meta< typeof Heading > = {
|
|
|
32
32
|
componentStatus: {
|
|
33
33
|
status: 'not-recommended',
|
|
34
34
|
whereUsed: 'global',
|
|
35
|
-
notes: '
|
|
35
|
+
notes: 'Use `Text` from `@wordpress/ui` instead, with the `render` prop set to the heading level element and the variant set to the visual heading size (e.g. `<Text render={ <h1 /> } variant="heading-2xl">`).',
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
};
|
|
@@ -12,26 +12,27 @@ import {
|
|
|
12
12
|
} from '@wordpress/compose';
|
|
13
13
|
|
|
14
14
|
export default createHigherOrderComponent(
|
|
15
|
-
( WrappedComponent ) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
( WrappedComponent ) =>
|
|
16
|
+
function WithFocusOutside( props ) {
|
|
17
|
+
const [ handleFocusOutside, setHandleFocusOutside ] = useState();
|
|
18
|
+
const bindFocusOutsideHandler = useCallback(
|
|
19
|
+
( node ) =>
|
|
20
|
+
setHandleFocusOutside( () =>
|
|
21
|
+
node?.handleFocusOutside
|
|
22
|
+
? node.handleFocusOutside.bind( node )
|
|
23
|
+
: undefined
|
|
24
|
+
),
|
|
25
|
+
[]
|
|
26
|
+
);
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
return (
|
|
29
|
+
<View { ...useFocusOutside( handleFocusOutside ) }>
|
|
30
|
+
<WrappedComponent
|
|
31
|
+
ref={ bindFocusOutsideHandler }
|
|
32
|
+
{ ...props }
|
|
33
|
+
/>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
},
|
|
36
37
|
'withFocusOutside'
|
|
37
38
|
);
|
package/src/icon/README.md
CHANGED
package/src/menu/README.md
CHANGED
|
@@ -19,7 +19,7 @@ component, and the `Menu.Popover` component.
|
|
|
19
19
|
|
|
20
20
|
### `as`
|
|
21
21
|
|
|
22
|
-
- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | ...
|
|
22
|
+
- Type: `"symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | ... 517 more ...`
|
|
23
23
|
- Required: No
|
|
24
24
|
|
|
25
25
|
The HTML element or React component to render the component as.
|
|
@@ -57,7 +57,7 @@ override the `defaultOpen` prop.
|
|
|
57
57
|
|
|
58
58
|
### `onOpenChange`
|
|
59
59
|
|
|
60
|
-
- Type: `(open: boolean) => void`
|
|
60
|
+
- Type: `((open: boolean) => void)`
|
|
61
61
|
- Required: No
|
|
62
62
|
|
|
63
63
|
A callback that gets called when the `open` state changes.
|
package/src/modal/index.tsx
CHANGED
|
@@ -121,6 +121,7 @@ function UnforwardedModal(
|
|
|
121
121
|
const onRequestCloseRef =
|
|
122
122
|
useRef< ModalProps[ 'onRequestClose' ] >( undefined );
|
|
123
123
|
useEffect( () => {
|
|
124
|
+
// eslint-disable-next-line react-compiler/react-compiler -- false positive, see https://github.com/facebook/react/issues/29196
|
|
124
125
|
onRequestCloseRef.current = onRequestClose;
|
|
125
126
|
}, [ onRequestClose ] );
|
|
126
127
|
|
|
@@ -299,6 +299,7 @@ function PaletteEditListView< T extends PaletteElement >( {
|
|
|
299
299
|
// When unmounting the component if there are empty elements (the user did not complete the insertion) clean them.
|
|
300
300
|
const elementsReferenceRef = useRef< T[] >( undefined );
|
|
301
301
|
useEffect( () => {
|
|
302
|
+
// eslint-disable-next-line react-compiler/react-compiler -- false positive, see https://github.com/facebook/react/issues/29196
|
|
302
303
|
elementsReferenceRef.current = elements;
|
|
303
304
|
}, [ elements ] );
|
|
304
305
|
|
|
@@ -67,6 +67,7 @@ export function RadioControl(
|
|
|
67
67
|
onChange,
|
|
68
68
|
onClick,
|
|
69
69
|
hideLabelFromVision,
|
|
70
|
+
disabled,
|
|
70
71
|
options = [],
|
|
71
72
|
id: preferredId,
|
|
72
73
|
...additionalProps
|
|
@@ -89,6 +90,7 @@ export function RadioControl(
|
|
|
89
90
|
id={ id }
|
|
90
91
|
role="radiogroup"
|
|
91
92
|
className={ clsx( className, 'components-radio-control' ) }
|
|
93
|
+
disabled={ disabled }
|
|
92
94
|
aria-describedby={ !! help ? generateHelpId( id ) : undefined }
|
|
93
95
|
>
|
|
94
96
|
{ hideLabelFromVision ? (
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
font-family: $default-font;
|
|
12
12
|
font-size: $default-font-size;
|
|
13
|
+
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
.components-radio-control__group-wrapper.has-help {
|
|
@@ -34,7 +35,10 @@
|
|
|
34
35
|
margin: 0;
|
|
35
36
|
padding: 0;
|
|
36
37
|
appearance: none;
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
&:not(:disabled) {
|
|
40
|
+
cursor: var(--wpds-cursor-control);
|
|
41
|
+
}
|
|
38
42
|
|
|
39
43
|
&:focus {
|
|
40
44
|
@include button-style-outset__focus(var(--wp-admin-theme-color));
|
|
@@ -49,13 +53,28 @@
|
|
|
49
53
|
border-radius: $radius-round;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
56
|
+
|
|
57
|
+
&:disabled {
|
|
58
|
+
background: $components-color-gray-100;
|
|
59
|
+
border: 1px solid $components-color-gray-300;
|
|
60
|
+
opacity: 1; // Override style from wp-admin forms.css.
|
|
61
|
+
|
|
62
|
+
&:checked::before {
|
|
63
|
+
border-color: $components-color-gray-400;
|
|
64
|
+
opacity: 1; // Override style from wp-admin forms.css.
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
.components-radio-control__label {
|
|
55
71
|
grid-column: 2;
|
|
56
72
|
grid-row: 1;
|
|
57
73
|
|
|
58
|
-
|
|
74
|
+
.components-radio-control:not(:disabled) & {
|
|
75
|
+
cursor: var(--wpds-cursor-control);
|
|
76
|
+
}
|
|
77
|
+
|
|
59
78
|
line-height: $radio-input-size-sm;
|
|
60
79
|
|
|
61
80
|
@include break-small() {
|
|
@@ -82,6 +82,16 @@ describe.each( [
|
|
|
82
82
|
).toBeVisible();
|
|
83
83
|
} );
|
|
84
84
|
|
|
85
|
+
it( 'should disable the radio group when `disabled` is true', () => {
|
|
86
|
+
render(
|
|
87
|
+
<Component { ...defaultProps } disabled onChange={ () => {} } />
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
expect(
|
|
91
|
+
screen.getByRole( 'radiogroup', { name: defaultProps.label } )
|
|
92
|
+
).toBeDisabled();
|
|
93
|
+
} );
|
|
94
|
+
|
|
85
95
|
it( 'should describe the radio group with the help text', () => {
|
|
86
96
|
const onChangeSpy = jest.fn();
|
|
87
97
|
render(
|
|
@@ -7,6 +7,12 @@ export type RadioControlProps = Pick<
|
|
|
7
7
|
BaseControlProps,
|
|
8
8
|
'label' | 'help' | 'hideLabelFromVision'
|
|
9
9
|
> & {
|
|
10
|
+
/**
|
|
11
|
+
* Whether the radio group should be disabled.
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
10
16
|
/**
|
|
11
17
|
* A function that receives the value of the new option that is being
|
|
12
18
|
* selected as input.
|
|
@@ -172,7 +172,7 @@ const style = `
|
|
|
172
172
|
|
|
173
173
|
const EMPTY_ARRAY = [];
|
|
174
174
|
|
|
175
|
-
const Sandbox = forwardRef( function
|
|
175
|
+
const Sandbox = forwardRef( function UnforwardedSandbox(
|
|
176
176
|
{
|
|
177
177
|
containerStyle,
|
|
178
178
|
customJS,
|
|
@@ -297,7 +297,7 @@ const Sandbox = forwardRef( function Sandbox(
|
|
|
297
297
|
|
|
298
298
|
try {
|
|
299
299
|
data = JSON.parse( data );
|
|
300
|
-
} catch
|
|
300
|
+
} catch {
|
|
301
301
|
return;
|
|
302
302
|
}
|
|
303
303
|
|
package/src/sandbox/index.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useRef,
|
|
7
7
|
useState,
|
|
8
8
|
useEffect,
|
|
9
|
+
useMemo,
|
|
9
10
|
} from '@wordpress/element';
|
|
10
11
|
import { useFocusableIframe, useMergeRefs } from '@wordpress/compose';
|
|
11
12
|
|
|
@@ -14,6 +15,8 @@ import { useFocusableIframe, useMergeRefs } from '@wordpress/compose';
|
|
|
14
15
|
*/
|
|
15
16
|
import type { SandBoxProps } from './types';
|
|
16
17
|
|
|
18
|
+
type SandBoxContentProps = Omit< SandBoxProps, 'allowSameOrigin' >;
|
|
19
|
+
|
|
17
20
|
const observeAndResizeJS = function () {
|
|
18
21
|
const { MutationObserver } = window;
|
|
19
22
|
|
|
@@ -115,17 +118,176 @@ const style = `
|
|
|
115
118
|
`;
|
|
116
119
|
|
|
117
120
|
/**
|
|
118
|
-
*
|
|
121
|
+
* Builds the full HTML document string for the sandbox iframe content.
|
|
122
|
+
*/
|
|
123
|
+
function buildSandBoxDocument( {
|
|
124
|
+
html,
|
|
125
|
+
title,
|
|
126
|
+
type,
|
|
127
|
+
styles,
|
|
128
|
+
scripts,
|
|
129
|
+
}: {
|
|
130
|
+
html: string;
|
|
131
|
+
title: string;
|
|
132
|
+
type?: string;
|
|
133
|
+
styles: string[];
|
|
134
|
+
scripts: string[];
|
|
135
|
+
} ): string {
|
|
136
|
+
const htmlDoc = (
|
|
137
|
+
<html lang={ document.documentElement.lang } className={ type }>
|
|
138
|
+
<head>
|
|
139
|
+
<title>{ title }</title>
|
|
140
|
+
<style dangerouslySetInnerHTML={ { __html: style } } />
|
|
141
|
+
{ styles.map( ( rules, i ) => (
|
|
142
|
+
<style
|
|
143
|
+
key={ i }
|
|
144
|
+
dangerouslySetInnerHTML={ { __html: rules } }
|
|
145
|
+
/>
|
|
146
|
+
) ) }
|
|
147
|
+
</head>
|
|
148
|
+
<body
|
|
149
|
+
data-resizable-iframe-connected="data-resizable-iframe-connected"
|
|
150
|
+
className={ type }
|
|
151
|
+
>
|
|
152
|
+
<div dangerouslySetInnerHTML={ { __html: html } } />
|
|
153
|
+
<script
|
|
154
|
+
type="text/javascript"
|
|
155
|
+
dangerouslySetInnerHTML={ {
|
|
156
|
+
__html: `(${ observeAndResizeJS.toString() })();`,
|
|
157
|
+
} }
|
|
158
|
+
/>
|
|
159
|
+
{ scripts.map( ( src ) => (
|
|
160
|
+
<script key={ src } src={ src } />
|
|
161
|
+
) ) }
|
|
162
|
+
</body>
|
|
163
|
+
</html>
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return '<!DOCTYPE html>' + renderToString( htmlDoc );
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Isolated sandbox that uses the `srcdoc` attribute to render content
|
|
171
|
+
* without `allow-same-origin`. This is the default for user-controlled
|
|
172
|
+
* content (e.g., the HTML block) where same-origin access would be a
|
|
173
|
+
* security risk.
|
|
119
174
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
175
|
+
* Because `srcdoc` is a declarative attribute, the browser automatically
|
|
176
|
+
* re-renders the content when the iframe is moved in the DOM (e.g.,
|
|
177
|
+
* block reordering), so no `load` event listener is needed.
|
|
178
|
+
* The `message` listener is re-synced on every `load` so
|
|
179
|
+
* it follows the iframe if it's reparented into a different document.
|
|
180
|
+
*/
|
|
181
|
+
function IsolatedSandBox( {
|
|
182
|
+
html = '',
|
|
183
|
+
title = '',
|
|
184
|
+
type,
|
|
185
|
+
styles = [],
|
|
186
|
+
scripts = [],
|
|
187
|
+
onFocus,
|
|
188
|
+
tabIndex,
|
|
189
|
+
}: SandBoxContentProps ) {
|
|
190
|
+
const ref = useRef< HTMLIFrameElement >( null );
|
|
191
|
+
const [ width, setWidth ] = useState( 0 );
|
|
192
|
+
const [ height, setHeight ] = useState( 0 );
|
|
193
|
+
|
|
194
|
+
const srcDoc = useMemo(
|
|
195
|
+
() => buildSandBoxDocument( { html, title, type, styles, scripts } ),
|
|
196
|
+
[ html, title, type, styles, scripts ]
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
useEffect( () => {
|
|
200
|
+
const iframe = ref.current;
|
|
201
|
+
if ( ! iframe ) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function checkMessageForResize( event: MessageEvent ) {
|
|
206
|
+
// Verify that the mounted element is the source of the message.
|
|
207
|
+
// iframe.contentWindow is accessible cross-origin as a
|
|
208
|
+
// WindowProxy reference, so this check still works without
|
|
209
|
+
// allow-same-origin.
|
|
210
|
+
if ( ! iframe || iframe.contentWindow !== event.source ) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Attempt to parse the message data as JSON if passed as string.
|
|
215
|
+
let data = event.data || {};
|
|
216
|
+
|
|
217
|
+
if ( 'string' === typeof data ) {
|
|
218
|
+
try {
|
|
219
|
+
data = JSON.parse( data );
|
|
220
|
+
} catch {}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Update the state only if the message is formatted as we expect,
|
|
224
|
+
// i.e. as an object with a 'resize' action.
|
|
225
|
+
if ( 'resize' !== data.action ) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
setWidth( data.width );
|
|
230
|
+
setHeight( data.height );
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
let currentView: Window | null = null;
|
|
234
|
+
function syncListener() {
|
|
235
|
+
const view = iframe?.ownerDocument?.defaultView ?? null;
|
|
236
|
+
if ( view === currentView ) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
currentView?.removeEventListener(
|
|
241
|
+
'message',
|
|
242
|
+
checkMessageForResize
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
currentView = view;
|
|
246
|
+
currentView?.addEventListener( 'message', checkMessageForResize );
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
syncListener();
|
|
250
|
+
iframe.addEventListener( 'load', syncListener );
|
|
251
|
+
|
|
252
|
+
return () => {
|
|
253
|
+
iframe.removeEventListener( 'load', syncListener );
|
|
254
|
+
currentView?.removeEventListener(
|
|
255
|
+
'message',
|
|
256
|
+
checkMessageForResize
|
|
257
|
+
);
|
|
258
|
+
};
|
|
259
|
+
}, [] );
|
|
260
|
+
|
|
261
|
+
return (
|
|
262
|
+
<iframe
|
|
263
|
+
ref={ useMergeRefs( [ ref, useFocusableIframe() ] ) }
|
|
264
|
+
title={ title }
|
|
265
|
+
tabIndex={ tabIndex }
|
|
266
|
+
className="components-sandbox"
|
|
267
|
+
sandbox="allow-scripts allow-presentation"
|
|
268
|
+
srcDoc={ srcDoc }
|
|
269
|
+
onFocus={ onFocus }
|
|
270
|
+
width={ Math.ceil( width ) }
|
|
271
|
+
height={ Math.ceil( height ) }
|
|
272
|
+
/>
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Same-origin sandbox that writes to `contentDocument` directly. This
|
|
278
|
+
* preserves the parent page's URL as the iframe's document URL, which
|
|
279
|
+
* provides a valid Referer header for nested iframes (required by
|
|
280
|
+
* providers like YouTube).
|
|
122
281
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
282
|
+
* Only used when `allowSameOrigin` is true — i.e., for server-fetched
|
|
283
|
+
* oEmbed previews that are not directly user-controlled.
|
|
284
|
+
*
|
|
285
|
+
* This implementation is intentionally kept close to the original
|
|
286
|
+
* pre-refactor code to preserve past bugfixes:
|
|
287
|
+
* - load listener for iframe re-initialization after DOM moves (#21916)
|
|
288
|
+
* - forceRerender guard to avoid unnecessary full rewrites (#20176)
|
|
127
289
|
*/
|
|
128
|
-
function
|
|
290
|
+
function SameOriginSandBox( {
|
|
129
291
|
html = '',
|
|
130
292
|
title = '',
|
|
131
293
|
type,
|
|
@@ -133,7 +295,7 @@ function SandBox( {
|
|
|
133
295
|
scripts = [],
|
|
134
296
|
onFocus,
|
|
135
297
|
tabIndex,
|
|
136
|
-
}:
|
|
298
|
+
}: SandBoxContentProps ) {
|
|
137
299
|
const ref = useRef< HTMLIFrameElement >( null );
|
|
138
300
|
const [ width, setWidth ] = useState( 0 );
|
|
139
301
|
const [ height, setHeight ] = useState( 0 );
|
|
@@ -141,7 +303,7 @@ function SandBox( {
|
|
|
141
303
|
function isFrameAccessible() {
|
|
142
304
|
try {
|
|
143
305
|
return !! ref.current?.contentDocument?.body;
|
|
144
|
-
} catch
|
|
306
|
+
} catch {
|
|
145
307
|
return false;
|
|
146
308
|
}
|
|
147
309
|
}
|
|
@@ -232,7 +394,7 @@ function SandBox( {
|
|
|
232
394
|
if ( 'string' === typeof data ) {
|
|
233
395
|
try {
|
|
234
396
|
data = JSON.parse( data );
|
|
235
|
-
} catch
|
|
397
|
+
} catch {}
|
|
236
398
|
}
|
|
237
399
|
|
|
238
400
|
// Update the state only if the message is formatted as we expect,
|
|
@@ -292,4 +454,22 @@ function SandBox( {
|
|
|
292
454
|
);
|
|
293
455
|
}
|
|
294
456
|
|
|
457
|
+
/**
|
|
458
|
+
* This component provides an isolated environment for arbitrary HTML via iframes.
|
|
459
|
+
*
|
|
460
|
+
* ```jsx
|
|
461
|
+
* import { SandBox } from '@wordpress/components';
|
|
462
|
+
*
|
|
463
|
+
* const MySandBox = () => (
|
|
464
|
+
* <SandBox html="<p>Content</p>" title="SandBox" type="embed" />
|
|
465
|
+
* );
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
function SandBox( { allowSameOrigin = false, ...contentProps }: SandBoxProps ) {
|
|
469
|
+
if ( allowSameOrigin ) {
|
|
470
|
+
return <SameOriginSandBox { ...contentProps } />;
|
|
471
|
+
}
|
|
472
|
+
return <IsolatedSandBox { ...contentProps } />;
|
|
473
|
+
}
|
|
474
|
+
|
|
295
475
|
export default SandBox;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { fireEvent, render, screen
|
|
4
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -16,10 +16,7 @@ import SandBox from '..';
|
|
|
16
16
|
describe( 'SandBox', () => {
|
|
17
17
|
const TestWrapper = () => {
|
|
18
18
|
const [ html, setHtml ] = useState(
|
|
19
|
-
|
|
20
|
-
// with iframes so we need to ignore it for the time being.
|
|
21
|
-
'<script type="text/javascript">window.MutationObserver = null;</script>' +
|
|
22
|
-
'<iframe title="Mock Iframe" src="https://super.embed"></iframe>'
|
|
19
|
+
'<iframe title="Mock Iframe" src="https://super.embed"></iframe>'
|
|
23
20
|
);
|
|
24
21
|
|
|
25
22
|
const updateHtml = () => {
|
|
@@ -38,34 +35,78 @@ describe( 'SandBox', () => {
|
|
|
38
35
|
);
|
|
39
36
|
};
|
|
40
37
|
|
|
41
|
-
it( 'should
|
|
38
|
+
it( 'should not include allow-same-origin by default', () => {
|
|
39
|
+
render( <SandBox html="<p>Hello</p>" title="Test" /> );
|
|
40
|
+
|
|
41
|
+
const iframe = screen.getByTitle< HTMLIFrameElement >( 'Test' );
|
|
42
|
+
|
|
43
|
+
expect( iframe ).toHaveAttribute(
|
|
44
|
+
'sandbox',
|
|
45
|
+
'allow-scripts allow-presentation'
|
|
46
|
+
);
|
|
47
|
+
expect( iframe.getAttribute( 'sandbox' ) ).not.toContain(
|
|
48
|
+
'allow-same-origin'
|
|
49
|
+
);
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
it( 'should set srcdoc with the provided html content', () => {
|
|
53
|
+
render( <SandBox html="<p>Hello</p>" title="Test Title" /> );
|
|
54
|
+
|
|
55
|
+
const iframe = screen.getByTitle< HTMLIFrameElement >( 'Test Title' );
|
|
56
|
+
const srcDoc = iframe.getAttribute( 'srcdoc' ) ?? '';
|
|
57
|
+
|
|
58
|
+
expect( srcDoc ).toContain( '<p>Hello</p>' );
|
|
59
|
+
expect( srcDoc ).toContain( '<title>Test Title</title>' );
|
|
60
|
+
} );
|
|
61
|
+
|
|
62
|
+
it( 'should include custom styles in srcdoc', () => {
|
|
63
|
+
render(
|
|
64
|
+
<SandBox
|
|
65
|
+
html="<p>Styled</p>"
|
|
66
|
+
title="Styled Test"
|
|
67
|
+
styles={ [ '.custom { color: red; }' ] }
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const iframe = screen.getByTitle< HTMLIFrameElement >( 'Styled Test' );
|
|
72
|
+
const srcDoc = iframe.getAttribute( 'srcdoc' ) ?? '';
|
|
73
|
+
|
|
74
|
+
expect( srcDoc ).toContain( '.custom { color: red; }' );
|
|
75
|
+
} );
|
|
76
|
+
|
|
77
|
+
it( 'should include script tags in srcdoc', () => {
|
|
78
|
+
render(
|
|
79
|
+
<SandBox
|
|
80
|
+
html="<p>Script</p>"
|
|
81
|
+
title="Script Test"
|
|
82
|
+
scripts={ [ 'https://example.com/embed.js' ] }
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const iframe = screen.getByTitle< HTMLIFrameElement >( 'Script Test' );
|
|
87
|
+
const srcDoc = iframe.getAttribute( 'srcdoc' ) ?? '';
|
|
88
|
+
|
|
89
|
+
expect( srcDoc ).toContain(
|
|
90
|
+
'<script src="https://example.com/embed.js">'
|
|
91
|
+
);
|
|
92
|
+
} );
|
|
93
|
+
|
|
94
|
+
it( 'should update srcdoc when html prop changes', () => {
|
|
42
95
|
render( <TestWrapper /> );
|
|
43
96
|
|
|
44
97
|
const iframe =
|
|
45
98
|
screen.getByTitle< HTMLIFrameElement >( 'SandBox Title' );
|
|
46
99
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let sandboxedIframe = within(
|
|
52
|
-
iframe.contentWindow.document.body
|
|
53
|
-
).getByTitle( 'Mock Iframe' );
|
|
54
|
-
|
|
55
|
-
expect( sandboxedIframe ).toHaveAttribute(
|
|
56
|
-
'src',
|
|
57
|
-
'https://super.embed'
|
|
100
|
+
expect( iframe ).toHaveAttribute(
|
|
101
|
+
'srcdoc',
|
|
102
|
+
expect.stringContaining( 'https://super.embed' )
|
|
58
103
|
);
|
|
59
104
|
|
|
60
105
|
fireEvent.click( screen.getByRole( 'button' ) );
|
|
61
106
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect( sandboxedIframe ).toHaveAttribute(
|
|
67
|
-
'src',
|
|
68
|
-
'https://another.super.embed'
|
|
107
|
+
expect( iframe ).toHaveAttribute(
|
|
108
|
+
'srcdoc',
|
|
109
|
+
expect.stringContaining( 'https://another.super.embed' )
|
|
69
110
|
);
|
|
70
111
|
} );
|
|
71
112
|
} );
|