glints-aries 4.0.170 → 4.0.172

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 (65) hide show
  1. package/es/@next/Avatar/Avatar.d.ts +12 -0
  2. package/es/@next/Avatar/Avatar.js +25 -0
  3. package/es/@next/Avatar/Avatar.stories.d.ts +4 -0
  4. package/es/@next/Avatar/Avatar.stories.js +18 -0
  5. package/es/@next/Avatar/AvatarStyle.d.ts +2 -0
  6. package/es/@next/Avatar/AvatarStyle.js +34 -0
  7. package/es/@next/Avatar/index.d.ts +1 -0
  8. package/es/@next/Avatar/index.js +1 -0
  9. package/es/@next/ButtonGroup/ButtonGroup.d.ts +8 -0
  10. package/es/@next/ButtonGroup/ButtonGroup.js +16 -0
  11. package/es/@next/ButtonGroup/ButtonGroup.stories.js +1 -1
  12. package/es/@next/ButtonGroup/ButtonGroupStyle.d.ts +1 -6
  13. package/es/@next/ButtonGroup/ButtonGroupStyle.js +3 -9
  14. package/es/@next/ButtonGroup/index.d.ts +1 -2
  15. package/es/@next/ButtonGroup/index.js +1 -2
  16. package/es/@next/Popover/Popover.d.ts +10 -0
  17. package/es/@next/Popover/Popover.js +14 -0
  18. package/es/@next/Popover/Popover.stories.d.ts +4 -0
  19. package/es/@next/Popover/Popover.stories.js +132 -0
  20. package/es/@next/Popover/PopoverFilter.stories.d.ts +4 -0
  21. package/es/@next/Popover/PopoverFilter.stories.js +145 -0
  22. package/es/@next/Popover/PopoverStyle.d.ts +1 -0
  23. package/es/@next/Popover/PopoverStyle.js +7 -0
  24. package/es/@next/Popover/index.d.ts +1 -0
  25. package/es/@next/Popover/index.js +1 -0
  26. package/es/@next/Popover/popoverStoryHelper/CheckboxGroup.d.ts +8 -0
  27. package/es/@next/Popover/popoverStoryHelper/CheckboxGroup.js +60 -0
  28. package/es/@next/Popover/popoverStoryHelper/SalarySelector.d.ts +7 -0
  29. package/es/@next/Popover/popoverStoryHelper/SalarySelector.js +22 -0
  30. package/es/@next/Tabs/Tabs.stories.js +1 -1
  31. package/es/@next/index.d.ts +2 -0
  32. package/es/@next/index.js +2 -0
  33. package/lib/@next/Avatar/Avatar.d.ts +12 -0
  34. package/lib/@next/Avatar/Avatar.js +31 -0
  35. package/lib/@next/Avatar/Avatar.stories.d.ts +4 -0
  36. package/lib/@next/Avatar/Avatar.stories.js +25 -0
  37. package/lib/@next/Avatar/AvatarStyle.d.ts +2 -0
  38. package/lib/@next/Avatar/AvatarStyle.js +42 -0
  39. package/lib/@next/Avatar/index.d.ts +1 -0
  40. package/lib/@next/Avatar/index.js +9 -0
  41. package/lib/@next/ButtonGroup/ButtonGroup.d.ts +8 -0
  42. package/lib/@next/ButtonGroup/ButtonGroup.js +22 -0
  43. package/lib/@next/ButtonGroup/ButtonGroup.stories.js +4 -4
  44. package/lib/@next/ButtonGroup/ButtonGroupStyle.d.ts +1 -6
  45. package/lib/@next/ButtonGroup/ButtonGroupStyle.js +5 -11
  46. package/lib/@next/ButtonGroup/index.d.ts +1 -2
  47. package/lib/@next/ButtonGroup/index.js +3 -2
  48. package/lib/@next/Popover/Popover.d.ts +10 -0
  49. package/lib/@next/Popover/Popover.js +20 -0
  50. package/lib/@next/Popover/Popover.stories.d.ts +4 -0
  51. package/lib/@next/Popover/Popover.stories.js +141 -0
  52. package/lib/@next/Popover/PopoverFilter.stories.d.ts +4 -0
  53. package/lib/@next/Popover/PopoverFilter.stories.js +154 -0
  54. package/lib/@next/Popover/PopoverStyle.d.ts +1 -0
  55. package/lib/@next/Popover/PopoverStyle.js +11 -0
  56. package/lib/@next/Popover/index.d.ts +1 -0
  57. package/lib/@next/Popover/index.js +7 -0
  58. package/lib/@next/Popover/popoverStoryHelper/CheckboxGroup.d.ts +8 -0
  59. package/lib/@next/Popover/popoverStoryHelper/CheckboxGroup.js +67 -0
  60. package/lib/@next/Popover/popoverStoryHelper/SalarySelector.d.ts +7 -0
  61. package/lib/@next/Popover/popoverStoryHelper/SalarySelector.js +28 -0
  62. package/lib/@next/Tabs/Tabs.stories.js +1 -1
  63. package/lib/@next/index.d.ts +2 -0
  64. package/lib/@next/index.js +5 -1
  65. package/package.json +9 -4
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ declare const avatarBackgroundColorVariant: readonly ["supplementary", "warning", "danger", "success", "outstanding"];
3
+ declare const avatarSizeVariant: readonly ["large", "medium"];
4
+ export declare type AvatarBackgroundColorVariant = typeof avatarBackgroundColorVariant[number];
5
+ export declare type AvatarSizeVariant = typeof avatarSizeVariant[number];
6
+ export interface AvatarProps extends React.HTMLAttributes<HTMLDivElement> {
7
+ variant?: AvatarBackgroundColorVariant;
8
+ size?: AvatarSizeVariant;
9
+ initials?: string;
10
+ }
11
+ export declare const Avatar: ({ variant, size, initials, ...props }: AvatarProps) => JSX.Element;
12
+ export {};
@@ -0,0 +1,25 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["variant", "size", "initials"];
4
+ import React from 'react';
5
+ import { Typography } from '../Typography';
6
+ import { Neutral } from '../utilities/colors';
7
+ import { AvatarStyle } from './AvatarStyle';
8
+ var avatarBackgroundColorVariant = ['supplementary', 'warning', 'danger', 'success', 'outstanding'];
9
+ var avatarSizeVariant = ['large', 'medium'];
10
+ export var Avatar = function Avatar(_ref) {
11
+ var _ref$variant = _ref.variant,
12
+ variant = _ref$variant === void 0 ? 'supplementary' : _ref$variant,
13
+ _ref$size = _ref.size,
14
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
15
+ initials = _ref.initials,
16
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
17
+ return /*#__PURE__*/React.createElement(AvatarStyle, _extends({
18
+ variant: variant,
19
+ size: size
20
+ }, props), /*#__PURE__*/React.createElement(Typography, {
21
+ variant: size === 'medium' ? 'body1' : 'headline6',
22
+ color: Neutral.B18,
23
+ as: 'span'
24
+ }, initials.slice(0, 2)));
25
+ };
@@ -0,0 +1,4 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const Interactive: any;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
3
+ import { Avatar } from './Avatar';
4
+ export default {
5
+ title: '@next/Avatar',
6
+ component: Avatar,
7
+ decorators: [function (Story) {
8
+ return /*#__PURE__*/React.createElement(BaseContainer, null, Story());
9
+ }],
10
+ argTypes: {}
11
+ };
12
+ var Template = function Template(args) {
13
+ return /*#__PURE__*/React.createElement(Avatar, args);
14
+ };
15
+ export var Interactive = Template.bind({});
16
+ Interactive.args = {
17
+ initials: 'HE'
18
+ };
@@ -0,0 +1,2 @@
1
+ import { AvatarProps } from './Avatar';
2
+ export declare const AvatarStyle: import("styled-components").StyledComponent<"div", any, AvatarProps, never>;
@@ -0,0 +1,34 @@
1
+ var _avatarBackgroundColo, _avatarSizeVariant;
2
+ import styled from 'styled-components';
3
+ import * as Breakpoints from '../utilities/breakpoints';
4
+ import { Blue, Green, Neutral, Orange, Red } from '../utilities/colors';
5
+ var mediumAvatarSizeStyle = "\n width: 40px;\n height: 40px;\n \n @media (max-width: " + Breakpoints.large + ") {\n width: 32px;\n height: 32px;\n }\n";
6
+ var largeAvatarSizeStyle = "\n width: 60px;\n height: 60px;\n\n @media (max-width: " + Breakpoints.large + ") {\n width: 40px;\n height: 40px;\n }\n";
7
+ var avatarBackgroundColor = (_avatarBackgroundColo = {}, _avatarBackgroundColo['supplementary'] = Neutral.B99, _avatarBackgroundColo['warning'] = Orange.S42, _avatarBackgroundColo['danger'] = Red.B100, _avatarBackgroundColo['success'] = Green.B89, _avatarBackgroundColo['outstanding'] = Blue.S08, _avatarBackgroundColo);
8
+ var avatarSizeVariant = (_avatarSizeVariant = {}, _avatarSizeVariant['large'] = largeAvatarSizeStyle, _avatarSizeVariant['medium'] = mediumAvatarSizeStyle, _avatarSizeVariant);
9
+ var getAvatarBackgroundColor = function getAvatarBackgroundColor(variant) {
10
+ if (!(variant in avatarBackgroundColor)) {
11
+ console.warn(variant + " is not a valid variant for the background color, default will be used");
12
+ return avatarBackgroundColor['supplementary'];
13
+ }
14
+ return avatarBackgroundColor[variant];
15
+ };
16
+ var getAvatarSizeStyle = function getAvatarSizeStyle(sizeVariant) {
17
+ if (!(sizeVariant in avatarSizeVariant)) {
18
+ console.warn(sizeVariant + " is not a valid variant for the size, default will be used");
19
+ return avatarSizeVariant['medium'];
20
+ }
21
+ return avatarSizeVariant[sizeVariant];
22
+ };
23
+ export var AvatarStyle = styled.div.withConfig({
24
+ displayName: "AvatarStyle",
25
+ componentId: "sc-1ys0vpf-0"
26
+ })(["", "}", "}display:flex;align-items:center;justify-content:center;border-radius:50%;"], function (_ref) {
27
+ var size = _ref.size;
28
+ return getAvatarSizeStyle(size);
29
+ }, function (_ref2) {
30
+ var variant = _ref2.variant;
31
+ return {
32
+ 'background-color': getAvatarBackgroundColor(variant)
33
+ };
34
+ });
@@ -0,0 +1 @@
1
+ export * from './Avatar';
@@ -0,0 +1 @@
1
+ export * from './Avatar';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface ButtonGroupProps extends React.HtmlHTMLAttributes<HTMLDivElement> {
3
+ segmented?: boolean;
4
+ fullWidth?: boolean;
5
+ /** Set this true when buttons are wrapped by another element (e.g as an activator for Popover) */
6
+ isButtonWrapped?: boolean;
7
+ }
8
+ export declare const ButtonGroup: ({ segmented, fullWidth, isButtonWrapped, ...props }: ButtonGroupProps) => JSX.Element;
@@ -0,0 +1,16 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["segmented", "fullWidth", "isButtonWrapped"];
4
+ import React from 'react';
5
+ import { StyledButtonGroup } from './ButtonGroupStyle';
6
+ export var ButtonGroup = function ButtonGroup(_ref) {
7
+ var segmented = _ref.segmented,
8
+ fullWidth = _ref.fullWidth,
9
+ isButtonWrapped = _ref.isButtonWrapped,
10
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
11
+ return /*#__PURE__*/React.createElement(StyledButtonGroup, _extends({
12
+ "data-segmented": segmented,
13
+ "data-full-width": fullWidth,
14
+ "data-button-wrapped": isButtonWrapped
15
+ }, props));
16
+ };
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import { ButtonGroup } from './ButtonGroupStyle';
3
2
  import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
