@semcore/button 16.1.0 → 16.1.1

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 (49) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/lib/cjs/component/AbstractButton/AbstractButton.js +189 -0
  3. package/lib/cjs/component/AbstractButton/AbstractButton.js.map +1 -0
  4. package/lib/cjs/component/AbstractButton/AbstractButton.type.js +2 -0
  5. package/lib/cjs/component/AbstractButton/AbstractButton.type.js.map +1 -0
  6. package/lib/cjs/component/AbstractButton/SpinButton.js.map +1 -0
  7. package/lib/cjs/component/Button/Button.js +50 -160
  8. package/lib/cjs/component/Button/Button.js.map +1 -1
  9. package/lib/cjs/component/Button/Button.type.js.map +1 -1
  10. package/lib/cjs/component/ButtonLink/ButtonLink.js +54 -29
  11. package/lib/cjs/component/ButtonLink/ButtonLink.js.map +1 -1
  12. package/lib/cjs/component/ButtonLink/ButtonLink.type.js.map +1 -1
  13. package/lib/cjs/component/ButtonLink/buttonLink.shadow.css +140 -10
  14. package/lib/cjs/index.js +4 -3
  15. package/lib/cjs/index.js.map +1 -1
  16. package/lib/es6/component/AbstractButton/AbstractButton.js +184 -0
  17. package/lib/es6/component/AbstractButton/AbstractButton.js.map +1 -0
  18. package/lib/es6/component/AbstractButton/AbstractButton.type.js +2 -0
  19. package/lib/es6/component/AbstractButton/AbstractButton.type.js.map +1 -0
  20. package/lib/es6/component/AbstractButton/SpinButton.js.map +1 -0
  21. package/lib/es6/component/Button/Button.js +49 -160
  22. package/lib/es6/component/Button/Button.js.map +1 -1
  23. package/lib/es6/component/Button/Button.type.js.map +1 -1
  24. package/lib/es6/component/ButtonLink/ButtonLink.js +56 -30
  25. package/lib/es6/component/ButtonLink/ButtonLink.js.map +1 -1
  26. package/lib/es6/component/ButtonLink/ButtonLink.type.js.map +1 -1
  27. package/lib/es6/component/ButtonLink/buttonLink.shadow.css +140 -10
  28. package/lib/es6/index.js +2 -1
  29. package/lib/es6/index.js.map +1 -1
  30. package/lib/esm/component/AbstractButton/AbstractButton.mjs +157 -0
  31. package/lib/esm/component/{Button → AbstractButton}/SpinButton.mjs +2 -1
  32. package/lib/esm/component/Button/Button.mjs +48 -140
  33. package/lib/esm/component/ButtonLink/ButtonLink.mjs +52 -30
  34. package/lib/esm/component/ButtonLink/buttonLink.shadow.css +140 -10
  35. package/lib/esm/index.mjs +2 -3
  36. package/lib/types/component/AbstractButton/AbstractButton.d.ts +24 -0
  37. package/lib/types/component/AbstractButton/AbstractButton.type.d.ts +38 -0
  38. package/lib/types/component/Button/Button.d.ts +1 -28
  39. package/lib/types/component/Button/Button.type.d.ts +39 -40
  40. package/lib/types/component/ButtonLink/ButtonLink.type.d.ts +19 -14
  41. package/lib/types/index.d.ts +2 -1
  42. package/package.json +7 -7
  43. package/lib/cjs/component/Button/SpinButton.js.map +0 -1
  44. package/lib/es6/component/Button/SpinButton.js.map +0 -1
  45. package/lib/esm/component/Button/Button.type.mjs +0 -1
  46. package/lib/esm/component/ButtonLink/ButtonLink.type.mjs +0 -1
  47. /package/lib/cjs/component/{Button → AbstractButton}/SpinButton.js +0 -0
  48. /package/lib/es6/component/{Button → AbstractButton}/SpinButton.js +0 -0
  49. /package/lib/types/component/{Button → AbstractButton}/SpinButton.d.ts +0 -0
