@ssa-ui-kit/core 3.5.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,60 @@
1
+ import { CounterProps } from './types';
2
+ /**
3
+ * Counter - Compact numeric indicator for displaying counts or notification badges.
4
+ *
5
+ * ### Sizing
6
+ * Accepts `'small' | 'medium' | 'large'` via the `size` prop (default `'medium'`).
7
+ * When `count` is omitted the counter shrinks to a small dot (`dot` size) — useful
8
+ * as a presence indicator with no number shown.
9
+ *
10
+ * ### Color
11
+ * Background is driven by `theme.palette[variant].main` for the five semantic variants.
12
+ * Pass `color` to override: a `theme.colors` key resolves to the design token value,
13
+ * any other string is used as a raw CSS color.
14
+ *
15
+ * ### CSS override
16
+ * Pass `css` to apply one-off Emotion styles on top of all internal styles
17
+ * (size → variant → color → css). Useful for margins, positioning, or shape tweaks.
18
+ *
19
+ * ### Overflow
20
+ * Values above 99 are automatically clamped to `"99+"`.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * // Basic usage — primary variant, medium size
25
+ * <Counter count={5} />
26
+ * ```
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * // Overflow label
31
+ * <Counter count={120} variant={CounterVariants.error} size="large" />
32
+ * // renders "99+"
33
+ * ```
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * // Raw hex color override
38
+ * <Counter count={3} color="#F7931A" />
39
+ * ```
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * // theme.colors key as color
44
+ * <Counter count={7} color="purple" />
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```tsx
49
+ * // Empty dot indicator (no count)
50
+ * <Counter variant={CounterVariants.error} />
51
+ * ```
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * // CSS override for layout / shape
56
+ * <Counter count={3} css={{ marginLeft: 8, borderRadius: 4 }} />
57
+ * ```
58
+ */
59
+ export declare const Counter: ({ count, variant, size, color, className, css, ref, }: CounterProps) => import("@emotion/react/jsx-runtime").JSX.Element;
60
+ export default Counter;
@@ -0,0 +1 @@
1
+ export * from './Counter';
@@ -0,0 +1,15 @@
1
+ import { VariantStyle, CounterSizes } from './types';
2
+ import { Theme, SerializedStyles } from '@emotion/react';
3
+ import { ColorsKeys } from '../../types/emotion';
4
+ export declare const variantStyles: VariantStyle;
5
+ export declare const sizeStyles: CounterSizes;
6
+ /**
7
+ * Builds a background override from a `color` string.
8
+ * If `color` matches a key in `theme.colors` the design token is used;
9
+ * otherwise the value is passed through as a raw CSS color string.
10
+ */
11
+ export declare const makeColorOverride: (theme: Theme, color: ColorsKeys | string) => SerializedStyles;
12
+ export declare const CounterBase: import("@emotion/styled").StyledComponent<{
13
+ theme?: Theme;
14
+ as?: React.ElementType;
15
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { MainSizes } from '../../types/global';
3
+ import { ColorsKeys } from '../../types/emotion';
4
+ import { Interpolation, SerializedStyles, Theme } from '@emotion/react';
5
+ export declare enum CounterVariants {
6
+ primary = "primary",
7
+ secondary = "secondary",
8
+ error = "error",
9
+ warning = "warning",
10
+ success = "success"
11
+ }
12
+ export type VariantStyle = {
13
+ [k in CounterVariants]: (theme: Theme) => SerializedStyles;
14
+ };
15
+ /**
16
+ * Extends `MainSizes` with a `dot` slot used internally when `count` is
17
+ * undefined — renders a small dot with no label as a presence indicator.
18
+ */
19
+ export type CounterSizes = MainSizes & {
20
+ dot: SerializedStyles;
21
+ };
22
+ export type CounterProps = {
23
+ /**
24
+ * The numeric value to display. Values above 99 are clamped to `"99+"`.
25
+ * When omitted, the counter renders as a dot with no label.
26
+ */
27
+ count?: number;
28
+ /**
29
+ * Visual style variant. Drives the background color from `theme.palette`.
30
+ * @default CounterVariants.primary
31
+ */
32
+ variant?: CounterVariants;
33
+ /**
34
+ * Size of the counter.
35
+ * Ignored when `count` is undefined — the component uses `dot` automatically.
36
+ * @default 'medium'
37
+ */
38
+ size?: keyof MainSizes;
39
+ /**
40
+ * Optional color override. Accepts a `theme.colors` key or any valid CSS color string.
41
+ * When provided, overrides the variant background.
42
+ */
43
+ color?: ColorsKeys | string;
44
+ /**
45
+ * Custom CSS class name.
46
+ */
47
+ className?: string;
48
+ /**
49
+ * Emotion CSS override applied after all internal styles.
50
+ * Use for one-off layout adjustments (e.g. margins, positioning).
51
+ */
52
+ css?: Interpolation<Theme>;
53
+ /**
54
+ * Ref forwarded to the root `<div>` element.
55
+ */
56
+ ref?: React.Ref<HTMLDivElement>;
57
+ };
@@ -70,6 +70,8 @@ export * from './Typography';
70
70
  export type * from './Typography/types';
71
71
  export { default as Badge } from './Badge';
72
72
  export type * from './Badge/types';
73
+ export * from './Counter';
74
+ export type * from './Counter/types';
73
75
  export { default as Tag } from './Tag';
74
76
  export * from './Tag';
75
77
  export type * from './Tag/types';
package/dist/index.js CHANGED
@@ -7980,6 +7980,7 @@ __webpack_require__.d(__webpack_exports__, {
7980
7980
  CollapsibleNavBarItemProvider: () => (/* reexport */ CollapsibleNavBarItemProvider),
7981
7981
  CollapsibleNavBarProvider: () => (/* reexport */ CollapsibleNavBarProvider),
7982
7982
  ColorPicker: () => (/* reexport */ ColorPicker),
7983
+ Counter: () => (/* reexport */ Counter),
7983
7984
  DEFAULT_EUROPEAN_MASK_FORMAT: () => (/* reexport */ DEFAULT_EUROPEAN_MASK_FORMAT),
7984
7985
  DEFAULT_MASK_FORMAT: () => (/* reexport */ constants_DEFAULT_MASK_FORMAT),
7985
7986
  DEFAULT_MONTH_MASK_FORMAT: () => (/* reexport */ constants_DEFAULT_MONTH_MASK_FORMAT),
@@ -15239,7 +15240,7 @@ const TextareaBase = /*#__PURE__*/base_default()('textarea', true ? {
15239
15240
  status = 'basic'
15240
15241
  }) => getStatusBoxShadow(theme, status, 'rest'), ";color:", ({
15241
15242
  theme
15242
- }) => theme.colors.greyDarker, ";width:100%;max-width:100%;box-sizing:border-box;min-height:114px;padding:14px;font-weight:400;font-size:0.875rem;line-height:1rem;&::placeholder{color:", ({
15243
+ }) => theme.colors.greyDarker, ";width:100%;max-width:100%;max-height:100%;box-sizing:border-box;min-height:114px;padding:14px;font-weight:400;font-size:0.875rem;line-height:1rem;&::placeholder{color:", ({
15243
15244
  theme
15244
15245
  }) => theme.colors.greyDarker60, ";}&[readonly]{cursor:default;}&:disabled{color:", ({
15245
15246
  theme
@@ -28540,6 +28541,154 @@ const CardList = ({
28540
28541
  ;// ./src/components/CardList/index.ts
28541
28542
 
28542
28543
 
28544
+ ;// ./src/components/Counter/types.ts
28545
+ let CounterVariants = /*#__PURE__*/function (CounterVariants) {
28546
+ CounterVariants["primary"] = "primary";
28547
+ CounterVariants["secondary"] = "secondary";
28548
+ CounterVariants["error"] = "error";
28549
+ CounterVariants["warning"] = "warning";
28550
+ CounterVariants["success"] = "success";
28551
+ return CounterVariants;
28552
+ }({});
28553
+
28554
+ /**
28555
+ * Extends `MainSizes` with a `dot` slot used internally when `count` is
28556
+ * undefined — renders a small dot with no label as a presence indicator.
28557
+ */
28558
+ ;// ./src/components/Counter/styles.tsx
28559
+
28560
+ function Counter_styles_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
28561
+
28562
+
28563
+ /** Resolves a variant key to its `theme.palette` background + white text. */
28564
+ const makeVariantStyle = (theme, key) => /*#__PURE__*/(0,react_namespaceObject.css)("color:", theme.colors.white, ";background:", theme.palette[key].main, ";" + ( true ? "" : 0), true ? "" : 0);
28565
+ const styles_variantStyles = {
28566
+ primary: theme => makeVariantStyle(theme, CounterVariants.primary),
28567
+ secondary: theme => makeVariantStyle(theme, CounterVariants.secondary),
28568
+ error: theme => makeVariantStyle(theme, CounterVariants.error),
28569
+ warning: theme => makeVariantStyle(theme, CounterVariants.warning),
28570
+ success: theme => makeVariantStyle(theme, CounterVariants.success)
28571
+ };
28572
+ const styles_sizeStyles = {
28573
+ dot: true ? {
28574
+ name: "9e7m57",
28575
+ styles: "width:8px;height:8px"
28576
+ } : 0,
28577
+ small: true ? {
28578
+ name: "14h28tx",
28579
+ styles: "height:24px;font-size:12px;padding:4px 9px"
28580
+ } : 0,
28581
+ medium: true ? {
28582
+ name: "fy8gxb",
28583
+ styles: "padding:4px 13px;height:32px;font-size:14px"
28584
+ } : 0,
28585
+ large: true ? {
28586
+ name: "irp62o",
28587
+ styles: "font-size:16px;height:44px;padding:4px 19px"
28588
+ } : 0
28589
+ };
28590
+
28591
+ /**
28592
+ * Builds a background override from a `color` string.
28593
+ * If `color` matches a key in `theme.colors` the design token is used;
28594
+ * otherwise the value is passed through as a raw CSS color string.
28595
+ */
28596
+ const makeColorOverride = (theme, color) => /*#__PURE__*/(0,react_namespaceObject.css)("background:", color in theme.colors ? theme.colors[color] : color, ";" + ( true ? "" : 0), true ? "" : 0);
28597
+ const CounterBase = /*#__PURE__*/base_default()("div", true ? {
28598
+ target: "eg7ht9z0"
28599
+ } : 0)( true ? {
28600
+ name: "1tmyl78",
28601
+ styles: "display:flex;align-items:center;justify-content:center;border:none;font:inherit;border-radius:50px;font-family:Manrope,sans-serif;width:min-content;font-style:normal;font-weight:700"
28602
+ } : 0);
28603
+ ;// ./src/components/Counter/Counter.tsx
28604
+
28605
+
28606
+
28607
+
28608
+ const MAX_COUNT = 99;
28609
+
28610
+ /**
28611
+ * Counter - Compact numeric indicator for displaying counts or notification badges.
28612
+ *
28613
+ * ### Sizing
28614
+ * Accepts `'small' | 'medium' | 'large'` via the `size` prop (default `'medium'`).
28615
+ * When `count` is omitted the counter shrinks to a small dot (`dot` size) — useful
28616
+ * as a presence indicator with no number shown.
28617
+ *
28618
+ * ### Color
28619
+ * Background is driven by `theme.palette[variant].main` for the five semantic variants.
28620
+ * Pass `color` to override: a `theme.colors` key resolves to the design token value,
28621
+ * any other string is used as a raw CSS color.
28622
+ *
28623
+ * ### CSS override
28624
+ * Pass `css` to apply one-off Emotion styles on top of all internal styles
28625
+ * (size → variant → color → css). Useful for margins, positioning, or shape tweaks.
28626
+ *
28627
+ * ### Overflow
28628
+ * Values above 99 are automatically clamped to `"99+"`.
28629
+ *
28630
+ * @example
28631
+ * ```tsx
28632
+ * // Basic usage — primary variant, medium size
28633
+ * <Counter count={5} />
28634
+ * ```
28635
+ *
28636
+ * @example
28637
+ * ```tsx
28638
+ * // Overflow label
28639
+ * <Counter count={120} variant={CounterVariants.error} size="large" />
28640
+ * // renders "99+"
28641
+ * ```
28642
+ *
28643
+ * @example
28644
+ * ```tsx
28645
+ * // Raw hex color override
28646
+ * <Counter count={3} color="#F7931A" />
28647
+ * ```
28648
+ *
28649
+ * @example
28650
+ * ```tsx
28651
+ * // theme.colors key as color
28652
+ * <Counter count={7} color="purple" />
28653
+ * ```
28654
+ *
28655
+ * @example
28656
+ * ```tsx
28657
+ * // Empty dot indicator (no count)
28658
+ * <Counter variant={CounterVariants.error} />
28659
+ * ```
28660
+ *
28661
+ * @example
28662
+ * ```tsx
28663
+ * // CSS override for layout / shape
28664
+ * <Counter count={3} css={{ marginLeft: 8, borderRadius: 4 }} />
28665
+ * ```
28666
+ */
28667
+ const Counter = ({
28668
+ count,
28669
+ variant = CounterVariants.primary,
28670
+ size = 'medium',
28671
+ color,
28672
+ className,
28673
+ css,
28674
+ ref
28675
+ }) => {
28676
+ const theme = (0,react_namespaceObject.useTheme)();
28677
+ const isEmpty = count === undefined;
28678
+ const label = !isEmpty && count > MAX_COUNT ? `${MAX_COUNT}+` : count;
28679
+ const appliedVariantStyle = styles_variantStyles[variant](theme);
28680
+ const appliedSizeStyle = styles_sizeStyles[!isEmpty ? size : 'dot'];
28681
+ const colorOverride = color ? makeColorOverride(theme, color) : undefined;
28682
+ return (0,jsx_runtime_namespaceObject.jsx)(CounterBase, {
28683
+ ref: ref,
28684
+ css: [appliedSizeStyle, appliedVariantStyle, colorOverride, css, true ? "" : 0, true ? "" : 0],
28685
+ className: className,
28686
+ children: label
28687
+ });
28688
+ };
28689
+ /* harmony default export */ const Counter_Counter = ((/* unused pure expression or super */ null && (Counter)));
28690
+ ;// ./src/components/Counter/index.ts
28691
+
28543
28692
  ;// ./src/components/Tag/styles.ts
28544
28693
 
28545
28694
 
@@ -51248,7 +51397,7 @@ const ValueWithCounter = /*#__PURE__*/base_default()("div", true ? {
51248
51397
  name: "1j5vobt",
51249
51398
  styles: "display:flex;align-items:center;gap:4px"
51250
51399
  } : 0);
51251
- const Counter = /*#__PURE__*/base_default()(TextBase.withComponent('span', true ? {
51400
+ const styles_Counter = /*#__PURE__*/base_default()(TextBase.withComponent('span', true ? {
51252
51401
  target: "ej2kihb16"
51253
51402
  } : 0), true ? {
51254
51403
  target: "ej2kihb7"
@@ -51507,7 +51656,7 @@ const PersonInfoCounter = ({
51507
51656
  children: user.name
51508
51657
  }, user.id))
51509
51658
  });
51510
- const counterNode = (0,jsx_runtime_namespaceObject.jsx)(Counter, {
51659
+ const counterNode = (0,jsx_runtime_namespaceObject.jsx)(styles_Counter, {
51511
51660
  css: css,
51512
51661
  "data-testid": "person-info-counter",
51513
51662
  children: counterValue
@@ -51956,6 +52105,7 @@ const UserProfile = ({
51956
52105
 
51957
52106
 
51958
52107
 
52108
+
51959
52109
 
51960
52110
 
51961
52111
  // ============================================================================