@synerise/ds-completed-within 0.5.82 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.6.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.5.82...@synerise/ds-completed-within@0.6.0) (2024-01-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * **completed-within:** added readonly prop ([b5dd622](https://github.com/Synerise/synerise-design/commit/b5dd622fc077ae212cc3302bee88d82651d300b3))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.5.82](https://github.com/Synerise/synerise-design/compare/@synerise/ds-completed-within@0.5.81...@synerise/ds-completed-within@0.5.82) (2024-01-17)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-completed-within
package/README.md CHANGED
@@ -38,6 +38,7 @@ import CompletedWithin from '@synerise/ds-completed-within'
38
38
  | periods | Custom list of periods | CustomPeriod[] | - |
39
39
  | placeholder | Trigger button label | string | - |
40
40
  | tooltip | Content of tooltip | string | - |
41
+ | readOnly | Whether value is editable | boolean | - |
41
42
 
42
43
  ### CompletedWithinTexts
43
44
 
@@ -3,4 +3,5 @@ export declare const TriggerButton: import("styled-components").StyledComponent<
3
3
  export declare const ClearButton: import("styled-components").StyledComponent<typeof Button, any, {}, never>;
4
4
  export declare const CompletedWithinWrapper: import("styled-components").StyledComponent<"div", any, {
5
5
  withValue: boolean;
6
+ readOnly?: boolean | undefined;
6
7
  }, never>;
@@ -21,5 +21,5 @@ export var CompletedWithinWrapper = styled.div.withConfig({
21
21
  displayName: "CompleteWithinstyles__CompletedWithinWrapper",
22
22
  componentId: "sc-1hcip2f-2"
23
23
  })(["display:flex;align-items:center;justify-content:flex-start;height:32px;position:relative;", ";"], function (props) {
24
- return Boolean(props.withValue) && css(["&&&{", "{padding-right:32px;}", "{background-color:transparent !important;position:absolute;right:0;opacity:1;pointer-events:all;}}"], TriggerButton, ClearButton);
24
+ return Boolean(props.withValue) && !props.readOnly && css(["&&&{", "{padding-right:32px;}", "{background-color:transparent !important;position:absolute;right:0;opacity:1;pointer-events:all;}}"], TriggerButton, ClearButton);
25
25
  });
@@ -20,7 +20,8 @@ var CompletedWithin = function CompletedWithin(_ref) {
20
20
  text = _ref.text,
21
21
  periods = _ref.periods,
22
22
  placeholder = _ref.placeholder,
23
- tooltip = _ref.tooltip;
23
+ tooltip = _ref.tooltip,
24
+ readOnly = _ref.readOnly;
24
25
  var intl = useIntl();
25
26
  var texts = React.useMemo(function () {
26
27
  return _objectSpread({
@@ -108,9 +109,25 @@ var CompletedWithin = function CompletedWithin(_ref) {
108
109
  return singlePeriod.value === value.period;
109
110
  })) == null ? void 0 : _getPeriods$find.label) : placeholder;
110
111
  }, [getPeriods, hasValue, texts, value, placeholder]);
112
+ var trigger = /*#__PURE__*/React.createElement(Tooltip, {
113
+ type: "largeSimple",
114
+ description: tooltip,
115
+ trigger: ['hover'],
116
+ onVisibleChange: setTooltipVisible,
117
+ visible: !settingsVisible && tooltipVisible
118
+ }, /*#__PURE__*/React.createElement(S.TriggerButton, {
119
+ "data-testid": "completed-within-trigger",
120
+ readOnly: readOnly,
121
+ className: "ds-completed-within",
122
+ type: "tertiary",
123
+ mode: triggerMode
124
+ }, /*#__PURE__*/React.createElement(Icon, {
125
+ component: /*#__PURE__*/React.createElement(ClockM, null)
126
+ }), triggerLabel));
111
127
  return /*#__PURE__*/React.createElement(S.CompletedWithinWrapper, {
128
+ readOnly: readOnly,
112
129
  withValue: hasValue
113
- }, /*#__PURE__*/React.createElement(Dropdown, {
130
+ }, readOnly ? trigger : /*#__PURE__*/React.createElement(Dropdown, {
114
131
  overlay: /*#__PURE__*/React.createElement(Settings, {
115
132
  value: {
116
133
  value: innerValue !== undefined ? Number(innerValue) : undefined,
@@ -120,6 +137,7 @@ var CompletedWithin = function CompletedWithin(_ref) {
120
137
  onValueChange: setInnerValue,
121
138
  onPeriodChange: setInnerPeriod,
122
139
  text: texts,
140
+ readOnly: readOnly,
123
141
  periods: getPeriods
124
142
  }),
125
143
  trigger: ['click'],
@@ -129,19 +147,7 @@ var CompletedWithin = function CompletedWithin(_ref) {
129
147
  maxWidth: '238px',
130
148
  minWidth: '238px'
131
149
  }
132
- }, /*#__PURE__*/React.createElement(Tooltip, {
133
- type: "largeSimple",
134
- description: tooltip,
135
- trigger: ['hover'],
136
- onVisibleChange: setTooltipVisible,
137
- visible: !settingsVisible && tooltipVisible
138
- }, /*#__PURE__*/React.createElement(S.TriggerButton, {
139
- className: "ds-completed-within",
140
- type: "tertiary",
141
- mode: triggerMode
142
- }, /*#__PURE__*/React.createElement(Icon, {
143
- component: /*#__PURE__*/React.createElement(ClockM, null)
144
- }), triggerLabel))), hasValue && /*#__PURE__*/React.createElement(Tooltip, {
150
+ }, trigger), hasValue && !readOnly && /*#__PURE__*/React.createElement(Tooltip, {
145
151
  title: texts.clear
146
152
  }, /*#__PURE__*/React.createElement(S.ClearButton, {
147
153
  mode: "single-icon",
@@ -22,4 +22,5 @@ export type CompletedWithinProps = {
22
22
  periods?: CustomPeriod[];
23
23
  placeholder?: string | undefined;
24
24
  tooltip?: string;
25
+ readOnly?: boolean;
25
26
  };
@@ -10,8 +10,11 @@ var Settings = function Settings(_ref) {
10
10
  onPeriodChange = _ref.onPeriodChange,
11
11
  onValueChange = _ref.onValueChange,
12
12
  periods = _ref.periods,
13
- maxValue = _ref.maxValue;
14
- return /*#__PURE__*/React.createElement(S.Settings, null, /*#__PURE__*/React.createElement(InputGroup, {
13
+ maxValue = _ref.maxValue,
14
+ readOnly = _ref.readOnly;
15
+ return /*#__PURE__*/React.createElement(S.Settings, {
16
+ "data-testid": "completed-within-dropdown"
17
+ }, /*#__PURE__*/React.createElement(InputGroup, {
15
18
  size: "default",
16
19
  label: text.header,
17
20
  resetMargin: true,
@@ -19,11 +22,13 @@ var Settings = function Settings(_ref) {
19
22
  }, /*#__PURE__*/React.createElement(InputNumber, {
20
23
  size: "small",
21
24
  raw: true,
25
+ readOnly: readOnly,
22
26
  value: value.value,
23
27
  onChange: onValueChange,
24
28
  min: 0,
25
29
  max: maxValue != null ? maxValue : Number.MAX_SAFE_INTEGER
26
30
  }), /*#__PURE__*/React.createElement(Select, {
31
+ readOnly: readOnly,
27
32
  size: 'default',
28
33
  value: value.period,
29
34
  placeholder: text.periodPlaceholder // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-completed-within",
3
- "version": "0.5.82",
3
+ "version": "0.6.0",
4
4
  "description": "CompletedWithin UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -33,13 +33,13 @@
33
33
  ],
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@synerise/ds-button": "^0.18.11",
37
- "@synerise/ds-dropdown": "^0.17.93",
38
- "@synerise/ds-icon": "^0.59.1",
39
- "@synerise/ds-input": "^0.19.14",
40
- "@synerise/ds-input-number": "^0.9.1",
41
- "@synerise/ds-select": "^0.15.32",
42
- "@synerise/ds-tooltip": "^0.14.15",
36
+ "@synerise/ds-button": "^0.19.0",
37
+ "@synerise/ds-dropdown": "^0.17.94",
38
+ "@synerise/ds-icon": "^0.60.0",
39
+ "@synerise/ds-input": "^0.19.15",
40
+ "@synerise/ds-input-number": "^0.9.2",
41
+ "@synerise/ds-select": "^0.15.33",
42
+ "@synerise/ds-tooltip": "^0.14.16",
43
43
  "react-intl": "3.12.0"
44
44
  },
45
45
  "peerDependencies": {
@@ -53,5 +53,5 @@
53
53
  "@testing-library/jest-dom": "5.1.1",
54
54
  "@testing-library/user-event": "^10.3.1"
55
55
  },
56
- "gitHead": "16918244eff3f4e37db24ae3d90687d4e6a233a4"
56
+ "gitHead": "9e7d97fc5f8a9fd938b38e9d1678e050e0478e0e"
57
57
  }