@aws-amplify/ui 6.0.17 → 6.2.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 (96) hide show
  1. package/dist/esm/i18n/dictionaries/authenticator/de.mjs +4 -4
  2. package/dist/esm/i18n/dictionaries/authenticator/ja.mjs +2 -2
  3. package/dist/esm/i18n/dictionaries/authenticator/kr.mjs +10 -0
  4. package/dist/esm/i18n/dictionaries/authenticator/th.mjs +101 -0
  5. package/dist/esm/i18n/dictionaries/index.mjs +3 -1
  6. package/dist/esm/i18n/translations.mjs +2 -1
  7. package/dist/esm/index.mjs +6 -3
  8. package/dist/esm/theme/createTheme/createAnimationCSS.mjs +23 -0
  9. package/dist/esm/theme/createTheme/createColorPalette.mjs +21 -0
  10. package/dist/esm/theme/createTheme/createComponentCSS.mjs +86 -0
  11. package/dist/esm/theme/createTheme/createComponentClasses.mjs +60 -0
  12. package/dist/esm/theme/{createTheme.mjs → createTheme/createTheme.mjs} +33 -44
  13. package/dist/esm/theme/createTheme/defineComponentTheme.mjs +55 -0
  14. package/dist/esm/theme/createTheme/utils.mjs +236 -0
  15. package/dist/esm/utils/humanFileSize.mjs +29 -0
  16. package/dist/esm/utils/utils.mjs +21 -1
  17. package/dist/index.js +566 -41
  18. package/dist/styles/breadcrumbs.css +2 -4
  19. package/dist/styles/breadcrumbs.layer.css +2 -4
  20. package/dist/styles/button.css +10 -19
  21. package/dist/styles/button.layer.css +10 -19
  22. package/dist/styles/input.css +2 -3
  23. package/dist/styles/input.layer.css +2 -3
  24. package/dist/styles/link.css +5 -10
  25. package/dist/styles/link.layer.css +5 -10
  26. package/dist/styles/reset.css +1 -3
  27. package/dist/styles/reset.layer.css +1 -3
  28. package/dist/styles/sliderField.css +2 -3
  29. package/dist/styles/sliderField.layer.css +2 -3
  30. package/dist/styles/textArea.css +2 -3
  31. package/dist/styles/textArea.layer.css +2 -3
  32. package/dist/styles.css +23 -42
  33. package/dist/styles.layer.css +23 -42
  34. package/dist/types/i18n/dictionaries/authenticator/index.d.ts +1 -0
  35. package/dist/types/i18n/dictionaries/authenticator/th.d.ts +2 -0
  36. package/dist/types/i18n/dictionaries/index.d.ts +52 -0
  37. package/dist/types/theme/components/accordion.d.ts +4 -0
  38. package/dist/types/theme/components/alert.d.ts +4 -0
  39. package/dist/types/theme/components/autocomplete.d.ts +8 -0
  40. package/dist/types/theme/components/badge.d.ts +4 -0
  41. package/dist/types/theme/components/breadcrumbs.d.ts +7 -0
  42. package/dist/types/theme/components/button.d.ts +7 -0
  43. package/dist/types/theme/components/buttonGroup.d.ts +2 -0
  44. package/dist/types/theme/components/card.d.ts +2 -0
  45. package/dist/types/theme/components/checkbox.d.ts +7 -0
  46. package/dist/types/theme/components/checkboxField.d.ts +2 -0
  47. package/dist/types/theme/components/collection.d.ts +4 -0
  48. package/dist/types/theme/components/divider.d.ts +2 -0
  49. package/dist/types/theme/components/dropZone.d.ts +2 -0
  50. package/dist/types/theme/components/field.d.ts +6 -0
  51. package/dist/types/theme/components/fieldGroup.d.ts +11 -0
  52. package/dist/types/theme/components/fieldset.d.ts +4 -0
  53. package/dist/types/theme/components/heading.d.ts +4 -0
  54. package/dist/types/theme/components/highlightMatch.d.ts +4 -0
  55. package/dist/types/theme/components/index.d.ts +92 -0
  56. package/dist/types/theme/components/input.d.ts +2 -0
  57. package/dist/types/theme/components/loader.d.ts +4 -0
  58. package/dist/types/theme/components/menu.d.ts +4 -0
  59. package/dist/types/theme/components/message.d.ts +4 -0
  60. package/dist/types/theme/components/pagination.d.ts +4 -0
  61. package/dist/types/theme/components/placeholder.d.ts +2 -0
  62. package/dist/types/theme/components/radio.d.ts +6 -0
  63. package/dist/types/theme/components/rating.d.ts +5 -0
  64. package/dist/types/theme/components/scrollview.d.ts +2 -0
  65. package/dist/types/theme/components/searchField.d.ts +4 -0
  66. package/dist/types/theme/components/select.d.ts +5 -0
  67. package/dist/types/theme/components/selectField.d.ts +2 -0
  68. package/dist/types/theme/components/sliderField.d.ts +9 -0
  69. package/dist/types/theme/components/stepperField.d.ts +6 -0
  70. package/dist/types/theme/components/storageManager.d.ts +20 -0
  71. package/dist/types/theme/components/switchField.d.ts +8 -0
  72. package/dist/types/theme/components/table.d.ts +4 -0
  73. package/dist/types/theme/components/tabs.d.ts +6 -0
  74. package/dist/types/theme/components/text.d.ts +3 -0
  75. package/dist/types/theme/components/textField.d.ts +2 -0
  76. package/dist/types/theme/components/textarea.d.ts +2 -0
  77. package/dist/types/theme/components/textareaField.d.ts +2 -0
  78. package/dist/types/theme/components/toggleButton.d.ts +3 -0
  79. package/dist/types/theme/components/utils.d.ts +52 -0
  80. package/dist/types/theme/createTheme/createAnimationCSS.d.ts +6 -0
  81. package/dist/types/theme/createTheme/createColorPalette.d.ts +16 -0
  82. package/dist/types/theme/createTheme/createComponentCSS.d.ts +7 -0
  83. package/dist/types/theme/createTheme/createComponentClasses.d.ts +25 -0
  84. package/dist/types/theme/{createTheme.d.ts → createTheme/createTheme.d.ts} +3 -2
  85. package/dist/types/theme/createTheme/defineComponentTheme.d.ts +54 -0
  86. package/dist/types/theme/createTheme/index.d.ts +4 -0
  87. package/dist/types/theme/createTheme/utils.d.ts +92 -0
  88. package/dist/types/theme/index.d.ts +1 -2
  89. package/dist/types/theme/types.d.ts +20 -3
  90. package/dist/types/utils/classNames.d.ts +1 -1
  91. package/dist/types/utils/humanFileSize.d.ts +11 -0
  92. package/dist/types/utils/index.d.ts +2 -1
  93. package/dist/types/utils/utils.d.ts +8 -0
  94. package/package.json +3 -3
  95. package/dist/esm/theme/utils.mjs +0 -81
  96. package/dist/types/theme/utils.d.ts +0 -35
