glints-aries 4.0.182 → 4.0.184

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 (67) hide show
  1. package/es/@next/Checkbox/Checkbox.js +8 -5
  2. package/es/@next/Checkbox/CheckboxStyle.js +2 -2
  3. package/es/@next/IndexTable/IndexTable.js +35 -0
  4. package/es/@next/IndexTable/IndexTable.stories.js +162 -0
  5. package/es/@next/IndexTable/components/Checkbox/Checkbox.js +20 -0
  6. package/es/@next/IndexTable/components/Checkbox/CheckboxStyle.js +9 -0
  7. package/es/@next/IndexTable/components/Checkbox/index.js +1 -0
  8. package/es/@next/IndexTable/components/Row/Row.js +13 -0
  9. package/es/@next/IndexTable/components/Row/index.js +2 -0
  10. package/es/@next/IndexTable/index.js +1 -0
  11. package/es/@next/IndexTable/indexTableStoryHelper/ButtonGroupStyle.js +11 -0
  12. package/es/@next/RadioButton/RadioButton.js +41 -0
  13. package/es/@next/RadioButton/RadioButton.stories.js +56 -0
  14. package/es/@next/RadioButton/RadioButtonStyle.js +16 -0
  15. package/es/@next/RadioButton/index.js +1 -0
  16. package/es/@next/index.js +2 -0
  17. package/es/@next/utilities/spacing/Spacing.js +2 -0
  18. package/es/src/@next/Checkbox/Checkbox.d.ts +2 -1
  19. package/es/src/@next/IndexTable/IndexTable.d.ts +9 -0
  20. package/es/src/@next/IndexTable/IndexTable.stories.d.ts +5 -0
  21. package/es/src/@next/IndexTable/components/Checkbox/Checkbox.d.ts +2 -0
  22. package/es/src/@next/IndexTable/components/Checkbox/CheckboxStyle.d.ts +2 -0
  23. package/es/src/@next/IndexTable/components/Checkbox/index.d.ts +1 -0
  24. package/es/src/@next/IndexTable/components/Row/Row.d.ts +3 -0
  25. package/es/src/@next/IndexTable/components/Row/index.d.ts +1 -0
  26. package/es/src/@next/IndexTable/index.d.ts +1 -0
  27. package/es/src/@next/IndexTable/indexTableStoryHelper/ButtonGroupStyle.d.ts +3 -0
  28. package/es/src/@next/RadioButton/RadioButton.d.ts +14 -0
  29. package/es/src/@next/RadioButton/RadioButton.stories.d.ts +6 -0
  30. package/es/src/@next/RadioButton/RadioButtonStyle.d.ts +3 -0
  31. package/es/src/@next/RadioButton/index.d.ts +1 -0
  32. package/es/src/@next/index.d.ts +2 -0
  33. package/es/src/@next/utilities/spacing/Spacing.d.ts +2 -0
  34. package/lib/@next/Checkbox/Checkbox.js +8 -5
  35. package/lib/@next/Checkbox/CheckboxStyle.js +2 -2
  36. package/lib/@next/IndexTable/IndexTable.js +41 -0
  37. package/lib/@next/IndexTable/IndexTable.stories.js +169 -0
  38. package/lib/@next/IndexTable/components/Checkbox/Checkbox.js +27 -0
  39. package/lib/@next/IndexTable/components/Checkbox/CheckboxStyle.js +16 -0
  40. package/lib/@next/IndexTable/components/Checkbox/index.js +9 -0
  41. package/lib/@next/IndexTable/components/Row/Row.js +19 -0
  42. package/lib/@next/IndexTable/components/Row/index.js +8 -0
  43. package/lib/@next/IndexTable/index.js +9 -0
  44. package/lib/@next/IndexTable/indexTableStoryHelper/ButtonGroupStyle.js +18 -0
  45. package/lib/@next/RadioButton/RadioButton.js +47 -0
  46. package/lib/@next/RadioButton/RadioButton.stories.js +65 -0
  47. package/lib/@next/RadioButton/RadioButtonStyle.js +24 -0
  48. package/lib/@next/RadioButton/index.js +9 -0
  49. package/lib/@next/index.js +8 -1
  50. package/lib/@next/utilities/spacing/Spacing.js +5 -1
  51. package/lib/src/@next/Checkbox/Checkbox.d.ts +2 -1
  52. package/lib/src/@next/IndexTable/IndexTable.d.ts +9 -0
  53. package/lib/src/@next/IndexTable/IndexTable.stories.d.ts +5 -0
  54. package/lib/src/@next/IndexTable/components/Checkbox/Checkbox.d.ts +2 -0
  55. package/lib/src/@next/IndexTable/components/Checkbox/CheckboxStyle.d.ts +2 -0
  56. package/lib/src/@next/IndexTable/components/Checkbox/index.d.ts +1 -0
  57. package/lib/src/@next/IndexTable/components/Row/Row.d.ts +3 -0
  58. package/lib/src/@next/IndexTable/components/Row/index.d.ts +1 -0
  59. package/lib/src/@next/IndexTable/index.d.ts +1 -0
  60. package/lib/src/@next/IndexTable/indexTableStoryHelper/ButtonGroupStyle.d.ts +3 -0
  61. package/lib/src/@next/RadioButton/RadioButton.d.ts +14 -0
  62. package/lib/src/@next/RadioButton/RadioButton.stories.d.ts +6 -0
  63. package/lib/src/@next/RadioButton/RadioButtonStyle.d.ts +3 -0
  64. package/lib/src/@next/RadioButton/index.d.ts +1 -0
  65. package/lib/src/@next/index.d.ts +2 -0
  66. package/lib/src/@next/utilities/spacing/Spacing.d.ts +2 -0
  67. package/package.json +2 -2
