@snack-uikit/status 0.4.1 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 0.5.0 (2023-12-14)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+
12
+ * **FF-3729:** replace enum with unions ([910db4a](https://github.com/cloud-ru-tech/snack-uikit/commit/910db4aa8231ccbc58e538e5c5c1f461b1dec275))
13
+
14
+
15
+
16
+
6
17
  ## 0.4.1 (2023-12-06)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -179,7 +190,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
179
190
 
180
191
  ## 0.1.1 (2023-04-07)
181
192
 
182
- **Note:** Version bump only for package @snack-uikit/status
193
+ ### Only dependencies have been changed
194
+ * [@snack-uikit/utils@3.2.0](https://git.sbercloud.tech/sbercloud-ui/tokens-design-system/snack-uikit/-/blob/master/packages/utils/CHANGELOG.md)
183
195
 
184
196
 
185
197
 
package/README.md CHANGED
@@ -8,18 +8,18 @@
8
8
  ## Example
9
9
 
10
10
  ```typescript jsx
11
- import {Status, StatusIndicator} from "@snack-uikit/status";
11
+ import { Status, StatusIndicator } from '@snack-uikit/status';
12
12
 
13
13
  <Status
14
14
  label="Text after status"
15
- appearance={Status.appearances.Pink}
16
- size={Status.sizes.Xs}
15
+ appearance='pink'
16
+ size='xs'
17
17
  hasBackground={true}
18
18
  />
19
19
 
20
20
  <StatusIndicator
21
- appearance={Status.appearances.Violet}
22
- size={Status.sizes.L}
21
+ appearance='violet'
22
+ size='l'
23
23
  />
24
24
  ```
25
25
 
@@ -30,16 +30,16 @@ import {Status, StatusIndicator} from "@snack-uikit/status";
30
30
  | name | type | default value | description |
31
31
  |------|------|---------------|-------------|
32
32
  | label* | `string` | - | Текст |
33
- | size | enum Size: `"xs"`, `"s"` | Size.Xs | Размер |
34
- | appearance | enum Appearance: `"primary"`, `"neutral"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | Appearance.Primary | Внешний вид |
33
+ | size | enum Size: `"xs"`, `"s"` | xs | Размер |
34
+ | appearance | enum Appearance: `"primary"`, `"neutral"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | primary | Внешний вид |
35
35
  | hasBackground | `boolean` | - | Наличие фона |
36
36
  | className | `string` | - | CSS-класс |
37
37
  ## StatusIndicator
38
38
  ### Props
39
39
  | name | type | default value | description |
40
40
  |------|------|---------------|-------------|
41
- | size | enum Size: `"xxs"`, `"xs"`, `"s"`, `"m"`, `"l"` | Size.M | Размер |
42
- | appearance | enum Appearance: `"primary"`, `"neutral"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | Appearance.Primary | Внешний вид |
41
+ | size | enum Size: `"xs"`, `"s"`, `"xxs"`, `"m"`, `"l"` | m | Размер |
42
+ | appearance | enum Appearance: `"primary"`, `"neutral"`, `"red"`, `"orange"`, `"yellow"`, `"green"`, `"blue"`, `"violet"`, `"pink"` | primary | Внешний вид |
43
43
  | className | `string` | - | CSS-класс |
44
44
 
45
45
 
@@ -1,9 +1,6 @@
1
1
  import { WithSupportProps } from '@snack-uikit/utils';
2
- import { Appearance } from '../../constants';
3
- declare enum Size {
4
- Xs = "xs",
5
- S = "s"
6
- }
2
+ import { Appearance } from '../../types';
3
+ import { Size } from './types';
7
4
  export type StatusProps = WithSupportProps<{
8
5
  /** Текст */
9
6
  label: string;
@@ -16,8 +13,3 @@ export type StatusProps = WithSupportProps<{
16
13
  className?: string;
17
14
  }>;
18
15
  export declare function Status({ label, size, appearance, hasBackground, className, ...rest }: StatusProps): import("react/jsx-runtime").JSX.Element;
19
- export declare namespace Status {
20
- var sizes: typeof Size;
21
- var appearances: typeof Appearance;
22
- }
23
- export {};
@@ -12,21 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
14
  import { extractSupportProps } from '@snack-uikit/utils';
15
- import { Appearance } from '../../constants';
15
+ import { APPEARANCE } from '../../constants';
16
16
  import { StatusIndicator } from '../StatusIndicator';
17
+ import { SIZE, STATUS_INDICATOR_SIZE_MAP } from './constants';
17
18
  import styles from './styles.module.css';
18
- var Size;
19
- (function (Size) {
20
- Size["Xs"] = "xs";
21
- Size["S"] = "s";
22
- })(Size || (Size = {}));
23
- const statusIndicatorSizeMap = {
24
- [Size.Xs]: StatusIndicator.sizes.Xs,
25
- [Size.S]: StatusIndicator.sizes.S,
26
- };
27
19
  export function Status(_a) {
28
- var { label, size = Size.Xs, appearance = Appearance.Primary, hasBackground, className } = _a, rest = __rest(_a, ["label", "size", "appearance", "hasBackground", "className"]);
29
- return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-size": size, "data-has-background": hasBackground || undefined }, { children: [_jsx(StatusIndicator, { appearance: appearance, size: statusIndicatorSizeMap[size] }), _jsx("span", Object.assign({ className: styles.label }, { children: label }))] })));
20
+ var { label, size = SIZE.Xs, appearance = APPEARANCE.Primary, hasBackground, className } = _a, rest = __rest(_a, ["label", "size", "appearance", "hasBackground", "className"]);
21
+ return (_jsxs("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-size": size, "data-has-background": hasBackground || undefined }, { children: [_jsx(StatusIndicator, { appearance: appearance, size: STATUS_INDICATOR_SIZE_MAP[size] }), _jsx("span", Object.assign({ className: styles.label }, { children: label }))] })));
30
22
  }
31
- Status.sizes = Size;
32
- Status.appearances = Appearance;
@@ -0,0 +1,8 @@
1
+ export declare const SIZE: {
2
+ readonly Xs: "xs";
3
+ readonly S: "s";
4
+ };
5
+ export declare const STATUS_INDICATOR_SIZE_MAP: {
6
+ xs: "xs";
7
+ s: "s";
8
+ };
@@ -0,0 +1,9 @@
1
+ import { SIZE as StatusIndicatorSize } from '../StatusIndicator/constants';
2
+ export const SIZE = {
3
+ Xs: 'xs',
4
+ S: 's',
5
+ };
6
+ export const STATUS_INDICATOR_SIZE_MAP = {
7
+ [SIZE.Xs]: StatusIndicatorSize.Xs,
8
+ [SIZE.S]: StatusIndicatorSize.S,
9
+ };
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { SIZE } from './constants';
3
+ export type Size = ValueOf<typeof SIZE>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,12 +1,6 @@
1
1
  import { WithSupportProps } from '@snack-uikit/utils';
2
- import { Appearance } from '../../constants';
3
- declare enum Size {
4
- Xxs = "xxs",
5
- Xs = "xs",
6
- S = "s",
7
- M = "m",
8
- L = "l"
9
- }
2
+ import { Appearance } from '../../types';
3
+ import { Size } from './types';
10
4
  export type StatusIndicatorProps = WithSupportProps<{
11
5
  /** Размер */
12
6
  size?: Size;
@@ -15,8 +9,3 @@ export type StatusIndicatorProps = WithSupportProps<{
15
9
  className?: string;
16
10
  }>;
17
11
  export declare function StatusIndicator({ size, appearance, className, ...rest }: StatusIndicatorProps): import("react/jsx-runtime").JSX.Element;
18
- export declare namespace StatusIndicator {
19
- var sizes: typeof Size;
20
- var appearances: typeof Appearance;
21
- }
22
- export {};
@@ -12,19 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import cn from 'classnames';
14
14
  import { extractSupportProps } from '@snack-uikit/utils';
15
- import { Appearance } from '../../constants';
15
+ import { APPEARANCE } from '../../constants';
16
+ import { SIZE } from './constants';
16
17
  import styles from './styles.module.css';
17
- var Size;
18
- (function (Size) {
19
- Size["Xxs"] = "xxs";
20
- Size["Xs"] = "xs";
21
- Size["S"] = "s";
22
- Size["M"] = "m";
23
- Size["L"] = "l";
24
- })(Size || (Size = {}));
25
18
  export function StatusIndicator(_a) {
26
- var { size = Size.M, appearance = Appearance.Primary, className } = _a, rest = __rest(_a, ["size", "appearance", "className"]);
19
+ var { size = SIZE.M, appearance = APPEARANCE.Primary, className } = _a, rest = __rest(_a, ["size", "appearance", "className"]);
27
20
  return (_jsx("div", Object.assign({ className: cn(styles.container, className) }, extractSupportProps(rest), { "data-size": size }, { children: _jsx("div", { className: styles.indicator, "data-appearance": appearance }) })));
28
21
  }
29
- StatusIndicator.sizes = Size;
30
- StatusIndicator.appearances = Appearance;
@@ -0,0 +1,7 @@
1
+ export declare const SIZE: {
2
+ readonly Xxs: "xxs";
3
+ readonly Xs: "xs";
4
+ readonly S: "s";
5
+ readonly M: "m";
6
+ readonly L: "l";
7
+ };
@@ -0,0 +1,7 @@
1
+ export const SIZE = {
2
+ Xxs: 'xxs',
3
+ Xs: 'xs',
4
+ S: 's',
5
+ M: 'm',
6
+ L: 'l',
7
+ };
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { SIZE } from './constants';
3
+ export type Size = ValueOf<typeof SIZE>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,11 @@
1
- export declare enum Appearance {
2
- Primary = "primary",
3
- Neutral = "neutral",
4
- Red = "red",
5
- Orange = "orange",
6
- Yellow = "yellow",
7
- Green = "green",
8
- Blue = "blue",
9
- Violet = "violet",
10
- Pink = "pink"
11
- }
1
+ export declare const APPEARANCE: {
2
+ readonly Primary: "primary";
3
+ readonly Neutral: "neutral";
4
+ readonly Red: "red";
5
+ readonly Orange: "orange";
6
+ readonly Yellow: "yellow";
7
+ readonly Green: "green";
8
+ readonly Blue: "blue";
9
+ readonly Violet: "violet";
10
+ readonly Pink: "pink";
11
+ };
package/dist/constants.js CHANGED
@@ -1,12 +1,11 @@
1
- export var Appearance;
2
- (function (Appearance) {
3
- Appearance["Primary"] = "primary";
4
- Appearance["Neutral"] = "neutral";
5
- Appearance["Red"] = "red";
6
- Appearance["Orange"] = "orange";
7
- Appearance["Yellow"] = "yellow";
8
- Appearance["Green"] = "green";
9
- Appearance["Blue"] = "blue";
10
- Appearance["Violet"] = "violet";
11
- Appearance["Pink"] = "pink";
12
- })(Appearance || (Appearance = {}));
1
+ export const APPEARANCE = {
2
+ Primary: 'primary',
3
+ Neutral: 'neutral',
4
+ Red: 'red',
5
+ Orange: 'orange',
6
+ Yellow: 'yellow',
7
+ Green: 'green',
8
+ Blue: 'blue',
9
+ Violet: 'violet',
10
+ Pink: 'pink',
11
+ };
@@ -0,0 +1,3 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+ import { APPEARANCE } from './constants';
3
+ export type Appearance = ValueOf<typeof APPEARANCE>;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Status",
7
- "version": "0.4.1",
7
+ "version": "0.5.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -32,8 +32,8 @@
32
32
  "license": "Apache-2.0",
33
33
  "scripts": {},
34
34
  "dependencies": {
35
- "@snack-uikit/utils": "3.1.0",
35
+ "@snack-uikit/utils": "3.2.0",
36
36
  "classnames": "2.3.2"
37
37
  },
38
- "gitHead": "76a159dde7baccf49dc7b11e1fd7abc31424b42f"
38
+ "gitHead": "bd39c5e674f3b91b0e2487782a04b15034cf3d8b"
39
39
  }
@@ -2,19 +2,12 @@ import cn from 'classnames';
2
2
 
3
3
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
4
4
 
5
- import { Appearance } from '../../constants';
5
+ import { APPEARANCE } from '../../constants';
6
+ import { Appearance } from '../../types';
6
7
  import { StatusIndicator } from '../StatusIndicator';
8
+ import { SIZE, STATUS_INDICATOR_SIZE_MAP } from './constants';
7
9
  import styles from './styles.module.scss';
8
-
9
- enum Size {
10
- Xs = 'xs',
11
- S = 's',
12
- }
13
-
14
- const statusIndicatorSizeMap = {
15
- [Size.Xs]: StatusIndicator.sizes.Xs,
16
- [Size.S]: StatusIndicator.sizes.S,
17
- };
10
+ import { Size } from './types';
18
11
 
19
12
  export type StatusProps = WithSupportProps<{
20
13
  /** Текст */
@@ -30,8 +23,8 @@ export type StatusProps = WithSupportProps<{
30
23
 
31
24
  export function Status({
32
25
  label,
33
- size = Size.Xs,
34
- appearance = Appearance.Primary,
26
+ size = SIZE.Xs,
27
+ appearance = APPEARANCE.Primary,
35
28
  hasBackground,
36
29
  className,
37
30
  ...rest
@@ -43,11 +36,8 @@ export function Status({
43
36
  data-size={size}
44
37
  data-has-background={hasBackground || undefined}
45
38
  >
46
- <StatusIndicator appearance={appearance} size={statusIndicatorSizeMap[size]} />
39
+ <StatusIndicator appearance={appearance} size={STATUS_INDICATOR_SIZE_MAP[size]} />
47
40
  <span className={styles.label}>{label}</span>
48
41
  </div>
49
42
  );
50
43
  }
51
-
52
- Status.sizes = Size;
53
- Status.appearances = Appearance;
@@ -0,0 +1,11 @@
1
+ import { SIZE as StatusIndicatorSize } from '../StatusIndicator/constants';
2
+
3
+ export const SIZE = {
4
+ Xs: 'xs',
5
+ S: 's',
6
+ } as const;
7
+
8
+ export const STATUS_INDICATOR_SIZE_MAP = {
9
+ [SIZE.Xs]: StatusIndicatorSize.Xs,
10
+ [SIZE.S]: StatusIndicatorSize.S,
11
+ };
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { SIZE } from './constants';
4
+
5
+ export type Size = ValueOf<typeof SIZE>;
@@ -2,16 +2,11 @@ import cn from 'classnames';
2
2
 
3
3
  import { extractSupportProps, WithSupportProps } from '@snack-uikit/utils';
4
4
 
5
- import { Appearance } from '../../constants';
5
+ import { APPEARANCE } from '../../constants';
6
+ import { Appearance } from '../../types';
7
+ import { SIZE } from './constants';
6
8
  import styles from './styles.module.scss';
7
-
8
- enum Size {
9
- Xxs = 'xxs',
10
- Xs = 'xs',
11
- S = 's',
12
- M = 'm',
13
- L = 'l',
14
- }
9
+ import { Size } from './types';
15
10
 
16
11
  export type StatusIndicatorProps = WithSupportProps<{
17
12
  /** Размер */
@@ -22,8 +17,8 @@ export type StatusIndicatorProps = WithSupportProps<{
22
17
  }>;
23
18
 
24
19
  export function StatusIndicator({
25
- size = Size.M,
26
- appearance = Appearance.Primary,
20
+ size = SIZE.M,
21
+ appearance = APPEARANCE.Primary,
27
22
  className,
28
23
  ...rest
29
24
  }: StatusIndicatorProps) {
@@ -33,6 +28,3 @@ export function StatusIndicator({
33
28
  </div>
34
29
  );
35
30
  }
36
-
37
- StatusIndicator.sizes = Size;
38
- StatusIndicator.appearances = Appearance;
@@ -0,0 +1,7 @@
1
+ export const SIZE = {
2
+ Xxs: 'xxs',
3
+ Xs: 'xs',
4
+ S: 's',
5
+ M: 'm',
6
+ L: 'l',
7
+ } as const;
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { SIZE } from './constants';
4
+
5
+ export type Size = ValueOf<typeof SIZE>;
package/src/constants.ts CHANGED
@@ -1,11 +1,11 @@
1
- export enum Appearance {
2
- Primary = 'primary',
3
- Neutral = 'neutral',
4
- Red = 'red',
5
- Orange = 'orange',
6
- Yellow = 'yellow',
7
- Green = 'green',
8
- Blue = 'blue',
9
- Violet = 'violet',
10
- Pink = 'pink',
11
- }
1
+ export const APPEARANCE = {
2
+ Primary: 'primary',
3
+ Neutral: 'neutral',
4
+ Red: 'red',
5
+ Orange: 'orange',
6
+ Yellow: 'yellow',
7
+ Green: 'green',
8
+ Blue: 'blue',
9
+ Violet: 'violet',
10
+ Pink: 'pink',
11
+ } as const;
package/src/types.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { ValueOf } from '@snack-uikit/utils';
2
+
3
+ import { APPEARANCE } from './constants';
4
+
5
+ export type Appearance = ValueOf<typeof APPEARANCE>;