@pingux/astro 2.135.0-alpha.0 → 2.135.0-alpha.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.
@@ -142,6 +142,11 @@ input.fieldControlWrapper = (_input$fieldControlWr = {
142
142
  opacity: 0.5
143
143
  }
144
144
  },
145
+ '&.is-invalid': {
146
+ '&:after': {
147
+ bg: 'critical.bright'
148
+ }
149
+ },
145
150
  '&.is-read-only': {
146
151
  '> input': {
147
152
  backgroundColor: 'accent.95',
@@ -59,19 +59,21 @@ var TimeField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
59
59
  var state = (0, _datepicker2.useTimeFieldState)(_objectSpread(_objectSpread(_objectSpread({}, props), parsedTimes), {}, {
60
60
  locale: locale
61
61
  }));
62
- var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
63
- isDisabled: isDisabled,
64
- isReadOnly: isReadOnly,
65
- is24Hour: props.hourCycle === 24
66
- }),
67
- classNames = _useStatusClasses.classNames;
68
62
  var _useTimeField = (0, _datepicker.useTimeField)(_objectSpread(_objectSpread({}, props), parsedTimes), state, fieldRef),
69
- fieldProps = _useTimeField.fieldProps;
63
+ fieldProps = _useTimeField.fieldProps,
64
+ isInvalid = _useTimeField.isInvalid;
70
65
  var _useField = (0, _hooks.useField)(_objectSpread(_objectSpread({}, others), {}, {
71
66
  value: (state === null || state === void 0 || (_state$value = state.value) === null || _state$value === void 0 ? void 0 : _state$value.toString()) || ''
72
67
  })),
73
68
  fieldContainerProps = _useField.fieldContainerProps,
74
69
  fieldLabelProps = _useField.fieldLabelProps;
70
+ var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
71
+ isDisabled: isDisabled,
72
+ isReadOnly: isReadOnly,
73
+ isInvalid: isInvalid,
74
+ is24Hour: props.hourCycle === 24
75
+ }),
76
+ classNames = _useStatusClasses.classNames;
75
77
  return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
76
78
  variant: "forms.input.fieldContainer"
77
79
  }, fieldContainerProps, {
@@ -9,3 +9,4 @@ export declare const Disabled: StoryFn<TimeFieldProps>;
9
9
  export declare const ReadOnly: StoryFn<TimeFieldProps>;
10
10
  export declare const Required: StoryFn<TimeFieldProps>;
11
11
  export declare const WithLabel: StoryFn<TimeFieldProps>;
12
+ export declare const Invalid: StoryFn<TimeFieldProps>;
@@ -8,7 +8,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
8
8
  _Object$defineProperty(exports, "__esModule", {
9
9
  value: true
10
10
  });
11
- exports["default"] = exports.WithLabel = exports.Required = exports.ReadOnly = exports.Disabled = exports.DefaultValue = exports.Default = exports.Controlled = void 0;
11
+ exports["default"] = exports.WithLabel = exports.Required = exports.ReadOnly = exports.Invalid = exports.Disabled = exports.DefaultValue = exports.Default = exports.Controlled = void 0;
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
13
13
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
14
14
  var _react = _interopRequireWildcard(require("react"));
@@ -98,4 +98,20 @@ var WithLabel = function WithLabel(args) {
98
98
  "aria-label": "timefield-default"
99
99
  }));
100
100
  };
101
- exports.WithLabel = WithLabel;
101
+ exports.WithLabel = WithLabel;
102
+ var Invalid = function Invalid() {
103
+ var _useState3 = (0, _react.useState)('02:30'),
104
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
105
+ time = _useState4[0],
106
+ setTime = _useState4[1];
107
+ var onChangeHandler = function onChangeHandler(value) {
108
+ return setTime(value.toString());
109
+ };
110
+ return (0, _react2.jsx)(_index.TimeField, {
111
+ "aria-label": "timefield-default",
112
+ value: time,
113
+ onChange: onChangeHandler,
114
+ isInvalid: true
115
+ });
116
+ };
117
+ exports.Invalid = Invalid;
@@ -19,6 +19,9 @@ declare const _default: {
19
19
  '&.is-24-hour': {
20
20
  minWidth: string;
21
21
  };
22
+ '&.is-invalid': {
23
+ borderColor: string;
24
+ };
22
25
  grid?: import("theme-ui").StylePropertyValue<import("csstype").Property.Grid | undefined>;
23
26
  accentColor?: import("theme-ui").StylePropertyValue<import("csstype").Property.AccentColor | undefined>;
24
27
  alignContent?: import("theme-ui").StylePropertyValue<import("csstype").Property.AlignContent | undefined>;
@@ -31,6 +31,9 @@ var inputField = _objectSpread(_objectSpread({}, _Input.input), {}, {
31
31
  },
32
32
  '&.is-24-hour': {
33
33
  minWidth: '0px'
34
+ },
35
+ '&.is-invalid': {
36
+ borderColor: 'critical.bright'
34
37
  }
35
38
  });