@@ -1,12 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText"];
3
+ var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText", "isPadded"];
4
4
  import React, { useEffect, useRef, useState } from 'react';
5
- import { nanoid } from 'nanoid';
6
5
  import { StyledCheckbox, StyledCheckboxContainer, StyledColumn, StyledContainer, StyledLeftColumn, StyledRow } from './CheckboxStyle';
7
6
  import { noop } from 'lodash-es';
8
7
  import { Icon } from '../Icon';
9
8
  import { Typography } from '../Typography';
9
+ import nextId from 'react-id-generator';
10
10
  export var Checkbox = function Checkbox(_ref) {
11
11
  var label = _ref.label,
12
12
  id = _ref.id,
@@ -16,8 +16,10 @@ export var Checkbox = function Checkbox(_ref) {
16
16
  indeterminate = _ref.indeterminate,
17
17
  hasError = _ref.hasError,
18
18
  helpText = _ref.helpText,
19
+ _ref$isPadded = _ref.isPadded,
20
+ isPadded = _ref$isPadded === void 0 ? true : _ref$isPadded,
19
21
  otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
20
- var randomId = nanoid();
22
+ var randomId = nextId('glints-checkbox');
21
23
  var checkBoxId = id ? id : randomId;
22
24
  var labelId = "label-" + checkBoxId;
23
25
  var inputNode = useRef(null);
@@ -42,7 +44,8 @@ export var Checkbox = function Checkbox(_ref) {
42
44
  };
43
45
  return /*#__PURE__*/React.createElement(StyledContainer, {
44
46
  "aria-disabled": disabled,
45
- "data-error": hasError
47
+ "data-error": hasError,
48
+ "data-spacing": isPadded
46
49
  }, /*#__PURE__*/React.createElement(StyledRow, null, /*#__PURE__*/React.createElement(StyledLeftColumn, null, /*#__PURE__*/React.createElement(StyledCheckboxContainer, null, /*#__PURE__*/React.createElement(StyledCheckbox, {
47
50
  role: "checkbox",
48
51
  "aria-labelledby": labelId,
@@ -89,7 +92,7 @@ export var Checkbox = function Checkbox(_ref) {
89
92
  }, /*#__PURE__*/React.createElement(Typography, {
90
93
  as: "div",
91
94
  variant: "body1"
92
- }, label)))), /*#__PURE__*/React.createElement(StyledRow, null, /*#__PURE__*/React.createElement(StyledLeftColumn, null), /*#__PURE__*/React.createElement(StyledColumn, {
95
+ }, label)))), helpText && /*#__PURE__*/React.createElement(StyledRow, null, /*#__PURE__*/React.createElement(StyledLeftColumn, null), /*#__PURE__*/React.createElement(StyledColumn, {
93
96
  className: "help-text"
94
97
  }, /*#__PURE__*/React.createElement(Typography, {
95
98
  as: "span",
@@ -1,12 +1,12 @@
1
1
  import styled from 'styled-components';
2
- import { Breakpoints } from '../..';
2
+ import { Breakpoints } from '..';
3
3
  import { borderRadius4 } from '../utilities/borderRadius';
4
4
  import { Blue, Neutral, Red } from '../utilities/colors';
5
5
  import { space4 } from '../utilities/spacing';
6
6
  export var StyledContainer = styled.div.withConfig({
7
7
  displayName: "CheckboxStyle__StyledContainer",
8
8
  componentId: "sc-a9bf1h-0"
9
- })(["flex-direction:row;align-items:flex-start;padding:", " 0px;gap:8px;color:", ";label{cursor:pointer;margin-top:-1px;}svg{border-radius:4px;position:absolute;height:20px;width:20px;top:0;left:0;opacity:0;pointer-events:none;fill:", ";}&[aria-disabled='true'],&[aria-disabled='true'] .help-text{color:", ";}&[aria-disabled='true'] div[role='checkbox']{border-color:", ";background:", ";}&[aria-disabled='true'] svg{background:", ";fill:", ";}&[data-error='true'] svg{fill:", ";}"], space4, Neutral.B18, Blue.S99, Neutral.B68, Neutral.B85, Neutral.B95, Neutral.B68, Neutral.B95, Red.B93);
9
+ })(["flex-direction:row;align-items:flex-start;gap:8px;color:", ";label{cursor:pointer;margin-top:-1px;}svg{border-radius:4px;position:absolute;height:20px;width:20px;top:0;left:0;opacity:0;pointer-events:none;fill:", ";}&[data-spacing='true']{padding:", " 0px;}&[aria-disabled='true'],&[aria-disabled='true'] .help-text{color:", ";}&[aria-disabled='true'] div[role='checkbox']{border-color:", ";background:", ";}&[aria-disabled='true'] svg{background:", ";fill:", ";}&[data-error='true'] svg{fill:", ";}"], Neutral.B18, Blue.S99, space4, Neutral.B68, Neutral.B85, Neutral.B95, Neutral.B68, Neutral.B95, Red.B93);
10
10
  export var StyledCheckboxContainer = styled.div.withConfig({
11
11
  displayName: "CheckboxStyle__StyledCheckboxContainer",
12
12
  componentId: "sc-a9bf1h-1"
@@ -0,0 +1,35 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["bulkActions", "children", "itemCount", "selectedItemsCount"],
4
+ _excluded2 = ["checked", "onChange"];
5
+ import React from 'react';
6
+ import { Cell, IndexTable as PolarisIndexTable, IndexTableProps } from 'polaris-glints';
7
+ import { Checkbox } from '../Checkbox';
8
+ import { Row } from './components/Row/Row';
9
+ var IndexTable = function IndexTable(_ref) {
10
+ var bulkActions = _ref.bulkActions,
11
+ children = _ref.children,
12
+ itemCount = _ref.itemCount,
13
+ selectedItemsCount = _ref.selectedItemsCount,
14
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
15
+ var renderCheckboxHeader = function renderCheckboxHeader(_ref2) {
16
+ var checked = _ref2.checked,
17
+ onChange = _ref2.onChange,
18
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
19
+ return /*#__PURE__*/React.createElement(Checkbox, _extends({
20
+ onChange: onChange,
21
+ checked: checked,
22
+ isPadded: false
23
+ }, props));
24
+ };
25
+ return /*#__PURE__*/React.createElement(PolarisIndexTable, _extends({
26
+ bulkActions: bulkActions,
27
+ checkbox: renderCheckboxHeader,
28
+ itemCount: itemCount,
29
+ selectedItemsCount: selectedItemsCount
30
+ }, props), children);
31
+ };
32
+ IndexTable.Cell = Cell;
33
+ IndexTable.Row = Row;
34
+ export { useIndexResourceState } from 'polaris-glints';
35
+ export { IndexTable, IndexTableProps };
@@ -0,0 +1,162 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { IndexTable, useIndexResourceState } from './IndexTable';
4
+ import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
5
+ import { Typography } from '..';
6
+ import 'polaris-glints/build/esm/styles.css';
7
+ import { Icon } from '../Icon';
8
+ import { PrimaryButton } from '../Button';
9
+ import { StyledButton, StyledButtonGroup } from './indexTableStoryHelper/ButtonGroupStyle';
10
+ import { Neutral } from '../utilities/colors';
11
+ IndexTable.displayName = 'Table';
12
+ export default {
13
+ title: '@next/IndexTable',
14
+ component: IndexTable,
15
+ decorators: [function (Story) {
16
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(BaseContainer, null, Story()), /*#__PURE__*/React.createElement("div", {
17
+ id: "glints-portal-container"
18
+ }));
19
+ }],
20
+ argTypes: {
21
+ disabled: {
22
+ control: 'boolean'
23
+ },
24
+ loading: {
25
+ control: 'boolean'
26
+ },
27
+ loadingLabel: {
28
+ control: 'text'
29
+ }
30
+ }
31
+ };
32
+ var candidates = [{
33
+ id: '1',
34
+ url: 'candidate/1',
35
+ name: 'Dwi Nugraha Putri',
36
+ location: 'Jakarta, Indonesia',
37
+ expectedSalary: 'Rp 11,400,000/mo',
38
+ yearsExperience: '4 years, 3 months',
39
+ latestWorkExperience: 'Backend Engineer at Google',
40
+ latestWorkDuration: 'Jan 2021 - Jan 2022'
41
+ }, {
42
+ id: '2',
43
+ url: 'candidate/2',
44
+ name: 'Ahmad Dani',
45
+ location: 'Jakarta, Indonesia',
46
+ expectedSalary: 'Rp 11,400,000/mo',
47
+ yearsExperience: '4 years, 3 months',
48
+ latestWorkExperience: 'Backend Engineer at Google',
49
+ latestWorkDuration: 'Jan 2021 - Jan 2022'
50
+ }, {
51
+ id: '3',
52
+ url: 'candidate/3',
53
+ name: 'Syed Ali',
54
+ location: 'Jakarta, Indonesia',
55
+ expectedSalary: 'Rp 11,400,000/mo',
56
+ yearsExperience: '4 years, 3 months',
57
+ latestWorkExperience: 'Backend Engineer at Google',
58
+ latestWorkDuration: 'Jan 2021 - Jan 2022'
59
+ }, {
60
+ id: '4',
61
+ url: 'candidate/4',
62
+ name: 'Muhammad Danial',
63
+ location: 'Jakarta, Indonesia',
64
+ expectedSalary: 'Rp 11,400,000/mo',
65
+ yearsExperience: '4 years, 3 months',
66
+ latestWorkExperience: 'Backend Engineer at Google',
67
+ latestWorkDuration: 'Jan 2021 - Jan 2022'
68
+ }];
69
+ var resourceName = {
70
+ singular: 'candidate',
71
+ plural: 'candidates'
72
+ };
73
+ var Template = function Template(args) {
74
+ var _useIndexResourceStat = useIndexResourceState(candidates),
75
+ selectedResources = _useIndexResourceStat.selectedResources,
76
+ allResourcesSelected = _useIndexResourceStat.allResourcesSelected,
77
+ handleSelectionChange = _useIndexResourceStat.handleSelectionChange;
78
+ var promotedBulkActions = [{
79
+ content: 'Reject',
80
+ onAction: function onAction() {
81
+ return console.log('Reject');
82
+ }
83
+ }, {
84
+ title: 'Move to',
85
+ actions: [{
86
+ content: 'Assessment',
87
+ onAction: function onAction() {
88
+ return console.log('Assessment');
89
+ }
90
+ }, {
91
+ content: 'Interviewing',
92
+ onAction: function onAction() {
93
+ return console.log('Interviewing');
94
+ }
95
+ }, {
96
+ content: 'Offered',
97
+ onAction: function onAction() {
98
+ return console.log('Offered');
99
+ }
100
+ }, {
101
+ content: 'Hired',
102
+ onAction: function onAction() {
103
+ return console.log('Hired');
104
+ }
105
+ }]
106
+ }];
107
+ var rowMarkup = candidates.map(function (_ref, index) {
108
+ var id = _ref.id,
109
+ name = _ref.name,
110
+ location = _ref.location,
111
+ expectedSalary = _ref.expectedSalary,
112
+ yearsExperience = _ref.yearsExperience,
113
+ latestWorkExperience = _ref.latestWorkExperience,
114
+ latestWorkDuration = _ref.latestWorkDuration;
115
+ return /*#__PURE__*/React.createElement(IndexTable.Row, {
116
+ id: id,
117
+ key: id,
118
+ selected: selectedResources.includes(id),
119
+ position: index,
120
+ onClick: function onClick() {
121
+ return console.log("row clicked " + id);
122
+ }
123
+ }, /*#__PURE__*/React.createElement(IndexTable.Cell, null, /*#__PURE__*/React.createElement(Icon, {
124
+ name: "ri-account-circle-fill",
125
+ height: 40,
126
+ fill: Neutral.B40
127
+ })), /*#__PURE__*/React.createElement(IndexTable.Cell, null, /*#__PURE__*/React.createElement(Typography, {
128
+ variant: "body2"
129
+ }, name), /*#__PURE__*/React.createElement(Typography, {
130
+ variant: "body1"
131
+ }, location)), /*#__PURE__*/React.createElement(IndexTable.Cell, null, expectedSalary), /*#__PURE__*/React.createElement(IndexTable.Cell, null, yearsExperience), /*#__PURE__*/React.createElement(IndexTable.Cell, null, /*#__PURE__*/React.createElement(Typography, {
132
+ variant: "body1"
133
+ }, latestWorkExperience), /*#__PURE__*/React.createElement(Typography, {
134
+ variant: "caption"
135
+ }, latestWorkDuration)), /*#__PURE__*/React.createElement(IndexTable.Cell, null, /*#__PURE__*/React.createElement(StyledButtonGroup, null, /*#__PURE__*/React.createElement(StyledButton, null, "Reject"), /*#__PURE__*/React.createElement(PrimaryButton, null, "Shortlist"))));
136
+ });
137
+ return /*#__PURE__*/React.createElement(IndexTable, _extends({}, args, {
138
+ resourceName: resourceName,
139
+ itemCount: candidates.length,
140
+ selectedItemsCount: allResourcesSelected ? 'All' : selectedResources.length,
141
+ onSelectionChange: handleSelectionChange,
142
+ promotedBulkActions: promotedBulkActions,
143
+ headings: [{
144
+ title: ''
145
+ }, {
146
+ title: 'Name & Location'
147
+ }, {
148
+ title: 'Expected Salary'
149
+ }, {
150
+ title: 'Years of Experience'
151
+ }, {
152
+ title: 'Latest Work Experience'
153
+ }, {
154
+ title: 'Actions'
155
+ }],
156
+ selectedLabel: "selected candidates"
157
+ }), rowMarkup);
158
+ };
159
+ export var Interactive = Template.bind({});
160
+ Interactive.args = {
161
+ loadingLabel: 'Loading...'
162
+ };
@@ -0,0 +1,20 @@
1
+ import { IndexTableRowContext } from 'polaris-glints';
2
+ import React, { memo, useContext } from 'react';
3
+ import { Checkbox as GlintsCheckbox } from '../../../Checkbox';
4
+ import { CheckboxCellContentContainer, CheckboxWrapper } from './CheckboxStyle';
5
+ var Checkbox = function Checkbox() {
6
+ var _useContext = useContext(IndexTableRowContext),
7
+ itemId = _useContext.itemId,
8
+ selected = _useContext.selected,
9
+ disabled = _useContext.disabled,
10
+ onInteraction = _useContext.onInteraction;
11
+ return /*#__PURE__*/React.createElement(CheckboxWrapper, null, /*#__PURE__*/React.createElement(CheckboxCellContentContainer, null, /*#__PURE__*/React.createElement("div", {
12
+ onClick: onInteraction
13
+ }, /*#__PURE__*/React.createElement(GlintsCheckbox, {
14
+ id: itemId,
15
+ checked: selected,
16
+ disabled: disabled,
17
+ isPadded: false
18
+ }))));
19
+ };
20
+ export var MemoizedCheckbox = /*#__PURE__*/memo(Checkbox);
@@ -0,0 +1,9 @@
1
+ import styled from 'styled-components';
2
+ export var CheckboxWrapper = styled.div.withConfig({
3
+ displayName: "CheckboxStyle__CheckboxWrapper",
4
+ componentId: "sc-1utzl7w-0"
5
+ })(["margin:0;position:relative;top:15%;"]);
6
+ export var CheckboxCellContentContainer = styled.div.withConfig({
7
+ displayName: "CheckboxStyle__CheckboxCellContentContainer",
8
+ componentId: "sc-1utzl7w-1"
9
+ })(["display:flex;align-items:center;"]);
@@ -0,0 +1 @@
1
+ export * from './Checkbox';
@@ -0,0 +1,13 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["children"];
4
+ import React from 'react';
5
+ import { Row as PolarisRow } from 'polaris-glints';
6
+ import { MemoizedCheckbox as Checkbox } from '../Checkbox';
7
+ export var Row = function Row(_ref) {
8
+ var children = _ref.children,
9
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
10
+ return /*#__PURE__*/React.createElement(PolarisRow, _extends({
11
+ checkbox: /*#__PURE__*/React.createElement(Checkbox, null)
12
+ }, props), children);
13
+ };
@@ -0,0 +1,2 @@
1
+ import * as _Row from './Row';
2
+ export { _Row as Row };
@@ -0,0 +1 @@
1
+ export * from './IndexTable';
@@ -0,0 +1,11 @@
1
+ import styled from 'styled-components';
2
+ import { Spacing } from '../..';
3
+ import { Button } from '../../Button';
4
+ export var StyledButtonGroup = styled.div.withConfig({
5
+ displayName: "ButtonGroupStyle__StyledButtonGroup",
6
+ componentId: "sc-1eqebqe-0"
7
+ })(["display:flex;"]);
8
+ export var StyledButton = styled(Button).withConfig({
9
+ displayName: "ButtonGroupStyle__StyledButton",
10
+ componentId: "sc-1eqebqe-1"
11
+ })(["margin-right:", ";"], Spacing.space8);
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["label", "helperText", "disabled", "name", "checked", "value", "onChange"];
4
+ import React from 'react';
5
+ import { LabelWrapper, RadioButtonInput, RadioButtonWrapper } from './RadioButtonStyle';
6
+ import { Typography } from '../Typography';
7
+ import { Colors } from '..';
8
+ /**
9
+ * This is a controlled component, so you need to pass in the `checked` and `onChange` prop to make it work.
10
+ */
11
+ export var RadioButton = function RadioButton(_ref) {
12
+ var label = _ref.label,
13
+ helperText = _ref.helperText,
14
+ disabled = _ref.disabled,
15
+ name = _ref.name,
16
+ checked = _ref.checked,
17
+ value = _ref.value,
18
+ onChange = _ref.onChange,
19
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
20
+ return /*#__PURE__*/React.createElement(RadioButtonWrapper, null, /*#__PURE__*/React.createElement(RadioButtonInput, _extends({
21
+ disabled: disabled,
22
+ name: name,
23
+ checked: checked,
24
+ value: value,
25
+ type: "radio",
26
+ onChange: onChange,
27
+ onMouseDown: function onMouseDown(e) {
28
+ return e.preventDefault();
29
+ }
30
+ }, props)), /*#__PURE__*/React.createElement(LabelWrapper, {
31
+ "data-disabled": disabled
32
+ }, /*#__PURE__*/React.createElement(Typography, {
33
+ variant: "body1",
34
+ as: "span",
35
+ color: Colors.Neutral.B18
36
+ }, label), /*#__PURE__*/React.createElement(Typography, {
37
+ variant: "subtitle2",
38
+ as: "span",
39
+ color: Colors.Neutral.B40
40
+ }, helperText)));
41
+ };
@@ -0,0 +1,56 @@
1
+ import React, { useState } from 'react';
2
+ import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
3
+ import { RadioButton } from './RadioButton';
4
+ import { Typography } from '../Typography';
5
+ RadioButton.displayName = 'RadioButton';
6
+ export default {
7
+ title: '@next/RadioButton',
8
+ component: RadioButton,
9
+ decorators: [function (Story) {
10
+ return /*#__PURE__*/React.createElement(BaseContainer, null, Story());
11
+ }]
12
+ };
13
+ var Template = function Template(args) {
14
+ return /*#__PURE__*/React.createElement(RadioButton, args);
15
+ };
16
+ export var Interactive = Template.bind({});
17
+ Interactive.args = {
18
+ label: 'Label',
19
+ helperText: 'Helper Text',
20
+ disabled: false,
21
+ name: 'name',
22
+ checked: false,
23
+ value: 'value'
24
+ };
25
+ export var ControlledRadioButton = function ControlledRadioButton() {
26
+ var _useState = useState('1'),
27
+ value = _useState[0],
28
+ setValue = _useState[1];
29
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, {
30
+ variant: "body1"
31
+ }, "Selected value: ", value), /*#__PURE__*/React.createElement(RadioButton, {
32
+ name: "radio-name",
33
+ label: "Label 1",
34
+ value: "1",
35
+ checked: value === '1',
36
+ onChange: function onChange(e) {
37
+ return setValue(e.target.value);
38
+ }
39
+ }), /*#__PURE__*/React.createElement(RadioButton, {
40
+ name: "radio-name",
41
+ label: "Label 2",
42
+ value: "2",
43
+ checked: value === '2',
44
+ onChange: function onChange(e) {
45
+ return setValue(e.target.value);
46
+ }
47
+ }), /*#__PURE__*/React.createElement(RadioButton, {
48
+ name: "radio-name",
49
+ label: "Label 3",
50
+ value: "3",
51
+ checked: value === '3',
52
+ onChange: function onChange(e) {
53
+ return setValue(e.target.value);
54
+ }
55
+ }));
56
+ };
@@ -0,0 +1,16 @@
1
+ import styled from 'styled-components';
2
+ import { Breakpoints, Colors } from '..';
3
+ import { space4, space8 } from '../utilities/spacing';
4
+ import { borderRadiusHalf } from '../utilities/borderRadius';
5
+ export var RadioButtonWrapper = styled.label.withConfig({
6
+ displayName: "RadioButtonStyle__RadioButtonWrapper",
7
+ componentId: "sc-138orlx-0"
8
+ })(["display:flex;align-items:flex-start;gap:", ";padding:", " 0;"], space8, space4);
9
+ export var RadioButtonInput = styled.input.withConfig({
10
+ displayName: "RadioButtonStyle__RadioButtonInput",
11
+ componentId: "sc-138orlx-1"
12
+ })(["cursor:pointer;appearance:none;margin:0;width:18px;height:18px;border:2px solid ", ";border-radius:", ";transform:translateY(1.5px);::after{content:'';display:block;border-radius:", ";width:8px;height:8px;margin:3px;}@media (min-width:", "){width:22px;height:22px;transform:none;::after{width:10px;height:10px;margin:", ";}}:hover{border-color:", ";}:focus-visible{box-shadow:0px 0px 0px 1px ", ",0px 0px 0px 3px ", ";outline:none;}:disabled{cursor:not-allowed;background-color:", ";border-color:", ";}:checked{border-color:", ";::after{background-color:", ";}:disabled{background-color:", ";border-color:", ";::after{background-color:", ";}}}"], Colors.Neutral.B68, borderRadiusHalf, borderRadiusHalf, Breakpoints.large, space4, Colors.Neutral.B68, Colors.Neutral.B100, Colors.Blue.S54, Colors.Neutral.B95, Colors.Neutral.B85, Colors.Blue.S99, Colors.Blue.S99, Colors.Neutral.B95, Colors.Neutral.B85, Colors.Neutral.B85);
13
+ export var LabelWrapper = styled.div.withConfig({
14
+ displayName: "RadioButtonStyle__LabelWrapper",
15
+ componentId: "sc-138orlx-2"
16
+ })(["cursor:pointer;display:flex;flex-direction:column;gap:", ";&[data-disabled='true']{span{color:", ";}cursor:not-allowed;}"], space4, Colors.Neutral.B85);
@@ -0,0 +1 @@
1
+ export * from './RadioButton';
package/es/@next/index.js CHANGED
@@ -13,8 +13,10 @@ export { Button, ButtonProps, DestructiveButton, OutlineButton, OutlineMonochrom
13
13
  export { ButtonGroup, ButtonGroupProps } from './ButtonGroup';
14
14
  export { Divider } from './Divider';
15
15
  export { Icon, IconProps } from './Icon';
16
+ export { IndexTable, IndexTableProps, useIndexResourceState } from './IndexTable';
16
17
  export { Pagination, SimplePagination, PaginationProps } from './Pagination';
17
18
  export { Popover, PopoverProps } from './Popover';
19
+ export { RadioButton, RadioButtonProps } from './RadioButton';
18
20
  export { Tab, TabModel, TabProps, Tabs, TabsProps } from './Tabs';
19
21
  export { Tag, TagProps } from './Tag';
20
22
  export { Typography, TypographyProps } from './Typography';
@@ -1,7 +1,9 @@
1
+ export var space2 = '2px';
1
2
  export var space4 = '4px';
2
3
  export var space8 = '8px';
3
4
  export var space12 = '12px';
4
5
  export var space16 = '16px';
6
+ export var space18 = '18px';
5
7
  export var space24 = '24px';
6
8
  export var space32 = '32px';
7
9
  export var space40 = '40px';
@@ -8,5 +8,6 @@ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
8
8
  disabled?: boolean;
9
9
  helpText?: string;
10
10
  onChange?(newChecked: boolean, id: string): void;
11
+ isPadded?: boolean;
11
12
  }
12
- export declare const Checkbox: ({ label, id, checked, onChange, disabled, indeterminate, hasError, helpText, ...otherProps }: CheckboxProps) => JSX.Element;
13
+ export declare const Checkbox: ({ label, id, checked, onChange, disabled, indeterminate, hasError, helpText, isPadded, ...otherProps }: CheckboxProps) => JSX.Element;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { IndexTableProps } from 'polaris-glints';
3
+ declare const IndexTable: {
4
+ ({ bulkActions, children, itemCount, selectedItemsCount, ...props }: IndexTableProps): JSX.Element;
5
+ Cell: React.NamedExoticComponent<import("polaris-glints/build/ts/latest/src/components/IndexTable").CellProps>;
6
+ Row: ({ children, ...props }: import("polaris-glints").RowProps) => JSX.Element;
7
+ };
8
+ export { useIndexResourceState } from 'polaris-glints';
9
+ export { IndexTable, IndexTableProps };
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import 'polaris-glints/build/esm/styles.css';
3
+ declare const _default: Meta<import("@storybook/react").Args>;
4
+ export default _default;
5
+ export declare const Interactive: any;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const MemoizedCheckbox: React.MemoExoticComponent<() => JSX.Element>;
@@ -0,0 +1,2 @@
1
+ export declare const CheckboxWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const CheckboxCellContentContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1 @@
1
+ export * from './Checkbox';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { RowProps } from 'polaris-glints';
3
+ export declare const Row: ({ children, ...props }: RowProps) => JSX.Element;
@@ -0,0 +1 @@
1
+ export * as Row from './Row';
@@ -0,0 +1 @@
1
+ export * from './IndexTable';
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare const StyledButtonGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const StyledButton: import("styled-components").StyledComponent<({ children, icon, iconPosition, active, fullWidth, loading, ...otherProps }: import("../..").ButtonProps) => JSX.Element, any, {}, never>;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface RadioButtonProps extends Omit<React.HTMLAttributes<HTMLInputElement>, 'onChange'> {
3
+ label?: string;
4
+ helperText?: string;
5
+ disabled?: boolean;
6
+ name?: string;
7
+ checked?: boolean;
8
+ value?: string;
9
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
10
+ }
11
+ /**
12
+ * This is a controlled component, so you need to pass in the `checked` and `onChange` prop to make it work.
13
+ */
14
+ export declare const RadioButton: ({ label, helperText, disabled, name, checked, value, onChange, ...props }: RadioButtonProps) => JSX.Element;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { Meta } from '@storybook/react';
3
+ declare const _default: Meta<import("@storybook/react").Args>;
4
+ export default _default;
5
+ export declare const Interactive: any;
6
+ export declare const ControlledRadioButton: () => JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare const RadioButtonWrapper: import("styled-components").StyledComponent<"label", any, {}, never>;
2
+ export declare const RadioButtonInput: import("styled-components").StyledComponent<"input", any, {}, never>;
3
+ export declare const LabelWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1 @@
1
+ export * from './RadioButton';
@@ -12,8 +12,10 @@ export { Button, ButtonProps, DestructiveButton, OutlineButton, OutlineMonochrom
12
12
  export { ButtonGroup, ButtonGroupProps } from './ButtonGroup';
13
13
  export { Divider } from './Divider';
14
14
  export { Icon, IconProps } from './Icon';
15
+ export { IndexTable, IndexTableProps, useIndexResourceState, } from './IndexTable';
15
16
  export { Pagination, SimplePagination, PaginationProps } from './Pagination';
16
17
  export { Popover, PopoverProps } from './Popover';
18
+ export { RadioButton, RadioButtonProps } from './RadioButton';
17
19
  export { Tab, TabModel, TabProps, Tabs, TabsProps } from './Tabs';
18
20
  export { Tag, TagProps } from './Tag';
19
21
  export { Typography, TypographyProps } from './Typography';
@@ -1,7 +1,9 @@
1
+ export declare const space2 = "2px";
1
2
  export declare const space4 = "4px";
2
3
  export declare const space8 = "8px";
3
4
  export declare const space12 = "12px";
4
5
  export declare const space16 = "16px";
6
+ export declare const space18 = "18px";
5
7
  export declare const space24 = "24px";
6
8
  export declare const space32 = "32px";
7
9
  export declare const space40 = "40px";
@@ -6,12 +6,12 @@ exports.Checkbox = void 0;
6
6
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
7
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- var _nanoid = require("nanoid");
10
9
  var _CheckboxStyle = require("./CheckboxStyle");
11
10
  var _lodash = require("lodash");
12
11
  var _Icon = require("../Icon");
13
12
  var _Typography = require("../Typography");
14
- var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText"];
13
+ var _reactIdGenerator = _interopRequireDefault(require("react-id-generator"));
14
+ var _excluded = ["label", "id", "checked", "onChange", "disabled", "indeterminate", "hasError", "helpText", "isPadded"];
15
15
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
16
16
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
17
  var Checkbox = function Checkbox(_ref) {
@@ -23,8 +23,10 @@ var Checkbox = function Checkbox(_ref) {
23
23
  indeterminate = _ref.indeterminate,
24
24
  hasError = _ref.hasError,
25
25
  helpText = _ref.helpText,
26
+ _ref$isPadded = _ref.isPadded,
27
+ isPadded = _ref$isPadded === void 0 ? true : _ref$isPadded,
26
28
  otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
27
- var randomId = (0, _nanoid.nanoid)();
29
+ var randomId = (0, _reactIdGenerator["default"])('glints-checkbox');
28
30
  var checkBoxId = id ? id : randomId;
29
31
  var labelId = "label-" + checkBoxId;
30
32
  var inputNode = (0, _react.useRef)(null);
@@ -49,7 +51,8 @@ var Checkbox = function Checkbox(_ref) {
49
51
  };
50
52
  return /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledContainer, {
51
53
  "aria-disabled": disabled,
52
- "data-error": hasError
54
+ "data-error": hasError,
55
+ "data-spacing": isPadded
53
56
  }, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledRow, null, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledLeftColumn, null, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledCheckboxContainer, null, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledCheckbox, {
54
57
  role: "checkbox",
55
58
  "aria-labelledby": labelId,
@@ -96,7 +99,7 @@ var Checkbox = function Checkbox(_ref) {
96
99
  }, /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
97
100
  as: "div",
98
101
  variant: "body1"
99
- }, label)))), /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledRow, null, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledLeftColumn, null), /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledColumn, {
102
+ }, label)))), helpText && /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledRow, null, /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledLeftColumn, null), /*#__PURE__*/_react["default"].createElement(_CheckboxStyle.StyledColumn, {
100
103
  className: "help-text"
101
104
  }, /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
102
105
  as: "span",