pixelize-design-library 2.4.2-beta.32 → 2.4.2-beta.34

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 (47) hide show
  1. package/README.md +21 -0
  2. package/dist/Components/Button/Button.styles.js +7 -6
  3. package/dist/Components/Card/PaymentCard/PaymentCard.js +14 -5
  4. package/dist/Components/Common/ErrorComponent.js +6 -5
  5. package/dist/Components/DatePicker/CalendarPanel.js +6 -7
  6. package/dist/Components/FilePreview/FilePreview.js +2 -1
  7. package/dist/Components/KanbanBoard/KanbanActions/KanbanActions.js +1 -2
  8. package/dist/Components/OrganizationDetails/OrganizationDetails.js +3 -2
  9. package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +4 -3
  10. package/dist/Components/ScrollToTop/ScrollToTop.js +3 -3
  11. package/dist/Components/SelectSearch/SelectSearch.js +1 -1
  12. package/dist/Components/SideBar/SideBar.js +4 -2
  13. package/dist/Components/StageProgress/StageProgressProps.js +6 -4
  14. package/dist/Components/Table/Table.js +2 -1
  15. package/dist/Components/Table/filters/LeftFilterPane.js +1 -1
  16. package/dist/Components/Tag/Tag.styles.js +13 -9
  17. package/dist/Theme/chakra/componentStyles.js +16 -9
  18. package/dist/Theme/chakra/createBrandTheme.js +15 -9
  19. package/dist/Theme/tokens/builders/filledSurface.d.ts +29 -0
  20. package/dist/Theme/tokens/builders/filledSurface.js +74 -0
  21. package/dist/Utils/table.js +5 -2
  22. package/dist/esm/Components/Button/Button.styles.js +8 -7
  23. package/dist/esm/Components/Card/PaymentCard/PaymentCard.js +14 -5
  24. package/dist/esm/Components/Common/ErrorComponent.js +6 -5
  25. package/dist/esm/Components/DatePicker/CalendarPanel.js +6 -7
  26. package/dist/esm/Components/FilePreview/FilePreview.js +2 -1
  27. package/dist/esm/Components/KanbanBoard/KanbanActions/KanbanActions.js +1 -2
  28. package/dist/esm/Components/OrganizationDetails/OrganizationDetails.js +4 -3
  29. package/dist/esm/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +5 -4
  30. package/dist/esm/Components/ScrollToTop/ScrollToTop.js +3 -3
  31. package/dist/esm/Components/SelectSearch/SelectSearch.js +1 -1
  32. package/dist/esm/Components/SideBar/SideBar.js +4 -2
  33. package/dist/esm/Components/StageProgress/StageProgressProps.js +7 -5
  34. package/dist/esm/Components/Table/Table.js +2 -1
  35. package/dist/esm/Components/Table/filters/LeftFilterPane.js +1 -1
  36. package/dist/esm/Components/Tag/Tag.styles.js +14 -10
  37. package/dist/esm/Theme/chakra/componentStyles.js +16 -9
  38. package/dist/esm/Theme/chakra/createBrandTheme.js +15 -9
  39. package/dist/esm/Theme/tokens/builders/filledSurface.js +67 -0
  40. package/dist/esm/Utils/table.js +5 -2
  41. package/dist/esm/index.js +3 -0
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.js +8 -1
  44. package/package.json +1 -1
  45. package/dist/Theme/tokens/builders/solidFillRung.d.ts +0 -4
  46. package/dist/Theme/tokens/builders/solidFillRung.js +0 -33
  47. package/dist/esm/Theme/tokens/builders/solidFillRung.js +0 -28
@@ -9,9 +9,9 @@ import { Tag } from "../../Components/Tag/Tag.styles.js";
9
9
  import { Textarea } from "../../Components/InputTextArea/InputTextArea.style.js";
10
10
  import { NumberInput } from "../../Components/NumberInput/NumberInput.styles.js";
11
11
  import { accentTextOnCanvas, isDarkCanvas, onFilled } from "../tokens/builders/accentText.js";
12
+ import { labelOnFill, solidFillRung } from "../tokens/builders/filledSurface.js";
12
13
  import { contrastRatio } from "../tokens/builders/color.js";
13
14
  import { resolveHoverTint } from "../tokens/builders/outlineRung.js";
14
- import { solidRung } from "../tokens/builders/solidFillRung.js";
15
15
  import { Drawer } from "./Drawer.styles.js";