@@ -0,0 +1,38 @@
1
+ import type { PropGetterFn } from '@semcore/core';
2
+ import type { BoxProps } from '@semcore/flex-box';
3
+ import type { NeighborItemProps } from '@semcore/neighbor-location';
4
+ import type { TooltipHintProps } from '@semcore/tooltip';
5
+ import type React from 'react';
6
+ export type AbstractButtonProps<S, U, T> = BoxProps & NeighborItemProps & {
7
+ /** Button activity state */
8
+ active?: boolean;
9
+ /** Disabled button state */
10
+ disabled?: boolean;
11
+ /** Loading button state */
12
+ loading?: boolean;
13
+ /** Tag for the left Addon */
14
+ addonLeft?: React.ElementType;
15
+ /** Tag for the right Addon */
16
+ addonRight?: React.ElementType;
17
+ /**
18
+ * Placement for hint
19
+ * @default top
20
+ */
21
+ hintPlacement?: TooltipHintProps['placement'];
22
+ /** Button size. Defined in Button.type or ButtonLink.type */
23
+ size?: S;
24
+ /** Button usage. Defined in Button.type or ButtonLink.type */
25
+ use?: U;
26
+ /** Button theme. Defined in Button.type or ButtonLink.type */
27
+ theme?: T;
28
+ };
29
+ export type AbstractButtonAddonProps<S> = BoxProps & {
30
+ size?: S;
31
+ };
32
+ export type AbstractButtonTextProps<S> = BoxProps & {
33
+ size?: S;
34
+ };
35
+ export type AbstractButtonContext = {
36
+ getTextProps: PropGetterFn;
37
+ getAddonProps: PropGetterFn;
38
+ };
@@ -1,30 +1,3 @@
1
- import { Component } from '@semcore/core';
2
- import React from 'react';
3
- import type { ButtonProps, ButtonComponent } from './Button.type';
4
- export declare const MAP_USE_DEFAULT_THEME: Record<string, string>;
5
- type State = {
6
- ariaLabelledByContent: null | string;
7
- };
8
- export declare class RootButton extends Component<ButtonProps, [], never, {}, State> {
9
- static displayName: string;
10
- static style: {
11
- [key: string]: string;
12
- };
13
- static defaultProps: {
14
- use: string;
15
- size: string;
16
- };
17
- containerRef: React.RefObject<HTMLButtonElement>;
18
- state: State;
19
- getTextProps(): {
20
- size: "l" | "m" | undefined;
21
- 'hint:triggerRef': React.RefObject<HTMLButtonElement>;
22
- };
23
- getAddonProps(): {
24
- size: "l" | "m" | undefined;
25
- };
26
- componentDidMount(): void;
27
- render(): React.JSX.Element;
28
- }
1
+ import type { ButtonComponent } from './Button.type';
29
2
  declare const Button: ButtonComponent;
30
3
  export default Button;
@@ -1,44 +1,43 @@
1
- import type { BoxProps, NeighborItemProps, SimpleHintPopperProps } from '@semcore/base-components';
2
- import type { Intergalactic, PropGetterFn } from '@semcore/core';
3
- import type { NSText } from '@semcore/typography';
4
- import type React from 'react';
5
- export type ButtonProps = BoxProps & NeighborItemProps & {
6
- /** Button activity state */
7
- active?: boolean;
8
- /** Disabled button state */
9
- disabled?: boolean;
10
- /** Loading button state */
11
- loading?: boolean;
12
- /** Tag for the left Addon */
13
- addonLeft?: React.ElementType;
14
- /** Tag for the right Addon */
15
- addonRight?: React.ElementType;
16
- /**
17
- * Placement for hint
18
- * @default top
19
- */
20
- hintPlacement?: SimpleHintPopperProps['placement'];
21
- /** Button size.
22
- * @default `m`
23
- */
24
- size?: 'l' | 'm';
25
- /** Button usage.
26
- * @default `primary`
27
- */
28
- use?: 'primary' | 'secondary' | 'tertiary';
29
- /** Button theme.
30
- * @default undefined
31
- */
32
- theme?: 'info' | 'success' | 'brand' | 'danger' | 'muted' | 'invert';
33
- };
34
- export type ButtonTextProps = NSText.Props;
35
- export type ButtonAddonProps = BoxProps;
36
- export type ButtonContext = {
37
- getTextProps: PropGetterFn;
38
- getAddonProps: PropGetterFn;
39
- };
1
+ import type { UnknownProperties, Intergalactic } from '@semcore/core';
2
+ import type { AbstractButtonAddonProps, AbstractButtonContext, AbstractButtonTextProps, AbstractButtonProps } from '../AbstractButton/AbstractButton.type';
3
+ /**
4
+ * Button size
5
+ * @default m
6
+ */
7
+ export type ButtonSize = 'l' | 'm';
8
+ /**
9
+ * Button type
10
+ * @default secondary
11
+ */
12
+ type Use = 'primary' | 'secondary' | 'tertiary';
13
+ /**
14
+ * @deprecated don't use it. use `danger` for incorrect or danger behavior and `brand` for the orange one.
15
+ */
16
+ type DeprecatedTheme = 'warning';
17
+ /** Button theme */
18
+ type Theme = 'info' | 'success' | 'brand' | 'danger' | 'muted' | 'invert';
19
+ /** @deprecated */
20
+ export interface IButtonProps extends ButtonProps, UnknownProperties {
21
+ }
22
+ export type ButtonProps = AbstractButtonProps<ButtonSize, Use, Theme | DeprecatedTheme>;
23
+ /** @deprecated */
24
+ export interface IButtonTextProps extends ButtonTextProps, UnknownProperties {
25
+ }
26
+ export type ButtonTextProps = AbstractButtonTextProps<ButtonSize>;
27
+ /** @deprecated */
28
+ export interface IButtonAddonProps extends ButtonAddonProps, UnknownProperties {
29
+ }
30
+ export type ButtonAddonProps = AbstractButtonAddonProps<ButtonSize>;
31
+ /** @deprecated */
32
+ export interface IButtonContext extends ButtonContext, UnknownProperties {
33
+ }
34
+ export type ButtonContext = AbstractButtonContext;
40
35
  export type ButtonChildren = {
41
36
  Text: Intergalactic.Component<'span', ButtonTextProps>;
42
37
  Addon: Intergalactic.Component<'span', ButtonAddonProps>;
43
38
  };
