@cloudscape-design/components-themeable 3.0.1242 → 3.0.1244
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
- package/lib/internal/template/i18n/providers/local-provider.d.ts.map +1 -1
- package/lib/internal/template/i18n/providers/local-provider.js +2 -26
- package/lib/internal/template/i18n/providers/local-provider.js.map +1 -1
- package/lib/internal/template/i18n/utils/i18n-formatter.d.ts.map +1 -1
- package/lib/internal/template/i18n/utils/i18n-formatter.js +3 -2
- package/lib/internal/template/i18n/utils/i18n-formatter.js.map +1 -1
- package/lib/internal/template/i18n/utils/messages.d.ts +3 -0
- package/lib/internal/template/i18n/utils/messages.d.ts.map +1 -0
- package/lib/internal/template/i18n/utils/messages.js +28 -0
- package/lib/internal/template/i18n/utils/messages.js.map +1 -0
- package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
- package/lib/internal/template/internal/environment.js +2 -2
- package/lib/internal/template/internal/environment.json +2 -2
- package/lib/internal/template/select/parts/trigger.js +2 -2
- package/lib/internal/template/select/parts/trigger.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-provider.d.ts","sourceRoot":"","sources":["../../../../src/i18n/providers/local-provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAiB,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"local-provider.d.ts","sourceRoot":"","sources":["../../../../src/i18n/providers/local-provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAiB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAItE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AASD,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,cAAc,EACtB,QAAQ,GACT,EAAE,sBAAsB,eA0BxB"}
|
|
@@ -5,6 +5,7 @@ import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
|
|
|
5
5
|
import { InternalI18nContext } from '../context';
|
|
6
6
|
import { I18nFormatter } from '../utils/i18n-formatter';
|
|
7
7
|
import { determineAppLocale } from '../utils/locales';
|
|
8
|
+
import { normalizeMessages } from '../utils/messages';
|
|
8
9
|
/**
|
|
9
10
|
* Context to send parent messages down to child I18nProviders. This isn't
|
|
10
11
|
* included in the InternalI18nContext to avoid components from depending on
|
|
@@ -19,7 +20,7 @@ export function LocalI18nProvider({ messages: messagesArray, locale: providedLoc
|
|
|
19
20
|
// The provider accepts an array of configs. We merge parent messages and
|
|
20
21
|
// flatten the tree early on so that accesses by key are simpler and faster.
|
|
21
22
|
const parentMessages = useContext(I18nMessagesContext);
|
|
22
|
-
const messages =
|
|
23
|
+
const messages = normalizeMessages([parentMessages, ...messagesArray]);
|
|
23
24
|
// The formatter is recreated on every render to ensure it has access to the
|
|
24
25
|
// latest messages. This is a trade-off between performance and correctness.
|
|
25
26
|
// In practice, this should only happen when the messages change, which is
|
|
@@ -28,29 +29,4 @@ export function LocalI18nProvider({ messages: messagesArray, locale: providedLoc
|
|
|
28
29
|
return (React.createElement(InternalI18nContext.Provider, { value: { locale, format: formatter.format.bind(formatter) } },
|
|
29
30
|
React.createElement(I18nMessagesContext.Provider, { value: messages }, children)));
|
|
30
31
|
}
|
|
31
|
-
function mergeMessages(sources) {
|
|
32
|
-
const result = {};
|
|
33
|
-
for (const messages of sources) {
|
|
34
|
-
for (const namespace in messages) {
|
|
35
|
-
if (!(namespace in result)) {
|
|
36
|
-
result[namespace] = {};
|
|
37
|
-
}
|
|
38
|
-
for (const casedLocale in messages[namespace]) {
|
|
39
|
-
const locale = casedLocale.toLowerCase();
|
|
40
|
-
if (!(locale in result[namespace])) {
|
|
41
|
-
result[namespace][locale] = {};
|
|
42
|
-
}
|
|
43
|
-
for (const component in messages[namespace][casedLocale]) {
|
|
44
|
-
if (!(component in result[namespace][locale])) {
|
|
45
|
-
result[namespace][locale][component] = {};
|
|
46
|
-
}
|
|
47
|
-
for (const key in messages[namespace][casedLocale][component]) {
|
|
48
|
-
result[namespace][locale][component][key] = messages[namespace][casedLocale][component][key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
32
|
//# sourceMappingURL=local-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-provider.js","sourceRoot":"","sources":["../../../../src/i18n/providers/local-provider.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,aAAa,EAAgB,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAQtD;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAe,EAAE,CAAC,CAAC;AAElE,MAAM,UAAU,iBAAiB,CAAC,EAChC,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,cAAc,EACtB,QAAQ,GACe;IACvB,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,CAAC,cAAc,EAAE,CAAC;QACvD,QAAQ,CACN,cAAc,EACd,mHAAmH,CACpH,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,kBAAkB,CAAC,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Q,CAAC,CAAC;IAEtD,OAAO,CACL,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QACvF,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,IAAG,QAAQ,CAAgC,CAC3D,CAChC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useContext } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { InternalI18nContext } from '../context';\nimport { I18nFormatter, I18nMessages } from '../utils/i18n-formatter';\nimport { determineAppLocale } from '../utils/locales';\nimport { normalizeMessages } from '../utils/messages';\n\nexport interface LocalI18nProviderProps {\n messages: ReadonlyArray<I18nMessages>;\n locale?: string;\n children: React.ReactNode;\n}\n\n/**\n * Context to send parent messages down to child I18nProviders. This isn't\n * included in the InternalI18nContext to avoid components from depending on\n * MessageFormatElement types.\n */\nconst I18nMessagesContext = React.createContext<I18nMessages>({});\n\nexport function LocalI18nProvider({\n messages: messagesArray,\n locale: providedLocale,\n children,\n}: LocalI18nProviderProps) {\n if (typeof document === 'undefined' && !providedLocale) {\n warnOnce(\n 'I18nProvider',\n 'An explicit locale was not provided during server rendering. This can lead to a hydration mismatch on the client.'\n );\n }\n\n const locale = determineAppLocale(providedLocale);\n\n // The provider accepts an array of configs. We merge parent messages and\n // flatten the tree early on so that accesses by key are simpler and faster.\n const parentMessages = useContext(I18nMessagesContext);\n const messages = normalizeMessages([parentMessages, ...messagesArray]);\n\n // The formatter is recreated on every render to ensure it has access to the\n // latest messages. This is a trade-off between performance and correctness.\n // In practice, this should only happen when the messages change, which is\n // infrequent.\n const formatter = new I18nFormatter(locale, messages);\n\n return (\n <InternalI18nContext.Provider value={{ locale, format: formatter.format.bind(formatter) }}>\n <I18nMessagesContext.Provider value={messages}>{children}</I18nMessagesContext.Provider>\n </InternalI18nContext.Provider>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-formatter.d.ts","sourceRoot":"","sources":["../../../../src/i18n/utils/i18n-formatter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"i18n-formatter.d.ts","sourceRoot":"","sources":["../../../../src/i18n/utils/i18n-formatter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,CAAC,MAAM,EAAE,MAAM,GAAG;YAChB,CAAC,SAAS,EAAE,MAAM,GAAG;gBACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,oBAAoB,EAAE,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAe;IAMhC,OAAO,CAAC,qBAAqB,CAAwC;gBAEzD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY;IAKlD,MAAM,CAAC,WAAW,EAAE,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EACtE,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,WAAW,EACrB,aAAa,CAAC,EAAE,aAAa,CAAC,WAAW,EAAE,YAAY,CAAC,GACvD,WAAW;CA2Cf"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import IntlMessageFormat from 'intl-messageformat';
|
|
4
4
|
import { getMatchableLocales } from './locales';
|
|
5
|
+
import { normalizeMessages } from './messages';
|
|
5
6
|
/**
|
|
6
7
|
* A stateful container for formatting internal strings. Caches formatters
|
|
7
8
|
* where possible; a new instance must be created if locale or messages may
|
|
@@ -14,8 +15,8 @@ export class I18nFormatter {
|
|
|
14
15
|
// with potentially different locale or messages. We expect this component to
|
|
15
16
|
// be placed above AppLayout and therefore rerender very infrequently.
|
|
16
17
|
this._localeFormatterCache = new Map();
|
|
17
|
-
this._locale = locale;
|
|
18
|
-
this._messages = messages;
|
|
18
|
+
this._locale = locale.toLowerCase();
|
|
19
|
+
this._messages = normalizeMessages([messages]);
|
|
19
20
|
}
|
|
20
21
|
format(namespace, component, key, provided, customHandler) {
|
|
21
22
|
var _a, _b, _c, _d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-formatter.js","sourceRoot":"","sources":["../../../../src/i18n/utils/i18n-formatter.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"i18n-formatter.js","sourceRoot":"","sources":["../../../../src/i18n/utils/i18n-formatter.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkB/C;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAUxB,YAAY,MAAc,EAAE,QAAsB;QANlD,yEAAyE;QACzE,6EAA6E;QAC7E,6EAA6E;QAC7E,sEAAsE;QAC9D,0BAAqB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,IAAI,CAAC,OAAO,CAAC,CAAC;YACjE,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAW,CAAC,CAAC;QACzE,CAAC;QACD,+EAA+E;QAC/E,OAAO,iBAAiB,CAAC,MAAM,EAAiB,CAAC;IACnD,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { MessageFormatElement } from '@formatjs/icu-messageformat-parser';\nimport IntlMessageFormat from 'intl-messageformat';\n\nimport { CustomHandler } from '../context';\nimport { getMatchableLocales } from './locales';\nimport { normalizeMessages } from './messages';\n\n/**\n * The expected shape of the fully resolved messages object.\n * Typescript ensures any static imports are properly typed, but since this\n * depends on types from formatjs, it should not be included in any files that\n * need to support older versions of TypeScript (3.7 and up).\n */\nexport interface I18nMessages {\n [namespace: string]: {\n [locale: string]: {\n [component: string]: {\n [key: string]: string | MessageFormatElement[];\n };\n };\n };\n}\n\n/**\n * A stateful container for formatting internal strings. Caches formatters\n * where possible; a new instance must be created if locale or messages may\n * have changed.\n */\nexport class I18nFormatter {\n private _locale: string;\n private _messages: I18nMessages;\n\n // Create a per-render cache of messages and IntlMessageFormat instances.\n // Not memoizing it allows us to reset the cache when the component rerenders\n // with potentially different locale or messages. We expect this component to\n // be placed above AppLayout and therefore rerender very infrequently.\n private _localeFormatterCache = new Map<string, IntlMessageFormat>();\n\n constructor(locale: string, messages: I18nMessages) {\n this._locale = locale.toLowerCase();\n this._messages = normalizeMessages([messages]);\n }\n\n format<ReturnValue, FormatFnArgs extends Record<string, string | number>>(\n namespace: string,\n component: string,\n key: string,\n provided: ReturnValue,\n customHandler?: CustomHandler<ReturnValue, FormatFnArgs>\n ): ReturnValue {\n // A general rule in this library is that undefined is basically\n // treated as \"not provided\". So even if a user explicitly provides an\n // undefined value, it will default to i18n provider values.\n if (provided !== undefined) {\n return provided;\n }\n\n const cacheKey = `${namespace}.${component}.${key}`;\n let intlMessageFormat: IntlMessageFormat;\n\n const cachedFormatter = this._localeFormatterCache.get(cacheKey);\n if (cachedFormatter) {\n // If an IntlMessageFormat instance was cached for this locale, just use that.\n intlMessageFormat = cachedFormatter;\n } else {\n // Widen the locale string (e.g. en-GB -> en) until we find a locale\n // that contains the message we need.\n let message: string | MessageFormatElement[] | undefined;\n const matchableLocales = getMatchableLocales(this._locale);\n for (const matchableLocale of matchableLocales) {\n message = this._messages?.[namespace]?.[matchableLocale]?.[component]?.[key];\n if (message !== undefined) {\n break;\n }\n }\n\n // If a message wasn't found, exit early.\n if (message === undefined) {\n return provided;\n }\n\n // Lazily create an IntlMessageFormat object for this key.\n intlMessageFormat = new IntlMessageFormat(message, this._locale);\n this._localeFormatterCache.set(cacheKey, intlMessageFormat);\n }\n\n if (customHandler) {\n return customHandler(args => intlMessageFormat.format(args) as string);\n }\n // Assuming `ReturnValue extends string` since a customHandler wasn't provided.\n return intlMessageFormat.format() as ReturnValue;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/i18n/utils/messages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,GAAG,YAAY,CAwBpF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export function normalizeMessages(sources) {
|
|
4
|
+
const result = {};
|
|
5
|
+
for (const messages of sources) {
|
|
6
|
+
for (const namespace in messages) {
|
|
7
|
+
if (!(namespace in result)) {
|
|
8
|
+
result[namespace] = {};
|
|
9
|
+
}
|
|
10
|
+
for (const casedLocale in messages[namespace]) {
|
|
11
|
+
const locale = casedLocale.toLowerCase();
|
|
12
|
+
if (!(locale in result[namespace])) {
|
|
13
|
+
result[namespace][locale] = {};
|
|
14
|
+
}
|
|
15
|
+
for (const component in messages[namespace][casedLocale]) {
|
|
16
|
+
if (!(component in result[namespace][locale])) {
|
|
17
|
+
result[namespace][locale][component] = {};
|
|
18
|
+
}
|
|
19
|
+
for (const key in messages[namespace][casedLocale][component]) {
|
|
20
|
+
result[namespace][locale][component][key] = messages[namespace][casedLocale][component][key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../src/i18n/utils/messages.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,MAAM,UAAU,iBAAiB,CAAC,OAAoC;IACpE,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;QAC/B,KAAK,MAAM,SAAS,IAAI,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC,CAAC,SAAS,IAAI,MAAM,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YACzB,CAAC;YACD,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC9C,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;gBACzC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;oBACnC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;gBACjC,CAAC;gBACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;oBACzD,IAAI,CAAC,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;wBAC9C,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;oBAC5C,CAAC;oBACD,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;wBAC9D,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC;oBAC/F,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { I18nMessages } from './i18n-formatter';\n\nexport function normalizeMessages(sources: ReadonlyArray<I18nMessages>): I18nMessages {\n const result: I18nMessages = {};\n for (const messages of sources) {\n for (const namespace in messages) {\n if (!(namespace in result)) {\n result[namespace] = {};\n }\n for (const casedLocale in messages[namespace]) {\n const locale = casedLocale.toLowerCase();\n if (!(locale in result[namespace])) {\n result[namespace][locale] = {};\n }\n for (const component in messages[namespace][casedLocale]) {\n if (!(component in result[namespace][locale])) {\n result[namespace][locale][component] = {};\n }\n for (const key in messages[namespace][casedLocale][component]) {\n result[namespace][locale][component][key] = messages[namespace][casedLocale][component][key];\n }\n }\n }\n }\n }\n return result;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "components";
|
|
2
|
-
export var PACKAGE_VERSION = "3.0.0 (
|
|
3
|
-
export var GIT_SHA = "
|
|
2
|
+
export var PACKAGE_VERSION = "3.0.0 (3189432f)";
|
|
3
|
+
export var GIT_SHA = "3189432f";
|
|
4
4
|
export var THEME = "open-source-visual-refresh";
|
|
5
5
|
export var SYSTEM = "core";
|
|
6
6
|
export var ALWAYS_VISUAL_REFRESH = true;
|
|
@@ -30,11 +30,11 @@ const Trigger = React.forwardRef(({ ariaLabelledby, ariaDescribedby, controlId,
|
|
|
30
30
|
ariaLabelledbyIds = ariaLabelledby;
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
triggerContent = (React.createElement("span", {
|
|
33
|
+
triggerContent = (React.createElement("span", { className: clsx(styles.placeholder, styles.trigger), id: triggerContentId }, placeholder));
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
else if (!selectedOption) {
|
|
37
|
-
triggerContent = (React.createElement("span", {
|
|
37
|
+
triggerContent = (React.createElement("span", { className: clsx(styles.placeholder, styles.trigger), id: triggerContentId }, placeholder));
|
|
38
38
|
}
|
|
39
39
|
else if (triggerVariant === 'option') {
|
|
40
40
|
const triggerCustomContent = renderOption === null || renderOption === void 0 ? void 0 : renderOption({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../../../src/select/parts/trigger.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE1F,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,MAAM,MAAM,kCAAkC,CAAC;AAGtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAA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EAChB,EAAE,EAAE,EAAE,EACN,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,CAAC,CAAC,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,IAAI,CAAC,OAAO,EAC5B,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,cAAc,KAAK,QAAQ,EACzC,gBAAgB,EAAE,gBAAgB,EAClC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,iBAAiB,IAEhC,cAAc,CACD,CACjB,CAAC;IACF,OAAO,CACL,0CACG,eAAe,CAAC,CAAC,CAAC,CACjB,6BAAK,SAAS,EAAE,MAAM,CAAC,sBAAsB,CAAC;QAC5C,+BACE,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,cAAc,CAAC,EACtB,QAAQ,IAAI,MAAM,CAAC,uBAAuB,CAAC,EAC3C,cAAc,KAAK,QAAQ,IAAI,MAAM,CAAC,4BAA4B,CAAC,CACpE,IAEA,eAAe,CACV;QACR,6BAAK,SAAS,EAAE,MAAM,CAAC,8BAA8B,CAAC,IAAG,aAAa,CAAO,CACzE,CACP,CAAC,CAAC,CAAC,CACF,0CAAG,aAAa,CAAI,CACrB,CACA,CACJ,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,OAAO,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport ButtonTrigger from '../../internal/components/button-trigger';\nimport Option from '../../internal/components/option';\nimport { OptionDefinition } from '../../internal/components/option/interfaces';\nimport { FormFieldValidationControlProps } from '../../internal/context/form-field-context';\nimport { useVisualRefresh } from '../../internal/hooks/use-visual-mode';\nimport { joinStrings } from '../../internal/utils/strings';\nimport { MultiselectProps } from '../../multiselect/interfaces';\nimport InternalToken from '../../token/internal';\nimport { SelectProps } from '../interfaces';\nimport { SelectTriggerProps } from '../utils/use-select';\n\nimport styles from './styles.css.js';\n\nexport interface TriggerProps extends FormFieldValidationControlProps {\n placeholder: string | undefined;\n disabled: boolean | undefined;\n readOnly?: boolean;\n triggerProps: SelectTriggerProps;\n selectedOption: OptionDefinition | null;\n inlineLabelText?: string;\n isOpen?: boolean;\n triggerVariant?: SelectProps.TriggerVariant | MultiselectProps.TriggerVariant;\n inFilteringToken?: 'root' | 'nested';\n selectedOptions?: ReadonlyArray<OptionDefinition>;\n renderOption?: SelectProps.SelectOptionItemRenderer;\n}\n\nconst Trigger = React.forwardRef(\n (\n {\n ariaLabelledby,\n ariaDescribedby,\n controlId,\n invalid,\n inlineLabelText,\n warning,\n triggerProps,\n selectedOption,\n selectedOptions,\n triggerVariant,\n inFilteringToken,\n isOpen,\n placeholder,\n disabled,\n readOnly,\n renderOption,\n }: TriggerProps,\n ref: React.Ref<HTMLButtonElement>\n ) => {\n const isVisualRefresh = useVisualRefresh();\n const generatedId = useUniqueId();\n const id = controlId ?? generatedId;\n const triggerContentId = useUniqueId('trigger-content-');\n\n let ariaLabelledbyIds = joinStrings(ariaLabelledby, triggerContentId);\n\n let triggerContent = null;\n let hasCustomContent = false;\n if (triggerVariant === 'tokens') {\n if (selectedOptions?.length) {\n triggerContent = (\n <span\n className={clsx(\n styles['inline-token-trigger'],\n disabled && styles['inline-token-trigger--disabled'],\n isVisualRefresh && styles['visual-refresh']\n )}\n >\n <span className={styles['inline-token-list']}>\n {selectedOptions.map(({ label }, i) => (\n <InternalToken key={i} label={label} variant=\"inline\" disabled={disabled} />\n ))}\n </span>\n <span className={styles['inline-token-counter']} id={triggerContentId}>\n <span className={styles['inline-token-hidden-placeholder']}>{placeholder}</span>\n <span>({selectedOptions.length})</span>\n </span>\n </span>\n );\n ariaLabelledbyIds = ariaLabelledby;\n } else {\n triggerContent = (\n <span className={clsx(styles.placeholder, styles.trigger)} id={triggerContentId}>\n {placeholder}\n </span>\n );\n }\n } else if (!selectedOption) {\n triggerContent = (\n <span className={clsx(styles.placeholder, styles.trigger)} id={triggerContentId}>\n {placeholder}\n </span>\n );\n } else if (triggerVariant === 'option') {\n const triggerCustomContent = renderOption?.({\n filterText: undefined,\n item: {\n type: 'trigger',\n option: selectedOption,\n },\n });\n if (triggerCustomContent) {\n hasCustomContent = true;\n triggerContent = (\n <Option\n customContent={triggerCustomContent}\n id={triggerContentId}\n option={{ ...selectedOption, disabled }}\n triggerVariant={true}\n />\n );\n } else {\n triggerContent = (\n <Option id={triggerContentId} option={{ ...selectedOption, disabled }} triggerVariant={true} />\n );\n }\n } else {\n triggerContent = (\n <span id={triggerContentId} className={styles.trigger}>\n {selectedOption.label || selectedOption.value}\n </span>\n );\n }\n\n const mergedRef = useMergeRefs(triggerProps.ref, ref);\n const triggerButton = (\n <ButtonTrigger\n {...triggerProps}\n id={id}\n ref={mergedRef}\n pressed={!!isOpen}\n disabled={disabled}\n readOnly={readOnly}\n invalid={invalid}\n warning={warning && !invalid}\n inFilteringToken={inFilteringToken}\n inlineTokens={triggerVariant === 'tokens'}\n hasCustomContent={hasCustomContent}\n ariaDescribedby={ariaDescribedby}\n ariaLabelledby={ariaLabelledbyIds}\n >\n {triggerContent}\n </ButtonTrigger>\n );\n return (\n <>\n {inlineLabelText ? (\n <div className={styles['inline-label-wrapper']}>\n <label\n htmlFor={controlId}\n className={clsx(\n styles['inline-label'],\n disabled && styles['inline-label-disabled'],\n triggerVariant === 'tokens' && styles['inline-label-inline-tokens']\n )}\n >\n {inlineLabelText}\n </label>\n <div className={styles['inline-label-trigger-wrapper']}>{triggerButton}</div>\n </div>\n ) : (\n <>{triggerButton}</>\n )}\n </>\n );\n }\n);\n\nexport default Trigger;\n"]}
|