@pega/cosmos-react-core 10.0.0-build.10.0 → 10.0.0-build.10.2
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/components/Checkbox/Checkbox.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.test-ids.d.ts +1 -1
- package/lib/components/Checkbox/Checkbox.test-ids.d.ts.map +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
- package/lib/components/ColorPicker/ColorPicker.d.ts +1 -1
- package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts +1 -1
- package/lib/components/ColorPicker/ColorPicker.test-ids.d.ts.map +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboxBox.test-ids.d.ts +1 -1
- package/lib/components/ComboBox/ComboxBox.test-ids.d.ts.map +1 -1
- package/lib/components/CompositeInput/CompositeInput.d.ts +1 -1
- package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts +1 -1
- package/lib/components/CompositeInput/CompositeInput.test-ids.d.ts.map +1 -1
- package/lib/components/Currency/Currency.test-ids.d.ts +1 -1
- package/lib/components/Currency/Currency.test-ids.d.ts.map +1 -1
- package/lib/components/Currency/CurrencyInput.d.ts +1 -1
- package/lib/components/Currency/CurrencyInput.styles.d.ts +1 -1
- package/lib/components/DateTime/DateTime.test-ids.d.ts +10 -10
- package/lib/components/DateTime/DateTime.test-ids.d.ts.map +1 -1
- package/lib/components/DateTime/Input/DateInput.d.ts +1 -1
- package/lib/components/DateTime/Input/DateRangeInput.d.ts +1 -1
- package/lib/components/DateTime/Input/DateTimeInput.d.ts +1 -1
- package/lib/components/DateTime/Input/DayOfWeekInput.d.ts +1 -1
- package/lib/components/DateTime/Input/Duration/DurationInput.d.ts +1 -1
- package/lib/components/DateTime/Input/MonthInput.d.ts +1 -1
- package/lib/components/DateTime/Input/QuarterInput.d.ts +1 -1
- package/lib/components/DateTime/Input/TimeInput.d.ts +1 -1
- package/lib/components/DateTime/Input/TimeRangeInput.d.ts +1 -1
- package/lib/components/DateTime/Input/WeekInput.d.ts +1 -1
- package/lib/components/File/File.test-ids.d.ts +1 -1
- package/lib/components/File/File.test-ids.d.ts.map +1 -1
- package/lib/components/File/FileInput.d.ts +1 -1
- package/lib/components/File/FileInput.styles.d.ts +1 -1
- package/lib/components/FormField/FormField.d.ts +9 -2
- package/lib/components/FormField/FormField.d.ts.map +1 -1
- package/lib/components/FormField/FormField.js +73 -3
- package/lib/components/FormField/FormField.js.map +1 -1
- package/lib/components/FormField/FormField.test-ids.d.ts +2 -2
- package/lib/components/FormField/FormField.test-ids.d.ts.map +1 -1
- package/lib/components/FormField/FormField.test-ids.js +1 -0
- package/lib/components/FormField/FormField.test-ids.js.map +1 -1
- package/lib/components/FormField/index.d.ts +1 -1
- package/lib/components/FormField/index.d.ts.map +1 -1
- package/lib/components/FormField/index.js.map +1 -1
- package/lib/components/Input/Input.d.ts +5 -4
- package/lib/components/Input/Input.d.ts.map +1 -1
- package/lib/components/Input/Input.js +1 -0
- package/lib/components/Input/Input.js.map +1 -1
- package/lib/components/Input/Input.test-ids.d.ts +1 -1
- package/lib/components/Input/Input.test-ids.d.ts.map +1 -1
- package/lib/components/Location/Location.test-ids.d.ts +1 -1
- package/lib/components/Location/Location.test-ids.d.ts.map +1 -1
- package/lib/components/Location/LocationInput.d.ts +1 -1
- package/lib/components/MultiStepForm/FormProgress.styles.js +5 -5
- package/lib/components/MultiStepForm/FormProgress.styles.js.map +1 -1
- package/lib/components/Number/Number.test-ids.d.ts +2 -2
- package/lib/components/Number/Number.test-ids.d.ts.map +1 -1
- package/lib/components/Number/NumberInput.d.ts +1 -1
- package/lib/components/Number/NumberRangeInput.d.ts +1 -1
- package/lib/components/Phone/Phone.test-ids.d.ts +1 -1
- package/lib/components/Phone/Phone.test-ids.d.ts.map +1 -1
- package/lib/components/Phone/PhoneInput.d.ts +1 -1
- package/lib/components/RadioButton/RadioButton.d.ts +1 -1
- package/lib/components/RadioButton/RadioButton.test-ids.d.ts +1 -1
- package/lib/components/RadioButton/RadioButton.test-ids.d.ts.map +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts.map +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js.map +1 -1
- package/lib/components/RadioCheck/RadioCheck.d.ts +1 -1
- package/lib/components/RadioCheck/RadioCheck.test-ids.d.ts +1 -1
- package/lib/components/RadioCheck/RadioCheck.test-ids.d.ts.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts +7 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.d.ts.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js +25 -14
- package/lib/components/RadioCheckGroup/RadioCheckGroup.js.map +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.test-ids.d.ts +1 -1
- package/lib/components/RadioCheckGroup/RadioCheckGroup.test-ids.d.ts.map +1 -1
- package/lib/components/SearchInput/SearchInput.styles.d.ts +1 -1
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/Select.test-ids.d.ts +1 -1
- package/lib/components/Select/Select.test-ids.d.ts.map +1 -1
- package/lib/components/Slider/Slider.d.ts +1 -1
- package/lib/components/Slider/Slider.test-ids.d.ts +1 -1
- package/lib/components/Slider/Slider.test-ids.d.ts.map +1 -1
- package/lib/components/TextArea/TextArea.d.ts +1 -1
- package/lib/components/TextArea/TextArea.test-ids.d.ts +1 -1
- package/lib/components/TextArea/TextArea.test-ids.d.ts.map +1 -1
- package/lib/hooks/useI18n.d.ts +2 -0
- package/lib/hooks/useI18n.d.ts.map +1 -1
- package/lib/i18n/default.d.ts +2 -0
- package/lib/i18n/default.d.ts.map +1 -1
- package/lib/i18n/default.js +2 -0
- package/lib/i18n/default.js.map +1 -1
- package/lib/i18n/i18n.d.ts +2 -0
- package/lib/i18n/i18n.d.ts.map +1 -1
- package/lib/styles/utils.d.ts +2 -0
- package/lib/styles/utils.d.ts.map +1 -1
- package/lib/styles/utils.js +7 -0
- package/lib/styles/utils.js.map +1 -1
- package/lib/theme/themes/aurigaDarkTheme.json +1 -1
- package/lib/theme/themes/aurigaTheme.json +3 -3
- package/lib/theme/themes/velaDarkTheme.json +1 -1
- package/lib/theme/themes/velaTheme.json +2 -2
- package/package.json +1 -1
package/lib/i18n/i18n.d.ts
CHANGED
|
@@ -150,6 +150,8 @@ export declare const DefaultTranslation: Readonly<Readonly<{
|
|
|
150
150
|
show_all: string;
|
|
151
151
|
clear_all: string;
|
|
152
152
|
clear_selection: string;
|
|
153
|
+
select_all: string;
|
|
154
|
+
unselect_all: string;
|
|
153
155
|
link_open_in_tab_text: string;
|
|
154
156
|
link_open_text: string;
|
|
155
157
|
edit_details: string;
|
package/lib/i18n/i18n.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAClE,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE7D,QAAA,MAAM,MAAM,GAAI,eAAe,WAAW,KAAG,QAAQ,CAAC,eAAe,CAEpE,CAAC;AACF,eAAe,MAAM,CAAC;AAEtB,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/i18n/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,WAAW,CAAC;AAE3C,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAClE,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE7D,Q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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAW,CAAC;AAiB3C,eAAO,MAAM,SAAS,GAAI,WAAW,MAAM,KAAG,KAAK,GAAG,KAErD,CAAC"}
|
package/lib/styles/utils.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare const supplementalColorMapping: {
|
|
|
31
31
|
export declare const resolveSupplementalColor: (theme: DefaultTheme, key: string) => string | undefined;
|
|
32
32
|
export declare const infiniteSupplementalColors: (theme: DefaultTheme, index: number) => string;
|
|
33
33
|
export declare const isSolidColor: (background: string) => boolean | undefined;
|
|
34
|
+
/** Returns whether the color is fully transparent. polished cannot parse the `transparent` keyword, so it is checked separately. */
|
|
35
|
+
export declare const isTransparentColor: (color: string) => boolean;
|
|
34
36
|
export declare const readableColor: (color: string, { mode, level }?: ContrastOptions) => string;
|
|
35
37
|
export declare const getHoverColors: (color: string, level: ContrastOptions["level"]) => {
|
|
36
38
|
background: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/styles/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAoBrE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,iEAAiE;AACjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEtC,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MACK,CAAC;AAEnE,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,OAAO,YAAY,GAAG,MAAM,CAAC;CAC5C;AAED,UAAU,2BAA2B;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iGAAiG;IACjG,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,KACnB;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CA0BlD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,KAAG,MAUnD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,MAU5E,CAAC;AAIF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,OAc5D,CAAC"}
|
package/lib/styles/utils.js
CHANGED
|
@@ -42,6 +42,13 @@ export const isSolidColor = (background) => {
|
|
|
42
42
|
(rgb.alpha === undefined ||
|
|
43
43
|
(rgb.alpha !== undefined && rgb.alpha === 1)));
|
|
44
44
|
};
|
|
45
|
+
/** Returns whether the color is fully transparent. polished cannot parse the `transparent` keyword, so it is checked separately. */
|
|
46
|
+
export const isTransparentColor = (color) => {
|
|
47
|
+
if (color.trim().toLowerCase() === 'transparent')
|
|
48
|
+
return true;
|
|
49
|
+
const rgb = tryCatch(() => parseToRgb(color));
|
|
50
|
+
return !!rgb && 'alpha' in rgb && rgb.alpha === 0;
|
|
51
|
+
};
|
|
45
52
|
export const readableColor = (color, { mode = 'light', level = 'AA' } = {}) => {
|
|
46
53
|
if (!isSolidColor(color) && mode === 'light') {
|
|
47
54
|
return '#fff';
|
package/lib/styles/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/styles/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,OAAO,EACP,aAAa,IAAI,qBAAqB,EACtC,MAAM,EACN,WAAW,EACX,GAAG,EACH,YAAY,EACZ,SAAS,EACT,IAAI,EACJ,eAAe,EACf,cAAc,EACd,UAAU,EACX,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,C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AAC;AACX,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,KAAoC,EAAE,EAAE,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhG;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,MAAc,EAAW,EAAE;IACrE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAEnC,OAAO,CACL,OAAO,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG;YAC3B,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK;YAC/B,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI;YAC7B,QAAQ,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,OAAO,CAAC,CACxC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { DefaultTheme, StyledOptions } from 'styled-components';\nimport {\n parseToHsl,\n lighten,\n readableColor as polishedReadableColor,\n darken,\n getContrast,\n hsl,\n modularScale,\n stripUnit,\n math,\n getValueAndUnit,\n transparentize,\n parseToRgb\n} from 'polished';\nimport type { RgbaColor } from 'polished/lib/types/color';\nimport type { ModularScaleRatio } from 'polished/lib/types/modularScaleRatio';\n\nimport { tryCatch } from '../utils';\n\nimport { wcagContrast } from './constants';\n\n/** Any positive number is valid on `theme.base.min-contrast`. */\nexport type MinContrastRatio = number;\n\nexport const isMinContrastRatio = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value) && value > 0;\n\ninterface ContrastOptions {\n mode?: 'light' | 'dark' | 'both';\n level?: keyof typeof wcagContrast | number;\n}\n\ninterface ResolveContrastColorOptions {\n background: string;\n /** Candidate brand/interactive color; when present and preference is `auto`, uses adjust-hue. */\n foreground?: string;\n theme: DefaultTheme;\n mode?: ContrastOptions['mode'];\n}\n\n/** Returns whether the color pair meets the given minimum contrast. */\nexport const meetsMinContrast = (\n foreground: string,\n background: string,\n minContrast: number\n): boolean => getContrast(foreground, background) >= minContrast;\n\nexport const backgroundCompatibleColors = (\n colors: string[],\n backgroundColor: string,\n { level = 'AA' }: Pick<ContrastOptions, 'level'> = {}\n) =>\n colors.filter(\n color =>\n getContrast(color, backgroundColor) >=\n (typeof level === 'string' ? wcagContrast[level] : level)\n );\n\nexport const supplementalColors = (theme: DefaultTheme): string[] =>\n Object.values(theme.base.palette['supplemental-colors']);\n\nexport const supplementalColorMapping = {\n 'Supplemental Color 1': 'color-1',\n 'Supplemental Color 2': 'color-2',\n 'Supplemental Color 3': 'color-3',\n 'Supplemental Color 4': 'color-4',\n 'Supplemental Color 5': 'color-5',\n 'Supplemental Color 6': 'color-6',\n 'Supplemental Color 7': 'color-7',\n 'Supplemental Color 8': 'color-8'\n} as const;\n\ntype SupplementalColorKey = keyof typeof supplementalColorMapping;\n\nconst isSupplementalColorKey = (key: string): key is SupplementalColorKey =>\n key in supplementalColorMapping;\n\nexport const resolveSupplementalColor = (theme: DefaultTheme, key: string): string | undefined => {\n if (isSupplementalColorKey(key)) {\n return theme.base.palette['supplemental-colors'][supplementalColorMapping[key]];\n }\n};\n\nexport const infiniteSupplementalColors = (theme: DefaultTheme, index: number): string => {\n const base = supplementalColors(theme);\n const baseCount = base.length;\n const colorIndex = index % baseCount;\n const wrapAround = 4;\n const decade = Math.floor(index / baseCount) % wrapAround;\n const baseColor = base[colorIndex];\n\n if (decade === 0) return baseColor;\n\n const isLighter = decade % 2 === 1;\n const shiftAmount = Math.min(Math.ceil(decade / 2) * 0.1, 0.2);\n\n return isLighter ? lighten(shiftAmount, baseColor) : darken(shiftAmount, baseColor);\n};\n\nexport const isSolidColor = (background: string) => {\n const rgb = tryCatch(() => parseToRgb(background));\n return (\n rgb &&\n ((rgb as RgbaColor).alpha === undefined ||\n ((rgb as RgbaColor).alpha !== undefined && (rgb as RgbaColor).alpha === 1))\n );\n};\n\nexport const readableColor = (\n color: string,\n { mode = 'light', level = 'AA' }: ContrastOptions = {}\n): string => {\n if (!isSolidColor(color) && mode === 'light') {\n return '#fff';\n }\n\n if (!isSolidColor(color) && mode === 'dark') {\n return '#000';\n }\n\n const minContrast = typeof level === 'string' ? wcagContrast[level] : level;\n\n if (mode === 'light' && getContrast('#fff', color) >= minContrast) {\n return '#fff';\n }\n\n if (mode === 'dark' && getContrast('#000', color) >= minContrast) {\n return '#000';\n }\n\n return tryCatch(\n () => polishedReadableColor(color),\n () => '#000'\n );\n};\n\nconst getBackgroundForegroundColors = (\n color: string,\n delta: number,\n level: ContrastOptions['level']\n) => {\n const backgroundLightness = tryCatch(\n () => parseToHsl(color).lightness,\n () => 1\n );\n let background = tryCatch(() => lighten(delta, color));\n let foreground = tryCatch(() => readableColor(lighten(delta, color), { level }));\n if (backgroundLightness > 0.35) {\n background = tryCatch(() => darken(delta, color));\n foreground = tryCatch(() => readableColor(darken(delta, color), { level }));\n }\n\n return { background, foreground };\n};\n\nexport const getHoverColors = (color: string, level: ContrastOptions['level']) => {\n return getBackgroundForegroundColors(color, 0.1, level);\n};\n\nexport const getActiveColors = (color: string, level: ContrastOptions['level']) => {\n return getBackgroundForegroundColors(color, 0.2, level);\n};\n\nexport const readableHue = (\n color1: string,\n color2: string,\n { mode = 'both', level = 'AA' }: ContrastOptions = {}\n): string => {\n // if both the color are not solid, return black as fallback\n if (!isSolidColor(color1) && !isSolidColor(color2)) {\n return '#000000';\n }\n\n // if one of the color is not solid, return the other color\n if (!isSolidColor(color2)) {\n return color1;\n }\n\n if (!isSolidColor(color1)) {\n return color2;\n }\n\n const minContrast = typeof level === 'string' ? wcagContrast[level] : level;\n\n if (getContrast(color1, color2) >= minContrast) return color1;\n\n const { lightness, ...hueSaturation } = parseToHsl(color1);\n\n let shouldLighten = true;\n let shouldDarken = true;\n\n let lightEnough = '';\n let darkEnough = '';\n\n for (let i = 0; i <= 1; i += 0.01) {\n if (shouldLighten) {\n const lightented = hsl({\n ...hueSaturation,\n lightness: Math.min(lightness + i, 1)\n });\n\n if (getContrast(lightented, color2) >= minContrast) {\n if (mode !== 'dark') return lightented;\n\n shouldLighten = false;\n lightEnough = lightented;\n }\n\n if (lightness + i >= 1) shouldLighten = false;\n }\n\n if (shouldDarken) {\n const darkened = hsl({\n ...hueSaturation,\n lightness: Math.max(lightness - i, 0)\n });\n\n if (getContrast(darkened, color2) >= minContrast) {\n if (mode !== 'light') return darkened;\n\n shouldDarken = false;\n darkEnough = darkened;\n }\n\n if (lightness - i <= 0) shouldDarken = false;\n }\n\n if (!shouldLighten && !shouldDarken) break;\n }\n\n if (lightEnough) return lightEnough;\n if (darkEnough) return darkEnough;\n\n return readableColor(color2, { mode, level });\n};\n\n/**\n * Resolves a readable color against a background using `base.min-contrast`\n * and `base.readable-color-preference`.\n *\n * - `light` / `dark`: pick that color when it meets min-contrast, otherwise fall back.\n * - `auto`: uses adjust-hue when a foreground candidate is provided; otherwise prefer-light.\n */\nexport const resolveContrastColor = ({\n background,\n foreground,\n theme,\n mode = 'light'\n}: ResolveContrastColorOptions): string => {\n const level = theme.base['min-contrast'];\n const preference = theme.base['readable-color-preference'];\n\n if (preference === 'dark') {\n return readableColor(background, { mode: 'dark', level });\n }\n\n if (preference === 'light') {\n return readableColor(background, { mode: 'light', level });\n }\n\n // `auto`: adjust-hue when a candidate foreground is provided; otherwise prefer-light.\n if (foreground) {\n return readableHue(foreground, background, { mode, level });\n }\n\n return readableColor(background, { mode: 'light', level });\n};\n\nexport const getReadableStatusColor = (\n theme: DefaultTheme,\n status: 'success' | 'warning' | 'error' | 'pending'\n): string => {\n const statusColor = theme.components['form-field'][status]['status-color'];\n const backgroundColor = theme.base.palette['primary-background'];\n\n return tryCatch(\n () =>\n resolveContrastColor({\n background: backgroundColor,\n foreground: statusColor,\n theme\n }),\n () => statusColor\n );\n};\n\nexport const omitProps = <O extends object = Record<PropertyKey, unknown>>(\n ...props: string[]\n): StyledOptions<'web', O> => ({\n shouldForwardProp: prop => !props.includes(prop)\n});\n\nexport type FontSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';\nconst stepsMap = {\n xxs: -2,\n xs: -1,\n s: 0,\n m: 1,\n l: 2,\n xl: 3,\n xxl: 4\n};\n\nexport const colorIconMapping = (theme: DefaultTheme, iconName: string) => {\n switch (iconName) {\n case 'polaris':\n case 'polaris-solid':\n return theme.base.palette.ai;\n case 'paper-clip':\n return theme.base.palette['supplemental-colors']['color-1'];\n case 'user-star':\n return theme.base.palette['supplemental-colors']['color-2'];\n case 'person':\n return theme.base.palette['supplemental-colors']['color-3'];\n case 'tag':\n return theme.base.palette['supplemental-colors']['color-4'];\n case 'folder-nested':\n return theme.base.palette['supplemental-colors']['color-5'];\n default:\n return theme.base.colors.gray.medium;\n }\n};\n\nexport const calculateFontSize = (baseFontSize: string, baseFontScale: string | number) => {\n return Object.fromEntries(\n Object.entries(stepsMap).map(([size, steps]) => {\n const calculation = tryCatch(\n () =>\n baseFontScale === 'linear'\n ? math(`${baseFontSize} + (${steps} * 0.0625rem)`)\n : modularScale(steps, baseFontSize, baseFontScale as ModularScaleRatio),\n () => baseFontSize\n );\n\n if (size === 'xs' && Number.parseFloat(`${stripUnit(calculation)}`) < 0.75) {\n return [size, `max(calc((${baseFontSize} + 12px) / 2), 12px)`];\n }\n\n return [size, `max(${calculation}, 12px)`];\n })\n ) as Record<FontSize, string>;\n};\n\nexport const calculateForegroundColor = (\n background: string,\n foregroundColor: string,\n theme?: DefaultTheme\n) => {\n if (foregroundColor !== 'auto') {\n return foregroundColor;\n }\n\n if (!isSolidColor(background)) {\n return '#000000';\n }\n\n if (theme) {\n return resolveContrastColor({\n background,\n theme\n });\n }\n\n return readableColor(background);\n};\n\nexport const calculateBackgroundAndContrastColor = (\n background: string,\n foregroundColor: string,\n theme?: DefaultTheme\n): { contrastColor: string; backgroundColor: string } => {\n const isGradientBackground = !isSolidColor(background);\n const computedFgColor = calculateForegroundColor(background, foregroundColor, theme);\n\n let computedBgColor = background;\n if (isGradientBackground) {\n computedBgColor = theme\n ? resolveContrastColor({\n background: computedFgColor,\n theme\n })\n : readableColor(computedFgColor);\n }\n\n let contrastColor = darken(0.05, computedBgColor);\n if (getContrast(computedBgColor, contrastColor) === 1) {\n contrastColor = lighten(0.15, computedBgColor);\n }\n if (isGradientBackground) {\n contrastColor = transparentize(0.9, computedFgColor);\n }\n\n return {\n contrastColor,\n backgroundColor: computedBgColor\n };\n};\n\nexport const getTranslucentColor = (color: string): string => {\n const fallbackColor = isSolidColor(color) ? color : '#000000';\n const luminance = tryCatch(\n () => parseToHsl(fallbackColor).lightness,\n () => 1\n );\n if (luminance > 0.5) {\n return transparentize(0.5, '#ffffff');\n }\n return transparentize(0.95, '#ffffff');\n};\n\n/**\n * Converts a CSS time value to a number in milliseconds.\n *\n * @param time - The CSS time value as a string (e.g: \"2s\", \"500ms\") or a number. If undefined, returns 0.\n * @returns The time value in milliseconds.\n * If the input is a number, it is returned as is.\n * If the input is a string, it is parsed and converted to milliseconds.\n */\nexport const getCSSTimeInMilliseconds = (time: string | number | undefined): number => {\n if (time === undefined) return 0;\n if (typeof time === 'number') return time;\n\n const [value, unit] = getValueAndUnit(time);\n\n if (unit === 's') return value * 1000;\n if (unit === 'ms') return value;\n\n return 0;\n};\n\nconst getAlpha = (color: ReturnType<typeof parseToRgb>) => ('alpha' in color ? color.alpha : 1);\n\n/**\n * Compares two color strings to determine if they are equivalent.\n *\n * Parses both color strings into RGB values and compares their red, green, blue,\n * and alpha components. Returns false if either color string cannot be parsed.\n *\n * @param color1 - The first color string to compare\n * @param color2 - The second color string to compare\n * @returns True if both colors have identical RGBA values, false otherwise\n *\n * @example\n * isSameColor('#FF0000', 'rgb(255, 0, 0)') // true\n * isSameColor('#FF0000', '#00FF00') // false\n * isSameColor('invalid', '#FF0000') // false\n */\nexport const isSameColor = (color1: string, color2: string): boolean => {\n try {\n const parsed1 = parseToRgb(color1);\n const parsed2 = parseToRgb(color2);\n\n return (\n parsed1.red === parsed2.red &&\n parsed1.green === parsed2.green &&\n parsed1.blue === parsed2.blue &&\n getAlpha(parsed1) === getAlpha(parsed2)\n );\n } catch {\n return false;\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/styles/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,OAAO,EACP,aAAa,IAAI,qBAAqB,EACtC,MAAM,EACN,WAAW,EACX,GAAG,EACH,YAAY,EACZ,SAAS,EACT,IAAI,EACJ,eAAe,EACf,cAAc,EACd,UAAU,EACX,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAmB,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;AAenE,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,UAAkB,EAClB,UAAkB,EAClB,WAAmB,EACV,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,WAAW,CAAC;AAEjE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,MAAgB,EAChB,eAAuB,EACvB,EAAE,KAAK,GAAG,IAAI,KAAqC,EAAE,EACrD,EAAE,CACF,MAAM,CAAC,MAAM,CACX,KAAK,CAAC,EAAE,CACN,WAAW,CAAC,KAAK,EAAE,eAAe,CAAC;IACnC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAA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AAC,MAAM,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;QAEnC,OAAO,CACL,OAAO,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG;YAC3B,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK;YAC/B,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI;YAC7B,QAAQ,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,OAAO,CAAC,CACxC,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { DefaultTheme, StyledOptions } from 'styled-components';\nimport {\n parseToHsl,\n lighten,\n readableColor as polishedReadableColor,\n darken,\n getContrast,\n hsl,\n modularScale,\n stripUnit,\n math,\n getValueAndUnit,\n transparentize,\n parseToRgb\n} from 'polished';\nimport type { RgbaColor } from 'polished/lib/types/color';\nimport type { ModularScaleRatio } from 'polished/lib/types/modularScaleRatio';\n\nimport { tryCatch } from '../utils';\n\nimport { wcagContrast } from './constants';\n\n/** Any positive number is valid on `theme.base.min-contrast`. */\nexport type MinContrastRatio = number;\n\nexport const isMinContrastRatio = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value) && value > 0;\n\ninterface ContrastOptions {\n mode?: 'light' | 'dark' | 'both';\n level?: keyof typeof wcagContrast | number;\n}\n\ninterface ResolveContrastColorOptions {\n background: string;\n /** Candidate brand/interactive color; when present and preference is `auto`, uses adjust-hue. */\n foreground?: string;\n theme: DefaultTheme;\n mode?: ContrastOptions['mode'];\n}\n\n/** Returns whether the color pair meets the given minimum contrast. */\nexport const meetsMinContrast = (\n foreground: string,\n background: string,\n minContrast: number\n): boolean => getContrast(foreground, background) >= minContrast;\n\nexport const backgroundCompatibleColors = (\n colors: string[],\n backgroundColor: string,\n { level = 'AA' }: Pick<ContrastOptions, 'level'> = {}\n) =>\n colors.filter(\n color =>\n getContrast(color, backgroundColor) >=\n (typeof level === 'string' ? wcagContrast[level] : level)\n );\n\nexport const supplementalColors = (theme: DefaultTheme): string[] =>\n Object.values(theme.base.palette['supplemental-colors']);\n\nexport const supplementalColorMapping = {\n 'Supplemental Color 1': 'color-1',\n 'Supplemental Color 2': 'color-2',\n 'Supplemental Color 3': 'color-3',\n 'Supplemental Color 4': 'color-4',\n 'Supplemental Color 5': 'color-5',\n 'Supplemental Color 6': 'color-6',\n 'Supplemental Color 7': 'color-7',\n 'Supplemental Color 8': 'color-8'\n} as const;\n\ntype SupplementalColorKey = keyof typeof supplementalColorMapping;\n\nconst isSupplementalColorKey = (key: string): key is SupplementalColorKey =>\n key in supplementalColorMapping;\n\nexport const resolveSupplementalColor = (theme: DefaultTheme, key: string): string | undefined => {\n if (isSupplementalColorKey(key)) {\n return theme.base.palette['supplemental-colors'][supplementalColorMapping[key]];\n }\n};\n\nexport const infiniteSupplementalColors = (theme: DefaultTheme, index: number): string => {\n const base = supplementalColors(theme);\n const baseCount = base.length;\n const colorIndex = index % baseCount;\n const wrapAround = 4;\n const decade = Math.floor(index / baseCount) % wrapAround;\n const baseColor = base[colorIndex];\n\n if (decade === 0) return baseColor;\n\n const isLighter = decade % 2 === 1;\n const shiftAmount = Math.min(Math.ceil(decade / 2) * 0.1, 0.2);\n\n return isLighter ? lighten(shiftAmount, baseColor) : darken(shiftAmount, baseColor);\n};\n\nexport const isSolidColor = (background: string) => {\n const rgb = tryCatch(() => parseToRgb(background));\n return (\n rgb &&\n ((rgb as RgbaColor).alpha === undefined ||\n ((rgb as RgbaColor).alpha !== undefined && (rgb as RgbaColor).alpha === 1))\n );\n};\n\n/** Returns whether the color is fully transparent. polished cannot parse the `transparent` keyword, so it is checked separately. */\nexport const isTransparentColor = (color: string) => {\n if (color.trim().toLowerCase() === 'transparent') return true;\n const rgb = tryCatch(() => parseToRgb(color));\n return !!rgb && 'alpha' in rgb && rgb.alpha === 0;\n};\n\nexport const readableColor = (\n color: string,\n { mode = 'light', level = 'AA' }: ContrastOptions = {}\n): string => {\n if (!isSolidColor(color) && mode === 'light') {\n return '#fff';\n }\n\n if (!isSolidColor(color) && mode === 'dark') {\n return '#000';\n }\n\n const minContrast = typeof level === 'string' ? wcagContrast[level] : level;\n\n if (mode === 'light' && getContrast('#fff', color) >= minContrast) {\n return '#fff';\n }\n\n if (mode === 'dark' && getContrast('#000', color) >= minContrast) {\n return '#000';\n }\n\n return tryCatch(\n () => polishedReadableColor(color),\n () => '#000'\n );\n};\n\nconst getBackgroundForegroundColors = (\n color: string,\n delta: number,\n level: ContrastOptions['level']\n) => {\n const backgroundLightness = tryCatch(\n () => parseToHsl(color).lightness,\n () => 1\n );\n let background = tryCatch(() => lighten(delta, color));\n let foreground = tryCatch(() => readableColor(lighten(delta, color), { level }));\n if (backgroundLightness > 0.35) {\n background = tryCatch(() => darken(delta, color));\n foreground = tryCatch(() => readableColor(darken(delta, color), { level }));\n }\n\n return { background, foreground };\n};\n\nexport const getHoverColors = (color: string, level: ContrastOptions['level']) => {\n return getBackgroundForegroundColors(color, 0.1, level);\n};\n\nexport const getActiveColors = (color: string, level: ContrastOptions['level']) => {\n return getBackgroundForegroundColors(color, 0.2, level);\n};\n\nexport const readableHue = (\n color1: string,\n color2: string,\n { mode = 'both', level = 'AA' }: ContrastOptions = {}\n): string => {\n // if both the color are not solid, return black as fallback\n if (!isSolidColor(color1) && !isSolidColor(color2)) {\n return '#000000';\n }\n\n // if one of the color is not solid, return the other color\n if (!isSolidColor(color2)) {\n return color1;\n }\n\n if (!isSolidColor(color1)) {\n return color2;\n }\n\n const minContrast = typeof level === 'string' ? wcagContrast[level] : level;\n\n if (getContrast(color1, color2) >= minContrast) return color1;\n\n const { lightness, ...hueSaturation } = parseToHsl(color1);\n\n let shouldLighten = true;\n let shouldDarken = true;\n\n let lightEnough = '';\n let darkEnough = '';\n\n for (let i = 0; i <= 1; i += 0.01) {\n if (shouldLighten) {\n const lightented = hsl({\n ...hueSaturation,\n lightness: Math.min(lightness + i, 1)\n });\n\n if (getContrast(lightented, color2) >= minContrast) {\n if (mode !== 'dark') return lightented;\n\n shouldLighten = false;\n lightEnough = lightented;\n }\n\n if (lightness + i >= 1) shouldLighten = false;\n }\n\n if (shouldDarken) {\n const darkened = hsl({\n ...hueSaturation,\n lightness: Math.max(lightness - i, 0)\n });\n\n if (getContrast(darkened, color2) >= minContrast) {\n if (mode !== 'light') return darkened;\n\n shouldDarken = false;\n darkEnough = darkened;\n }\n\n if (lightness - i <= 0) shouldDarken = false;\n }\n\n if (!shouldLighten && !shouldDarken) break;\n }\n\n if (lightEnough) return lightEnough;\n if (darkEnough) return darkEnough;\n\n return readableColor(color2, { mode, level });\n};\n\n/**\n * Resolves a readable color against a background using `base.min-contrast`\n * and `base.readable-color-preference`.\n *\n * - `light` / `dark`: pick that color when it meets min-contrast, otherwise fall back.\n * - `auto`: uses adjust-hue when a foreground candidate is provided; otherwise prefer-light.\n */\nexport const resolveContrastColor = ({\n background,\n foreground,\n theme,\n mode = 'light'\n}: ResolveContrastColorOptions): string => {\n const level = theme.base['min-contrast'];\n const preference = theme.base['readable-color-preference'];\n\n if (preference === 'dark') {\n return readableColor(background, { mode: 'dark', level });\n }\n\n if (preference === 'light') {\n return readableColor(background, { mode: 'light', level });\n }\n\n // `auto`: adjust-hue when a candidate foreground is provided; otherwise prefer-light.\n if (foreground) {\n return readableHue(foreground, background, { mode, level });\n }\n\n return readableColor(background, { mode: 'light', level });\n};\n\nexport const getReadableStatusColor = (\n theme: DefaultTheme,\n status: 'success' | 'warning' | 'error' | 'pending'\n): string => {\n const statusColor = theme.components['form-field'][status]['status-color'];\n const backgroundColor = theme.base.palette['primary-background'];\n\n return tryCatch(\n () =>\n resolveContrastColor({\n background: backgroundColor,\n foreground: statusColor,\n theme\n }),\n () => statusColor\n );\n};\n\nexport const omitProps = <O extends object = Record<PropertyKey, unknown>>(\n ...props: string[]\n): StyledOptions<'web', O> => ({\n shouldForwardProp: prop => !props.includes(prop)\n});\n\nexport type FontSize = 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl';\nconst stepsMap = {\n xxs: -2,\n xs: -1,\n s: 0,\n m: 1,\n l: 2,\n xl: 3,\n xxl: 4\n};\n\nexport const colorIconMapping = (theme: DefaultTheme, iconName: string) => {\n switch (iconName) {\n case 'polaris':\n case 'polaris-solid':\n return theme.base.palette.ai;\n case 'paper-clip':\n return theme.base.palette['supplemental-colors']['color-1'];\n case 'user-star':\n return theme.base.palette['supplemental-colors']['color-2'];\n case 'person':\n return theme.base.palette['supplemental-colors']['color-3'];\n case 'tag':\n return theme.base.palette['supplemental-colors']['color-4'];\n case 'folder-nested':\n return theme.base.palette['supplemental-colors']['color-5'];\n default:\n return theme.base.colors.gray.medium;\n }\n};\n\nexport const calculateFontSize = (baseFontSize: string, baseFontScale: string | number) => {\n return Object.fromEntries(\n Object.entries(stepsMap).map(([size, steps]) => {\n const calculation = tryCatch(\n () =>\n baseFontScale === 'linear'\n ? math(`${baseFontSize} + (${steps} * 0.0625rem)`)\n : modularScale(steps, baseFontSize, baseFontScale as ModularScaleRatio),\n () => baseFontSize\n );\n\n if (size === 'xs' && Number.parseFloat(`${stripUnit(calculation)}`) < 0.75) {\n return [size, `max(calc((${baseFontSize} + 12px) / 2), 12px)`];\n }\n\n return [size, `max(${calculation}, 12px)`];\n })\n ) as Record<FontSize, string>;\n};\n\nexport const calculateForegroundColor = (\n background: string,\n foregroundColor: string,\n theme?: DefaultTheme\n) => {\n if (foregroundColor !== 'auto') {\n return foregroundColor;\n }\n\n if (!isSolidColor(background)) {\n return '#000000';\n }\n\n if (theme) {\n return resolveContrastColor({\n background,\n theme\n });\n }\n\n return readableColor(background);\n};\n\nexport const calculateBackgroundAndContrastColor = (\n background: string,\n foregroundColor: string,\n theme?: DefaultTheme\n): { contrastColor: string; backgroundColor: string } => {\n const isGradientBackground = !isSolidColor(background);\n const computedFgColor = calculateForegroundColor(background, foregroundColor, theme);\n\n let computedBgColor = background;\n if (isGradientBackground) {\n computedBgColor = theme\n ? resolveContrastColor({\n background: computedFgColor,\n theme\n })\n : readableColor(computedFgColor);\n }\n\n let contrastColor = darken(0.05, computedBgColor);\n if (getContrast(computedBgColor, contrastColor) === 1) {\n contrastColor = lighten(0.15, computedBgColor);\n }\n if (isGradientBackground) {\n contrastColor = transparentize(0.9, computedFgColor);\n }\n\n return {\n contrastColor,\n backgroundColor: computedBgColor\n };\n};\n\nexport const getTranslucentColor = (color: string): string => {\n const fallbackColor = isSolidColor(color) ? color : '#000000';\n const luminance = tryCatch(\n () => parseToHsl(fallbackColor).lightness,\n () => 1\n );\n if (luminance > 0.5) {\n return transparentize(0.5, '#ffffff');\n }\n return transparentize(0.95, '#ffffff');\n};\n\n/**\n * Converts a CSS time value to a number in milliseconds.\n *\n * @param time - The CSS time value as a string (e.g: \"2s\", \"500ms\") or a number. If undefined, returns 0.\n * @returns The time value in milliseconds.\n * If the input is a number, it is returned as is.\n * If the input is a string, it is parsed and converted to milliseconds.\n */\nexport const getCSSTimeInMilliseconds = (time: string | number | undefined): number => {\n if (time === undefined) return 0;\n if (typeof time === 'number') return time;\n\n const [value, unit] = getValueAndUnit(time);\n\n if (unit === 's') return value * 1000;\n if (unit === 'ms') return value;\n\n return 0;\n};\n\nconst getAlpha = (color: ReturnType<typeof parseToRgb>) => ('alpha' in color ? color.alpha : 1);\n\n/**\n * Compares two color strings to determine if they are equivalent.\n *\n * Parses both color strings into RGB values and compares their red, green, blue,\n * and alpha components. Returns false if either color string cannot be parsed.\n *\n * @param color1 - The first color string to compare\n * @param color2 - The second color string to compare\n * @returns True if both colors have identical RGBA values, false otherwise\n *\n * @example\n * isSameColor('#FF0000', 'rgb(255, 0, 0)') // true\n * isSameColor('#FF0000', '#00FF00') // false\n * isSameColor('invalid', '#FF0000') // false\n */\nexport const isSameColor = (color1: string, color2: string): boolean => {\n try {\n const parsed1 = parseToRgb(color1);\n const parsed2 = parseToRgb(color2);\n\n return (\n parsed1.red === parsed2.red &&\n parsed1.green === parsed2.green &&\n parsed1.blue === parsed2.blue &&\n getAlpha(parsed1) === getAlpha(parsed2)\n );\n } catch {\n return false;\n }\n};\n"]}
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
},
|
|
56
56
|
"case-view": {
|
|
57
57
|
"icon": {
|
|
58
|
-
"color": "#
|
|
59
|
-
"background": "
|
|
58
|
+
"color": "#3f57e4",
|
|
59
|
+
"background": "#E0E4F6"
|
|
60
60
|
},
|
|
61
61
|
"stages": {
|
|
62
62
|
"status": {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
"icon": {
|
|
105
|
-
"border-radius-multiplier": "
|
|
105
|
+
"border-radius-multiplier": "0.5"
|
|
106
106
|
},
|
|
107
107
|
"tabs": {
|
|
108
108
|
"detached": true
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
},
|
|
79
79
|
"header": {
|
|
80
80
|
"background": "transparent",
|
|
81
|
-
"foreground-color": "#
|
|
81
|
+
"foreground-color": "#044548"
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
"card": {
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
"icon": {
|
|
104
|
-
"border-radius-multiplier": "
|
|
104
|
+
"border-radius-multiplier": "0.5"
|
|
105
105
|
},
|
|
106
106
|
"tabs": {
|
|
107
107
|
"detached": true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-core",
|
|
3
|
-
"version": "10.0.0-build.10.
|
|
3
|
+
"version": "10.0.0-build.10.2",
|
|
4
4
|
"description": "Cosmos is a visual design system and UI component collection. Its goal is to empower application developers in their pursuit to create engaging and rewarding user experiences.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Pegasystems",
|