@@ -0,0 +1,52 @@
1
+ import type * as CSS from 'csstype';
2
+ import { DesignToken } from '../types';
3
+ import { WebTokens } from '../tokens';
4
+ import { Breakpoints } from '../breakpoints';
5
+ export type ColorTheme = 'info' | 'warning' | 'success' | 'error';
6
+ export type Size = 'small' | 'large';
7
+ export type Orientation = 'horizontal' | 'vertical';
8
+ export type FieldControlModifiers = Size | 'error' | 'quiet';
9
+ export type CSSProperties = {
10
+ [Key in keyof CSS.Properties]: DesignToken<CSS.Properties[Key] | (string & {})> | CSS.Properties[Key];
11
+ };
12
+ export type Selectors = {
13
+ [key in CSS.HtmlAttributes | CSS.Pseudos]?: CSSProperties;
14
+ };
15
+ export interface ComponentStyles extends CSSProperties, Selectors {
16
+ _vars?: Record<string, DesignToken | string>;
17
+ }
18
+ export type Modifiers<Keys extends string = string, Required extends boolean = false> = Required extends true ? {
19
+ _modifiers: {
20
+ [key in Keys]: ComponentStyles;
21
+ };
22
+ } : {
23
+ _modifiers?: {
24
+ [key in Keys]?: ComponentStyles;
25
+ };
26
+ };
27
+ export type Elements<Properties extends Record<string, ComponentStyles & {
28
+ _modifiers?: Record<string, ComponentStyles>;
29
+ }>, Required extends boolean = false> = Required extends true ? {
30
+ _element: Properties;
31
+ } : {
32
+ _element?: Properties;
33
+ };
34
+ export interface BaseTheme extends ComponentStyles {
35
+ _modifiers?: Record<string, ComponentStyles>;
36
+ _element?: Record<string, ComponentStyles & {
37
+ _modifiers?: Record<string, ComponentStyles>;
38
+ }>;
39
+ }
40
+ export type ComponentTheme<ThemeType extends BaseTheme = BaseTheme, TokensType extends WebTokens = WebTokens> = ThemeType | ((tokens: TokensType) => ThemeType);
41
+ export type ComponentThemeOverride<ThemeType> = {
42
+ theme: ThemeType;
43
+ colorMode?: 'light' | 'dark';
44
+ breakpoint?: keyof Breakpoints['values'];
45
+ mediaQuery?: string;
46
+ selector?: string;
47
+ };
48
+ export type BaseComponentTheme<ThemeType extends BaseTheme = BaseTheme, NameType extends string = string, TokensType extends WebTokens = WebTokens> = {
49
+ name: NameType;
50
+ theme: ComponentTheme<ThemeType, TokensType>;
51
+ overrides?: Array<ComponentThemeOverride<ComponentTheme<ThemeType, TokensType>>>;
52
+ };
@@ -0,0 +1,6 @@
1
+ import { WebTokens } from '../tokens';
2
+ import { Animations } from '../types';
3
+ export declare function createAnimationCSS({ animations, tokens, }: {
4
+ animations: Animations;
5
+ tokens: WebTokens;
6
+ }): string;
@@ -0,0 +1,16 @@
1
+ import { ColorValues, ScaleKey } from '../tokens/colors';
2
+ /**
3
+ * Takes a set of keys and a color name and returns an object of design tokens,
4
+ * used for applying a primary color at the theme level to our tokens.
5
+ *
6
+ * createColorPalette({keys: ['10','20',...], value: 'red'})
7
+ * returns {
8
+ * 10: { value: '{colors.red.10.value}' },
9
+ * 20: { value: '{colors.red.20.value}' },
10
+ * ...
11
+ * }
12
+ */
13
+ export declare function createColorPalette<ColorType extends ColorValues<ScaleKey, 'default'> = ColorValues<ScaleKey, 'default'>>({ keys, value }: {
14
+ keys: string[];
15
+ value: string;
16
+ }): ColorType;
@@ -0,0 +1,7 @@
1
+ import { DefaultTheme, WebTheme } from '../types';
2
+ import { ComponentsTheme } from '../components';
3
+ /**
4
+ * This will take a component theme and create the appropriate CSS for it.
5
+ *
6
+ */
7
+ export declare function createComponentCSS(themeName: string, components: Array<ComponentsTheme>, tokens: WebTheme['tokens'], breakpoints: DefaultTheme['breakpoints']): string;
@@ -0,0 +1,25 @@
1
+ import { ClassNamesArgs } from '../../utils';
2
+ import { ComponentThemeFromName } from '../components';
3
+ import { BaseTheme } from '../components/utils';
4
+ type ElementNames<T extends unknown> = T extends {
5
+ _element?: any;
6
+ } ? keyof Required<T['_element']> : never;
7
+ type ModifierNames<T extends unknown> = T extends {
8
+ _modifiers?: any;
9
+ } ? Arrayify<keyof Required<T['_modifiers']> | {
10
+ [key in keyof Required<T['_modifiers']>]?: boolean | null | undefined;
11
+ } | undefined> : never;
12
+ type Arrayify<T> = T | T[];
13
+ export type ClassNameArgs<T extends BaseTheme> = {
14
+ _element?: ElementNames<Required<T>> | {
15
+ [Key in ElementNames<Required<T>>]?: ModifierNames<Required<Required<Required<T>['_element']>[Key]>>;
16
+ };
17
+ _modifiers?: ModifierNames<Required<T>>;
18
+ };
19
+ export type ClassNameFunction<T extends BaseTheme = BaseTheme, NameType extends string = string> = (props?: ClassNameArgs<UnwrapTheme<ComponentThemeFromName<NameType, T>>>, extraClassnames?: ClassNamesArgs) => string;
20
+ type UnwrapTheme<ThemeType extends BaseTheme = BaseTheme> = ThemeType extends (...args: any) => any ? ReturnType<ThemeType> : ThemeType;
21
+ export declare function createComponentClasses<ThemeType extends BaseTheme, NameType extends string = string>({ name, prefix }: {
22
+ name: NameType;
23
+ prefix?: string;
24
+ }): ClassNameFunction<ThemeType, NameType>;
25
+ export {};
@@ -1,4 +1,5 @@
1
- import { Theme, DefaultTheme, WebTheme } from './types';
1
+ import { Theme, DefaultTheme, WebTheme } from '../types';
2
+ import { WebTokens } from '../tokens';
2
3
  /**
3
4
  * This will be used like `const myTheme = createTheme({})`
4
5
  * `myTheme` can then be passed to a Provider or the generated CSS
@@ -6,4 +7,4 @@ import { Theme, DefaultTheme, WebTheme } from './types';
6
7
  * const myTheme = createTheme({})
7
8
  * const myOtherTheme = createTheme({}, myTheme);
8
9
  */