44
- export type ButtonComponent = Intergalactic.Component<'button', ButtonProps, ButtonContext> & ButtonChildren;
39
+ export type ButtonComponent = Intergalactic.Component<'button', ButtonProps, ButtonContext> & {
40
+ Text: Intergalactic.Component<'span', ButtonTextProps>;
41
+ Addon: Intergalactic.Component<'span', ButtonAddonProps>;
42
+ };
43
+ export {};
@@ -1,19 +1,24 @@
1
- import type { BoxProps } from '@semcore/base-components';
2
1
  import type { Intergalactic } from '@semcore/core';
3
- import type { LinkProps } from '@semcore/link';
4
- import type { NSText } from '@semcore/typography';
5
- import type { ButtonContext } from '../Button/Button.type';
6
- export type ButtonLinkProps = Intergalactic.InternalTypings.EfficientOmit<LinkProps, 'enableVisited'> & {
7
- /**
8
- * Button link type
9
- * @default primary
10
- */
11
- use?: 'primary' | 'secondary';
12
- };
13
- export type ButtonLinkTextProps = NSText.Props;
14
- export type ButtonLinkAddonProps = BoxProps;
2
+ import type { AbstractButtonAddonProps, AbstractButtonContext, AbstractButtonTextProps, AbstractButtonProps } from '../AbstractButton/AbstractButton.type';
3
+ /**
4
+ * Button link size
5
+ */
6
+ export type ButtonLinkSize = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800;
7
+ /**
8
+ * Button link type
9
+ * @default primary
10
+ */
11
+ type Use = 'primary' | 'secondary';
12
+ export type ButtonLinkProps = AbstractButtonProps<ButtonLinkSize, Use, never>;
13
+ export type ButtonLinkTextProps = AbstractButtonTextProps<ButtonLinkSize>;
14
+ export type ButtonLinkAddonProps = AbstractButtonAddonProps<ButtonLinkSize>;
15
+ export type ButtonLinkContext = AbstractButtonContext;
15
16
  export type ButtonLinkChildren = {
16
17
  Text: Intergalactic.Component<'span', ButtonLinkTextProps>;
17
18
  Addon: Intergalactic.Component<'span', ButtonLinkAddonProps>;
18
19
  };
19
- export type ButtonLinkComponent = Intergalactic.Component<'button', ButtonLinkProps, ButtonContext> & ButtonLinkChildren;
20
+ export type ButtonLinkComponent = Intergalactic.Component<'button', ButtonLinkProps, ButtonLinkContext> & {
21
+ Text: Intergalactic.Component<'span', ButtonLinkTextProps>;
22
+ Addon: Intergalactic.Component<'span', ButtonLinkAddonProps>;
23
+ };
24
+ export {};
@@ -1,4 +1,5 @@
1
- export { default, MAP_USE_DEFAULT_THEME } from './component/Button/Button';
1
+ export { default } from './component/Button/Button';
2
2
  export * from './component/Button/Button.type';
3
3
  export * from './component/ButtonLink/ButtonLink';
4
4
  export * from './component/ButtonLink/ButtonLink.type';
5
+ export { MAP_USE_DEFAULT_THEME } from './component/AbstractButton/AbstractButton';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/button",
3
3
  "description": "Semrush Button Component",