16
16
  import { Menu } from "./Menu.styles.js";
17
17
  import { Modal } from "./Modal.styles.js";
@@ -25,6 +25,14 @@ import { Avatar } from "./Avatar.styles.js";
25
25
  // math (hexToRgb) throws on those on purpose (see color.ts). Guard so those scales fall back to
26
26
  // Chakra's own original fixed rung instead of computing contrast on a color it can't parse.
27
27
  const isHexColor = (color) => typeof color === "string" && /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(color);
28
+ const solidFillStyle = (palette, swatch) => {
29
+ const rung = solidFillRung(swatch, palette.white);
30
+ const bg = swatch[rung];
31
+ return {
32
+ bg,
33
+ color: isHexColor(bg) ? labelOnFill(bg, palette.white, palette.black) : swatch[800],
34
+ };
35
+ };
28
36
  // Badge isn't its own component family (no Components/Badge/), so its style config lives here —
29
37
  // Chakra's stock `solid` variant hardcodes a white label on a variable fill, same AA gap Tag had.
30
38
  const Badge = {
@@ -32,10 +40,7 @@ const Badge = {
32
40
  solid: ({ theme, colorScheme = "gray" }) => {
33
41
  const palette = paletteOf(theme);
34
42
  const swatch = scaleFor(palette, colorScheme);
35
- if (!isHexColor(swatch[500]))
36
- return { bg: swatch[500], color: swatch[800] };
37
- const bg = swatch[solidRung(swatch, palette.white)];
38
- return { bg, color: onFilled(bg, palette.white, palette.black) };
43
+ return solidFillStyle(palette, swatch);
39
44
  },
40
45
  // Chakra's stock `subtle` picks its bg/color pair via `mode()`, keyed to Chakra's own
41
46
  // colorMode — which this app never toggles (dark mode swaps the palette object instead), so
@@ -87,13 +92,14 @@ const Alert = defineAlertStyles({
87
92
  variants: {
88
93
  solid: defineAlertParts(({ theme, colorScheme = "gray" }) => {
89
94
  const palette = paletteOf(theme);
90
- const bg = scaleFor(palette, colorScheme)[500];
95
+ const swatch = scaleFor(palette, colorScheme);
96
+ const { bg, color } = solidFillStyle(palette, swatch);
91
97
  if (!isHexColor(bg))
92
98
  return { container: {} };
93
99
  return {
94
100
  container: {
95
101
  [$alertBg.variable]: bg,
96
- [$alertFg.variable]: onFilled(bg, palette.white, palette.black),
102
+ [$alertFg.variable]: color,
97
103
  },
98
104
  };
99
105
  }),
@@ -151,8 +157,9 @@ const Skeleton = {
151
157
  const Radio = {
152
158
  baseStyle: ({ theme, colorScheme }) => {
153
159
  const palette = paletteOf(theme);
154
- const fill = scaleFor(palette, colorScheme)[500];
155
- const dot = onFilled(fill, palette.white, palette.black);
160
+ const swatch = scaleFor(palette, colorScheme);
161
+ const fill = swatch[solidFillRung(swatch, palette.white)];
162
+ const dot = labelOnFill(fill, palette.white, palette.black);
156
163
  // A browser probe found the checked radio's hover repeating its own resting `fill` —
157
164
  // Chakra's stock checked._hover (inherited from checkbox) lands on the SAME `bg`/`borderColor`
158
165
  // keys we do, so extendTheme's merge is a scalar overwrite here, not a coexisting selector;
@@ -2,7 +2,7 @@ import { extendTheme } from "@chakra-ui/react";
2
2
  import common from "./common.web.js";
3
3
  import fonts from "./fonts.web.js";
4
4
  import { componentStyles } from "./componentStyles.js";
5
- import { onFilled } from "../tokens/builders/accentText.js";
5
+ import { resolveFilledSurface } from "../tokens/builders/filledSurface.js";
6
6
  import { globalScrollbarStyles } from "../tokens/builders/scrollbar.js";
7
7
  import { focusRingShadow } from "./focusRing.styles.js";
8
8
  /**
@@ -82,14 +82,20 @@ export const createBrandTheme = (palette, options = {}) => {
82
82
  // selecting text anywhere (e.g. a table cell) shows a stray white/lavender patch on
83
83
  // the dark canvas. Brand it instead, with WCAG-safe ink via the same `onFilled` math
84
84
  // used for buttons/badges.
85
- "::selection": {
86
- background: palette.primary[500],
87
- color: onFilled(palette.primary[500], palette.white, palette.black),
88
- },
89
- "::-moz-selection": {
90
- background: palette.primary[500],
91
- color: onFilled(palette.primary[500], palette.white, palette.black),
92
- },
85
+ "::selection": (() => {
86
+ const solid = resolveFilledSurface(palette.primary, palette);
87
+ return {
88
+ background: solid.fill,
89
+ color: solid.color,
90
+ };
91
+ })(),
92
+ "::-moz-selection": (() => {
93
+ const solid = resolveFilledSurface(palette.primary, palette);
94
+ return {
95
+ background: solid.fill,
96
+ color: solid.color,
97
+ };
98
+ })(),
93
99
  // `color-scheme: dark` gives WebKit/Blink a dark scrollbar by default, but it's the
94
100
  // OS's generic dark gray, not brand-aware.
95
101
  ...globalScrollbarStyles(palette),
@@ -0,0 +1,67 @@
1
+ import { contrastRatio } from "./color.js";
2
+ import { AA_NORMAL_TEXT, isDarkCanvas, onFilled } from "./accentText.js";
3
+ const RUNGS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
4
+ /**
5
+ * The rung one/two steps DARKER than the accent — what a filled button's hover/active needs so its
6
+ * white label stays legible.
7
+ *
8
+ * Every dark scale runs dark -> light across 50 -> 900 (brand scales are rebuilt that way, utility
9
+ * hues are reversed), the mirror of light mode. So "darker than [500]" is [600]/[700] in light but
10
+ * [400]/[300] in dark.
11
+ */
12
+ const FILL_STEP_RUNGS = { light: [600, 700], dark: [400, 300] };
13
+ /**
14
+ * Lightest rung on `scale` that still carries `white` at WCAG AA. Prefers [500] when it already
15
+ * passes; otherwise walks toward darker rungs. Used for solid fills on buttons, tags, badges and
16
+ * table status pills so consumers never get black ink on a saturated fill when white is achievable.
17
+ */
18
+ export const solidFillRung = (scale, white) => {
19
+ if (contrastRatio(scale[500], white) >= AA_NORMAL_TEXT)
20
+ return 500;
21
+ const passing = RUNGS.filter((r) => scale[r] && contrastRatio(scale[r], white) >= AA_NORMAL_TEXT);
22
+ if (!passing.length)
23
+ return 500;
24
+ return passing.reduce((a, b) => contrastRatio(scale[a], white) <= contrastRatio(scale[b], white) ? a : b);
25
+ };
26
+ const steppedRung = (base, canvas, step) => {
27
+ const dir = isDarkCanvas(canvas) ? -100 : 100;
28
+ return Math.min(900, Math.max(50, base + dir * step));
29
+ };
30
+ /** Hover (step 0) or active (step 1) fill rung, one step darker than `solidFillRung`. */
31
+ export const darkerFillRung = (scale, canvas, white, step) => {
32
+ const base = solidFillRung(scale, white);
33
+ if (base === 500) {
34
+ const mode = isDarkCanvas(canvas) ? "dark" : "light";
35
+ return FILL_STEP_RUNGS[mode][step];
36
+ }
37
+ const stepped = steppedRung(base, canvas, step === 0 ? 1 : 2);
38
+ return stepped;
39
+ };
40
+ /** Label ink for a specific fill swatch — always `onFilled`, exported for style configs. */
41
+ export const labelOnFill = (fill, white, black) => onFilled(fill, white, black);
42
+ /**
43
+ * Consumer-facing helper: given any `ColorScale` (primary, red, semantic.error, …), return the
44
+ * fill rung and matching ink for solid / hover / active states. Use this whenever you paint a
45
+ * `bg` from a scale — never pair `scale[500]` with `onFilled` or `colors.white` by hand.
46
+ */
47
+ export const resolveFilledSurface = (scale, colors) => {
48
+ const { white, black, backgroundColor } = colors;
49
+ const canvas = backgroundColor.main;
50
+ const rung = solidFillRung(scale, white);
51
+ const fill = scale[rung];
52
+ const hoverRung = darkerFillRung(scale, canvas, white, 0);
53
+ const hoverFill = scale[hoverRung];
54
+ const activeRung = darkerFillRung(scale, canvas, white, 1);
55
+ const activeFill = scale[activeRung];
56
+ return {
57
+ rung,
58
+ fill,
59
+ color: labelOnFill(fill, white, black),
60
+ hoverRung,
61
+ hoverFill,
62
+ hoverColor: labelOnFill(hoverFill, white, black),
63
+ activeRung,
64
+ activeFill,
65
+ activeColor: labelOnFill(activeFill, white, black),
66
+ };
67
+ };
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback, useEffect, useRef } from "react";
2
2
  import { DEFAULT_BLACK, DEFAULT_WHITE, isDarkCanvas, onFilled, } from "../Theme/tokens/builders/accentText.js";
3
+ import { labelOnFill, solidFillRung } from "../Theme/tokens/builders/filledSurface.js";
3
4
  import { resolveStatusTone } from "../Theme/tokens/builders/statusTone.js";
4
5
  // Built once, not per comparison: sorting 10k rows runs this ~130k times, and constructing a
5
6
  // collator is orders of magnitude dearer than using one.
@@ -72,11 +73,13 @@ export function buildTablePalette(theme) {
72
73
  ];
73
74
  return scales.map((scale) => {
74
75
  const tone = resolveStatusTone(scale, mode);
76
+ const solidRung = solidFillRung(scale, c.white);
77
+ const solid = scale[solidRung];
75
78
  return {
76
- solid: scale[500],
79
+ solid,
77
80
  soft: tone.bg,
78
81
  text: tone.fg,
79
- onSolid: onFilled(scale[500], c.white, c.black),
82
+ onSolid: labelOnFill(solid, c.white, c.black),
80
83
  };
81
84
  });
82
85
  }
package/dist/esm/index.js CHANGED
@@ -143,6 +143,9 @@ export { AVATAR_SEEDS, avatarFillFor, meetsBodyText, resolveAvatarFill, resolveS
143
143
  // of re-deriving contrast math themselves.
144
144
  export { statusGradient, inkSafeGradient, chipFill, chipBorder, ACCENT_GRADIENT, STATUS_INK, } from "./Components/PlanPill/planPillGradient.js";
145
145
  export { isDarkCanvas, onFilled, onGradient, accentTextOnCanvas, pickAccentText, AA_NORMAL_TEXT, DARK_CANVAS_LUMINANCE, } from "./Theme/tokens/builders/accentText.js";
146
+ // Filled-surface helpers — use whenever you paint a `bg` from a ColorScale (buttons, badges,
147
+ // chips, alerts). Never pair `scale[500]` with `onFilled` or `colors.white` by hand.
148
+ export { solidFillRung, darkerFillRung, labelOnFill, resolveFilledSurface, } from "./Theme/tokens/builders/filledSurface.js";
146
149
  // Pure color math backing the helpers above (and `buildDarkPalette`) — no Chakra/React/DOM
147
150
  // dependency, safe for the mobile port. `relativeLuminance`/`contrastRatio` are the WCAG 2.1
148
151
  // primitives; `compositeOver` flattens a translucent color onto a backdrop first (an alpha
package/dist/index.d.ts CHANGED
@@ -123,6 +123,8 @@ export type { StatusTone } from "./Theme/tokens/builders/statusTone";
123
123
  export type { ColorMode, ResolvedColorMode, ThemeName, PaletteProps, ColorScale, BrandScale, SemanticColors, NamedSurfaces, FocusRingTokens, } from "./Theme/tokens/types";
124
124
  export { statusGradient, inkSafeGradient, chipFill, chipBorder, ACCENT_GRADIENT, STATUS_INK, } from "./Components/PlanPill/planPillGradient";
125
125
  export { isDarkCanvas, onFilled, onGradient, accentTextOnCanvas, pickAccentText, AA_NORMAL_TEXT, DARK_CANVAS_LUMINANCE, } from "./Theme/tokens/builders/accentText";
126
+ export { solidFillRung, darkerFillRung, labelOnFill, resolveFilledSurface, } from "./Theme/tokens/builders/filledSurface";
127
+ export type { FilledSurface } from "./Theme/tokens/builders/filledSurface";
126
128
  export { hexToRgb, hexToRgba, compositeOver, rgbToHex, rgbToHsl, hslToRgb, hexToHsl, hslToHex, withLightness, mix, relativeLuminance, contrastRatio, } from "./Theme/tokens/builders/color";
127
129
  export type { Rgb, Hsl } from "./Theme/tokens/builders/color";
128
130
  export type { SelectV2Props, SelectV2Size, OptionProp as SelectV2Option } from "./Components/SelectV2/SelectV2Props";
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
43
43
  exports.splitMonthsAndDays = exports.resolvePlanBadge = exports.formatPlanRemaining = exports.formatPlanExpiry = exports.formatPlanElapsed = exports.PlanBadge = exports.PlanPill = exports.UpgradeButton = exports.LimitReachedModal = exports.AppSwitcher = exports.OrgSwitcher = exports.StageItem = exports.StageProgress = exports.CopyButton = exports.ScrollToTop = exports.PdfViewer = exports.MoreItems = exports.LazyWrapper = exports.FormWrapper = exports.FilterSidebar = exports.FileUploader = exports.FileUpload = exports.FilePreviewTrigger = exports.FilePreview = exports.FieldSelectModal = exports.WorkspaceTrayPreview = exports.WorkspaceTray = exports.WorkspaceWindow = exports.EmptyState = exports.Editor = exports.Dropdown = exports.DrawerFooter = exports.DrawerBody = exports.DrawerHeader = exports.Drawer = exports.DatePicker = exports.ContactForm = exports.Checkbox = exports.Card = exports.ButtonGroupIcon = exports.Button = exports.Breadcrumbs = exports.ApexRadialChart = exports.ApexAreaChart = exports.ApexLineChart = exports.ApexPolarChart = exports.ApexPieChart = exports.ApexBarChart = exports.AlertDialog = exports.Accordian = void 0;
44
44
  exports.TextInput = exports.Tag = exports.TableToggle = exports.Table = exports.SegmentedControl = exports.ToggleSwitch = exports.Switch = exports.Skeletons = exports.ScrollbarBox = exports.Slider = exports.SideBar = exports.SelectSearch = exports.SearchSelect = exports.SelectV2 = exports.Select = exports.Search = exports.Reorder = exports.RadioButtonGroup = exports.RadioButton = exports.ProgressBar = exports.ProfilePhotoViewer = exports.ProfileCardFooter = exports.ProfileCardBody = exports.ProfileCardHeader = exports.ProfileCard = exports.ProductDetails = exports.ProductCard = exports.PinInput = exports.PhoneNumberInput = exports.PaymentCard = exports.NumberInput = exports.MultiSelect = exports.NoteTextArea = exports.Notification = exports.NavigationBar = exports.ModalFooter = exports.ModalBody = exports.ModalHeader = exports.Modal = exports.Loading = exports.KanbanBoard = exports.InputSwitch = exports.InputTextArea = exports.HeaderActions = exports.Header = exports.OrganizationDetails = exports.SignInActivityTable = exports.CustomModulesTable = exports.RolesPermission = exports.UserDetails = void 0;
45
45
  exports.chipFill = exports.inkSafeGradient = exports.statusGradient = exports.resolveStatusTone = exports.resolveAvatarFill = exports.meetsBodyText = exports.avatarFillFor = exports.AVATAR_SEEDS = exports.FOCUS_RING_WIDTH = exports.FOCUS_HALO_WIDTH = exports.FOCUS_VISIBLE_OVER_STATE = exports.focusVisibleStyles = exports.focusVisibleRing = exports.focusRingShadow = exports.withFocusRing = exports.settleBetween = exports.buildFocusRing = exports.listRowBackgrounds = exports.withOutlineRung = exports.liftToContrast = exports.AA_NON_TEXT = exports.buildDarkPalette = exports.themeNames = exports.palettes = exports.darkPalettes = exports.lightPalettes = exports.brandThemes = exports.AppearanceSettings = exports.useFontSizeSync = exports.resolveFontSize = exports.isFontSize = exports.FONT_SIZE_OPTIONS = exports.DEFAULT_FONT_SIZE = exports.ThemeSwitcher = exports.useThemeMode = exports.PixelizeThemeProvider = exports.createAccountHandoff = exports.resolveReturnUrl = exports.isAllowedReturnUrl = exports.debounce = exports.ThemesList = exports.useCustomTheme = exports.useIsTruncated = exports.useSidebarPrefs = exports.VerifyEmailOtp = exports.useToaster = exports.OverflowToolTip = exports.ToolTip = exports.Toaster = exports.Timeline = void 0;
46
- exports.inkSafeGradientToken = exports.gradientCss = exports.resolveGradient = exports.fieldSurfaces = exports.placeholderInkOn = exports.placeholderInk = exports.SCROLLBAR_WIDTH = exports.globalScrollbarStyles = exports.scrollbarStyles = exports.useAppSwitcherShortcut = exports.buildSuiteApps = exports.formatShortcut = exports.matchesShortcut = exports.filterApps = exports.appInitials = exports.describeDayStates = exports.resolveDayStateVisual = exports.isDayStateKey = exports.CALENDAR_DAY_CLASS = exports.DAY_STATE_KEYS = exports.contrastRatio = exports.relativeLuminance = exports.mix = exports.withLightness = exports.hslToHex = exports.hexToHsl = exports.hslToRgb = exports.rgbToHsl = exports.rgbToHex = exports.compositeOver = exports.hexToRgba = exports.hexToRgb = exports.DARK_CANVAS_LUMINANCE = exports.AA_NORMAL_TEXT = exports.pickAccentText = exports.accentTextOnCanvas = exports.onGradient = exports.onFilled = exports.isDarkCanvas = exports.STATUS_INK = exports.ACCENT_GRADIENT = exports.chipBorder = void 0;
46
+ exports.inkSafeGradientToken = exports.gradientCss = exports.resolveGradient = exports.fieldSurfaces = exports.placeholderInkOn = exports.placeholderInk = exports.SCROLLBAR_WIDTH = exports.globalScrollbarStyles = exports.scrollbarStyles = exports.useAppSwitcherShortcut = exports.buildSuiteApps = exports.formatShortcut = exports.matchesShortcut = exports.filterApps = exports.appInitials = exports.describeDayStates = exports.resolveDayStateVisual = exports.isDayStateKey = exports.CALENDAR_DAY_CLASS = exports.DAY_STATE_KEYS = exports.contrastRatio = exports.relativeLuminance = exports.mix = exports.withLightness = exports.hslToHex = exports.hexToHsl = exports.hslToRgb = exports.rgbToHsl = exports.rgbToHex = exports.compositeOver = exports.hexToRgba = exports.hexToRgb = exports.resolveFilledSurface = exports.labelOnFill = exports.darkerFillRung = exports.solidFillRung = exports.DARK_CANVAS_LUMINANCE = exports.AA_NORMAL_TEXT = exports.pickAccentText = exports.accentTextOnCanvas = exports.onGradient = exports.onFilled = exports.isDarkCanvas = exports.STATUS_INK = exports.ACCENT_GRADIENT = exports.chipBorder = void 0;
47
47
  const Accordion_1 = __importDefault(require("./Components/Accordion/Accordion"));
48
48
  exports.Accordian = Accordion_1.default;
49
49
  const AlertDialog_1 = __importDefault(require("./Components/AlertDialog/AlertDialog"));
@@ -337,6 +337,13 @@ Object.defineProperty(exports, "accentTextOnCanvas", { enumerable: true, get: fu
337
337
  Object.defineProperty(exports, "pickAccentText", { enumerable: true, get: function () { return accentText_1.pickAccentText; } });
338
338
  Object.defineProperty(exports, "AA_NORMAL_TEXT", { enumerable: true, get: function () { return accentText_1.AA_NORMAL_TEXT; } });
339
339
  Object.defineProperty(exports, "DARK_CANVAS_LUMINANCE", { enumerable: true, get: function () { return accentText_1.DARK_CANVAS_LUMINANCE; } });
340
+ // Filled-surface helpers — use whenever you paint a `bg` from a ColorScale (buttons, badges,
341
+ // chips, alerts). Never pair `scale[500]` with `onFilled` or `colors.white` by hand.
342
+ var filledSurface_1 = require("./Theme/tokens/builders/filledSurface");
343
+ Object.defineProperty(exports, "solidFillRung", { enumerable: true, get: function () { return filledSurface_1.solidFillRung; } });
344
+ Object.defineProperty(exports, "darkerFillRung", { enumerable: true, get: function () { return filledSurface_1.darkerFillRung; } });
345
+ Object.defineProperty(exports, "labelOnFill", { enumerable: true, get: function () { return filledSurface_1.labelOnFill; } });
346
+ Object.defineProperty(exports, "resolveFilledSurface", { enumerable: true, get: function () { return filledSurface_1.resolveFilledSurface; } });
340
347
  // Pure color math backing the helpers above (and `buildDarkPalette`) — no Chakra/React/DOM
341
348
  // dependency, safe for the mobile port. `relativeLuminance`/`contrastRatio` are the WCAG 2.1
342
349
  // primitives; `compositeOver` flattens a translucent color onto a backdrop first (an alpha
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixelize-design-library",
3
- "version": "2.4.2-beta.32",
3
+ "version": "2.4.2-beta.34",
4
4
  "description": "React component library for Pixelize apps: themeable Chakra-based components, design tokens and light/dark brand theming.",
5
5
  "keywords": [
6
6
  "react",
@@ -1,4 +0,0 @@
1
- import type { ColorScale, BrandScale } from "../types";
2
- export type Rung = keyof ColorScale;
3
- export declare const solidRung: (scale: ColorScale | BrandScale, white: string) => Rung;
4
- export declare const darkerFillRung: (scale: ColorScale | BrandScale, white: string, isDark: boolean, step: 0 | 1) => Rung;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.darkerFillRung = exports.solidRung = void 0;
4
- const color_1 = require("./color");
5
- const AA_NORMAL_TEXT = 4.5;
6
- const RUNGS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
7
- const FILL_STEP_RUNGS = { light: [600, 700], dark: [400, 300] };
8
- const hasOpacity = (scale) => "opacity" in scale;
9
- // Brand scales keep [500]; utility scales (red, green, …) step to the closest passing rung.
10
- const solidRung = (scale, white) => {
11
- if (hasOpacity(scale))
12
- return 500;
13
- if ((0, color_1.contrastRatio)(scale[500], white) >= AA_NORMAL_TEXT)
14
- return 500;
15
- const passing = RUNGS.filter((r) => scale[r] && (0, color_1.contrastRatio)(scale[r], white) >= AA_NORMAL_TEXT);
16
- if (!passing.length)
17
- return 500;
18
- return passing.reduce((a, b) => (0, color_1.contrastRatio)(scale[a], white) <= (0, color_1.contrastRatio)(scale[b], white) ? a : b);
19
- };
20
- exports.solidRung = solidRung;
21
- const steppedRung = (base, step, isDark) => {
22
- const dir = isDark ? -100 : 100;
23
- return Math.min(900, Math.max(50, base + dir * step));
24
- };
25
- const darkerFillRung = (scale, white, isDark, step) => {
26
- const base = (0, exports.solidRung)(scale, white);
27
- if (base === 500) {
28
- const mode = isDark ? "dark" : "light";
29
- return FILL_STEP_RUNGS[mode][step];
30
- }
31
- return steppedRung(base, step === 0 ? 1 : 2, isDark);
32
- };
33
- exports.darkerFillRung = darkerFillRung;
@@ -1,28 +0,0 @@
1
- import { contrastRatio } from "./color.js";
2
- const AA_NORMAL_TEXT = 4.5;
3
- const RUNGS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
4
- const FILL_STEP_RUNGS = { light: [600, 700], dark: [400, 300] };
5
- const hasOpacity = (scale) => "opacity" in scale;
6
- // Brand scales keep [500]; utility scales (red, green, …) step to the closest passing rung.
7
- export const solidRung = (scale, white) => {
8
- if (hasOpacity(scale))
9
- return 500;
10
- if (contrastRatio(scale[500], white) >= AA_NORMAL_TEXT)
11
- return 500;
12
- const passing = RUNGS.filter((r) => scale[r] && contrastRatio(scale[r], white) >= AA_NORMAL_TEXT);
13
- if (!passing.length)
14
- return 500;
15
- return passing.reduce((a, b) => contrastRatio(scale[a], white) <= contrastRatio(scale[b], white) ? a : b);
16
- };
17
- const steppedRung = (base, step, isDark) => {
18
- const dir = isDark ? -100 : 100;
19
- return Math.min(900, Math.max(50, base + dir * step));
20
- };
21
- export const darkerFillRung = (scale, white, isDark, step) => {
22
- const base = solidRung(scale, white);
23
- if (base === 500) {
24
- const mode = isDark ? "dark" : "light";
25
- return FILL_STEP_RUNGS[mode][step];
26
- }
27
- return steppedRung(base, step === 0 ? 1 : 2, isDark);
28
- };