@momentum-design/components 0.57.0 → 0.58.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.
- package/dist/browser/index.js +304 -283
- package/dist/browser/index.js.map +4 -4
- package/dist/components/button/button.component.d.ts +3 -56
- package/dist/components/button/button.component.js +3 -96
- package/dist/components/buttonlink/buttonlink.component.d.ts +59 -0
- package/dist/components/buttonlink/buttonlink.component.js +106 -0
- package/dist/components/buttonlink/buttonlink.constants.d.ts +2 -0
- package/dist/components/buttonlink/buttonlink.constants.js +3 -0
- package/dist/components/buttonlink/buttonlink.types.d.ts +7 -0
- package/dist/components/buttonlink/buttonlink.types.js +1 -0
- package/dist/components/buttonlink/index.d.ts +8 -0
- package/dist/components/buttonlink/index.js +5 -0
- package/dist/components/statictoggle/index.d.ts +8 -0
- package/dist/components/statictoggle/index.js +5 -0
- package/dist/components/statictoggle/statictoggle.component.d.ts +48 -0
- package/dist/components/statictoggle/statictoggle.component.js +82 -0
- package/dist/components/statictoggle/statictoggle.constants.d.ts +17 -0
- package/dist/components/statictoggle/statictoggle.constants.js +18 -0
- package/dist/components/statictoggle/statictoggle.styles.d.ts +2 -0
- package/dist/components/statictoggle/statictoggle.styles.js +82 -0
- package/dist/components/statictoggle/statictoggle.types.d.ts +4 -0
- package/dist/components/statictoggle/statictoggle.types.js +1 -0
- package/dist/components/toggle/index.d.ts +2 -1
- package/dist/components/toggle/index.js +2 -1
- package/dist/components/toggle/toggle.component.d.ts +16 -20
- package/dist/components/toggle/toggle.component.js +27 -33
- package/dist/components/toggle/toggle.styles.js +26 -96
- package/dist/custom-elements.json +1806 -828
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/react/buttonlink/index.d.ts +30 -0
- package/dist/react/buttonlink/index.js +38 -0
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +3 -1
- package/dist/react/statictoggle/index.d.ts +30 -0
- package/dist/react/statictoggle/index.js +39 -0
- package/dist/react/toggle/index.d.ts +14 -18
- package/dist/react/toggle/index.js +14 -18
- package/dist/utils/mixins/ButtonComponentMixin.d.ts +16 -0
- package/dist/utils/mixins/ButtonComponentMixin.js +114 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -11,6 +11,7 @@ import Chip from './components/chip';
|
|
11
11
|
import Coachmark from './components/coachmark';
|
12
12
|
import StaticCheckbox from './components/staticcheckbox';
|
13
13
|
import StaticRadio from './components/staticradio';
|
14
|
+
import StaticToggle from './components/statictoggle';
|
14
15
|
import Divider from './components/divider';
|
15
16
|
import FilterChip from './components/filterchip';
|
16
17
|
import FormfieldGroup from './components/formfieldgroup';
|
@@ -43,6 +44,7 @@ import Tooltip from './components/tooltip';
|
|
43
44
|
import ToggleTip from './components/toggletip';
|
44
45
|
import VirtualizedList from './components/virtualizedlist';
|
45
46
|
import TabList from './components/tablist';
|
47
|
+
import ButtonLink from './components/buttonlink';
|
46
48
|
import Linksimple from './components/linksimple';
|
47
49
|
import type { BadgeType } from './components/badge/badge.types';
|
48
50
|
import type { ButtonColor, ButtonVariant, IconButtonSize, PillButtonSize } from './components/button/button.types';
|
@@ -51,6 +53,6 @@ import type { SpinnerSize, SpinnerVariant } from './components/spinner/spinner.t
|
|
51
53
|
import type { TextType } from './components/text/text.types';
|
52
54
|
import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
|
53
55
|
import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from './components/button/button.constants';
|
54
|
-
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, Linksimple, };
|
56
|
+
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, StaticToggle, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, ButtonLink, Linksimple, };
|
55
57
|
export type { TextType, SpinnerSize, SpinnerVariant, PopoverPlacement, BadgeType, IconButtonSize, PillButtonSize, ButtonVariant, ButtonColor, };
|
56
58
|
export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES };
|
package/dist/index.js
CHANGED
@@ -12,6 +12,7 @@ import Chip from './components/chip';
|
|
12
12
|
import Coachmark from './components/coachmark';
|
13
13
|
import StaticCheckbox from './components/staticcheckbox';
|
14
14
|
import StaticRadio from './components/staticradio';
|
15
|
+
import StaticToggle from './components/statictoggle';
|
15
16
|
import Divider from './components/divider';
|
16
17
|
import FilterChip from './components/filterchip';
|
17
18
|
import FormfieldGroup from './components/formfieldgroup';
|
@@ -44,11 +45,12 @@ import Tooltip from './components/tooltip';
|
|
44
45
|
import ToggleTip from './components/toggletip';
|
45
46
|
import VirtualizedList from './components/virtualizedlist';
|
46
47
|
import TabList from './components/tablist';
|
48
|
+
import ButtonLink from './components/buttonlink';
|
47
49
|
import Linksimple from './components/linksimple';
|
48
50
|
import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
|
49
51
|
// Constants / Utils Imports
|
50
52
|
import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from './components/button/button.constants';
|
51
53
|
// Components Exports
|
52
|
-
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, Linksimple, };
|
54
|
+
export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, StaticToggle, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, ButtonLink, Linksimple, };
|
53
55
|
// Constants / Utils Exports
|
54
56
|
export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES };
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { type EventName } from '@lit/react';
|
2
|
+
import Component from '../../components/buttonlink';
|
3
|
+
/**
|
4
|
+
* `mdc-buttonlink` combines the functional behavior of `mdc-linksimple` with the visual and structural
|
5
|
+
* features of `mdc-button`. This includes support for variants, sizing, and optional
|
6
|
+
* prefix and postfix icons via slots.
|
7
|
+
*
|
8
|
+
* ### Features:
|
9
|
+
* - Behaves like an link while visually resembling a button.
|
10
|
+
* - Supports slots for `prefix-icon` and `postfix-icon`.
|
11
|
+
* - Customizable size, color, and variant through attributes.
|
12
|
+
* - Inherits accessibility and keyboard interaction support from `mdc-linksimple`.
|
13
|
+
*
|
14
|
+
* @dependency mdc-icon
|
15
|
+
*
|
16
|
+
* @tagname mdc-buttonlink
|
17
|
+
*
|
18
|
+
* @event click - (React: onClick) Fired when the user activates the buttonLink using a mouse or assistive technology.
|
19
|
+
* @event keydown - (React: onKeyDown) Fired when the user presses a key while the buttonLink has focus.
|
20
|
+
* @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
|
21
|
+
* @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
|
22
|
+
*
|
23
|
+
*/
|
24
|
+
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {
|
25
|
+
onClick: EventName<MouseEvent>;
|
26
|
+
onKeyDown: EventName<KeyboardEvent>;
|
27
|
+
onFocus: EventName<FocusEvent>;
|
28
|
+
onBlur: EventName<Event>;
|
29
|
+
}>;
|
30
|
+
export default reactWrapper;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { createComponent } from '@lit/react';
|
3
|
+
import Component from '../../components/buttonlink';
|
4
|
+
import { TAG_NAME } from '../../components/buttonlink/buttonlink.constants';
|
5
|
+
/**
|
6
|
+
* `mdc-buttonlink` combines the functional behavior of `mdc-linksimple` with the visual and structural
|
7
|
+
* features of `mdc-button`. This includes support for variants, sizing, and optional
|
8
|
+
* prefix and postfix icons via slots.
|
9
|
+
*
|
10
|
+
* ### Features:
|
11
|
+
* - Behaves like an link while visually resembling a button.
|
12
|
+
* - Supports slots for `prefix-icon` and `postfix-icon`.
|
13
|
+
* - Customizable size, color, and variant through attributes.
|
14
|
+
* - Inherits accessibility and keyboard interaction support from `mdc-linksimple`.
|
15
|
+
*
|
16
|
+
* @dependency mdc-icon
|
17
|
+
*
|
18
|
+
* @tagname mdc-buttonlink
|
19
|
+
*
|
20
|
+
* @event click - (React: onClick) Fired when the user activates the buttonLink using a mouse or assistive technology.
|
21
|
+
* @event keydown - (React: onKeyDown) Fired when the user presses a key while the buttonLink has focus.
|
22
|
+
* @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
|
23
|
+
* @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
|
24
|
+
*
|
25
|
+
*/
|
26
|
+
const reactWrapper = createComponent({
|
27
|
+
tagName: TAG_NAME,
|
28
|
+
elementClass: Component,
|
29
|
+
react: React,
|
30
|
+
events: {
|
31
|
+
onClick: 'click',
|
32
|
+
onKeyDown: 'keydown',
|
33
|
+
onFocus: 'focus',
|
34
|
+
onBlur: 'blur',
|
35
|
+
},
|
36
|
+
displayName: 'ButtonLink',
|
37
|
+
});
|
38
|
+
export default reactWrapper;
|
package/dist/react/index.d.ts
CHANGED
@@ -2,10 +2,11 @@ export { default as AlertChip } from './alertchip';
|
|
2
2
|
export { default as Appheader } from './appheader';
|
3
3
|
export { default as Avatar } from './avatar';
|
4
4
|
export { default as AvatarButton } from './avatarbutton';
|
5
|
+
export { default as Badge } from './badge';
|
5
6
|
export { default as Brandvisual } from './brandvisual';
|
6
7
|
export { default as Bullet } from './bullet';
|
7
8
|
export { default as Button } from './button';
|
8
|
-
export { default as
|
9
|
+
export { default as ButtonLink } from './buttonlink';
|
9
10
|
export { default as Buttonsimple } from './buttonsimple';
|
10
11
|
export { default as Checkbox } from './checkbox';
|
11
12
|
export { default as Chip } from './chip';
|
@@ -37,6 +38,7 @@ export { default as Select } from './select';
|
|
37
38
|
export { default as Spinner } from './spinner';
|
38
39
|
export { default as StaticCheckbox } from './staticcheckbox';
|
39
40
|
export { default as StaticRadio } from './staticradio';
|
41
|
+
export { default as StaticToggle } from './statictoggle';
|
40
42
|
export { default as Tab } from './tab';
|
41
43
|
export { default as TabList } from './tablist';
|
42
44
|
export { default as Text } from './text';
|
package/dist/react/index.js
CHANGED
@@ -2,10 +2,11 @@ export { default as AlertChip } from './alertchip';
|
|
2
2
|
export { default as Appheader } from './appheader';
|
3
3
|
export { default as Avatar } from './avatar';
|
4
4
|
export { default as AvatarButton } from './avatarbutton';
|
5
|
+
export { default as Badge } from './badge';
|
5
6
|
export { default as Brandvisual } from './brandvisual';
|
6
7
|
export { default as Bullet } from './bullet';
|
7
8
|
export { default as Button } from './button';
|
8
|
-
export { default as
|
9
|
+
export { default as ButtonLink } from './buttonlink';
|
9
10
|
export { default as Buttonsimple } from './buttonsimple';
|
10
11
|
export { default as Checkbox } from './checkbox';
|
11
12
|
export { default as Chip } from './chip';
|
@@ -37,6 +38,7 @@ export { default as Select } from './select';
|
|
37
38
|
export { default as Spinner } from './spinner';
|
38
39
|
export { default as StaticCheckbox } from './staticcheckbox';
|
39
40
|
export { default as StaticRadio } from './staticradio';
|
41
|
+
export { default as StaticToggle } from './statictoggle';
|
40
42
|
export { default as Tab } from './tab';
|
41
43
|
export { default as TabList } from './tablist';
|
42
44
|
export { default as Text } from './text';
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import Component from '../../components/statictoggle';
|
2
|
+
/**
|
3
|
+
* This is a decorative component that is styled to look as a toggle. <br/>
|
4
|
+
* It has 3 properties - checked, size and disabled. <br/>
|
5
|
+
* We are using the same styling that has been created for the `mdc-toggle` component.
|
6
|
+
*
|
7
|
+
* @dependency mdc-icon
|
8
|
+
*
|
9
|
+
* @tagname mdc-statictoggle
|
10
|
+
*
|
11
|
+
* @slot default - This is a default/unnamed slot
|
12
|
+
*
|
13
|
+
* @cssproperty --mdc-statictoggle-width - Width of the toggle
|
14
|
+
* @cssproperty --mdc-statictoggle-height - Height of the toggle
|
15
|
+
* @cssproperty --mdc-statictoggle-width-compact - Width of the toggle when it's size is compact
|
16
|
+
* @cssproperty --mdc-statictoggle-height-compact - Height of the toggle when it's size is compact
|
17
|
+
* @cssproperty --mdc-statictoggle-border-radius - Border radius of the toggle
|
18
|
+
* @cssproperty --mdc-statictoggle-border-radius-compact - Border radius of the toggle when it's size is compact
|
19
|
+
* @cssproperty --mdc-statictoggle-border - Border of the toggle
|
20
|
+
* @cssproperty --mdc-statictoggle-inactive-rest-color - Background color of the inactive toggle in rest state
|
21
|
+
* @cssproperty --mdc-statictoggle-inactive-disabled-color - Background color of the inactive toggle in disabled state
|
22
|
+
* @cssproperty --mdc-statictoggle-active-rest-color - Background color of the active toggle in rest state
|
23
|
+
* @cssproperty --mdc-statictoggle-active-disabled-color - Background color of the active toggle in disabled state
|
24
|
+
* @cssproperty --mdc-statictoggle-icon-color-normal - Color of the icon in normal state
|
25
|
+
* @cssproperty --mdc-statictoggle-icon-color-disabled - Color of the icon in disabled state
|
26
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-normal - Background color of the icon in normal state
|
27
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-disabled - Background color of the icon in disabled state
|
28
|
+
*/
|
29
|
+
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {}>;
|
30
|
+
export default reactWrapper;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { createComponent } from '@lit/react';
|
3
|
+
import Component from '../../components/statictoggle';
|
4
|
+
import { TAG_NAME } from '../../components/statictoggle/statictoggle.constants';
|
5
|
+
/**
|
6
|
+
* This is a decorative component that is styled to look as a toggle. <br/>
|
7
|
+
* It has 3 properties - checked, size and disabled. <br/>
|
8
|
+
* We are using the same styling that has been created for the `mdc-toggle` component.
|
9
|
+
*
|
10
|
+
* @dependency mdc-icon
|
11
|
+
*
|
12
|
+
* @tagname mdc-statictoggle
|
13
|
+
*
|
14
|
+
* @slot default - This is a default/unnamed slot
|
15
|
+
*
|
16
|
+
* @cssproperty --mdc-statictoggle-width - Width of the toggle
|
17
|
+
* @cssproperty --mdc-statictoggle-height - Height of the toggle
|
18
|
+
* @cssproperty --mdc-statictoggle-width-compact - Width of the toggle when it's size is compact
|
19
|
+
* @cssproperty --mdc-statictoggle-height-compact - Height of the toggle when it's size is compact
|
20
|
+
* @cssproperty --mdc-statictoggle-border-radius - Border radius of the toggle
|
21
|
+
* @cssproperty --mdc-statictoggle-border-radius-compact - Border radius of the toggle when it's size is compact
|
22
|
+
* @cssproperty --mdc-statictoggle-border - Border of the toggle
|
23
|
+
* @cssproperty --mdc-statictoggle-inactive-rest-color - Background color of the inactive toggle in rest state
|
24
|
+
* @cssproperty --mdc-statictoggle-inactive-disabled-color - Background color of the inactive toggle in disabled state
|
25
|
+
* @cssproperty --mdc-statictoggle-active-rest-color - Background color of the active toggle in rest state
|
26
|
+
* @cssproperty --mdc-statictoggle-active-disabled-color - Background color of the active toggle in disabled state
|
27
|
+
* @cssproperty --mdc-statictoggle-icon-color-normal - Color of the icon in normal state
|
28
|
+
* @cssproperty --mdc-statictoggle-icon-color-disabled - Color of the icon in disabled state
|
29
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-normal - Background color of the icon in normal state
|
30
|
+
* @cssproperty --mdc-statictoggle-icon-background-color-disabled - Background color of the icon in disabled state
|
31
|
+
*/
|
32
|
+
const reactWrapper = createComponent({
|
33
|
+
tagName: TAG_NAME,
|
34
|
+
elementClass: Component,
|
35
|
+
react: React,
|
36
|
+
events: {},
|
37
|
+
displayName: 'StaticToggle',
|
38
|
+
});
|
39
|
+
export default reactWrapper;
|
@@ -11,30 +11,26 @@ import Component from '../../components/toggle';
|
|
11
11
|
* Note: It internally renders a checkbox styled as a toggle switch.
|
12
12
|
*
|
13
13
|
* @dependency mdc-icon
|
14
|
+
* @dependency mdc-statictoggle
|
14
15
|
*
|
15
16
|
* @tagname mdc-toggle
|
16
17
|
*
|
17
18
|
* @event change - (React: onChange) Event that gets dispatched when the toggle state changes.
|
18
19
|
* @event focus - (React: onFocus) Event that gets dispatched when the toggle receives focus.
|
19
20
|
*
|
20
|
-
* @cssproperty --mdc-toggle-width -
|
21
|
-
* @cssproperty --mdc-toggle-height -
|
22
|
-
* @cssproperty --mdc-toggle-width-compact -
|
23
|
-
* @cssproperty --mdc-toggle-height-compact -
|
24
|
-
* @cssproperty --mdc-toggle-
|
25
|
-
* @cssproperty --mdc-toggle-
|
26
|
-
* @cssproperty --mdc-toggle-
|
27
|
-
* @cssproperty --mdc-toggle-
|
28
|
-
* @cssproperty --mdc-toggle-
|
29
|
-
* @cssproperty --mdc-toggle-
|
30
|
-
* @cssproperty --mdc-toggle-
|
31
|
-
* @cssproperty --mdc-toggle-
|
32
|
-
* @cssproperty --mdc-toggle-
|
33
|
-
* @cssproperty --mdc-toggle-active-pressed-color - background color of the active toggle in pressed state
|
34
|
-
* @cssproperty --mdc-toggle-active-disabled-color - background color of the active toggle in disabled state
|
35
|
-
* @cssproperty --mdc-toggle-help-text-color - color of the help text label
|
36
|
-
* @cssproperty --mdc-toggle-label-color-disabled - color of the toggle label and help text in disabled state
|
37
|
-
*
|
21
|
+
* @cssproperty --mdc-toggle-width - Width of the toggle
|
22
|
+
* @cssproperty --mdc-toggle-height - Height of the toggle
|
23
|
+
* @cssproperty --mdc-toggle-width-compact - Width of the toggle when it's size is compact
|
24
|
+
* @cssproperty --mdc-toggle-height-compact - Height of the toggle when it's size is compact
|
25
|
+
* @cssproperty --mdc-toggle-label-lineheight - Line height of the toggle label
|
26
|
+
* @cssproperty --mdc-toggle-label-fontsize - Font size of the toggle label
|
27
|
+
* @cssproperty --mdc-toggle-label-fontweight - Font weight of the toggle label
|
28
|
+
* @cssproperty --mdc-toggle-label-color-disabled - Color of the toggle label and help text in disabled state
|
29
|
+
* @cssproperty --mdc-toggle-help-text-color - Color of the help text label
|
30
|
+
* @cssproperty --mdc-toggle-active-hover-color - Background color of the active toggle in hover state
|
31
|
+
* @cssproperty --mdc-toggle-active-pressed-color - Background color of the active toggle in pressed state
|
32
|
+
* @cssproperty --mdc-toggle-inactive-hover-color - Background color of the inactive toggle in hover state
|
33
|
+
* @cssproperty --mdc-toggle-inactive-pressed-color - Background color of the inactive toggle in pressed state
|
38
34
|
*/
|
39
35
|
declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {
|
40
36
|
onChange: EventName<Event>;
|
@@ -13,30 +13,26 @@ import { TAG_NAME } from '../../components/toggle/toggle.constants';
|
|
13
13
|
* Note: It internally renders a checkbox styled as a toggle switch.
|
14
14
|
*
|
15
15
|
* @dependency mdc-icon
|
16
|
+
* @dependency mdc-statictoggle
|
16
17
|
*
|
17
18
|
* @tagname mdc-toggle
|
18
19
|
*
|
19
20
|
* @event change - (React: onChange) Event that gets dispatched when the toggle state changes.
|
20
21
|
* @event focus - (React: onFocus) Event that gets dispatched when the toggle receives focus.
|
21
22
|
*
|
22
|
-
* @cssproperty --mdc-toggle-width -
|
23
|
-
* @cssproperty --mdc-toggle-height -
|
24
|
-
* @cssproperty --mdc-toggle-width-compact -
|
25
|
-
* @cssproperty --mdc-toggle-height-compact -
|
26
|
-
* @cssproperty --mdc-toggle-
|
27
|
-
* @cssproperty --mdc-toggle-
|
28
|
-
* @cssproperty --mdc-toggle-
|
29
|
-
* @cssproperty --mdc-toggle-
|
30
|
-
* @cssproperty --mdc-toggle-
|
31
|
-
* @cssproperty --mdc-toggle-
|
32
|
-
* @cssproperty --mdc-toggle-
|
33
|
-
* @cssproperty --mdc-toggle-
|
34
|
-
* @cssproperty --mdc-toggle-
|
35
|
-
* @cssproperty --mdc-toggle-active-pressed-color - background color of the active toggle in pressed state
|
36
|
-
* @cssproperty --mdc-toggle-active-disabled-color - background color of the active toggle in disabled state
|
37
|
-
* @cssproperty --mdc-toggle-help-text-color - color of the help text label
|
38
|
-
* @cssproperty --mdc-toggle-label-color-disabled - color of the toggle label and help text in disabled state
|
39
|
-
*
|
23
|
+
* @cssproperty --mdc-toggle-width - Width of the toggle
|
24
|
+
* @cssproperty --mdc-toggle-height - Height of the toggle
|
25
|
+
* @cssproperty --mdc-toggle-width-compact - Width of the toggle when it's size is compact
|
26
|
+
* @cssproperty --mdc-toggle-height-compact - Height of the toggle when it's size is compact
|
27
|
+
* @cssproperty --mdc-toggle-label-lineheight - Line height of the toggle label
|
28
|
+
* @cssproperty --mdc-toggle-label-fontsize - Font size of the toggle label
|
29
|
+
* @cssproperty --mdc-toggle-label-fontweight - Font weight of the toggle label
|
30
|
+
* @cssproperty --mdc-toggle-label-color-disabled - Color of the toggle label and help text in disabled state
|
31
|
+
* @cssproperty --mdc-toggle-help-text-color - Color of the help text label
|
32
|
+
* @cssproperty --mdc-toggle-active-hover-color - Background color of the active toggle in hover state
|
33
|
+
* @cssproperty --mdc-toggle-active-pressed-color - Background color of the active toggle in pressed state
|
34
|
+
* @cssproperty --mdc-toggle-inactive-hover-color - Background color of the inactive toggle in hover state
|
35
|
+
* @cssproperty --mdc-toggle-inactive-pressed-color - Background color of the inactive toggle in pressed state
|
40
36
|
*/
|
41
37
|
const reactWrapper = createComponent({
|
42
38
|
tagName: TAG_NAME,
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { ButtonColor, ButtonTypeInternal, ButtonVariant, IconButtonSize, PillButtonSize } from '../../components/button/button.types';
|
2
|
+
import type { IconNames } from '../../components/icon/icon.types';
|
3
|
+
import type { Component } from '../../models';
|
4
|
+
import type { Constructor } from './index.types';
|
5
|
+
export interface ButtonComponentMixinInterface {
|
6
|
+
prefixIcon?: IconNames;
|
7
|
+
postfixIcon?: IconNames;
|
8
|
+
variant: ButtonVariant;
|
9
|
+
color: ButtonColor;
|
10
|
+
typeInternal: ButtonTypeInternal;
|
11
|
+
setSize(size: PillButtonSize | IconButtonSize): void;
|
12
|
+
setVariant(variant: ButtonVariant): void;
|
13
|
+
setColor(color: ButtonColor): void;
|
14
|
+
inferButtonType(): void;
|
15
|
+
}
|
16
|
+
export declare const ButtonComponentMixin: <T extends Constructor<Component>>(superClass: T) => Constructor<ButtonComponentMixinInterface> & T;
|
@@ -0,0 +1,114 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { property, state } from 'lit/decorators.js';
|
11
|
+
import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, DEFAULTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from '../../components/button/button.constants';
|
12
|
+
export const ButtonComponentMixin = (superClass) => {
|
13
|
+
class InnerMixinClass extends superClass {
|
14
|
+
constructor() {
|
15
|
+
super(...arguments);
|
16
|
+
/**
|
17
|
+
* There are 3 variants of button: primary, secondary, tertiary. They are styled differently.
|
18
|
+
* - **Primary**: Solid background color.
|
19
|
+
* - **Secondary**: Transparent background with a solid border.
|
20
|
+
* - **Tertiary**: No background or border, appears as plain text but retains all button functionalities.
|
21
|
+
* @default primary
|
22
|
+
*/
|
23
|
+
this.variant = DEFAULTS.VARIANT;
|
24
|
+
/**
|
25
|
+
* There are 5 colors for button: positive, negative, accent, promotional, default.
|
26
|
+
* @default default
|
27
|
+
*/
|
28
|
+
this.color = DEFAULTS.COLOR;
|
29
|
+
/** @internal */
|
30
|
+
this.typeInternal = DEFAULTS.TYPE_INTERNAL;
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Sets the variant attribute for the button component.
|
34
|
+
* If the provided variant is not included in the BUTTON_VARIANTS,
|
35
|
+
* it defaults to the value specified in DEFAULTS.VARIANT.
|
36
|
+
*
|
37
|
+
* @param variant - The variant to set.
|
38
|
+
*/
|
39
|
+
setVariant(variant) {
|
40
|
+
this.setAttribute('variant', Object.values(BUTTON_VARIANTS).includes(variant) ? variant : DEFAULTS.VARIANT);
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Sets the color attribute for the button.
|
44
|
+
* Defaults to DEFAULTS.COLOR if invalid or for tertiary button.
|
45
|
+
*
|
46
|
+
* @param color - The color to set.
|
47
|
+
*/
|
48
|
+
setColor(color) {
|
49
|
+
if (!Object.values(BUTTON_COLORS).includes(color) || this.variant === BUTTON_VARIANTS.TERTIARY) {
|
50
|
+
this.setAttribute('color', `${DEFAULTS.COLOR}`);
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
this.setAttribute('color', color);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Sets the size attribute for the button component.
|
58
|
+
* Validates the size based on the button type (icon, pill, or tertiary).
|
59
|
+
* Defaults to DEFAULTS.SIZE if invalid.
|
60
|
+
*
|
61
|
+
* @param size - The size to set.
|
62
|
+
*/
|
63
|
+
setSize(size) {
|
64
|
+
const isIconType = this.typeInternal === BUTTON_TYPE_INTERNAL.ICON;
|
65
|
+
const isValidSize = isIconType
|
66
|
+
? Object.values(ICON_BUTTON_SIZES).includes(size)
|
67
|
+
&& !(size === ICON_BUTTON_SIZES[20] && this.variant !== BUTTON_VARIANTS.TERTIARY)
|
68
|
+
: Object.values(PILL_BUTTON_SIZES).includes(size);
|
69
|
+
this.setAttribute('size', isValidSize ? `${size}` : `${DEFAULTS.SIZE}`);
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Infers the type of button based on the presence of slot and/or prefix and postfix icons.
|
73
|
+
* @param slot - default slot of button
|
74
|
+
*/
|
75
|
+
inferButtonType() {
|
76
|
+
var _a, _b;
|
77
|
+
const slot = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot')) === null || _b === void 0 ? void 0 : _b.assignedNodes().filter((node) => { var _a; return node.nodeType !== Node.TEXT_NODE || ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()); }).length;
|
78
|
+
if (slot && (this.prefixIcon || this.postfixIcon)) {
|
79
|
+
this.typeInternal = BUTTON_TYPE_INTERNAL.PILL_WITH_ICON;
|
80
|
+
this.setAttribute('data-btn-type', 'pill-with-icon');
|
81
|
+
}
|
82
|
+
else if (!slot && (this.prefixIcon || this.postfixIcon)) {
|
83
|
+
this.typeInternal = BUTTON_TYPE_INTERNAL.ICON;
|
84
|
+
this.setAttribute('data-btn-type', 'icon');
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
this.typeInternal = BUTTON_TYPE_INTERNAL.PILL;
|
88
|
+
this.setAttribute('data-btn-type', 'pill');
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
__decorate([
|
93
|
+
property({ type: String, attribute: 'prefix-icon', reflect: true }),
|
94
|
+
__metadata("design:type", String)
|
95
|
+
], InnerMixinClass.prototype, "prefixIcon", void 0);
|
96
|
+
__decorate([
|
97
|
+
property({ type: String, attribute: 'postfix-icon', reflect: true }),
|
98
|
+
__metadata("design:type", String)
|
99
|
+
], InnerMixinClass.prototype, "postfixIcon", void 0);
|
100
|
+
__decorate([
|
101
|
+
property({ type: String }),
|
102
|
+
__metadata("design:type", String)
|
103
|
+
], InnerMixinClass.prototype, "variant", void 0);
|
104
|
+
__decorate([
|
105
|
+
property({ type: String }),
|
106
|
+
__metadata("design:type", String)
|
107
|
+
], InnerMixinClass.prototype, "color", void 0);
|
108
|
+
__decorate([
|
109
|
+
state(),
|
110
|
+
__metadata("design:type", String)
|
111
|
+
], InnerMixinClass.prototype, "typeInternal", void 0);
|
112
|
+
// Cast return type to your mixin's interface intersected with the superClass type
|
113
|
+
return InnerMixinClass;
|
114
|
+
};
|
package/package.json
CHANGED