@wordpress/media-editor 0.10.1 → 0.11.1
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/CHANGELOG.md +16 -0
- package/build/components/media-editor/index.cjs +41 -51
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor-crop-panel/index.cjs +15 -45
- package/build/components/media-editor-crop-panel/index.cjs.map +3 -3
- package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
- package/build/components/media-editor-image-controls/index.cjs +230 -0
- package/build/components/media-editor-image-controls/index.cjs.map +7 -0
- package/build/components/media-form/index.cjs +12 -23
- package/build/components/media-form/index.cjs.map +3 -3
- package/build/image-editor/core/constants.cjs +3 -0
- package/build/image-editor/core/constants.cjs.map +2 -2
- package/build/image-editor/core/stencil-math.cjs +11 -2
- package/build/image-editor/core/stencil-math.cjs.map +2 -2
- package/build/image-editor/react/components/cropper.cjs +12 -7
- package/build/image-editor/react/components/cropper.cjs.map +2 -2
- package/build-module/components/media-editor/index.mjs +41 -51
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +8 -51
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
- package/build-module/components/media-editor-image-controls/index.mjs +221 -0
- package/build-module/components/media-editor-image-controls/index.mjs.map +7 -0
- package/build-module/components/media-form/index.mjs +12 -13
- package/build-module/components/media-form/index.mjs.map +2 -2
- package/build-module/image-editor/core/constants.mjs +2 -0
- package/build-module/image-editor/core/constants.mjs.map +2 -2
- package/build-module/image-editor/core/stencil-math.mjs +9 -1
- package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper.mjs +12 -7
- package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
- package/build-style/style-rtl.css +136 -47
- package/build-style/style.css +136 -46
- package/build-types/components/media-editor/index.d.ts +6 -7
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts +11 -6
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-fine-rotation/index.d.ts +4 -3
- package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
- package/build-types/components/media-editor-image-controls/index.d.ts +46 -0
- package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -0
- package/build-types/components/media-editor-toolbar/index.d.ts +24 -0
- package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -0
- package/build-types/components/media-editor-transform-controls/index.d.ts +18 -5
- package/build-types/components/media-editor-transform-controls/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/image-editor/core/constants.d.ts +10 -0
- package/build-types/image-editor/core/constants.d.ts.map +1 -1
- package/build-types/image-editor/core/stencil-math.d.ts +16 -3
- package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +108 -0
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -0
- package/package.json +25 -20
- package/src/components/media-editor/index.tsx +69 -77
- package/src/components/media-editor/style.scss +124 -4
- package/src/components/media-editor-crop-panel/index.tsx +16 -62
- package/src/components/media-editor-crop-panel/test/index.tsx +25 -41
- package/src/components/media-editor-fine-rotation/index.tsx +4 -3
- package/src/components/media-editor-image-controls/index.tsx +262 -0
- package/src/components/media-editor-image-controls/style.scss +48 -0
- package/src/components/media-editor-image-controls/test/index.tsx +150 -0
- package/src/components/media-editor-modal/style.scss +32 -42
- package/src/components/media-form/index.tsx +17 -21
- package/src/components/media-form/style.scss +6 -0
- package/src/components/rotation-ruler/style.scss +10 -3
- package/src/image-editor/core/constants.ts +11 -0
- package/src/image-editor/core/stencil-math.ts +23 -0
- package/src/image-editor/core/test/stencil-math.ts +39 -0
- package/src/image-editor/react/components/cropper.scss +28 -17
- package/src/image-editor/react/components/cropper.tsx +17 -7
- package/src/style.scss +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/media-editor-transform-controls/index.cjs +0 -84
- package/build/components/media-editor-transform-controls/index.cjs.map +0 -7
- package/build/components/media-form/sidebar-datetime-view.cjs +0 -53
- package/build/components/media-form/sidebar-datetime-view.cjs.map +0 -7
- package/build-module/components/media-editor-transform-controls/index.mjs +0 -68
- package/build-module/components/media-editor-transform-controls/index.mjs.map +0 -7
- package/build-module/components/media-form/sidebar-datetime-view.mjs +0 -32
- package/build-module/components/media-form/sidebar-datetime-view.mjs.map +0 -7
- package/src/components/media-editor-transform-controls/index.tsx +0 -70
- package/src/components/media-editor-transform-controls/style.scss +0 -8
- package/src/components/media-form/sidebar-datetime-view.tsx +0 -47
- package/src/components/media-form/test/sidebar-datetime-view.test.tsx +0 -96
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/media-editor/src/components/media-editor-transform-controls/index.tsx
|
|
21
|
-
var media_editor_transform_controls_exports = {};
|
|
22
|
-
__export(media_editor_transform_controls_exports, {
|
|
23
|
-
default: () => MediaEditorTransformControls
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(media_editor_transform_controls_exports);
|
|
26
|
-
var import_components = require("@wordpress/components");
|
|
27
|
-
var import_i18n = require("@wordpress/i18n");
|
|
28
|
-
var import_icons = require("@wordpress/icons");
|
|
29
|
-
var import_state = require("../../state/index.cjs");
|
|
30
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
-
function MediaEditorTransformControls() {
|
|
32
|
-
const { state, setFlip, snapRotate90 } = (0, import_state.useMediaEditor)();
|
|
33
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-transform-controls", children: [
|
|
34
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
35
|
-
import_components.Button,
|
|
36
|
-
{
|
|
37
|
-
size: "compact",
|
|
38
|
-
icon: import_icons.rotateLeft,
|
|
39
|
-
label: (0, import_i18n.__)("Rotate 90\xB0 counter-clockwise"),
|
|
40
|
-
showTooltip: true,
|
|
41
|
-
onClick: () => snapRotate90(-1)
|
|
42
|
-
}
|
|
43
|
-
),
|
|
44
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
45
|
-
import_components.Button,
|
|
46
|
-
{
|
|
47
|
-
size: "compact",
|
|
48
|
-
icon: import_icons.rotateRight,
|
|
49
|
-
label: (0, import_i18n.__)("Rotate 90\xB0 clockwise"),
|
|
50
|
-
showTooltip: true,
|
|
51
|
-
onClick: () => snapRotate90(1)
|
|
52
|
-
}
|
|
53
|
-
),
|
|
54
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
55
|
-
import_components.Button,
|
|
56
|
-
{
|
|
57
|
-
size: "compact",
|
|
58
|
-
icon: import_icons.flipHorizontal,
|
|
59
|
-
label: (0, import_i18n.__)("Flip horizontal"),
|
|
60
|
-
showTooltip: true,
|
|
61
|
-
isPressed: state.flip.horizontal,
|
|
62
|
-
onClick: () => setFlip({
|
|
63
|
-
horizontal: !state.flip.horizontal,
|
|
64
|
-
vertical: state.flip.vertical
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
-
import_components.Button,
|
|
70
|
-
{
|
|
71
|
-
size: "compact",
|
|
72
|
-
icon: import_icons.flipVertical,
|
|
73
|
-
label: (0, import_i18n.__)("Flip vertical"),
|
|
74
|
-
showTooltip: true,
|
|
75
|
-
isPressed: state.flip.vertical,
|
|
76
|
-
onClick: () => setFlip({
|
|
77
|
-
horizontal: state.flip.horizontal,
|
|
78
|
-
vertical: !state.flip.vertical
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
)
|
|
82
|
-
] });
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-editor-transform-controls/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\n\n/**\n * Snap-rotate and flip controls for the media-editor footer. Rotation and\n * reflection are both geometric transforms, hence \"transform controls\".\n * Lives separately from the fine-rotation slider so the footer can place\n * the two halves on different rows at intermediate viewport widths.\n */\nexport default function MediaEditorTransformControls() {\n\tconst { state, setFlip, snapRotate90 } = useMediaEditor();\n\treturn (\n\t\t<div className=\"media-editor-transform-controls\">\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAuB;AACvB,kBAAmB;AACnB,mBAKO;AAKP,mBAA+B;AAW7B;AAHa,SAAR,+BAAgD;AACtD,QAAM,EAAE,OAAO,SAAS,aAAa,QAAI,6BAAe;AACxD,SACC,6CAAC,SAAI,WAAU,mCACd;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,iCAA+B;AAAA,QAC3C,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,EAAG;AAAA;AAAA,IAClC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,yBAAuB;AAAA,QACnC,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,CAAE;AAAA;AAAA,IACjC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,iBAAkB;AAAA,QAC9B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,CAAE,MAAM,KAAK;AAAA,UACzB,UAAU,MAAM,KAAK;AAAA,QACtB,CAAE;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,eAAgB;AAAA,QAC5B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,MAAM,KAAK;AAAA,UACvB,UAAU,CAAE,MAAM,KAAK;AAAA,QACxB,CAAE;AAAA;AAAA,IAEJ;AAAA,KACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/media-editor/src/components/media-form/sidebar-datetime-view.tsx
|
|
21
|
-
var sidebar_datetime_view_exports = {};
|
|
22
|
-
__export(sidebar_datetime_view_exports, {
|
|
23
|
-
default: () => SidebarDatetimeView
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(sidebar_datetime_view_exports);
|
|
26
|
-
var import_date = require("@wordpress/date");
|
|
27
|
-
var import_components = require("@wordpress/components");
|
|
28
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
29
|
-
function SidebarDatetimeView({
|
|
30
|
-
item,
|
|
31
|
-
field
|
|
32
|
-
}) {
|
|
33
|
-
const value = field.getValue({ item });
|
|
34
|
-
if (!value) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const settings = (0, import_date.getSettings)();
|
|
38
|
-
const dateOnly = (0, import_date.dateI18n)(settings.formats.date, (0, import_date.getDate)(value));
|
|
39
|
-
const fullDatetime = (0, import_date.dateI18n)(
|
|
40
|
-
settings.formats.datetimeAbbreviated,
|
|
41
|
-
(0, import_date.getDate)(value)
|
|
42
|
-
);
|
|
43
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Tooltip, { text: fullDatetime, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
-
"time",
|
|
45
|
-
{
|
|
46
|
-
dateTime: value,
|
|
47
|
-
"aria-label": fullDatetime,
|
|
48
|
-
tabIndex: -1,
|
|
49
|
-
children: dateOnly
|
|
50
|
-
}
|
|
51
|
-
) });
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=sidebar-datetime-view.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-form/sidebar-datetime-view.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\nimport { Tooltip as WCTooltip } from '@wordpress/components';\nimport type { NormalizedField } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Media } from '../media-editor-provider';\n\nexport default function SidebarDatetimeView( {\n\titem,\n\tfield,\n}: {\n\titem: Media;\n\tfield: NormalizedField< Media >;\n} ) {\n\tconst value = field.getValue( { item } ) as string | null | undefined;\n\tif ( ! value ) {\n\t\treturn null;\n\t}\n\tconst settings = getSettings();\n\tconst dateOnly = dateI18n( settings.formats.date, getDate( value ) );\n\tconst fullDatetime = dateI18n(\n\t\tsettings.formats.datetimeAbbreviated,\n\t\tgetDate( value )\n\t);\n\t// `aria-label` makes assistive tech announce the full date (the visible\n\t// text is a shortened summary; `<time dateTime>` is for machines, not\n\t// announced by screen readers). `tabIndex={-1}` keeps the Tooltip anchor\n\t// out of the keyboard tab order \u2014 Ariakit's `useFocusable` preserves an\n\t// explicit `tabIndex` on non-natively-focusable elements rather than\n\t// defaulting it to `0`. The Tooltip remains available on mouse hover.\n\treturn (\n\t\t<WCTooltip text={ fullDatetime } placement=\"top\">\n\t\t\t<time\n\t\t\t\tdateTime={ value }\n\t\t\t\taria-label={ fullDatetime }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t>\n\t\t\t\t{ dateOnly }\n\t\t\t</time>\n\t\t</WCTooltip>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA+C;AAC/C,wBAAqC;AAiClC;AAzBY,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAGI;AACH,QAAM,QAAQ,MAAM,SAAU,EAAE,KAAK,CAAE;AACvC,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AACA,QAAM,eAAW,yBAAY;AAC7B,QAAM,eAAW,sBAAU,SAAS,QAAQ,UAAM,qBAAS,KAAM,CAAE;AACnE,QAAM,mBAAe;AAAA,IACpB,SAAS,QAAQ;AAAA,QACjB,qBAAS,KAAM;AAAA,EAChB;AAOA,SACC,4CAAC,kBAAAA,SAAA,EAAU,MAAO,cAAe,WAAU,OAC1C;AAAA,IAAC;AAAA;AAAA,MACA,UAAW;AAAA,MACX,cAAa;AAAA,MACb,UAAW;AAAA,MAET;AAAA;AAAA,EACH,GACD;AAEF;",
|
|
6
|
-
"names": ["WCTooltip"]
|
|
7
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
// packages/media-editor/src/components/media-editor-transform-controls/index.tsx
|
|
2
|
-
import { Button } from "@wordpress/components";
|
|
3
|
-
import { __ } from "@wordpress/i18n";
|
|
4
|
-
import {
|
|
5
|
-
rotateLeft,
|
|
6
|
-
rotateRight,
|
|
7
|
-
flipHorizontal,
|
|
8
|
-
flipVertical
|
|
9
|
-
} from "@wordpress/icons";
|
|
10
|
-
import { useMediaEditor } from "../../state/index.mjs";
|
|
11
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
function MediaEditorTransformControls() {
|
|
13
|
-
const { state, setFlip, snapRotate90 } = useMediaEditor();
|
|
14
|
-
return /* @__PURE__ */ jsxs("div", { className: "media-editor-transform-controls", children: [
|
|
15
|
-
/* @__PURE__ */ jsx(
|
|
16
|
-
Button,
|
|
17
|
-
{
|
|
18
|
-
size: "compact",
|
|
19
|
-
icon: rotateLeft,
|
|
20
|
-
label: __("Rotate 90\xB0 counter-clockwise"),
|
|
21
|
-
showTooltip: true,
|
|
22
|
-
onClick: () => snapRotate90(-1)
|
|
23
|
-
}
|
|
24
|
-
),
|
|
25
|
-
/* @__PURE__ */ jsx(
|
|
26
|
-
Button,
|
|
27
|
-
{
|
|
28
|
-
size: "compact",
|
|
29
|
-
icon: rotateRight,
|
|
30
|
-
label: __("Rotate 90\xB0 clockwise"),
|
|
31
|
-
showTooltip: true,
|
|
32
|
-
onClick: () => snapRotate90(1)
|
|
33
|
-
}
|
|
34
|
-
),
|
|
35
|
-
/* @__PURE__ */ jsx(
|
|
36
|
-
Button,
|
|
37
|
-
{
|
|
38
|
-
size: "compact",
|
|
39
|
-
icon: flipHorizontal,
|
|
40
|
-
label: __("Flip horizontal"),
|
|
41
|
-
showTooltip: true,
|
|
42
|
-
isPressed: state.flip.horizontal,
|
|
43
|
-
onClick: () => setFlip({
|
|
44
|
-
horizontal: !state.flip.horizontal,
|
|
45
|
-
vertical: state.flip.vertical
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
),
|
|
49
|
-
/* @__PURE__ */ jsx(
|
|
50
|
-
Button,
|
|
51
|
-
{
|
|
52
|
-
size: "compact",
|
|
53
|
-
icon: flipVertical,
|
|
54
|
-
label: __("Flip vertical"),
|
|
55
|
-
showTooltip: true,
|
|
56
|
-
isPressed: state.flip.vertical,
|
|
57
|
-
onClick: () => setFlip({
|
|
58
|
-
horizontal: state.flip.horizontal,
|
|
59
|
-
vertical: !state.flip.vertical
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
] });
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
MediaEditorTransformControls as default
|
|
67
|
-
};
|
|
68
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-editor-transform-controls/index.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\n\n/**\n * Snap-rotate and flip controls for the media-editor footer. Rotation and\n * reflection are both geometric transforms, hence \"transform controls\".\n * Lives separately from the fine-rotation slider so the footer can place\n * the two halves on different rows at intermediate viewport widths.\n */\nexport default function MediaEditorTransformControls() {\n\tconst { state, setFlip, snapRotate90 } = useMediaEditor();\n\treturn (\n\t\t<div className=\"media-editor-transform-controls\">\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,cAAc;AACvB,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,sBAAsB;AAW7B,SACC,KADD;AAHa,SAAR,+BAAgD;AACtD,QAAM,EAAE,OAAO,SAAS,aAAa,IAAI,eAAe;AACxD,SACC,qBAAC,SAAI,WAAU,mCACd;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,iCAA+B;AAAA,QAC3C,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,EAAG;AAAA;AAAA,IAClC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,yBAAuB;AAAA,QACnC,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,CAAE;AAAA;AAAA,IACjC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,iBAAkB;AAAA,QAC9B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,CAAE,MAAM,KAAK;AAAA,UACzB,UAAU,MAAM,KAAK;AAAA,QACtB,CAAE;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,OAAQ,GAAI,eAAgB;AAAA,QAC5B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,MAAM,KAAK;AAAA,UACvB,UAAU,CAAE,MAAM,KAAK;AAAA,QACxB,CAAE;AAAA;AAAA,IAEJ;AAAA,KACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// packages/media-editor/src/components/media-form/sidebar-datetime-view.tsx
|
|
2
|
-
import { dateI18n, getDate, getSettings } from "@wordpress/date";
|
|
3
|
-
import { Tooltip as WCTooltip } from "@wordpress/components";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
function SidebarDatetimeView({
|
|
6
|
-
item,
|
|
7
|
-
field
|
|
8
|
-
}) {
|
|
9
|
-
const value = field.getValue({ item });
|
|
10
|
-
if (!value) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const settings = getSettings();
|
|
14
|
-
const dateOnly = dateI18n(settings.formats.date, getDate(value));
|
|
15
|
-
const fullDatetime = dateI18n(
|
|
16
|
-
settings.formats.datetimeAbbreviated,
|
|
17
|
-
getDate(value)
|
|
18
|
-
);
|
|
19
|
-
return /* @__PURE__ */ jsx(WCTooltip, { text: fullDatetime, placement: "top", children: /* @__PURE__ */ jsx(
|
|
20
|
-
"time",
|
|
21
|
-
{
|
|
22
|
-
dateTime: value,
|
|
23
|
-
"aria-label": fullDatetime,
|
|
24
|
-
tabIndex: -1,
|
|
25
|
-
children: dateOnly
|
|
26
|
-
}
|
|
27
|
-
) });
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
SidebarDatetimeView as default
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=sidebar-datetime-view.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-form/sidebar-datetime-view.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\nimport { Tooltip as WCTooltip } from '@wordpress/components';\nimport type { NormalizedField } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { Media } from '../media-editor-provider';\n\nexport default function SidebarDatetimeView( {\n\titem,\n\tfield,\n}: {\n\titem: Media;\n\tfield: NormalizedField< Media >;\n} ) {\n\tconst value = field.getValue( { item } ) as string | null | undefined;\n\tif ( ! value ) {\n\t\treturn null;\n\t}\n\tconst settings = getSettings();\n\tconst dateOnly = dateI18n( settings.formats.date, getDate( value ) );\n\tconst fullDatetime = dateI18n(\n\t\tsettings.formats.datetimeAbbreviated,\n\t\tgetDate( value )\n\t);\n\t// `aria-label` makes assistive tech announce the full date (the visible\n\t// text is a shortened summary; `<time dateTime>` is for machines, not\n\t// announced by screen readers). `tabIndex={-1}` keeps the Tooltip anchor\n\t// out of the keyboard tab order \u2014 Ariakit's `useFocusable` preserves an\n\t// explicit `tabIndex` on non-natively-focusable elements rather than\n\t// defaulting it to `0`. The Tooltip remains available on mouse hover.\n\treturn (\n\t\t<WCTooltip text={ fullDatetime } placement=\"top\">\n\t\t\t<time\n\t\t\t\tdateTime={ value }\n\t\t\t\taria-label={ fullDatetime }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t>\n\t\t\t\t{ dateOnly }\n\t\t\t</time>\n\t\t</WCTooltip>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,UAAU,SAAS,mBAAmB;AAC/C,SAAS,WAAW,iBAAiB;AAiClC;AAzBY,SAAR,oBAAsC;AAAA,EAC5C;AAAA,EACA;AACD,GAGI;AACH,QAAM,QAAQ,MAAM,SAAU,EAAE,KAAK,CAAE;AACvC,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AACA,QAAM,WAAW,YAAY;AAC7B,QAAM,WAAW,SAAU,SAAS,QAAQ,MAAM,QAAS,KAAM,CAAE;AACnE,QAAM,eAAe;AAAA,IACpB,SAAS,QAAQ;AAAA,IACjB,QAAS,KAAM;AAAA,EAChB;AAOA,SACC,oBAAC,aAAU,MAAO,cAAe,WAAU,OAC1C;AAAA,IAAC;AAAA;AAAA,MACA,UAAW;AAAA,MACX,cAAa;AAAA,MACb,UAAW;AAAA,MAET;AAAA;AAAA,EACH,GACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Button } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
7
|
-
rotateLeft,
|
|
8
|
-
rotateRight,
|
|
9
|
-
flipHorizontal,
|
|
10
|
-
flipVertical,
|
|
11
|
-
} from '@wordpress/icons';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { useMediaEditor } from '../../state';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Snap-rotate and flip controls for the media-editor footer. Rotation and
|
|
20
|
-
* reflection are both geometric transforms, hence "transform controls".
|
|
21
|
-
* Lives separately from the fine-rotation slider so the footer can place
|
|
22
|
-
* the two halves on different rows at intermediate viewport widths.
|
|
23
|
-
*/
|
|
24
|
-
export default function MediaEditorTransformControls() {
|
|
25
|
-
const { state, setFlip, snapRotate90 } = useMediaEditor();
|
|
26
|
-
return (
|
|
27
|
-
<div className="media-editor-transform-controls">
|
|
28
|
-
<Button
|
|
29
|
-
size="compact"
|
|
30
|
-
icon={ rotateLeft }
|
|
31
|
-
label={ __( 'Rotate 90° counter-clockwise' ) }
|
|
32
|
-
showTooltip
|
|
33
|
-
onClick={ () => snapRotate90( -1 ) }
|
|
34
|
-
/>
|
|
35
|
-
<Button
|
|
36
|
-
size="compact"
|
|
37
|
-
icon={ rotateRight }
|
|
38
|
-
label={ __( 'Rotate 90° clockwise' ) }
|
|
39
|
-
showTooltip
|
|
40
|
-
onClick={ () => snapRotate90( 1 ) }
|
|
41
|
-
/>
|
|
42
|
-
<Button
|
|
43
|
-
size="compact"
|
|
44
|
-
icon={ flipHorizontal }
|
|
45
|
-
label={ __( 'Flip horizontal' ) }
|
|
46
|
-
showTooltip
|
|
47
|
-
isPressed={ state.flip.horizontal }
|
|
48
|
-
onClick={ () =>
|
|
49
|
-
setFlip( {
|
|
50
|
-
horizontal: ! state.flip.horizontal,
|
|
51
|
-
vertical: state.flip.vertical,
|
|
52
|
-
} )
|
|
53
|
-
}
|
|
54
|
-
/>
|
|
55
|
-
<Button
|
|
56
|
-
size="compact"
|
|
57
|
-
icon={ flipVertical }
|
|
58
|
-
label={ __( 'Flip vertical' ) }
|
|
59
|
-
showTooltip
|
|
60
|
-
isPressed={ state.flip.vertical }
|
|
61
|
-
onClick={ () =>
|
|
62
|
-
setFlip( {
|
|
63
|
-
horizontal: state.flip.horizontal,
|
|
64
|
-
vertical: ! state.flip.vertical,
|
|
65
|
-
} )
|
|
66
|
-
}
|
|
67
|
-
/>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { dateI18n, getDate, getSettings } from '@wordpress/date';
|
|
5
|
-
import { Tooltip as WCTooltip } from '@wordpress/components';
|
|
6
|
-
import type { NormalizedField } from '@wordpress/dataviews';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import type { Media } from '../media-editor-provider';
|
|
12
|
-
|
|
13
|
-
export default function SidebarDatetimeView( {
|
|
14
|
-
item,
|
|
15
|
-
field,
|
|
16
|
-
}: {
|
|
17
|
-
item: Media;
|
|
18
|
-
field: NormalizedField< Media >;
|
|
19
|
-
} ) {
|
|
20
|
-
const value = field.getValue( { item } ) as string | null | undefined;
|
|
21
|
-
if ( ! value ) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
const settings = getSettings();
|
|
25
|
-
const dateOnly = dateI18n( settings.formats.date, getDate( value ) );
|
|
26
|
-
const fullDatetime = dateI18n(
|
|
27
|
-
settings.formats.datetimeAbbreviated,
|
|
28
|
-
getDate( value )
|
|
29
|
-
);
|
|
30
|
-
// `aria-label` makes assistive tech announce the full date (the visible
|
|
31
|
-
// text is a shortened summary; `<time dateTime>` is for machines, not
|
|
32
|
-
// announced by screen readers). `tabIndex={-1}` keeps the Tooltip anchor
|
|
33
|
-
// out of the keyboard tab order — Ariakit's `useFocusable` preserves an
|
|
34
|
-
// explicit `tabIndex` on non-natively-focusable elements rather than
|
|
35
|
-
// defaulting it to `0`. The Tooltip remains available on mouse hover.
|
|
36
|
-
return (
|
|
37
|
-
<WCTooltip text={ fullDatetime } placement="top">
|
|
38
|
-
<time
|
|
39
|
-
dateTime={ value }
|
|
40
|
-
aria-label={ fullDatetime }
|
|
41
|
-
tabIndex={ -1 }
|
|
42
|
-
>
|
|
43
|
-
{ dateOnly }
|
|
44
|
-
</time>
|
|
45
|
-
</WCTooltip>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { dateI18n, getDate, getSettings } from '@wordpress/date';
|
|
10
|
-
import type { NormalizedField } from '@wordpress/dataviews';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import SidebarDatetimeView from '../sidebar-datetime-view';
|
|
16
|
-
import type { Media } from '../../media-editor-provider';
|
|
17
|
-
|
|
18
|
-
function makeField(
|
|
19
|
-
value: string | null | undefined
|
|
20
|
-
): NormalizedField< Media > {
|
|
21
|
-
return {
|
|
22
|
-
id: 'date_created',
|
|
23
|
-
type: 'datetime',
|
|
24
|
-
label: 'Date created',
|
|
25
|
-
getValue: () => value,
|
|
26
|
-
} as unknown as NormalizedField< Media >;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe( 'SidebarDatetimeView', () => {
|
|
30
|
-
it( 'exposes the full datetime to assistive tech via aria-label', () => {
|
|
31
|
-
const value = '2026-05-20T14:30:00';
|
|
32
|
-
const settings = getSettings();
|
|
33
|
-
const fullDatetime = dateI18n(
|
|
34
|
-
settings.formats.datetimeAbbreviated,
|
|
35
|
-
getDate( value )
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
render(
|
|
39
|
-
<SidebarDatetimeView
|
|
40
|
-
item={ {} as Media }
|
|
41
|
-
field={ makeField( value ) }
|
|
42
|
-
/>
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const rendered = screen.getByLabelText( fullDatetime );
|
|
46
|
-
expect( rendered.tagName ).toBe( 'TIME' );
|
|
47
|
-
expect( rendered ).toHaveAttribute( 'datetime', value );
|
|
48
|
-
} );
|
|
49
|
-
|
|
50
|
-
it( 'does not add a tab stop for the datetime anchor', () => {
|
|
51
|
-
const value = '2026-05-20T14:30:00';
|
|
52
|
-
const settings = getSettings();
|
|
53
|
-
const fullDatetime = dateI18n(
|
|
54
|
-
settings.formats.datetimeAbbreviated,
|
|
55
|
-
getDate( value )
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
render(
|
|
59
|
-
<SidebarDatetimeView
|
|
60
|
-
item={ {} as Media }
|
|
61
|
-
field={ makeField( value ) }
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
expect( screen.getByLabelText( fullDatetime ) ).toHaveAttribute(
|
|
66
|
-
'tabindex',
|
|
67
|
-
'-1'
|
|
68
|
-
);
|
|
69
|
-
} );
|
|
70
|
-
|
|
71
|
-
it( 'shows the short date as visible text', () => {
|
|
72
|
-
const value = '2026-05-20T14:30:00';
|
|
73
|
-
const settings = getSettings();
|
|
74
|
-
const dateOnly = dateI18n( settings.formats.date, getDate( value ) );
|
|
75
|
-
|
|
76
|
-
render(
|
|
77
|
-
<SidebarDatetimeView
|
|
78
|
-
item={ {} as Media }
|
|
79
|
-
field={ makeField( value ) }
|
|
80
|
-
/>
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
expect( screen.getByText( dateOnly ) ).toBeInTheDocument();
|
|
84
|
-
} );
|
|
85
|
-
|
|
86
|
-
it( 'renders nothing when the field value is missing', () => {
|
|
87
|
-
const { container } = render(
|
|
88
|
-
<SidebarDatetimeView
|
|
89
|
-
item={ {} as Media }
|
|
90
|
-
field={ makeField( null ) }
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
expect( container ).toBeEmptyDOMElement();
|
|
95
|
-
} );
|
|
96
|
-
} );
|