9
- export declare function createTheme(theme?: Theme | WebTheme, DefaultTheme?: DefaultTheme | WebTheme): WebTheme;
10
+ export declare function createTheme<TokensType extends WebTokens = WebTokens>(theme?: Theme<TokensType> | WebTheme, DefaultTheme?: DefaultTheme | WebTheme): WebTheme;
@@ -0,0 +1,54 @@
1
+ import { ComponentThemeFromName, ComponentsTheme } from '../components';
2
+ import { BaseTheme, ComponentTheme, ComponentThemeOverride } from '../components/utils';
3
+ import { WebTokens } from '../tokens';
4
+ import { ClassNameFunction } from './createComponentClasses';
5
+ type CreateComponentThemeProps<TokensType extends WebTokens = WebTokens, ThemeType extends BaseTheme = BaseTheme, NameType extends string = string, OverridesType extends BaseTheme = BaseTheme> = {
6
+ name: NameType;
7
+ theme?: ComponentTheme<ThemeType, TokensType>;
8
+ overrides?: ComponentThemeOverride<ComponentTheme<OverridesType, TokensType>>[];
9
+ } & ComponentsTheme<TokensType>;
10
+ /**
11
+ * Use this to create the theme of a component. You can use this
12
+ * to both completely customize built-in components and
13
+ * build your own components!
14
+ *
15
+ * @experimental
16
+ *
17
+ * ```ts
18
+ * // built-in component styling
19
+ * const alertTheme = defineComponentTheme({
20
+ * name: 'alert',
21
+ * theme: (tokens) => {
22
+ * return {
23
+ * padding: tokens.space.large
24
+ * }
25
+ * }
26
+ * });
27
+ *
28
+ * // custom component styling
29
+ * const avatarTheme = defineComponentTheme({
30
+ * name: 'avatar',
31
+ * theme: (tokens) => {
32
+ * return {
33
+ * padding: tokens.space.large
34
+ * }
35
+ * }
36
+ * })
37
+ *
38
+ * const theme = createTheme({
39
+ * name: 'my-theme',
40
+ * components: [alertTheme, avatarTheme]
41
+ * })
42
+ * ```
43
+ *
44
+ * @param {Object} params
45
+ * @param {string} params.name - The name of the component. Use a built-in component name like button to theme buttons.
46
+ * @returns
47
+ */
48
+ export declare function defineComponentTheme<ThemeType extends BaseTheme = BaseTheme, TokensType extends WebTokens = WebTokens, NameType extends string = string>({ name, theme, overrides, }: CreateComponentThemeProps<TokensType, ThemeType, NameType>): {
49
+ className: ClassNameFunction<ComponentThemeFromName<NameType, ThemeType>>;
50
+ theme: typeof theme;
51
+ name: string;
52
+ overrides?: typeof overrides;
53
+ };
54
+ export {};
@@ -0,0 +1,4 @@
1
+ export { createTheme } from './createTheme';
2
+ export { defineComponentTheme } from './defineComponentTheme';
3
+ export { cssNameTransform, setupTokens, SetupToken, isDesignToken, } from './utils';
4
+ export { createComponentClasses, ClassNameArgs, } from './createComponentClasses';
@@ -0,0 +1,92 @@
1
+ import { WebDesignToken } from '../types';
2
+ import { ShadowValue } from '../tokens/types/designToken';
3
+ import { CSSProperties } from '../components/utils';
4
+ export declare const CSS_VARIABLE_PREFIX = "amplify";
5
+ interface NameTransformProps {
6
+ path?: Array<string>;
7
+ }
8
+ /**
9
+ * This will take an object like:
10
+ * {paddingTop:'20px',color:'{colors.font.primary}'}
11
+ * and turn it into a CSS string:
12
+ * `padding-top:20px; color: var(--colors-font-primary);`
13
+ */
14
+ export declare function propsToString(props: CSSProperties): string;
15
+ export declare function cssNameTransform({ path }: NameTransformProps): string;
16
+ type BaseDesignToken = {
17
+ value: string | number;
18
+ };
19
+ /**
20
+ * Will take a design token in a theme and return its value as CSS
21
+ *
22
+ * @param token
23
+ * @returns
24
+ */
25
+ export declare function cssValue(token: BaseDesignToken): string | number;
26
+ /**
27
+ * Helper function to test if something is a design token or not.
28
+ * Used in the React component style props.
29
+ *
30
+ * @param value - thing to test if it is a design token or not
31
+ * @returns boolean
32
+ */
33
+ export declare function isDesignToken(value: unknown): value is WebDesignToken;
34
+ export declare function isShadowTokenObject(value: unknown): value is ShadowValue & object;
35
+ /**
36
+ * Function that sees if a string contains a design token reference
37
+ * and if so will turn that into a CSS variable.
38
+ *
39
+ * @param {string} value
40
+ * @returns string
41
+ */
42
+ export declare function referenceValue(value?: string): string;
43
+ export type SetupToken<ReturnType = any> = (args: {
44
+ token: BaseDesignToken;
45
+ path: Array<string>;
46
+ }) => ReturnType;
47
+ /**
48
+ * This will take a design token and add some data to it for it
49
+ * to be used in JS/CSS. It will create its CSS var name and update
50
+ * the value to use a CSS var if it is a reference. It will also
51
+ * add a `.toString()` method to make it easier to use in JS.
52
+ *
53
+ * We should see if there is a way to share this logic with style dictionary...
54
+ */
55
+ export declare const setupToken: SetupToken<WebDesignToken>;
56
+ type SetupTokensProps = {
57
+ tokens?: Record<string | number, any>;
58
+ path?: Array<string>;
59
+ setupToken: SetupToken;
60
+ };
61
+ /**
62
+ * Recursive function that will walk down the token object
63
+ * and perform the setupToken function on each token.
64
+ * Similar to what Style Dictionary does.
65
+ */
66
+ export declare function setupTokens({ tokens, path, setupToken, }: SetupTokensProps): any;
67
+ /**
68
+ * Takes an plain javascript object and will make a flat array of all the leaf nodes.
69
+ * A leaf node in this context has a 'value' property. Potentially refactor this to
70
+ * be more generic.
71
+ * @private
72
+ * @param {Object} properties - The plain object you want flattened into an array.
73
+ * @param {Array} [to_ret=[]] - Properties array. This function is recursive therefore this is what gets passed along.
74
+ * @return {Array}
75
+ */
76
+ export declare function flattenProperties(properties: object, to_ret?: object[]): object[];
77
+ /**
78
+ * Performs an deep extend on the objects, from right to left.
79
+ * @private
80
+ * @param {Object[]} objects - An array of JS objects
81
+ * @param {Function} collision - A function to be called when a merge collision happens.
82
+ * @param {string[]} path - (for internal use) An array of strings which is the current path down the object when this is called recursively.
83
+ * @returns {Object}
84
+ */
85
+ export declare function deepExtend<T>(objects?: (object | undefined)[], collision?: Function, path?: string[]): T;
86
+ /**
87
+ * Checks if the value uses a value reference.
88
+ * @param {string} value
89
+ * @returns {boolean} - True, if the value uses a value reference
90
+ */
91
+ export declare function usesReference(value: any): boolean;
92
+ export {};
@@ -1,6 +1,5 @@
1
- export { createTheme } from './createTheme';
1
+ export { createTheme, defineComponentTheme, createComponentClasses, cssNameTransform, isDesignToken, setupTokens, SetupToken, } from './createTheme';
2
2
  export { defaultTheme } from './defaultTheme';
