@wordpress/components 29.5.0 → 29.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/font-size-picker/font-size-picker-select.js +1 -8
  3. package/build/font-size-picker/font-size-picker-select.js.map +1 -1
  4. package/build/font-size-picker/index.js +12 -34
  5. package/build/font-size-picker/index.js.map +1 -1
  6. package/build/font-size-picker/styles.js +12 -19
  7. package/build/font-size-picker/styles.js.map +1 -1
  8. package/build/font-size-picker/utils.js +0 -22
  9. package/build/font-size-picker/utils.js.map +1 -1
  10. package/build/query-controls/index.js +18 -16
  11. package/build/query-controls/index.js.map +1 -1
  12. package/build/query-controls/index.native.js +3 -2
  13. package/build/query-controls/index.native.js.map +1 -1
  14. package/build/query-controls/types.js.map +1 -1
  15. package/build-module/font-size-picker/font-size-picker-select.js +2 -9
  16. package/build-module/font-size-picker/font-size-picker-select.js.map +1 -1
  17. package/build-module/font-size-picker/index.js +14 -36
  18. package/build-module/font-size-picker/index.js.map +1 -1
  19. package/build-module/font-size-picker/styles.js +11 -18
  20. package/build-module/font-size-picker/styles.js.map +1 -1
  21. package/build-module/font-size-picker/utils.js +0 -22
  22. package/build-module/font-size-picker/utils.js.map +1 -1
  23. package/build-module/query-controls/index.js +18 -16
  24. package/build-module/query-controls/index.js.map +1 -1
  25. package/build-module/query-controls/index.native.js +3 -2
  26. package/build-module/query-controls/index.native.js.map +1 -1
  27. package/build-module/query-controls/types.js.map +1 -1
  28. package/build-style/style-rtl.css +0 -2
  29. package/build-style/style.css +0 -2
  30. package/build-types/font-size-picker/font-size-picker-select.d.ts.map +1 -1
  31. package/build-types/font-size-picker/index.d.ts.map +1 -1
  32. package/build-types/font-size-picker/styles.d.ts +0 -4
  33. package/build-types/font-size-picker/styles.d.ts.map +1 -1
  34. package/build-types/font-size-picker/utils.d.ts +1 -9
  35. package/build-types/font-size-picker/utils.d.ts.map +1 -1
  36. package/build-types/query-controls/index.d.ts +2 -2
  37. package/build-types/query-controls/index.d.ts.map +1 -1
  38. package/build-types/query-controls/types.d.ts +15 -1
  39. package/build-types/query-controls/types.d.ts.map +1 -1
  40. package/package.json +19 -19
  41. package/src/button/style.scss +0 -2
  42. package/src/font-size-picker/font-size-picker-select.tsx +2 -12
  43. package/src/font-size-picker/index.tsx +18 -47
  44. package/src/font-size-picker/styles.ts +0 -5
  45. package/src/font-size-picker/test/index.tsx +36 -80
  46. package/src/font-size-picker/test/utils.ts +1 -37
  47. package/src/font-size-picker/utils.ts +1 -24
  48. package/src/query-controls/README.md +10 -3
  49. package/src/query-controls/index.native.js +3 -2
  50. package/src/query-controls/index.tsx +25 -21
  51. package/src/query-controls/types.ts +16 -1
  52. package/tsconfig.tsbuildinfo +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/components/src/query-controls/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { FormTokenFieldProps } from '../form-token-field/types';\nimport type { TreeSelectProps } from '../tree-select/types';\n\nexport type Author = {\n\tid: number;\n\tname: string;\n};\n\nexport type Category = {\n\tid: number;\n\tname: string;\n\tparent: number;\n};\n\nexport type TermWithParentAndChildren = {\n\tid: string;\n\tname: string;\n\tparent: number | null;\n\tchildren: TermWithParentAndChildren[];\n};\n\nexport type TermsByParent = Record< string, TermWithParentAndChildren[] >;\n\nexport type CategorySelectProps = Pick<\n\tTreeSelectProps,\n\t'label' | 'noOptionLabel'\n> & {\n\tcategoriesList: Category[];\n\tonChange: ( newCategory: string ) => void;\n\tselectedCategoryId?: Category[ 'id' ];\n\t__next40pxDefaultSize: boolean;\n};\n\nexport type AuthorSelectProps = Pick<\n\tTreeSelectProps,\n\t'label' | 'noOptionLabel'\n> & {\n\tauthorList?: Author[];\n\tonChange: ( newAuthor: string ) => void;\n\tselectedAuthorId?: Author[ 'id' ];\n\t__next40pxDefaultSize: boolean;\n};\n\ntype Order = 'asc' | 'desc';\ntype OrderBy = 'date' | 'title';\n\ntype BaseQueryControlsProps = {\n\t/**\n\t * An array of the authors to select from.\n\t */\n\tauthorList?: AuthorSelectProps[ 'authorList' ];\n\t/**\n\t * The maximum number of items.\n\t *\n\t * @default 100\n\t */\n\tmaxItems?: number;\n\t/**\n\t * The minimum number of items.\n\t *\n\t * @default 1\n\t */\n\tminItems?: number;\n\t/**\n\t * The selected number of items to retrieve via the query.\n\t */\n\tnumberOfItems?: number;\n\t/**\n\t * A function that receives the new author value.\n\t * If not specified, the author controls are not rendered.\n\t */\n\tonAuthorChange?: AuthorSelectProps[ 'onChange' ];\n\t/**\n\t * A function that receives the new number of items.\n\t * If not specified, then the number of items\n\t * range control is not rendered.\n\t */\n\tonNumberOfItemsChange?: ( newNumber?: number ) => void;\n\t/**\n\t * A function that receives the new order value.\n\t * If this prop or the `onOrderByChange` prop are not specified,\n\t * then the order controls are not rendered.\n\t */\n\tonOrderChange?: ( newOrder: Order ) => void;\n\t/**\n\t * A function that receives the new orderby value.\n\t * If this prop or the `onOrderChange` prop are not specified,\n\t * then the order controls are not rendered.\n\t */\n\tonOrderByChange?: ( newOrderBy: OrderBy ) => void;\n\t/**\n\t * The order in which to retrieve posts.\n\t */\n\torder?: Order;\n\t/**\n\t * The meta key by which to order posts.\n\t */\n\torderBy?: OrderBy;\n\t/**\n\t * The selected author ID.\n\t */\n\tselectedAuthorId?: AuthorSelectProps[ 'selectedAuthorId' ];\n\t/**\n\t * Start opting into the larger default height that will become the\n\t * default size in a future version.\n\t *\n\t * @deprecated Default behavior since WP 6.7. Prop can be safely removed.\n\t * @ignore\n\t */\n\t__next40pxDefaultSize?: boolean;\n};\n\nexport type QueryControlsWithSingleCategorySelectionProps =\n\tBaseQueryControlsProps & {\n\t\t/**\n\t\t * An array of categories. When passed in conjunction with the\n\t\t * `onCategoryChange` prop, it causes the component to render UI that allows\n\t\t * selecting one category at a time.\n\t\t */\n\t\tcategoriesList?: CategorySelectProps[ 'categoriesList' ];\n\t\t/**\n\t\t * The selected category for the `categoriesList` prop.\n\t\t */\n\t\tselectedCategoryId?: CategorySelectProps[ 'selectedCategoryId' ];\n\t\t/**\n\t\t * A function that receives the new category value. If not specified, the\n\t\t * category controls are not rendered.\n\t\t * The function's signature changes depending on whether multiple category\n\t\t * selection is enabled or not.\n\t\t */\n\t\tonCategoryChange?: CategorySelectProps[ 'onChange' ];\n\t};\n\nexport type QueryControlsWithMultipleCategorySelectionProps =\n\tBaseQueryControlsProps & {\n\t\t/**\n\t\t * An object of categories with the category name as the key. When passed in\n\t\t * conjunction with the `onCategoryChange` prop, it causes the component to\n\t\t * render UI that enables multiple selection.\n\t\t */\n\t\tcategorySuggestions?: Record< Category[ 'name' ], Category >;\n\t\t/**\n\t\t * The selected categories for the `categorySuggestions` prop.\n\t\t */\n\t\tselectedCategories?: Category[];\n\t\t/**\n\t\t * A function that receives the new category value. If not specified, the\n\t\t * category controls are not rendered.\n\t\t * The function's signature changes depending on whether multiple category\n\t\t * selection is enabled or not.\n\t\t */\n\t\tonCategoryChange?: FormTokenFieldProps[ 'onChange' ];\n\t};\n\nexport type QueryControlsProps =\n\t| QueryControlsWithSingleCategorySelectionProps\n\t| QueryControlsWithMultipleCategorySelectionProps;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/components/src/query-controls/types.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport type { FormTokenFieldProps } from '../form-token-field/types';\nimport type { TreeSelectProps } from '../tree-select/types';\n\nexport type Author = {\n\tid: number;\n\tname: string;\n};\n\nexport type Category = {\n\tid: number;\n\tname: string;\n\tparent: number;\n};\n\nexport type TermWithParentAndChildren = {\n\tid: string;\n\tname: string;\n\tparent: number | null;\n\tchildren: TermWithParentAndChildren[];\n};\n\nexport type TermsByParent = Record< string, TermWithParentAndChildren[] >;\n\nexport type CategorySelectProps = Pick<\n\tTreeSelectProps,\n\t'label' | 'noOptionLabel'\n> & {\n\tcategoriesList: Category[];\n\tonChange: ( newCategory: string ) => void;\n\tselectedCategoryId?: Category[ 'id' ];\n\t__next40pxDefaultSize: boolean;\n};\n\nexport type AuthorSelectProps = Pick<\n\tTreeSelectProps,\n\t'label' | 'noOptionLabel'\n> & {\n\tauthorList?: Author[];\n\tonChange: ( newAuthor: string ) => void;\n\tselectedAuthorId?: Author[ 'id' ];\n\t__next40pxDefaultSize: boolean;\n};\n\ntype Order = 'asc' | 'desc';\ntype OrderBy = 'date' | 'title' | 'menu_order';\n\nexport type OrderByOption = {\n\t/**\n\t * The label to be shown to the user.\n\t */\n\tlabel: string;\n\t/**\n\t * Option value passed to `onChange` when the option is selected.\n\t */\n\tvalue: `${ OrderBy }/${ Order }`;\n};\n\ntype BaseQueryControlsProps = {\n\t/**\n\t * An array of the authors to select from.\n\t */\n\tauthorList?: AuthorSelectProps[ 'authorList' ];\n\t/**\n\t * The maximum number of items.\n\t *\n\t * @default 100\n\t */\n\tmaxItems?: number;\n\t/**\n\t * The minimum number of items.\n\t *\n\t * @default 1\n\t */\n\tminItems?: number;\n\t/**\n\t * The selected number of items to retrieve via the query.\n\t */\n\tnumberOfItems?: number;\n\t/**\n\t * A function that receives the new author value.\n\t * If not specified, the author controls are not rendered.\n\t */\n\tonAuthorChange?: AuthorSelectProps[ 'onChange' ];\n\t/**\n\t * A function that receives the new number of items.\n\t * If not specified, then the number of items\n\t * range control is not rendered.\n\t */\n\tonNumberOfItemsChange?: ( newNumber?: number ) => void;\n\t/**\n\t * A function that receives the new order value.\n\t * If this prop or the `onOrderByChange` prop are not specified,\n\t * then the order controls are not rendered.\n\t */\n\tonOrderChange?: ( newOrder: Order ) => void;\n\t/**\n\t * A function that receives the new orderby value.\n\t * If this prop or the `onOrderChange` prop are not specified,\n\t * then the order controls are not rendered.\n\t */\n\tonOrderByChange?: ( newOrderBy: OrderBy ) => void;\n\t/**\n\t * The order in which to retrieve posts.\n\t */\n\torder?: Order;\n\t/**\n\t * The meta key by which to order posts.\n\t */\n\torderBy?: OrderBy;\n\t/**\n\t * List of available ordering options.\n\t */\n\torderByOptions?: OrderByOption[];\n\t/**\n\t * The selected author ID.\n\t */\n\tselectedAuthorId?: AuthorSelectProps[ 'selectedAuthorId' ];\n\t/**\n\t * Start opting into the larger default height that will become the\n\t * default size in a future version.\n\t *\n\t * @deprecated Default behavior since WP 6.7. Prop can be safely removed.\n\t * @ignore\n\t */\n\t__next40pxDefaultSize?: boolean;\n};\n\nexport type QueryControlsWithSingleCategorySelectionProps =\n\tBaseQueryControlsProps & {\n\t\t/**\n\t\t * An array of categories. When passed in conjunction with the\n\t\t * `onCategoryChange` prop, it causes the component to render UI that allows\n\t\t * selecting one category at a time.\n\t\t */\n\t\tcategoriesList?: CategorySelectProps[ 'categoriesList' ];\n\t\t/**\n\t\t * The selected category for the `categoriesList` prop.\n\t\t */\n\t\tselectedCategoryId?: CategorySelectProps[ 'selectedCategoryId' ];\n\t\t/**\n\t\t * A function that receives the new category value. If not specified, the\n\t\t * category controls are not rendered.\n\t\t * The function's signature changes depending on whether multiple category\n\t\t * selection is enabled or not.\n\t\t */\n\t\tonCategoryChange?: CategorySelectProps[ 'onChange' ];\n\t};\n\nexport type QueryControlsWithMultipleCategorySelectionProps =\n\tBaseQueryControlsProps & {\n\t\t/**\n\t\t * An object of categories with the category name as the key. When passed in\n\t\t * conjunction with the `onCategoryChange` prop, it causes the component to\n\t\t * render UI that enables multiple selection.\n\t\t */\n\t\tcategorySuggestions?: Record< Category[ 'name' ], Category >;\n\t\t/**\n\t\t * The selected categories for the `categorySuggestions` prop.\n\t\t */\n\t\tselectedCategories?: Category[];\n\t\t/**\n\t\t * A function that receives the new category value. If not specified, the\n\t\t * category controls are not rendered.\n\t\t * The function's signature changes depending on whether multiple category\n\t\t * selection is enabled or not.\n\t\t */\n\t\tonCategoryChange?: FormTokenFieldProps[ 'onChange' ];\n\t};\n\nexport type QueryControlsProps =\n\t| QueryControlsWithSingleCategorySelectionProps\n\t| QueryControlsWithMultipleCategorySelectionProps;\n"],"mappings":"","ignoreList":[]}