4
- "version": "16.1.0",
4
+ "version": "16.1.1",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,10 +14,10 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/flex-box": "16.1.0",
18
- "@semcore/neighbor-location": "16.1.0",
19
- "@semcore/spin": "16.1.0",
20
- "@semcore/tooltip": "16.1.0"
17
+ "@semcore/flex-box": "16.1.1",
18
+ "@semcore/neighbor-location": "16.1.1",
19
+ "@semcore/spin": "16.1.1",
20
+ "@semcore/tooltip": "16.1.1"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "@semcore/base-components": "^16.6.0"
@@ -28,9 +28,9 @@
28
28
  "directory": "semcore/button"
29
29
  },
30
30
  "devDependencies": {
31
- "@semcore/core": "16.6.0",
32
- "@semcore/icon": "16.8.0",
31
+ "@semcore/icon": "16.8.1",
33
32
  "@semcore/testing-utils": "1.0.0",
33
+ "@semcore/core": "16.6.0",
34
34
  "@semcore/base-components": "16.6.0"
35
35
  },
36
36
  "scripts": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpinButton.js","names":["_spin","_interopRequireDefault","require","_react","_excluded","SPIN_SIZE_MAP","exports","xl","l","m","s","SpinButton","_ref","theme","size","others","_objectWithoutProperties2","createElement","_extends2"],"sources":["../../../../src/component/Button/SpinButton.tsx"],"sourcesContent":["import Spin from '@semcore/spin';\nimport React from 'react';\n\nexport const SPIN_SIZE_MAP: Record<string, string> = {\n xl: 'm',\n l: 's',\n m: 'xs',\n s: 'xxs',\n};\n\nexport default function SpinButton({ theme, size, ...others }: any) {\n return (\n <Spin\n size={typeof size === 'string' ? SPIN_SIZE_MAP[size] : size}\n theme='currentColor'\n {...others}\n />\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA0B,IAAAE,SAAA;AAEnB,IAAMC,aAAqC,GAAAC,OAAA,CAAAD,aAAA,GAAG;EACnDE,EAAE,EAAE,GAAG;EACPC,CAAC,EAAE,GAAG;EACNC,CAAC,EAAE,IAAI;EACPC,CAAC,EAAE;AACL,CAAC;AAEc,SAASC,UAAUA,CAAAC,IAAA,EAAkC;EAAA,IAA/BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IAAKC,MAAM,OAAAC,yBAAA,aAAAJ,IAAA,EAAAR,SAAA;EACzD,oBACED,MAAA,YAAAc,aAAA,CAACjB,KAAA,WAAI,MAAAkB,SAAA;IACHJ,IAAI,EAAE,OAAOA,IAAI,KAAK,QAAQ,GAAGT,aAAa,CAACS,IAAI,CAAC,GAAGA,IAAK;IAC5DD,KAAK,EAAC;EAAc,GAChBE,MAAM,CACX,CAAC;AAEN","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpinButton.js","names":["Spin","React","SPIN_SIZE_MAP","xl","l","m","s","SpinButton","_ref","theme","size","others","_objectWithoutProperties","_excluded","createElement","_extends"],"sources":["../../../../src/component/Button/SpinButton.tsx"],"sourcesContent":["import Spin from '@semcore/spin';\nimport React from 'react';\n\nexport const SPIN_SIZE_MAP: Record<string, string> = {\n xl: 'm',\n l: 's',\n m: 'xs',\n s: 'xxs',\n};\n\nexport default function SpinButton({ theme, size, ...others }: any) {\n return (\n <Spin\n size={typeof size === 'string' ? SPIN_SIZE_MAP[size] : size}\n theme='currentColor'\n {...others}\n />\n );\n}\n"],"mappings":";;;AAAA,OAAOA,IAAI,MAAM,eAAe;AAChC,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAO,IAAMC,aAAqC,GAAG;EACnDC,EAAE,EAAE,GAAG;EACPC,CAAC,EAAE,GAAG;EACNC,CAAC,EAAE,IAAI;EACPC,CAAC,EAAE;AACL,CAAC;AAED,eAAe,SAASC,UAAUA,CAAAC,IAAA,EAAkC;EAAA,IAA/BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IAAKC,MAAM,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EACzD,oBACEZ,KAAA,CAAAa,aAAA,CAACd,IAAI,EAAAe,QAAA;IACHL,IAAI,EAAE,OAAOA,IAAI,KAAK,QAAQ,GAAGR,aAAa,CAACQ,IAAI,CAAC,GAAGA,IAAK;IAC5DD,KAAK,EAAC;EAAc,GAChBE,MAAM,CACX,CAAC;AAEN","ignoreList":[]}