3
3
  export { defaultDarkModeOverride, reactNativeDarkTokens, } from './defaultDarkModeOverride';
4
4
  export { reactNativeTokens, ReactNativeTokens } from './tokens';
5
5
  export * from './types';
6
- export { cssNameTransform, isDesignToken, setupTokens, SetupToken, } from './utils';
@@ -1,6 +1,8 @@
1
1
  import { PartialDeep } from '../types';
2
2
  import { DefaultTokens, Tokens, WebTokens } from './tokens';
3
3
  import { Breakpoints } from './breakpoints';
4
+ import { ComponentsTheme } from './components';
5
+ import { CSSProperties } from './components/utils';
4
6
  export * from './tokens/types/designToken';
5
7
  export type { BorderWidths } from './tokens/borderWidths';
6
8
  export type { FontSizes } from './tokens/fontSizes';
@@ -9,6 +11,7 @@ export type { LineHeights } from './tokens/lineHeights';
9
11
  export type { Radii } from './tokens/radii';
10
12
  export type { Shadows } from './tokens/shadows';
11
13
  export type { SpaceSizes } from './tokens/space';
14
+ export { Tokens };
12
15
  /**
13
16
  * An override is a set of tokens that override others
14
17
  * in certain contexts. On Android, these are like resource
@@ -82,7 +85,7 @@ export interface ColorModeOverride extends BaseOverride {
82
85
  * They can define any tokens or breakpoints they need, but they don't need a
83
86
  * complete theme with all tokens.
84
87
  */