36
39
  var segment = {
@@ -93,6 +93,15 @@ test('renders TimeField component with isReadOnly', function () {
93
93
  expect(segment).toHaveAttribute('aria-readonly', 'true');
94
94
  });
95
95
  });
96
+ test('renders TimeField component with isInvalid', function () {
97
+ getComponent({
98
+ isInvalid: true
99
+ });
100
+ var timeSegments = _testWrapper.screen.getAllByRole('spinbutton');
101
+ (0, _forEach["default"])(timeSegments).call(timeSegments, function (segment) {
102
+ expect(segment).toHaveAttribute('aria-invalid', 'true');
103
+ });
104
+ });
96
105
  test('should handle autofocus when deleting segments from left to right', function () {
97
106
  var defaultValue = new _date.Time(12, 30);
98
107
  getComponent({
@@ -134,6 +134,11 @@ input.fieldControlWrapper = (_input$fieldControlWr = {
134
134
  opacity: 0.5
135
135
  }
136
136
  },
137
+ '&.is-invalid': {
138
+ '&:after': {
139
+ bg: 'critical.bright'
140
+ }
141
+ },
137
142
  '&.is-read-only': {
138
143
  '> input': {
139
144
  backgroundColor: 'accent.95',
@@ -47,19 +47,21 @@ var TimeField = /*#__PURE__*/forwardRef(function (props, ref) {
47
47
  var state = useTimeFieldState(_objectSpread(_objectSpread(_objectSpread({}, props), parsedTimes), {}, {
48
48
  locale: locale
49
49
  }));
50
- var _useStatusClasses = useStatusClasses(className, {
51
- isDisabled: isDisabled,
52
- isReadOnly: isReadOnly,
53
- is24Hour: props.hourCycle === 24
54
- }),
55
- classNames = _useStatusClasses.classNames;
56
50
  var _useTimeField = useTimeField(_objectSpread(_objectSpread({}, props), parsedTimes), state, fieldRef),
57
- fieldProps = _useTimeField.fieldProps;
51
+ fieldProps = _useTimeField.fieldProps,
52
+ isInvalid = _useTimeField.isInvalid;
58
53
  var _useField = useField(_objectSpread(_objectSpread({}, others), {}, {
59
54
  value: (state === null || state === void 0 || (_state$value = state.value) === null || _state$value === void 0 ? void 0 : _state$value.toString()) || ''
60
55
  })),
61
56
  fieldContainerProps = _useField.fieldContainerProps,
62
57
  fieldLabelProps = _useField.fieldLabelProps;
58
+ var _useStatusClasses = useStatusClasses(className, {
59
+ isDisabled: isDisabled,
60
+ isReadOnly: isReadOnly,
61
+ isInvalid: isInvalid,
62
+ is24Hour: props.hourCycle === 24
63
+ }),
64
+ classNames = _useStatusClasses.classNames;
63
65
  return ___EmotionJSX(Box, _extends({
64
66
  variant: "forms.input.fieldContainer"
65
67
  }, fieldContainerProps, {
@@ -77,4 +77,19 @@ export var WithLabel = function WithLabel(args) {
77
77
  label: "Lorem Ipsum",
78
78
  "aria-label": "timefield-default"
79
79
  }));
80
+ };
81
+ export var Invalid = function Invalid() {
82
+ var _useState3 = useState('02:30'),
83
+ _useState4 = _slicedToArray(_useState3, 2),
84
+ time = _useState4[0],
85
+ setTime = _useState4[1];
86
+ var onChangeHandler = function onChangeHandler(value) {
87
+ return setTime(value.toString());
88
+ };
89
+ return ___EmotionJSX(TimeField, {
90
+ "aria-label": "timefield-default",
91
+ value: time,
92
+ onChange: onChangeHandler,
93
+ isInvalid: true
94
+ });
80
95
  };
@@ -24,6 +24,9 @@ var inputField = _objectSpread(_objectSpread({}, input), {}, {
24
24
  },
25
25
  '&.is-24-hour': {
26
26
  minWidth: '0px'
27
+ },
28
+ '&.is-invalid': {
29
+ borderColor: 'critical.bright'
27
30
  }
28
31
  });
29
32
  var segment = {
@@ -90,6 +90,15 @@ test('renders TimeField component with isReadOnly', function () {
90
90
  expect(segment).toHaveAttribute('aria-readonly', 'true');
91
91
  });
92
92
  });
93
+ test('renders TimeField component with isInvalid', function () {
94
+ getComponent({
95
+ isInvalid: true
96
+ });
97
+ var timeSegments = screen.getAllByRole('spinbutton');
98
+ _forEachInstanceProperty(timeSegments).call(timeSegments, function (segment) {
99
+ expect(segment).toHaveAttribute('aria-invalid', 'true');
100
+ });
101
+ });
93
102
  test('should handle autofocus when deleting segments from left to right', function () {
94
103
  var defaultValue = new Time(12, 30);
95
104
  getComponent({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.135.0-alpha.0",
3
+ "version": "2.135.0-alpha.1",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",