@@ -485,7 +485,6 @@ p + .components-button.is-tertiary {
485
485
  }
486
486
  .components-button.is-compact.has-icon:not(.has-text) {
487
487
  padding: 0;
488
- width: 32px;
489
488
  min-width: 32px;
490
489
  }
491
490
  .components-button.is-small {
@@ -496,7 +495,6 @@ p + .components-button.is-tertiary {
496
495
  }
497
496
  .components-button.is-small.has-icon:not(.has-text) {
498
497
  padding: 0;
499
- width: 24px;
500
498
  min-width: 24px;
501
499
  }
502
500
  .components-button.has-icon {
@@ -485,7 +485,6 @@ p + .components-button.is-tertiary {
485
485
  }
486
486
  .components-button.is-compact.has-icon:not(.has-text) {
487
487
  padding: 0;
488
- width: 32px;
489
488
  min-width: 32px;
490
489
  }
491
490
  .components-button.is-small {
@@ -496,7 +495,6 @@ p + .components-button.is-tertiary {
496
495
  }
497
496
  .components-button.is-small.has-icon:not(.has-text) {
498
497
  padding: 0;
499
- width: 24px;
500
498
  min-width: 24px;
501
499
  }
502
500
  .components-button.has-icon {
@@ -1 +1 @@
1
- {"version":3,"file":"font-size-picker-select.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/font-size-picker-select.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,SAAS,CAAC;AASjB,QAAA,MAAM,oBAAoB,UAAY,yBAAyB,gCAwD9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"font-size-picker-select.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/font-size-picker-select.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,SAAS,CAAC;AASjB,QAAA,MAAM,oBAAoB,UAAY,yBAAyB,gCA+C9D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/index.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoRnD,eAAO,MAAM,cAAc,qGAA0C,CAAC;AAEtE,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAwPnD,eAAO,MAAM,cAAc,qGAA0C,CAAC;AAEtE,eAAe,cAAc,CAAC"}
@@ -18,8 +18,4 @@ export declare const HeaderLabel: import("@emotion/styled").StyledComponent<impo
18
18
  } & import("react").RefAttributes<any> & {
19
19
  theme?: import("@emotion/react").Theme;
20
20
  }, {}, {}>;
21
- export declare const HeaderHint: import("@emotion/styled").StyledComponent<{
22
- theme?: import("@emotion/react").Theme;
23
- as?: React.ElementType;
24
- }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
25
21
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/styles.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,SAAS;;SAYR,MAAO,WACpB;2HARA,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;UAElB,CAAC;AAEF,eAAO,MAAM,YAAY;;UAExB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;UAKvB,CAAC;AAEF,eAAO,MAAM,UAAU;;SAVT,MAAO,WACpB;2GAWA,CAAC"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/styles.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,SAAS;;SAeR,MAAO,WAAW;2HAV/B,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;;UAElB,CAAC;AAEF,eAAO,MAAM,YAAY;;UAExB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;UAKvB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
- import type { FontSizePickerProps, FontSize } from './types';
4
+ import type { FontSizePickerProps } from './types';
5
5
  /**
6
6
  * Some themes use css vars for their font sizes, so until we
7
7
  * have the way of calculating them don't display them.
@@ -10,12 +10,4 @@ import type { FontSizePickerProps, FontSize } from './types';
10
10
  * @return Whether the value is a simple css value.
11
11
  */
12
12
  export declare function isSimpleCssValue(value: NonNullable<FontSizePickerProps['value']>): boolean;
13
- /**
14
- * If all of the given font sizes have the same unit (e.g. 'px'), return that
15
- * unit. Otherwise return null.
16
- *
17
- * @param fontSizes List of font sizes.
18
- * @return The common unit, or null.
19
- */
20
- export declare function getCommonSizeUnit(fontSizes: FontSize[]): string | null | undefined;
21
13
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG7D;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,WAAW,CAAE,mBAAmB,CAAE,OAAO,CAAE,CAAE,WAKpD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAE,SAAS,EAAE,QAAQ,EAAE,6BAavD"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/font-size-picker/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,WAAW,CAAE,mBAAmB,CAAE,OAAO,CAAE,CAAE,WAKpD"}
@@ -5,7 +5,7 @@ import type { QueryControlsProps } from './types';
5
5
  * ```jsx
6
6
  * const MyQueryControls = () => (
7
7
  * <QueryControls
8
- * { ...{ maxItems, minItems, numberOfItems, order, orderBy } }
8
+ * { ...{ maxItems, minItems, numberOfItems, order, orderBy, orderByOptions } }
9
9
  * onOrderByChange={ ( newOrderBy ) => {
10
10
  * updateQuery( { orderBy: newOrderBy } )
11
11
  * }
@@ -24,6 +24,6 @@ import type { QueryControlsProps } from './types';
24
24
  * );
25
25
  * ```
26
26
  */
27
- export declare function QueryControls({ authorList, selectedAuthorId, numberOfItems, order, orderBy, maxItems, minItems, onAuthorChange, onNumberOfItemsChange, onOrderChange, onOrderByChange, ...props }: QueryControlsProps): import("react").JSX.Element;
27
+ export declare function QueryControls({ authorList, selectedAuthorId, numberOfItems, order, orderBy, orderByOptions, maxItems, minItems, onAuthorChange, onNumberOfItemsChange, onOrderChange, onOrderByChange, ...props }: QueryControlsProps): import("react").JSX.Element;
28
28
  export default QueryControls;
29
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query-controls/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACX,kBAAkB,EAGlB,MAAM,SAAS,CAAC;AAkBjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAE,EAC9B,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,OAAO,EACP,QAA4B,EAC5B,QAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,eAAe,EAGf,GAAG,KAAK,EACR,EAAE,kBAAkB,+BA4HpB;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query-controls/index.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACX,kBAAkB,EAIlB,MAAM,SAAS,CAAC;AAuCjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAE,EAC9B,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,OAAO,EACP,cAAsC,EACtC,QAA4B,EAC5B,QAA4B,EAC5B,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,eAAe,EAGf,GAAG,KAAK,EACR,EAAE,kBAAkB,+BAyGpB;AAED,eAAe,aAAa,CAAC"}
@@ -32,7 +32,17 @@ export type AuthorSelectProps = Pick<TreeSelectProps, 'label' | 'noOptionLabel'>
32
32
  __next40pxDefaultSize: boolean;
33
33
  };
34
34
  type Order = 'asc' | 'desc';
35
- type OrderBy = 'date' | 'title';
35
+ type OrderBy = 'date' | 'title' | 'menu_order';
36
+ export type OrderByOption = {
37
+ /**
38
+ * The label to be shown to the user.
39
+ */
40
+ label: string;
41
+ /**
42
+ * Option value passed to `onChange` when the option is selected.
43
+ */
44
+ value: `${OrderBy}/${Order}`;
45
+ };
36
46
  type BaseQueryControlsProps = {
37
47
  /**
38
48
  * An array of the authors to select from.
@@ -85,6 +95,10 @@ type BaseQueryControlsProps = {
85
95
  * The meta key by which to order posts.
86
96
  */
87
97
  orderBy?: OrderBy;
98
+ /**
99
+ * List of available ordering options.
100
+ */
101
+ orderByOptions?: OrderByOption[];
88
102
  /**
89
103
  * The selected author ID.
90
104
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/query-controls/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,MAAM,MAAM,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,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AU,CAAE,CAAC;CACrD,CAAC;AAEH,MAAM,MAAM,+CAA+C,GAC1D,sBAAsB,GAAG;IACxB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAE,QAAQ,CAAE,MAAM,CAAE,EAAE,QAAQ,CAAE,CAAC;IAC7D;;OAEG;IACH,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAChC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,mBAAmB,CAAE,UAAU,CAAE,CAAC;CACrD,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAC3B,6CAA6C,GAC7C,+CAA+C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "29.5.0",
3
+ "version": "29.6.0",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -44,23 +44,23 @@
44
44
  "@types/gradient-parser": "0.1.3",
45
45
  "@types/highlight-words-core": "1.2.1",
46
46
  "@use-gesture/react": "^10.3.1",
47
- "@wordpress/a11y": "^4.19.0",
48
- "@wordpress/compose": "^7.19.0",
49
- "@wordpress/date": "^5.19.0",
50
- "@wordpress/deprecated": "^4.19.0",
51
- "@wordpress/dom": "^4.19.0",
52
- "@wordpress/element": "^6.19.0",
53
- "@wordpress/escape-html": "^3.19.0",
54
- "@wordpress/hooks": "^4.19.0",
55
- "@wordpress/html-entities": "^4.19.0",
56
- "@wordpress/i18n": "^5.19.0",
57
- "@wordpress/icons": "^10.19.0",
58
- "@wordpress/is-shallow-equal": "^5.19.0",
59
- "@wordpress/keycodes": "^4.19.0",
60
- "@wordpress/primitives": "^4.19.0",
61
- "@wordpress/private-apis": "^1.19.0",
62
- "@wordpress/rich-text": "^7.19.0",
63
- "@wordpress/warning": "^3.19.0",
47
+ "@wordpress/a11y": "^4.20.0",
48
+ "@wordpress/compose": "^7.20.0",
49
+ "@wordpress/date": "^5.20.0",
50
+ "@wordpress/deprecated": "^4.20.0",
51
+ "@wordpress/dom": "^4.20.0",
52
+ "@wordpress/element": "^6.20.0",
53
+ "@wordpress/escape-html": "^3.20.0",
54
+ "@wordpress/hooks": "^4.20.0",
55
+ "@wordpress/html-entities": "^4.20.0",
56
+ "@wordpress/i18n": "^5.20.0",
57
+ "@wordpress/icons": "^10.20.0",
58
+ "@wordpress/is-shallow-equal": "^5.20.0",
59
+ "@wordpress/keycodes": "^4.20.0",
60
+ "@wordpress/primitives": "^4.20.0",
61
+ "@wordpress/private-apis": "^1.20.0",
62
+ "@wordpress/rich-text": "^7.20.0",
63
+ "@wordpress/warning": "^3.20.0",
64
64
  "change-case": "^4.1.2",
65
65
  "clsx": "^2.1.1",
66
66
  "colord": "^2.7.0",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "d6b0b20fa927b110140dc7fdd906a7e0bf662004"
88
+ "gitHead": "72476970386146d450c375e5c71a96dda7c9aaa8"
89
89
  }
@@ -302,7 +302,6 @@
302
302
 
303
303
  &.has-icon:not(.has-text) {
304
304
  padding: 0;
305
- width: $button-size-compact;
306
305
  min-width: $button-size-compact;
307
306
  }
308
307
  }
@@ -315,7 +314,6 @@
315
314
 
316
315
  &.has-icon:not(.has-text) {
317
316
  padding: 0;
318
- width: $button-size-small;
319
317
  min-width: $button-size-small;
320
318
  }
321
319
  }
@@ -7,12 +7,11 @@ import { __, sprintf } from '@wordpress/i18n';
7
7
  * Internal dependencies
8
8
  */
9
9
  import CustomSelectControl from '../custom-select-control';
10
- import { parseQuantityAndUnitFromRawValue } from '../unit-control';
11
10
  import type {
12
11
  FontSizePickerSelectProps,
13
12
  FontSizePickerSelectOption,
14
13
  } from './types';
15
- import { getCommonSizeUnit, isSimpleCssValue } from './utils';
14
+ import { isSimpleCssValue } from './utils';
16
15
 
17
16
  const DEFAULT_OPTION: FontSizePickerSelectOption = {
18
17
  key: 'default',
@@ -23,20 +22,11 @@ const DEFAULT_OPTION: FontSizePickerSelectOption = {
23
22
  const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
24
23
  const { __next40pxDefaultSize, fontSizes, value, size, onChange } = props;
25
24
 
26
- const areAllSizesSameUnit = !! getCommonSizeUnit( fontSizes );
27
-
28
25
  const options: FontSizePickerSelectOption[] = [
29
26
  DEFAULT_OPTION,
30
27
  ...fontSizes.map( ( fontSize ) => {
31
28
  let hint;
32
- if ( areAllSizesSameUnit ) {
33
- const [ quantity ] = parseQuantityAndUnitFromRawValue(
34
- fontSize.size
35
- );
36
- if ( quantity !== undefined ) {
37
- hint = String( quantity );
38
- }
39
- } else if ( isSimpleCssValue( fontSize.size ) ) {
29
+ if ( isSimpleCssValue( fontSize.size ) ) {
40
30
  hint = String( fontSize.size );
41
31
  }
42
32
  return {
@@ -8,7 +8,8 @@ import type { ForwardedRef } from 'react';
8
8
  */
9
9
  import { __ } from '@wordpress/i18n';
10
10
  import { settings } from '@wordpress/icons';
11
- import { useState, useMemo, forwardRef } from '@wordpress/element';
11
+ import { useState, forwardRef } from '@wordpress/element';
12
+ import { useInstanceId } from '@wordpress/compose';
12
13
 
13
14
  /**
14
15
  * Internal dependencies
@@ -21,20 +22,11 @@ import {
21
22
  parseQuantityAndUnitFromRawValue,
22
23
  useCustomUnits,
23
24
  } from '../unit-control';
24
- import { VisuallyHidden } from '../visually-hidden';
25
- import { getCommonSizeUnit } from './utils';
26
25
  import type { FontSizePickerProps } from './types';
27
- import {
28
- Container,
29
- Header,
30
- HeaderHint,
31
- HeaderLabel,
32
- HeaderToggle,
33
- } from './styles';
26
+ import { Container, Header, HeaderLabel, HeaderToggle } from './styles';
34
27
  import { Spacer } from '../spacer';
35
28
  import FontSizePickerSelect from './font-size-picker-select';
36
29
  import FontSizePickerToggleGroup from './font-size-picker-toggle-group';
37
- import { T_SHIRT_NAMES } from './constants';
38
30
  import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';
39
31
 
40
32
  const DEFAULT_UNITS = [ 'px', 'em', 'rem', 'vw', 'vh' ];
@@ -58,6 +50,11 @@ const UnforwardedFontSizePicker = (
58
50
  withReset = true,
59
51
  } = props;
60
52
 
53
+ const labelId = useInstanceId(
54
+ UnforwardedFontSizePicker,
55
+ 'font-size-picker-label'
56
+ );
57
+
61
58
  const units = useCustomUnits( {
62
59
  availableUnits: unitsProp,
63
60
  } );
@@ -83,29 +80,6 @@ const UnforwardedFontSizePicker = (
83
80
  : ( 'togglegroup' as const );
84
81
  }
85
82
 
86
- const headerHint = useMemo( () => {
87
- switch ( currentPickerType ) {
88
- case 'custom':
89
- return __( 'Custom' );
90
- case 'togglegroup':
91
- if ( selectedFontSize ) {
92
- return (
93
- selectedFontSize.name ||
94
- T_SHIRT_NAMES[ fontSizes.indexOf( selectedFontSize ) ]
95
- );
96
- }
97
- break;
98
- case 'select':
99
- const commonUnit = getCommonSizeUnit( fontSizes );
100
- if ( commonUnit ) {
101
- return `(${ commonUnit })`;
102
- }
103
- break;
104
- }
105
-
106
- return '';
107
- }, [ currentPickerType, selectedFontSize, fontSizes ] );
108
-
109
83
  if ( fontSizes.length === 0 && disableCustomFontSizes ) {
110
84
  return null;
111
85
  }
@@ -131,19 +105,16 @@ const UnforwardedFontSizePicker = (
131
105
  } );
132
106
 
133
107
  return (
134
- <Container ref={ ref } className="components-font-size-picker">
135
- <VisuallyHidden as="legend">{ __( 'Font size' ) }</VisuallyHidden>
108
+ <Container
109
+ ref={ ref }
110
+ className="components-font-size-picker"
111
+ // This Container component renders a fieldset element that needs to be labeled.
112
+ aria-labelledby={ labelId }
113
+ >
136
114
  <Spacer>
137
115
  <Header className="components-font-size-picker__header">
138
- <HeaderLabel
139
- aria-label={ `${ __( 'Size' ) } ${ headerHint || '' }` }
140
- >
141
- { __( 'Size' ) }
142
- { headerHint && (
143
- <HeaderHint className="components-font-size-picker__header__hint">
144
- { headerHint }
145
- </HeaderHint>
146
- ) }
116
+ <HeaderLabel id={ labelId }>
117
+ { __( 'Font size' ) }
147
118
  </HeaderLabel>
148
119
  { ! disableCustomFontSizes && (
149
120
  <HeaderToggle
@@ -213,7 +184,7 @@ const UnforwardedFontSizePicker = (
213
184
  <UnitControl
214
185
  __next40pxDefaultSize={ __next40pxDefaultSize }
215
186
  __shouldNotWarnDeprecated36pxSize
216
- label={ __( 'Custom' ) }
187
+ label={ __( 'Font size' ) }
217
188
  labelPosition="top"
218
189
  hideLabelFromVision
219
190
  value={ value }
@@ -245,7 +216,7 @@ const UnforwardedFontSizePicker = (
245
216
  }
246
217
  __shouldNotWarnDeprecated36pxSize
247
218
  className="components-font-size-picker__custom-input"
248
- label={ __( 'Custom Size' ) }
219
+ label={ __( 'Font size' ) }
249
220
  hideLabelFromVision
250
221
  value={ valueQuantity }
251
222
  initialPosition={ fallbackFontSize }
@@ -10,7 +10,6 @@ import BaseControl from '../base-control';
10
10
  import Button from '../button';
11
11
  import { HStack } from '../h-stack';
12
12
  import { space } from '../utils/space';
13
- import { COLORS } from '../utils';
14
13
 
15
14
  export const Container = styled.fieldset`
16
15
  border: 0;
@@ -33,7 +32,3 @@ export const HeaderLabel = styled( BaseControl.VisualLabel )`
33
32
  justify-content: flex-start;
34
33
  margin-bottom: 0;
35
34
  `;
36
-
37
- export const HeaderHint = styled.span`
38
- color: ${ COLORS.gray[ 700 ] };
39
- `;
@@ -52,7 +52,9 @@ describe( 'FontSizePicker', () => {
52
52
  await render(
53
53
  <FontSizePicker value={ value } onChange={ onChange } />
54
54
  );
55
- const input = screen.getByLabelText( 'Custom' );
55
+ const input = screen.getByRole( 'spinbutton', {
56
+ name: 'Font size',
57
+ } );
56
58
  await user.clear( input );
57
59
  await user.type( input, '80' );
58
60
  expect( onChange ).toHaveBeenCalledTimes( 3 ); // Once for the clear, then once per keystroke.
@@ -79,7 +81,9 @@ describe( 'FontSizePicker', () => {
79
81
  await user.click(
80
82
  screen.getByRole( 'button', { name: 'Set custom size' } )
81
83
  );
82
- const input = screen.getByLabelText( 'Custom' );
84
+ const input = screen.getByRole( 'spinbutton', {
85
+ name: 'Font size',
86
+ } );
83
87
  await user.type( input, '80' );
84
88
  expect( onChange ).toHaveBeenCalledTimes( 2 ); // Once per keystroke.
85
89
  expect( onChange ).toHaveBeenCalledWith( expectedValue );
@@ -129,28 +133,14 @@ describe( 'FontSizePicker', () => {
129
133
  const options = screen.getAllByRole( 'option' );
130
134
  expect( options ).toHaveLength( 7 );
131
135
  expect( options[ 0 ] ).toHaveAccessibleName( 'Default' );
132
- expect( options[ 1 ] ).toHaveAccessibleName( 'Tiny 8' );
133
- expect( options[ 2 ] ).toHaveAccessibleName( 'Small 12' );
134
- expect( options[ 3 ] ).toHaveAccessibleName( 'Medium 16' );
135
- expect( options[ 4 ] ).toHaveAccessibleName( 'Large 20' );
136
- expect( options[ 5 ] ).toHaveAccessibleName( 'Extra Large 30' );
137
- expect( options[ 6 ] ).toHaveAccessibleName( 'xx-large 40' );
136
+ expect( options[ 1 ] ).toHaveAccessibleName( 'Tiny 8px' );
137
+ expect( options[ 2 ] ).toHaveAccessibleName( 'Small 12px' );
138
+ expect( options[ 3 ] ).toHaveAccessibleName( 'Medium 16px' );
139
+ expect( options[ 4 ] ).toHaveAccessibleName( 'Large 20px' );
140
+ expect( options[ 5 ] ).toHaveAccessibleName( 'Extra Large 30px' );
141
+ expect( options[ 6 ] ).toHaveAccessibleName( 'xx-large 40px' );
138
142
  } );
139
143
 
140
- test.each( [
141
- { value: undefined, expectedLabel: 'Size (px)' },
142
- { value: '8px', expectedLabel: 'Size (px)' },
143
- { value: '3px', expectedLabel: 'Size Custom' },
144
- ] )(
145
- 'displays $expectedLabel as label when value is $value',
146
- async ( { value, expectedLabel } ) => {
147
- await render(
148
- <FontSizePicker fontSizes={ fontSizes } value={ value } />
149
- );
150
- expect( screen.getByLabelText( expectedLabel ) ).toBeVisible();
151
- }
152
- );
153
-
154
144
  test.each( [
155
145
  {
156
146
  option: 'Default',
@@ -158,7 +148,7 @@ describe( 'FontSizePicker', () => {
158
148
  expectedArguments: [ undefined ],
159
149
  },
160
150
  {
161
- option: 'Tiny 8',
151
+ option: 'Tiny 8px',
162
152
  value: undefined,
163
153
  expectedArguments: [ '8px', fontSizes[ 0 ] ],
164
154
  },
@@ -255,23 +245,6 @@ describe( 'FontSizePicker', () => {
255
245
  }
256
246
  );
257
247
 
258
- test.each( [
259
- { value: undefined, expectedLabel: 'Size' },
260
- { value: '8px', expectedLabel: 'Size' },
261
- { value: '1em', expectedLabel: 'Size' },
262
- { value: '2rem', expectedLabel: 'Size' },
263
- { value: 'clamp(1.75rem, 3vw, 2.25rem)', expectedLabel: 'Size' },
264
- { value: '3px', expectedLabel: 'Size Custom' },
265
- ] )(
266
- 'displays $expectedLabel as label when value is $value',
267
- async ( { value, expectedLabel } ) => {
268
- await render(
269
- <FontSizePicker fontSizes={ fontSizes } value={ value } />
270
- );
271
- expect( screen.getByLabelText( expectedLabel ) ).toBeVisible();
272
- }
273
- );
274
-
275
248
  test.each( [
276
249
  {
277
250
  option: 'Default',
@@ -372,20 +345,6 @@ describe( 'FontSizePicker', () => {
372
345
  expect( options[ 4 ] ).toHaveAccessibleName( 'Gigantosaurus' );
373
346
  } );
374
347
 
375
- test.each( [
376
- { value: undefined, expectedLabel: 'Size' },
377
- { value: '12px', expectedLabel: 'Size Small' },
378
- { value: '40px', expectedLabel: 'Size Gigantosaurus' },
379
- ] )(
380
- 'displays $expectedLabel as label when value is $value',
381
- async ( { value, expectedLabel } ) => {
382
- await render(
383
- <FontSizePicker fontSizes={ fontSizes } value={ value } />
384
- );
385
- expect( screen.getByLabelText( expectedLabel ) ).toBeVisible();
386
- }
387
- );
388
-
389
348
  it( 'calls onChange when a font size is selected', async () => {
390
349
  const user = userEvent.setup();
391
350
  const onChange = jest.fn();
@@ -439,25 +398,6 @@ describe( 'FontSizePicker', () => {
439
398
  expect( options[ 3 ] ).toHaveAccessibleName( 'Extra Large' );
440
399
  } );
441
400
 
442
- test.each( [
443
- { value: undefined, expectedLabel: 'Size' },
444
- { value: '12px', expectedLabel: 'Size Small' },
445
- { value: '1em', expectedLabel: 'Size Medium' },
446
- { value: '2rem', expectedLabel: 'Size Large' },
447
- {
448
- value: 'clamp(1.75rem, 3vw, 2.25rem)',
449
- expectedLabel: 'Size Extra Large',
450
- },
451
- ] )(
452
- 'displays $expectedLabel as label when value is $value',
453
- async ( { value, expectedLabel } ) => {
454
- await render(
455
- <FontSizePicker fontSizes={ fontSizes } value={ value } />
456
- );
457
- expect( screen.getByLabelText( expectedLabel ) ).toBeVisible();
458
- }
459
- );
460
-
461
401
  test.each( [
462
402
  { radio: 'Small', expectedArguments: [ '12px', fontSizes[ 0 ] ] },
463
403
  { radio: 'Medium', expectedArguments: [ '1em', fontSizes[ 1 ] ] },
@@ -524,14 +464,18 @@ describe( 'FontSizePicker', () => {
524
464
  await render(
525
465
  <FontSizePicker fontSizes={ fontSizes } value="3px" />
526
466
  );
527
- expect( screen.getByLabelText( 'Custom' ) ).toBeVisible();
467
+ expect(
468
+ screen.getByRole( 'spinbutton', { name: 'Font size' } )
469
+ ).toBeVisible();
528
470
  } );
529
471
 
530
472
  it( 'hides custom input when disableCustomFontSizes is set to `true` with a custom font size', async () => {
531
473
  const { rerender } = await render(
532
474
  <FontSizePicker fontSizes={ fontSizes } value="3px" />
533
475
  );
534
- expect( screen.getByLabelText( 'Custom' ) ).toBeVisible();
476
+ expect(
477
+ screen.getByRole( 'spinbutton', { name: 'Font size' } )
478
+ ).toBeVisible();
535
479
 
536
480
  rerender(
537
481
  <FontSizePicker
@@ -549,7 +493,9 @@ describe( 'FontSizePicker', () => {
549
493
  const { rerender } = await render(
550
494
  <FontSizePicker fontSizes={ fontSizes } value="3px" />
551
495
  );
552
- expect( screen.getByLabelText( 'Custom' ) ).toBeVisible();
496
+ expect(
497
+ screen.getByRole( 'spinbutton', { name: 'Font size' } )
498
+ ).toBeVisible();
553
499
 
554
500
  rerender(
555
501
  <FontSizePicker
@@ -557,7 +503,9 @@ describe( 'FontSizePicker', () => {
557
503
  value={ fontSizes[ 0 ].size }
558
504
  />
559
505
  );
560
- expect( screen.getByLabelText( 'Custom' ) ).toBeVisible();
506
+ expect(
507
+ screen.getByRole( 'spinbutton', { name: 'Font size' } )
508
+ ).toBeVisible();
561
509
  } );
562
510
 
563
511
  it( 'allows custom values by default', async () => {
@@ -569,7 +517,10 @@ describe( 'FontSizePicker', () => {
569
517
  await user.click(
570
518
  screen.getByRole( 'button', { name: 'Set custom size' } )
571
519
  );
572
- await user.type( screen.getByLabelText( 'Custom' ), '80' );
520
+ await user.type(
521
+ screen.getByRole( 'spinbutton', { name: 'Font size' } ),
522
+ '80'
523
+ );
573
524
  expect( onChange ).toHaveBeenCalledTimes( 2 ); // Once per keystroke.
574
525
  expect( onChange ).toHaveBeenCalledWith( '80px' );
575
526
  } );
@@ -585,7 +536,10 @@ describe( 'FontSizePicker', () => {
585
536
  screen.getByRole( 'button', { name: 'Set custom size' } )
586
537
  );
587
538
 
588
- await user.type( screen.getByLabelText( 'Custom' ), '80' );
539
+ await user.type(
540
+ screen.getByRole( 'spinbutton', { name: 'Font size' } ),
541
+ '80'
542
+ );
589
543
 
590
544
  await user.click(
591
545
  screen.getByRole( 'button', { name: 'Use size preset' } )
@@ -632,7 +586,9 @@ describe( 'FontSizePicker', () => {
632
586
  await user.click(
633
587
  screen.getByRole( 'button', { name: 'Set custom size' } )
634
588
  );
635
- const sliderInput = screen.getByLabelText( 'Custom Size' );
589
+ const sliderInput = screen.getByRole( 'slider', {
590
+ name: 'Font size',
591
+ } );
636
592
  fireEvent.change( sliderInput, {
637
593
  target: { value: 80 },
638
594
  } );