85
- export interface Theme {
88
+ export interface Theme<TokensType extends WebTokens = WebTokens> {
86
89
  /**
87
90
  * The name of the theme. This is used to create scoped CSS to allow for
88
91
  * multiple themes on a page.
@@ -99,22 +102,36 @@ export interface Theme {
99
102
  * and a generic selector override.
100
103
  */
101
104
  overrides?: Array<Override>;
105
+ components?: Array<ComponentsTheme<TokensType>>;
106
+ animations?: Animations;
107
+ }
108
+ export interface Animations {
109
+ [key: string]: {
110
+ [key in 'to' | 'from' | `${string}%`]?: CSSProperties | ((tokens: WebTokens) => CSSProperties);
111
+ };
102
112
  }
103
113
  /**
104
114
  * A DefaultTheme has all tokens and breakpoints required
105
115
  */
106
- export interface DefaultTheme extends Pick<Theme, 'name' | 'overrides' | 'primaryColor' | 'secondaryColor'> {
116
+ export interface DefaultTheme extends Pick<Theme, 'name' | 'overrides' | 'primaryColor' | 'secondaryColor' | 'components' | 'animations'> {
107
117
  tokens: DefaultTokens;
108
118
  breakpoints: Breakpoints;
109
119
  }
120
+ interface ContainerPropsArgs {
121
+ colorMode?: ColorMode | 'system';
122
+ }
110
123
  /**
111
124
  * WebTheme is a fully built theme that has cssText based
112
125
  * on the design tokens and all design tokens have added fields
113
126
  * to be used in Javascript/Typescript.
114
127
  */
115
- export interface WebTheme extends Pick<DefaultTheme, 'breakpoints' | 'name' | 'overrides'> {
128
+ export interface WebTheme extends Pick<DefaultTheme, 'breakpoints' | 'name' | 'overrides' | 'components' | 'animations'> {
116
129
  primaryColor?: string;
117
130
  secondaryColor?: string;
118
131
  cssText: string;
132
+ containerProps: (containerProps?: ContainerPropsArgs) => {
133
+ 'data-amplify-theme'?: string;
134
+ 'data-amplify-color-mode'?: string;
135
+ };
119
136
  tokens: WebTokens;
120
137
  }
@@ -1,4 +1,4 @@
1
1
  type ClassNamesInput = string | number | boolean | undefined | null | Record<string, unknown> | ClassNamesArgs;
2
- type ClassNamesArgs = Array<ClassNamesInput>;
2
+ export type ClassNamesArgs = Array<ClassNamesInput>;
3
3
  export declare const classNames: (...args: ClassNamesArgs) => string;
4
4
  export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Format bytes as human-readable text.
3
+ *
4
+ * @param bytes Number of bytes.
5
+ * @param si True to use metric (SI) units, aka powers of 1000. False to use
6
+ * binary (IEC), aka powers of 1024.
7
+ * @param dp Number of decimal places to display.
8
+ *
9
+ * @return Formatted string.
10
+ */
11
+ export declare function humanFileSize(bytes: number, si?: boolean, dp?: number): string;
@@ -1,3 +1,4 @@
1
1
  export { setUserAgent, SetUserAgentOptions } from './setUserAgent';
2
2
  export * from './utils';
3
- export { classNames } from './classNames';
3
+ export { classNames, ClassNamesArgs } from './classNames';
4
+ export { humanFileSize } from './humanFileSize';
@@ -145,3 +145,11 @@ export declare function noop(..._: any[]): void;
145
145
  * @param events string values related to group
146
146
  */
147
147
  export declare function groupLog(groupName: string, ...events: any[]): void;
148
+ /**
149
+ * Splits an object into 2 objects based on a predicate
150
+ *
151
+ * @param {object} obj an object to split into two
152
+ * @param {function} predicate function to determin where an element should go
153
+ * @returns
154
+ */
155
+ export declare function splitObject(obj: Record<string, unknown>, predicate: (key: string) => boolean): readonly [Record<string, unknown>, Record<string, unknown>];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/ui",
3
- "version": "6.0.17",
3
+ "version": "6.2.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "exports": {
@@ -46,7 +46,6 @@
46
46
  "dependencies": {
47
47
  "csstype": "^3.1.1",
48
48
  "lodash": "4.17.21",
49
- "style-dictionary": "3.9.1",
50
49
  "tslib": "^2.5.2"
51
50
  },
52
51
  "peerDependencies": {
@@ -64,7 +63,8 @@
64
63
  "autoprefixer": "^10.3.1",
65
64
  "glob": "^10.3.10",
66
65
  "postcss": "^8.4.31",
67
- "sass": "^1.35.2"
66
+ "sass": "^1.35.2",
67
+ "style-dictionary": "3.9.1"
68
68
  },
69
69
  "sideEffects": [
70
70
  "dist/**/*.css"
@@ -1,81 +0,0 @@
1
- import kebabCase from 'lodash/kebabCase.js';
2
- import usesReference from 'style-dictionary/lib/utils/references/usesReference.js';
3
- import '@aws-amplify/core/internals/utils';
4
- import '../utils/setUserAgent/constants.mjs';
5
- import { isObject, has, isString } from '../utils/utils.mjs';
6
-
7
- const CSS_VARIABLE_PREFIX = 'amplify';
8
- // Important: these properties should not be altered in
9
- // order to maintain the expected order of the CSS `box-shadow` property
10
- const SHADOW_PROPERTIES = [
11
- 'offsetX',
12
- 'offsetY',
13
- 'blurRadius',
14
- 'spreadRadius',
15
- 'color',
16
- ];
17
- function referenceValue(value) {
18
- if (!value)
19
- return '';
20
- if (usesReference(value)) {
21
- const path = value.replace(/\{|\}/g, '').replace('.value', '').split('.');
22
- return `var(--${cssNameTransform({ path })})`;
23
- }
24
- return value;
25
- }
26
- function cssValue(token) {
27
- const { value } = token;
28
- if (isString(value)) {
29
- return referenceValue(value);
30
- }
31
- if (isShadowTokenObject(value)) {
32
- return SHADOW_PROPERTIES.map((property) => {
33
- return referenceValue(
34
- // lookup property against `token` first for custom non-nested value, then lookup
35
- // property against `value` for design token value
36
- isShadowTokenObject(token) ? token[property] : value[property]);
37
- }).join(' ');
38
- }
39
- return value;
40
- }
41
- function cssNameTransform({ path = [] }) {
42
- return `${kebabCase([CSS_VARIABLE_PREFIX, ...path].join(' '))}`;
43
- }
44
- /**
45
- * Helper function to test if something is a design token or not.
46
- * Used in the React component style props.
47
- *
48
- * @param value - thing to test if it is a design token or not
49
- * @returns boolean
50
- */
51
- function isDesignToken(value) {
52
- return isObject(value) && has(value, 'value');
53
- }
54
- function isShadowTokenObject(value) {
55
- return isObject(value) && has(value, 'offsetX');
56
- }
57
- /**
58
- * Recursive function that will walk down the token object
59
- * and perform the setupToken function on each token.
60
- * Similar to what Style Dictionary does.
61
- */
62
- function setupTokens({ tokens, path = [], setupToken, }) {
63
- if (has(tokens, 'value')) {
64
- return setupToken({ token: tokens, path });
65
- }
66
- const output = {};
67
- for (const name in tokens) {
68
- if (has(tokens, name)) {
69
- const value = tokens[name];
70
- const nextTokens = isObject(value) ? value : { value };
71
- output[name] = setupTokens({
72
- tokens: nextTokens,
73
- path: path.concat(name),
74
- setupToken,
75
- });
76
- }
77
- }
78
- return output;
79
- }
80
-
81
- export { CSS_VARIABLE_PREFIX, cssNameTransform, cssValue, isDesignToken, isShadowTokenObject, setupTokens };
@@ -1,35 +0,0 @@
1
- import { ShadowValue, WebDesignToken } from './tokens/types/designToken';
2
- export declare const CSS_VARIABLE_PREFIX = "amplify";
3
- export declare function cssValue(token: BaseDesignToken): string | number;
4
- interface NameTransformProps {
5
- path?: Array<string>;
6
- }
7
- export declare function cssNameTransform({ path }: NameTransformProps): string;
8
- /**
9
- * Helper function to test if something is a design token or not.
10
- * Used in the React component style props.
11
- *
12
- * @param value - thing to test if it is a design token or not
13
- * @returns boolean
14
- */
15
- export declare function isDesignToken(value: unknown): value is WebDesignToken;
16
- export declare function isShadowTokenObject(value: unknown): value is ShadowValue & object;
17
- type SetupTokensProps = {
18
- tokens?: Record<string | number, any>;
19
- path?: Array<string>;
20
- setupToken: SetupToken;
21
- };
22
- export type SetupToken<ReturnType = any> = (args: {
23
- token: BaseDesignToken;
24
- path: Array<string>;
25
- }) => ReturnType;
26
- type BaseDesignToken = {
27
- value: string | number;
28
- };
29
- /**
30
- * Recursive function that will walk down the token object
31
- * and perform the setupToken function on each token.
32
- * Similar to what Style Dictionary does.
33
- */
34
- export declare function setupTokens({ tokens, path, setupToken, }: SetupTokensProps): any;
35
- export {};