4
3
  import { PrimaryButton } from '../Button/PrimaryButtonStyle';
5
4
  import { Button } from '../Button/Button';
6
5
  import { OutlineButton } from '../Button/OutlineButtonStyle';
6
+ import { ButtonGroup } from './ButtonGroup';
7
7
  ButtonGroup.displayName = 'ButtonGroup';
8
8
  export default {
9
9
  title: '@next/ButtonGroup',
@@ -1,6 +1 @@
1
- import React from 'react';
2
- export interface ButtonGroupProps extends React.HtmlHTMLAttributes<HTMLDivElement> {
3
- segmented?: boolean;
4
- fullWidth?: boolean;
5
- }
6
- export declare const ButtonGroup: import("styled-components").StyledComponent<"div", any, ButtonGroupProps, never>;
1
+ export declare const StyledButtonGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -2,13 +2,7 @@ import styled from 'styled-components';
2
2
  import { borderRadius4 } from '../utilities/borderRadius';
3
3
  import { Neutral } from '../utilities/colors';
4
4
  import { space8 } from '../utilities/spacing';
5
- export var ButtonGroup = styled.div.withConfig({
6
- displayName: "ButtonGroupStyle__ButtonGroup",
5
+ export var StyledButtonGroup = styled.div.withConfig({
6
+ displayName: "ButtonGroupStyle__StyledButtonGroup",
7
7
  componentId: "sc-7vhxrt-0"
8
- })(["display:flex;flex-direction:row;align-items:center;padding:0px;", " ", ""], function (_ref) {
9
- var segmented = _ref.segmented;
10
- return segmented ? "> button {\n border-radius: 0;\n border-right: 0;\n \n :nth-child(1) {\n border-radius: " + borderRadius4 + " 0px 0px " + borderRadius4 + "; \n }\n\n :nth-last-child(1) {\n border-radius: 0px " + borderRadius4 + " " + borderRadius4 + " 0px;\n border-right: 1px solid " + Neutral.B68 + "\n }\n }\n > button:focus {\n z-index: 1;\n border: 1px solid " + Neutral.B68 + "\n }\n\n button[data-active='true'] {\n border: 1px solid " + Neutral.B40 + "\n }\n " : "gap: " + space8 + ";";
11
- }, function (_ref2) {
12
- var fullWidth = _ref2.fullWidth;
13
- return fullWidth ? "> button {\n flex: 1;\n }" : "";
14
- });
8
+ })(["display:flex;flex-direction:row;align-items:center;padding:0px;gap:", ";&[data-segmented='true']{gap:0;}&[data-segmented='true'] button[data-active='true']{border:1px solid ", ";}&[data-segmented='true'] button{border-radius:0;border-right:0;:nth-child(1){border-radius:", " 0px 0px ", ";}:nth-last-child(1){border-radius:0px ", " ", " 0px;border-right:1px solid ", ";}}&[data-segmented='true'] button:focus{z-index:1;border:1px solid ", ";}&[data-full-width='true'] button{flex:1;}&[data-segmented='true']&[data-button-wrapped='true'] > *{button{border-radius:0;border-right:0;}:nth-child(1) button{border-radius:", " 0px 0px ", ";}:nth-last-child(1) button{border-radius:0px ", " ", " 0px;border-right:1px solid ", ";}}"], space8, Neutral.B40, borderRadius4, borderRadius4, borderRadius4, borderRadius4, Neutral.B68, Neutral.B68, borderRadius4, borderRadius4, borderRadius4, borderRadius4, Neutral.B68);
@@ -1,2 +1 @@
1
- import { ButtonGroup } from './ButtonGroupStyle';
2
- export { ButtonGroup };
1
+ export { ButtonGroup } from './ButtonGroup';
@@ -1,2 +1 @@
1
- import { ButtonGroup } from './ButtonGroupStyle';
2
- export { ButtonGroup };
1
+ export { ButtonGroup } from './ButtonGroup';
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { PopoverProps as PolarisPopoverProps } from 'polaris-glints';
3
+ export declare type PopoverProps = PolarisPopoverProps;
4
+ /** Using Popover from polaris-glints repository internally
5
+ * Please add `<div id="glints-portal-container"></div>` as a sibling element of where your React app is rendered.
6
+ * This is a temporary workaround, as React Portal need this as the anchor */
7
+ export declare const Popover: ((props: PopoverProps) => JSX.Element) & {
8
+ Pane: typeof import("polaris-glints/build/ts/latest/src/components/Popover/components").Pane;
9
+ Section: typeof import("polaris-glints/build/ts/latest/src/components/Popover/components").Section;
10
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { Popover as PolarisPopover } from 'polaris-glints';
3
+ import { StyledPopover } from './PopoverStyle';
4
+ var PopoverComponent = function PopoverComponent(props) {
5
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledPopover, null), /*#__PURE__*/React.createElement(PolarisPopover, props));
6
+ };
7
+
8
+ /** Using Popover from polaris-glints repository internally
9
+ * Please add `<div id="glints-portal-container"></div>` as a sibling element of where your React app is rendered.
10
+ * This is a temporary workaround, as React Portal need this as the anchor */
11
+ export var Popover = Object.assign(PopoverComponent, {
12
+ Pane: PolarisPopover.Pane,
13
+ Section: PolarisPopover.Section
14
+ });
@@ -0,0 +1,4 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const Interactive: any;
@@ -0,0 +1,132 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { useCallback, useState } from 'react';
3
+ import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
4
+ import { Button, PrimaryButton } from '../Button';
5
+ import { ButtonGroup } from '../ButtonGroup';
6
+ import { Icon } from '../Icon';
7
+ import { Typography } from '../Typography';
8
+ import { Popover } from './Popover';
9
+ Popover.displayName = 'Popover';
10
+ export default {
11
+ title: '@next/Popover',
12
+ component: Popover,
13
+ decorators: [function (Story) {
14
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BaseContainer, null, Story()), /*#__PURE__*/React.createElement("div", {
15
+ id: "glints-portal-container"
16
+ }));
17
+ }],
18
+ argTypes: {
19
+ preferredPosition: {
20
+ control: 'select',
21
+ options: ['above', 'below', 'mostSpace']
22
+ },
23
+ preferredAlignment: {
24
+ control: 'select',
25
+ options: ['left', 'center', 'right']
26
+ }
27
+ }
28
+ };
29
+ var PopoverExample = function PopoverExample(props) {
30
+ var _useState = useState(false),
31
+ popoverActive = _useState[0],
32
+ setPopoverActive = _useState[1];
33
+ var _useState2 = useState(false),
34
+ popoverActive2 = _useState2[0],
35
+ setPopoverActive2 = _useState2[1];
36
+ var _useState3 = useState(false),
37
+ popoverActive3 = _useState3[0],
38
+ setPopoverActive3 = _useState3[1];
39
+ var Suffix = /*#__PURE__*/React.createElement(Icon, {
40
+ name: "ri-arrow-m-up-fill"
41
+ });
42
+ var togglePopoverActive = useCallback(function () {
43
+ return setPopoverActive(function (popoverActive) {
44
+ return !popoverActive;
45
+ });
46
+ }, []);
47
+ var togglePopoverActive2 = useCallback(function () {
48
+ return setPopoverActive2(function (popoverActive) {
49
+ return !popoverActive;
50
+ });
51
+ }, []);
52
+ var togglePopoverActive3 = useCallback(function () {
53
+ return setPopoverActive3(function (popoverActive) {
54
+ return !popoverActive;
55
+ });
56
+ }, []);
57
+ var example1Activator = /*#__PURE__*/React.createElement(Button, {
58
+ onClick: togglePopoverActive
59
+ }, "Show");
60
+ var example2Activator = /*#__PURE__*/React.createElement(Button, {
61
+ onClick: togglePopoverActive2
62
+ }, "Show");
63
+ var example3Activator = /*#__PURE__*/React.createElement(Button, {
64
+ onClick: togglePopoverActive3
65
+ }, "Show");
66
+ return /*#__PURE__*/React.createElement("div", {
67
+ style: {
68
+ marginLeft: '100px',
69
+ paddingTop: '150px',
70
+ display: 'flex',
71
+ gap: '50px'
72
+ }
73
+ }, /*#__PURE__*/React.createElement(Popover, _extends({}, props, {
74
+ active: popoverActive,
75
+ activator: example1Activator,
76
+ onClose: togglePopoverActive
77
+ }), /*#__PURE__*/React.createElement(Popover.Pane, null, /*#__PURE__*/React.createElement("div", {
78
+ style: {
79
+ padding: '10px'
80
+ }
81
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Typography, {
82
+ as: "span",
83
+ variant: "subtitle1"
84
+ }, "Title")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Typography, {
85
+ variant: "body1"
86
+ }, "Description")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, null, "Label"), " ", /*#__PURE__*/React.createElement(PrimaryButton, null, "Label")))))), /*#__PURE__*/React.createElement(Popover, _extends({}, props, {
87
+ active: popoverActive2,
88
+ activator: example2Activator,
89
+ onClose: togglePopoverActive2
90
+ }), /*#__PURE__*/React.createElement(Popover.Pane, null, /*#__PURE__*/React.createElement(Popover.Section, null, /*#__PURE__*/React.createElement(Typography, {
91
+ as: "span",
92
+ variant: "subtitle2"
93
+ }, "AVAILABLE SALES CHANNEL"))), /*#__PURE__*/React.createElement(Popover.Pane, null, /*#__PURE__*/React.createElement("div", {
94
+ style: {
95
+ padding: '0px 16px'
96
+ }
97
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Typography, {
98
+ variant: "body1"
99
+ }, "Online")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Typography, {
100
+ variant: "body1"
101
+ }, "Facebook")), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Typography, {
102
+ variant: "body1"
103
+ }, "Shopify POS"))))), /*#__PURE__*/React.createElement(Popover, _extends({}, props, {
104
+ active: popoverActive3,
105
+ activator: example3Activator,
106
+ onClose: togglePopoverActive3
107
+ }), /*#__PURE__*/React.createElement(Popover.Pane, null, /*#__PURE__*/React.createElement("div", {
108
+ style: {
109
+ padding: '10px'
110
+ }
111
+ }, /*#__PURE__*/React.createElement(ButtonGroup, null, /*#__PURE__*/React.createElement(Button, null, "Action"), /*#__PURE__*/React.createElement(Button, null, "Action"), /*#__PURE__*/React.createElement(Button, {
112
+ icon: Suffix,
113
+ iconPosition: "right"
114
+ }, "Move to"))))));
115
+ };
116
+ var Template = function Template(args) {
117
+ return /*#__PURE__*/React.createElement(PopoverExample, args);
118
+ };
119
+ export var Interactive = Template.bind({});
120
+ Interactive.args = {
121
+ preferredPosition: 'mostSpace',
122
+ preferredAlignment: 'center'
123
+ };
124
+ Interactive.parameters = {
125
+ docs: {
126
+ source: {
127
+ code: "const [popoverActive, setPopoverActive] = useState(false);\n const [popoverActive2, setPopoverActive2] = useState(false);\n const [popoverActive3, setPopoverActive3] = useState(false);\n const Suffix = <Icon name=\"ri-arrow-m-up-fill\" />;\n \n const togglePopoverActive = useCallback(\n () => setPopoverActive(popoverActive => !popoverActive),\n []\n );\n \n const togglePopoverActive2 = useCallback(\n () => setPopoverActive2(popoverActive => !popoverActive),\n []\n );\n \n const togglePopoverActive3 = useCallback(\n () => setPopoverActive3(popoverActive => !popoverActive),\n []\n );\n \n const example1Activator = <Button onClick={togglePopoverActive}>Show</Button>;\n const example2Activator = (\n <Button onClick={togglePopoverActive2}>Show</Button>\n );\n const example3Activator = (\n <Button onClick={togglePopoverActive3}>Show</Button>\n );\n return (\n <div\n style={{\n marginLeft: '100px',\n paddingTop: '200px',\n display: 'flex',\n gap: '50px',\n }}\n >\n <Popover\n {...props}\n active={popoverActive}\n activator={example1Activator}\n onClose={togglePopoverActive}\n >\n <Popover.Pane>\n <div style={{ padding: '10px' }}>\n <div>\n <Typography as=\"span\" variant=\"subtitle1\">\n Title\n </Typography>\n </div>\n <div>\n <Typography variant=\"body1\">Description</Typography>\n </div>\n <div>\n <ButtonGroup>\n <Button>Label</Button> <PrimaryButton>Label</PrimaryButton>\n </ButtonGroup>\n </div>\n </div>\n </Popover.Pane>\n </Popover>\n <Popover\n {...props}\n active={popoverActive2}\n activator={example2Activator}\n onClose={togglePopoverActive2}\n >\n <Popover.Pane>\n <Popover.Section>\n <Typography variant=\"subtitle2\">AVAILABLE SALES CHANNEL</Typography>\n </Popover.Section>\n </Popover.Pane>\n <Popover.Pane>\n <div>\n <Typography variant=\"body1\">Online</Typography>\n </div>\n <div>\n <Typography variant=\"body1\">Facebook</Typography>\n </div>\n <div>\n <Typography variant=\"body1\">Shopify POS</Typography>\n </div>\n </Popover.Pane>\n </Popover>\n <Popover\n {...props}\n active={popoverActive3}\n activator={example3Activator}\n onClose={togglePopoverActive3}\n >\n <Popover.Pane>\n <div style={{ padding: '10px' }}>\n <ButtonGroup>\n <Button>Action</Button>\n <Button>Action</Button>\n <Button icon={Suffix} iconPosition=\"right\">\n Move to\n </Button>\n </ButtonGroup>\n </div>\n </Popover.Pane>\n </Popover>\n </div>\n );"
128
+ },
129
+ language: 'javascript',
130
+ type: 'auto'
131
+ }
132
+ };
@@ -0,0 +1,4 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const Interactive: any;
@@ -0,0 +1,145 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import React, { useCallback, useState } from 'react';
3
+ import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
4
+ import { Popover } from './Popover';
5
+ import { OutlineButton } from '../Button';
6
+ import { ButtonGroup } from '../ButtonGroup';
7
+ import { CheckboxGroup } from './popoverStoryHelper/CheckboxGroup';
8
+ import { Typography } from '../Typography';
9
+ import { SalarySelector } from './popoverStoryHelper/SalarySelector';
10
+ import { Icon } from '../Icon';
11
+ Popover.displayName = 'Popover';
12
+ export default {
13
+ title: '@next/Popover as Filter',
14
+ component: Popover,
15
+ decorators: [function (Story) {
16
+ return /*#__PURE__*/React.createElement(BaseContainer, null, Story(), /*#__PURE__*/React.createElement("div", {
17
+ id: "glints-portal-container"
18
+ }));
19
+ }],
20
+ argTypes: {}
21
+ };
22
+ var cities = {
23
+ Indonesia: ['Jakarta', 'Bandung', 'Bali'],
24
+ Malaysia: ['Kuala Lumpur', 'Ipoh', 'Penang'],
25
+ Singapore: ['Singapore']
26
+ };
27
+ var PopoverAsFilterExample = function PopoverAsFilterExample() {
28
+ var _useState = useState(false),
29
+ popoverCityActive = _useState[0],
30
+ setPopoverCityActive = _useState[1];
31
+ var _useState2 = useState(false),
32
+ popoverSalaryActive = _useState2[0],
33
+ setPopoverSalaryActive = _useState2[1];
34
+ var _useState3 = useState([]),
35
+ selectedCities = _useState3[0],
36
+ setSelectedCities = _useState3[1];
37
+ var _useState4 = useState(0),
38
+ salaryFrom = _useState4[0],
39
+ setSalaryFrom = _useState4[1];
40
+ var _useState5 = useState(0),
41
+ salaryTo = _useState5[0],
42
+ setSalaryTo = _useState5[1];
43
+ var Suffix = /*#__PURE__*/React.createElement(Icon, {
44
+ name: "ri-arrow-m-down-fill"
45
+ });
46
+ var togglePopoverCityActive = useCallback(function () {
47
+ return setPopoverCityActive(function (popoverActive) {
48
+ return !popoverActive;
49
+ });
50
+ }, []);
51
+ var toggleSalaryActive = useCallback(function () {
52
+ return setPopoverSalaryActive(function (popoverActive) {
53
+ return !popoverActive;
54
+ });
55
+ }, []);
56
+ var cityActivator = /*#__PURE__*/React.createElement(OutlineButton, {
57
+ onClick: togglePopoverCityActive,
58
+ icon: Suffix,
59
+ iconPosition: "right"
60
+ }, "City");
61
+ var salaryActivator = /*#__PURE__*/React.createElement(OutlineButton, {
62
+ onClick: toggleSalaryActive,
63
+ icon: Suffix,
64
+ iconPosition: "right"
65
+ }, "Salary");
66
+ var handleCityChanged = function handleCityChanged(action, cities) {
67
+ if (action === 'Add') {
68
+ var selected = new Set([].concat(selectedCities, cities));
69
+ setSelectedCities(Array.from(selected));
70
+ return;
71
+ }
72
+ setSelectedCities(selectedCities.filter(function (sc) {
73
+ return !cities.includes(sc);
74
+ }));
75
+ };
76
+ return /*#__PURE__*/React.createElement("div", {
77
+ style: {
78
+ marginLeft: '10px'
79
+ }
80
+ }, /*#__PURE__*/React.createElement(ButtonGroup, {
81
+ segmented: true,
82
+ isButtonWrapped: true
83
+ }, /*#__PURE__*/React.createElement(Popover, {
84
+ active: popoverCityActive,
85
+ activator: cityActivator,
86
+ autofocusTarget: "first-node",
87
+ onClose: togglePopoverCityActive
88
+ }, /*#__PURE__*/React.createElement(Popover.Pane, {
89
+ fixed: true
90
+ }, /*#__PURE__*/React.createElement(Popover.Section, null, /*#__PURE__*/React.createElement(Typography, {
91
+ as: "span",
92
+ variant: "subtitle2"
93
+ }, "Select Cities"))), /*#__PURE__*/React.createElement(Popover.Pane, null, /*#__PURE__*/React.createElement("div", {
94
+ style: {
95
+ padding: '10px'
96
+ }
97
+ }, Object.keys(cities).map(function (country) {
98
+ return /*#__PURE__*/React.createElement(CheckboxGroup, {
99
+ key: country,
100
+ country: country
101
+ // @ts-ignore
102
+ ,
103
+ cities: cities[country],
104
+ onChanged: handleCityChanged
105
+ });
106
+ })))), /*#__PURE__*/React.createElement(Popover, {
107
+ active: popoverSalaryActive,
108
+ activator: salaryActivator,
109
+ autofocusTarget: "first-node",
110
+ onClose: toggleSalaryActive,
111
+ fullWidth: true
112
+ }, /*#__PURE__*/React.createElement(Popover.Pane, {
113
+ fixed: true
114
+ }, /*#__PURE__*/React.createElement(Popover.Section, null, /*#__PURE__*/React.createElement(Typography, {
115
+ as: "span",
116
+ variant: "caption"
117
+ }, "Salary"))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SalarySelector, {
118
+ onFromChanged: setSalaryFrom,
119
+ onToChanged: setSalaryTo
120
+ })))), /*#__PURE__*/React.createElement("div", {
121
+ style: {
122
+ marginTop: '10px'
123
+ }
124
+ }, /*#__PURE__*/React.createElement(Typography, {
125
+ as: "span",
126
+ variant: "caption"
127
+ }, "Selected cities: ", selectedCities.join(','))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Typography, {
128
+ as: "span",
129
+ variant: "caption"
130
+ }, "Selected salary range: ", new Intl.NumberFormat().format(salaryFrom), " to", ' ', new Intl.NumberFormat().format(salaryTo))));
131
+ };
132
+ var Template = function Template() {
133
+ return /*#__PURE__*/React.createElement(PopoverAsFilterExample, null);
134
+ };
135
+ export var Interactive = Template.bind({});
136
+ Interactive.args = {};
137
+ Interactive.parameters = {
138
+ docs: {
139
+ source: {
140
+ code: "\n import { Popover } from 'Popover';\n import { OutlineButton } from '../Button';\n import { ButtonGroup } from '../ButtonGroup';\n import { CheckboxGroup } from './popoverStoryHelper/CheckboxGroup';\n import { Typography } from '../Typography';\n import { SalarySelector } from './popoverStoryHelper/SalarySelector';\n import { Icon } from '../Icon';\n\n const cities = {\n Indonesia: ['Jakarta', 'Bandung', 'Bali'],\n Malaysia: ['Kuala Lumpur', 'Ipoh', 'Penang'],\n Singapore: ['Singapore'],\n };\n \n const [popoverCityActive, setPopoverCityActive] = useState(false);\n const [popoverSalaryActive, setPopoverSalaryActive] = useState(false);\n const [selectedCities, setSelectedCities] = useState([]);\n const [salaryFrom, setSalaryFrom] = useState(0);\n const [salaryTo, setSalaryTo] = useState(0);\n \n const Suffix = <Icon name=\"ri-arrow-m-down-fill\" />;\n const togglePopoverCityActive = useCallback(\n () => setPopoverCityActive(popoverActive => !popoverActive),\n []\n );\n \n const toggleSalaryActive = useCallback(\n () => setPopoverSalaryActive(popoverActive => !popoverActive),\n []\n );\n \n const cityActivator = (\n <OutlineButton\n onClick={togglePopoverCityActive}\n icon={Suffix}\n iconPosition=\"right\"\n >\n City\n </OutlineButton>\n );\n const salaryActivator = (\n <OutlineButton\n onClick={toggleSalaryActive}\n icon={Suffix}\n iconPosition=\"right\"\n >\n Salary\n </OutlineButton>\n );\n \n const handleCityChanged = (action: 'Add' | 'Remove', cities: string[]) => {\n if (action === 'Add') {\n const selected = new Set([...selectedCities, ...cities]);\n setSelectedCities(Array.from(selected));\n return;\n }\n setSelectedCities(selectedCities.filter(sc => !cities.includes(sc)));\n };\n \n return (\n <div style={{ marginLeft: '10px' }}>\n <ButtonGroup segmented isButtonWrapped>\n <Popover\n active={popoverCityActive}\n activator={cityActivator}\n autofocusTarget=\"first-node\"\n onClose={togglePopoverCityActive}\n >\n <Popover.Pane fixed>\n <Popover.Section>\n <Typography as=\"span\" variant=\"subtitle2\">\n Select Cities\n </Typography>\n </Popover.Section>\n </Popover.Pane>\n <Popover.Pane>\n <div style={{ padding: '10px' }}>\n {Object.keys(cities).map((country: string) => {\n return (\n <CheckboxGroup\n key={country}\n country={country}\n cities={cities[country]}\n onChanged={handleCityChanged}\n />\n );\n })}\n </div>\n </Popover.Pane>\n </Popover>\n <Popover\n active={popoverSalaryActive}\n activator={salaryActivator}\n autofocusTarget=\"first-node\"\n onClose={toggleSalaryActive}\n fullWidth\n >\n <Popover.Pane fixed>\n <Popover.Section>\n <Typography as=\"span\" variant=\"caption\">\n Salary\n </Typography>\n </Popover.Section>\n </Popover.Pane>\n <div>\n <SalarySelector\n onFromChanged={setSalaryFrom}\n onToChanged={setSalaryTo}\n />\n </div>\n </Popover>\n </ButtonGroup>\n <div style={{ marginTop: '10px' }}>\n <Typography as=\"span\" variant=\"caption\">\n Selected cities: {selectedCities.join(',')}\n </Typography>\n </div>\n <div>\n <Typography as=\"span\" variant=\"caption\">\n Selected salary range: {new Intl.NumberFormat().format(salaryFrom)} to{' '}\n {new Intl.NumberFormat().format(salaryTo)}\n </Typography>\n </div>\n </div>\n );"
141
+ },
142
+ language: 'javascript',
143
+ type: 'auto'
144
+ }
145
+ };
@@ -0,0 +1 @@
1
+ export declare const StyledPopover: any;
@@ -0,0 +1,7 @@
1
+ import { createGlobalStyle } from 'styled-components';
2
+ import { borderRadius8 } from '../utilities/borderRadius';
3
+ import { Neutral } from '../utilities/colors';
4
+ import { space16, space4, space8 } from '../utilities/spacing';
5
+
6
+ // we need to use global style here because popover is created outside the root element for react app
7
+ export var StyledPopover = createGlobalStyle([".Polaris-Popover{max-width:calc(100vw - ", ");margin:0.3125rem 2px ", ";box-shadow:0px ", " 20px rgba(71,71,71,0.2),0px 3px 6px -3px rgba(71,71,71,0.08);border-radius:", ";backface-visibility:hidden;will-change:left,top;}.Polaris-Popover__PopoverOverlay{opacity:0;transition:opacity 100ms ease,transform 100ms ease;transform:translateY(-0.3125rem);}.Polaris-Popover__PopoverOverlay--entering{opacity:1;transform:translateY(0);}.Polaris-Popover__PopoverOverlay--open{opacity:1;transform:none;}.Polaris-Popover__PopoverOverlay--exiting{opacity:1;transform:translateY(0);transition-duration:0ms;}.Polaris-Popover--measuring:not(.Polaris-Popover__PopoverOverlay--exiting){opacity:0;transform:translateY(-0.3125rem);}.Polaris-Popover--fullWidth{margin:0.3125rem auto 0 auto;width:fit-content;}.Polaris-Popover--fullWidth .Polaris-Popover__Content{max-width:none;}.Polaris-Popover--positionedAbove{margin:", " 2px 0.3125rem;}.Polaris-Popover--positionedAbove.Polaris-Popover--fullWidth{margin:0 auto 0.3125rem auto;}.Polaris-Popover__Wrapper{position:relative;overflow:hidden;background-color:", ";border-radius:", ";outline:1px solid transparent;}.Polaris-Popover__Content{position:relative;display:flex;flex-direction:column;border-radius:1px;max-width:25rem;max-height:31.25rem;}.Polaris-Popover__Content:focus{outline:none;}.Polaris-Popover__Content--fullHeight{max-height:none;}.Polaris-Popover__Content--fluidContent{max-height:none;max-width:none;}.Polaris-Popover__Pane{flex:1 1;max-width:100%;}.Polaris-Popover__Pane + .Polaris-Popover__Pane{border-top:1px solid ", ";}.Polaris-Popover__Pane:focus{outline:none;}.Polaris-Popover__Pane--fixed{overflow:visible;flex:0 0 auto;}.Polaris-Popover__Pane--captureOverscroll{overscroll-behavior:contain;}.Polaris-Popover__Section{padding:", ";color:", ";}.Polaris-Popover__Section + .Polaris-Popover__Section{border-top:1px solid #e1e3e5;}.Polaris-Popover__FocusTracker{position:absolute !important;top:0;width:0.0625rem !important;height:0.0625rem !important;margin:0 !important;padding:0 !important;overflow:hidden !important;clip-path:inset(50%) !important;border:0 !important;white-space:nowrap !important;}@media print{.Polaris-Popover__PopoverOverlay--hideOnPrint{display:none !important;}}.Polaris-PositionedOverlay{position:absolute;z-index:400;}.Polaris-PositionedOverlay--fixed{position:fixed;}.Polaris-PositionedOverlay--calculating{visibility:hidden;}.Polaris-PositionedOverlay--preventInteraction{pointer-events:none;}"], space8, space4, space8, borderRadius8, space4, Neutral.B100, borderRadius8, Neutral.B85, space16, Neutral.B40);
@@ -0,0 +1 @@
1
+ export { Popover, PopoverProps } from './Popover';
@@ -0,0 +1 @@
1
+ export { Popover, PopoverProps } from './Popover';
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ country: string;
4
+ cities: string[];
5
+ onChanged: (action: 'Add' | 'Remove', cities: string[]) => void;
6
+ };
7
+ export declare const CheckboxGroup: ({ country, cities, onChanged }: Props) => JSX.Element;
8
+ export {};
@@ -0,0 +1,60 @@
1
+ import React, { useState } from 'react';
2
+ import { Checkbox } from '../../Checkbox';
3
+ export var CheckboxGroup = function CheckboxGroup(_ref) {
4
+ var country = _ref.country,
5
+ cities = _ref.cities,
6
+ onChanged = _ref.onChanged;
7
+ var _useState = useState(false),
8
+ isCountrySelected = _useState[0],
9
+ setIsCountrySelected = _useState[1];
10
+ var _useState2 = useState([]),
11
+ selectedCities = _useState2[0],
12
+ setSelectedCities = _useState2[1];
13
+ var handleCountryChanged = function handleCountryChanged(checked) {
14
+ setIsCountrySelected(checked);
15
+ if (checked) {
16
+ setSelectedCities(cities);
17
+ } else {
18
+ setSelectedCities([]);
19
+ }
20
+ onChanged(checked ? 'Add' : 'Remove', cities);
21
+ };
22
+ var handleCityChanged = function handleCityChanged(checked, id) {
23
+ if (checked && !selectedCities.includes(id)) {
24
+ var selected = [].concat(selectedCities, [id]);
25
+ setSelectedCities(selected);
26
+ onChanged('Add', [id]);
27
+ return;
28
+ }
29
+ if (!checked) {
30
+ var _selected = selectedCities.filter(function (s) {
31
+ return s !== id;
32
+ });
33
+ setSelectedCities(_selected);
34
+ onChanged('Remove', [id]);
35
+ }
36
+ };
37
+ return /*#__PURE__*/React.createElement("div", {
38
+ key: country
39
+ }, /*#__PURE__*/React.createElement(Checkbox, {
40
+ id: country,
41
+ label: country,
42
+ checked: isCountrySelected,
43
+ onChange: function onChange(newChecked) {
44
+ return handleCountryChanged(newChecked);
45
+ }
46
+ }), cities.map(function (city) {
47
+ return /*#__PURE__*/React.createElement("div", {
48
+ key: "div-" + city,
49
+ style: {
50
+ marginLeft: '10px'
51
+ }
52
+ }, /*#__PURE__*/React.createElement(Checkbox, {
53
+ id: city,
54
+ label: city,
55
+ key: city,
56
+ checked: selectedCities.includes(city) || isCountrySelected,
57
+ onChange: handleCityChanged
58
+ }));
59
+ }));
60
+ };
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ onFromChanged: (amount: number) => void;
4
+ onToChanged: (amount: number) => void;
5
+ };
6
+ export declare const SalarySelector: ({ onFromChanged, onToChanged }: Props) => JSX.Element;
7
+ export {};