@bolttech/atoms-date-input 0.1.1 → 0.1.2

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/index.cjs.js CHANGED
@@ -5,6 +5,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var react = require('react');
7
7
  var styled = require('styled-components');
8
+ var uiUtils = require('@bolttech/ui-utils');
9
+ var reactDom = require('react-dom');
10
+ var moleculesCalendar = require('@bolttech/molecules-calendar');
11
+ var atomsIcon = require('@bolttech/atoms-icon');
8
12
 
9
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
14
 
@@ -96,7 +100,7 @@ var check = function (it) {
96
100
  };
97
101
 
98
102
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
99
- var global$b =
103
+ var globalThis_1 =
100
104
  // eslint-disable-next-line es/no-global-this -- safe
101
105
  check(typeof globalThis == 'object' && globalThis) ||
102
106
  check(typeof window == 'object' && window) ||
@@ -109,30 +113,30 @@ var global$b =
109
113
 
110
114
  var sharedStore = {exports: {}};
111
115
 
112
- var global$a = global$b;
116
+ var globalThis$c = globalThis_1;
113
117
 
114
118
  // eslint-disable-next-line es/no-object-defineproperty -- safe
115
119
  var defineProperty$5 = Object.defineProperty;
116
120
 
117
121
  var defineGlobalProperty$3 = function (key, value) {
118
122
  try {
119
- defineProperty$5(global$a, key, { value: value, configurable: true, writable: true });
123
+ defineProperty$5(globalThis$c, key, { value: value, configurable: true, writable: true });
120
124
  } catch (error) {
121
- global$a[key] = value;
125
+ globalThis$c[key] = value;
122
126
  } return value;
123
127
  };
124
128
 
125
- var globalThis$1 = global$b;
129
+ var globalThis$b = globalThis_1;
126
130
  var defineGlobalProperty$2 = defineGlobalProperty$3;
127
131
 
128
132
  var SHARED = '__core-js_shared__';
129
- var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
133
+ var store$3 = sharedStore.exports = globalThis$b[SHARED] || defineGlobalProperty$2(SHARED, {});
130
134
 
131
135
  (store$3.versions || (store$3.versions = [])).push({
132
- version: '3.37.1',
136
+ version: '3.39.0',
133
137
  mode: 'global',
134
138
  copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
135
- license: 'https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE',
139
+ license: 'https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE',
136
140
  source: 'https://github.com/zloirock/core-js'
137
141
  });
138
142
 
@@ -174,13 +178,18 @@ var uid$2 = function (key) {
174
178
  return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
175
179
  };
176
180
 
177
- var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
181
+ var globalThis$a = globalThis_1;
178
182
 
179
- var global$9 = global$b;
180
- var userAgent = engineUserAgent;
183
+ var navigator = globalThis$a.navigator;
184
+ var userAgent$1 = navigator && navigator.userAgent;
181
185
 
182
- var process = global$9.process;
183
- var Deno = global$9.Deno;
186
+ var environmentUserAgent = userAgent$1 ? String(userAgent$1) : '';
187
+
188
+ var globalThis$9 = globalThis_1;
189
+ var userAgent = environmentUserAgent;
190
+
191
+ var process = globalThis$9.process;
192
+ var Deno = globalThis$9.Deno;
184
193
  var versions = process && process.versions || Deno && Deno.version;
185
194
  var v8 = versions && versions.v8;
186
195
  var match, version;
@@ -202,14 +211,14 @@ if (!version && userAgent) {
202
211
  }
203
212
  }
204
213
 
205
- var engineV8Version = version;
214
+ var environmentV8Version = version;
206
215
 
207
216
  /* eslint-disable es/no-symbol -- required for testing */
208
- var V8_VERSION = engineV8Version;
217
+ var V8_VERSION = environmentV8Version;
209
218
  var fails$8 = fails$b;
210
- var global$8 = global$b;
219
+ var globalThis$8 = globalThis_1;
211
220
 
212
- var $String$4 = global$8.String;
221
+ var $String$4 = globalThis$8.String;
213
222
 
214
223
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
215
224
  var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$8(function () {
@@ -226,18 +235,18 @@ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$8(func
226
235
  /* eslint-disable es/no-symbol -- required for testing */
227
236
  var NATIVE_SYMBOL$1 = symbolConstructorDetection;
228
237
 
229
- var useSymbolAsUid = NATIVE_SYMBOL$1
230
- && !Symbol.sham
231
- && typeof Symbol.iterator == 'symbol';
238
+ var useSymbolAsUid = NATIVE_SYMBOL$1 &&
239
+ !Symbol.sham &&
240
+ typeof Symbol.iterator == 'symbol';
232
241
 
233
- var global$7 = global$b;
242
+ var globalThis$7 = globalThis_1;
234
243
  var shared$2 = shared$3;
235
244
  var hasOwn$8 = hasOwnProperty_1;
236
245
  var uid$1 = uid$2;
237
246
  var NATIVE_SYMBOL = symbolConstructorDetection;
238
247
  var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
239
248
 
240
- var Symbol$1 = global$7.Symbol;
249
+ var Symbol$1 = globalThis$7.Symbol;
241
250
  var WellKnownSymbolsStore = shared$2('wks');
242
251
  var createWellKnownSymbol = USE_SYMBOL_AS_UID$1 ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
243
252
 
@@ -303,10 +312,10 @@ var v8PrototypeDefineBug = DESCRIPTORS$9 && fails$6(function () {
303
312
 
304
313
  var objectDefineProperty = {};
305
314
 
306
- var global$6 = global$b;
315
+ var globalThis$6 = globalThis_1;
307
316
  var isObject$6 = isObject$8;
308
317
 
309
- var document$1 = global$6.document;
318
+ var document$1 = globalThis$6.document;
310
319
  // typeof document.createElement is 'object' in old IE
311
320
  var EXISTS$1 = isObject$6(document$1) && isObject$6(document$1.createElement);
312
321
 
@@ -334,7 +343,7 @@ var functionCall = NATIVE_BIND ? call$5.bind(call$5) : function () {
334
343
  return call$5.apply(call$5, arguments);
335
344
  };
336
345
 
337
- var global$5 = global$b;
346
+ var globalThis$5 = globalThis_1;
338
347
  var isCallable$b = isCallable$d;
339
348
 
340
349
  var aFunction = function (argument) {
@@ -342,7 +351,7 @@ var aFunction = function (argument) {
342
351
  };
343
352
 
344
353
  var getBuiltIn$3 = function (namespace, method) {
345
- return arguments.length < 2 ? aFunction(global$5[namespace]) : global$5[namespace] && global$5[namespace][method];
354
+ return arguments.length < 2 ? aFunction(globalThis$5[namespace]) : globalThis$5[namespace] && globalThis$5[namespace][method];
346
355
  };
347
356
 
348
357
  var uncurryThis$6 = functionUncurryThis;
@@ -681,7 +690,8 @@ var NullProtoObjectViaActiveX = function (activeXDocument) {
681
690
  activeXDocument.write(scriptTag(''));
682
691
  activeXDocument.close();
683
692
  var temp = activeXDocument.parentWindow.Object;
684
- activeXDocument = null; // avoid memory leak
693
+ // eslint-disable-next-line no-useless-assignment -- avoid memory leak
694
+ activeXDocument = null;
685
695
  return temp;
686
696
  };
687
697
 
@@ -762,10 +772,10 @@ var addToUnscopables$1 = function (key) {
762
772
 
763
773
  var iterators = {};
764
774
 
765
- var global$4 = global$b;
775
+ var globalThis$4 = globalThis_1;
766
776
  var isCallable$7 = isCallable$d;
767
777
 
768
- var WeakMap$1 = global$4.WeakMap;
778
+ var WeakMap$1 = globalThis$4.WeakMap;
769
779
 
770
780
  var weakMapBasicDetection = isCallable$7(WeakMap$1) && /native code/.test(String(WeakMap$1));
771
781
 
@@ -790,7 +800,7 @@ var createNonEnumerableProperty$4 = DESCRIPTORS$5 ? function (object, key, value
790
800
  };
791
801
 
792
802
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
793
- var global$3 = global$b;
803
+ var globalThis$3 = globalThis_1;
794
804
  var isObject$3 = isObject$8;
795
805
  var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
796
806
  var hasOwn$6 = hasOwnProperty_1;
@@ -799,8 +809,8 @@ var sharedKey$1 = sharedKey$3;
799
809
  var hiddenKeys$1 = hiddenKeys$4;
800
810
 
801
811
  var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
802
- var TypeError$1 = global$3.TypeError;
803
- var WeakMap = global$3.WeakMap;
812
+ var TypeError$1 = globalThis$3.TypeError;
813
+ var WeakMap = globalThis$3.WeakMap;
804
814
  var set, get, has;
805
815
 
806
816
  var enforce = function (it) {
@@ -1093,7 +1103,7 @@ var POLYFILL = isForced$1.POLYFILL = 'P';
1093
1103
 
1094
1104
  var isForced_1 = isForced$1;
1095
1105
 
1096
- var global$2 = global$b;
1106
+ var globalThis$2 = globalThis_1;
1097
1107
  var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1098
1108
  var createNonEnumerableProperty$2 = createNonEnumerableProperty$4;
1099
1109
  var defineBuiltIn$2 = defineBuiltIn$3;
@@ -1122,11 +1132,11 @@ var _export = function (options, source) {
1122
1132
  var STATIC = options.stat;
1123
1133
  var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1124
1134
  if (GLOBAL) {
1125
- target = global$2;
1135
+ target = globalThis$2;
1126
1136
  } else if (STATIC) {
1127
- target = global$2[TARGET] || defineGlobalProperty(TARGET, {});
1137
+ target = globalThis$2[TARGET] || defineGlobalProperty(TARGET, {});
1128
1138
  } else {
1129
- target = global$2[TARGET] && global$2[TARGET].prototype;
1139
+ target = globalThis$2[TARGET] && globalThis$2[TARGET].prototype;
1130
1140
  }
1131
1141
  if (target) for (key in source) {
1132
1142
  sourceProperty = source[key];
@@ -1452,7 +1462,7 @@ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind)
1452
1462
  var target = state.target;
1453
1463
  var index = state.index++;
1454
1464
  if (!target || index >= target.length) {
1455
- state.target = undefined;
1465
+ state.target = null;
1456
1466
  return createIterResultObject(undefined, true);
1457
1467
  }
1458
1468
  switch (state.kind) {
@@ -1587,7 +1597,7 @@ var DOMTokenListPrototype$1 = classList && classList.constructor && classList.co
1587
1597
 
1588
1598
  var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
1589
1599
 
1590
- var global$1 = global$b;
1600
+ var globalThis$1 = globalThis_1;
1591
1601
  var DOMIterables = domIterables;
1592
1602
  var DOMTokenListPrototype = domTokenListPrototype;
1593
1603
  var ArrayIteratorMethods = es_array_iterator;
@@ -1619,7 +1629,7 @@ var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
1619
1629
  };
1620
1630
 
1621
1631
  for (var COLLECTION_NAME in DOMIterables) {
1622
- handlePrototype(global$1[COLLECTION_NAME] && global$1[COLLECTION_NAME].prototype, COLLECTION_NAME);
1632
+ handlePrototype(globalThis$1[COLLECTION_NAME] && globalThis$1[COLLECTION_NAME].prototype, COLLECTION_NAME);
1623
1633
  }
1624
1634
 
1625
1635
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
@@ -1637,7 +1647,11 @@ let _ = t => t,
1637
1647
  _t10,
1638
1648
  _t11,
1639
1649
  _t12,
1640
- _t13;
1650
+ _t13,
1651
+ _t14,
1652
+ _t15,
1653
+ _t16,
1654
+ _t17;
1641
1655
  const Label = styled__default["default"].label(_t || (_t = _`
1642
1656
  ${0}
1643
1657
  `), ({
@@ -1655,6 +1669,7 @@ const Label = styled__default["default"].label(_t || (_t = _`
1655
1669
  theme
1656
1670
  }) => theme.components.input[$variant].text.color.required.default));
1657
1671
  const InputWrapper = styled__default["default"].div(_t3 || (_t3 = _`
1672
+ position: relative;
1658
1673
  display: flex;
1659
1674
  flex-direction: column;
1660
1675
  font-weight: ${0};
@@ -1697,6 +1712,7 @@ const InputWrapper = styled__default["default"].div(_t3 || (_t3 = _`
1697
1712
  const Container = styled__default["default"].div(_t5 || (_t5 = _`
1698
1713
  display: flex;
1699
1714
  flex: 1;
1715
+ align-items: center;
1700
1716
  padding: ${0};
1701
1717
  background-color: ${0};
1702
1718
  margin-bottom: ${0};
@@ -1895,6 +1911,42 @@ const Error = styled__default["default"].span(_t13 || (_t13 = _`
1895
1911
  }) => theme.components.input.error.letterSpacing, ({
1896
1912
  theme
1897
1913
  }) => theme.components.input.paddingHorizontal);
1914
+ const OpenAnimation = styled.keyframes(_t14 || (_t14 = _`
1915
+ 100% { opacity: 1; }
1916
+ `));
1917
+ styled__default["default"].div(_t15 || (_t15 = _`
1918
+ position: relative;
1919
+
1920
+ ${0}
1921
+ `), ({
1922
+ disabled
1923
+ }) => disabled && styled.css(_t16 || (_t16 = _`
1924
+ pointer-events: none;
1925
+ `)));
1926
+ const CalendarContainer = styled__default["default"].div(_t17 || (_t17 = _`
1927
+ position: absolute;
1928
+ z-index: 2;
1929
+ left: 0;
1930
+ animation-delay: 1ms;
1931
+ animation-duration: 250ms;
1932
+ animation-fill-mode: forwards;
1933
+ animation-name: ${0};
1934
+ animation-timing-function: ease-in-out;
1935
+ opacity: 0;
1936
+
1937
+ &.top {
1938
+ transform: translateY(-100%);
1939
+ top: -${0};
1940
+ }
1941
+
1942
+ &.bottom {
1943
+ top: ${0};
1944
+ }
1945
+ `), OpenAnimation, ({
1946
+ theme
1947
+ }) => theme.components.input.borderWidth.default, ({
1948
+ theme
1949
+ }) => `calc(100% + ${theme.components.input.borderWidth.default})`);
1898
1950
 
1899
1951
  const DateInput = /*#__PURE__*/react.forwardRef(({
1900
1952
  id: _id = 'date-of-birth-input-id',
@@ -1905,17 +1957,31 @@ const DateInput = /*#__PURE__*/react.forwardRef(({
1905
1957
  required,
1906
1958
  disabled,
1907
1959
  value,
1960
+ min,
1961
+ max,
1962
+ locale,
1963
+ cancel,
1964
+ confirm,
1965
+ showDatepicker,
1908
1966
  onChange,
1909
1967
  onBlur
1910
1968
  }, ref) => {
1911
1969
  const [, forceUpdate] = react.useReducer(x => x + 1, 0);
1970
+ const calendarRef = react.useRef(null);
1971
+ const containerRef = react.useRef(null);
1972
+ const dayInputRef = react.useRef(null);
1912
1973
  const day = react.useRef(value ? String(value).substring(0, 2) : '');
1913
1974
  const month = react.useRef(value ? String(value).substring(3, 5) : '');
1914
1975
  const year = react.useRef(value ? String(value).substring(6, 10) : '');
1976
+ const [isCalendarOpen, setIsCalendarOpen] = react.useState(false);
1977
+ const {
1978
+ addOpenPositionClass
1979
+ } = uiUtils.useOpenPosition(calendarRef, containerRef, ['top', 'bottom'], 'bottom');
1915
1980
  const updateDate = e => {
1981
+ const value = !year.current && !month.current && !day.current ? '' : `${year.current}-${month.current}-${day.current}`;
1916
1982
  onChange && onChange(Object.assign(Object.assign({}, e), {
1917
1983
  target: Object.assign(Object.assign({}, e.target), {
1918
- value: `${year.current}-${month.current}-${day.current}`
1984
+ value
1919
1985
  })
1920
1986
  }));
1921
1987
  };
@@ -1948,30 +2014,69 @@ const DateInput = /*#__PURE__*/react.forwardRef(({
1948
2014
  // @ts-ignore
1949
2015
  onBlur(`${year.current}-${month.current}-${day.current}`);
1950
2016
  };
2017
+ const handleFocus = () => {
2018
+ setIsCalendarOpen(false);
2019
+ };
1951
2020
  const handleNextInput = next => {
1952
2021
  const input = document.getElementById(`${_id}-input-${next}`);
1953
2022
  input === null || input === void 0 ? void 0 : input.focus();
1954
2023
  };
2024
+ const handleCancel = react.useCallback(() => {
2025
+ setIsCalendarOpen(false);
2026
+ }, []);
2027
+ const handleConfirm = react.useCallback(date => {
2028
+ setInputValue(date);
2029
+ setIsCalendarOpen(false);
2030
+ updateDate({});
2031
+ }, [onChange]);
1955
2032
  react.useEffect(() => {
1956
2033
  if (!value || typeof value !== 'string') return;
2034
+ setInputValue(value);
2035
+ }, [value]);
2036
+ const setInputValue = value => {
1957
2037
  const [yearValue, monthValue, dayValue] = value.split('-');
1958
- day.current = dayValue;
1959
- month.current = monthValue;
1960
- year.current = yearValue;
2038
+ day.current = dayValue || '';
2039
+ month.current = monthValue || '';
2040
+ year.current = yearValue || '';
1961
2041
  forceUpdate();
1962
- }, [value]);
2042
+ };
2043
+ const onClickIcon = () => {
2044
+ var _a;
2045
+ reactDom.flushSync(() => {
2046
+ var _a, _b;
2047
+ if (disabled) return;
2048
+ if (isCalendarOpen) {
2049
+ (_a = dayInputRef === null || dayInputRef === void 0 ? void 0 : dayInputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
2050
+ }
2051
+ setIsCalendarOpen(!isCalendarOpen);
2052
+ (_b = dayInputRef === null || dayInputRef === void 0 ? void 0 : dayInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
2053
+ });
2054
+ if (!isCalendarOpen) {
2055
+ (_a = calendarRef === null || calendarRef === void 0 ? void 0 : calendarRef.current) === null || _a === void 0 ? void 0 : _a.focus({
2056
+ preventScroll: true
2057
+ });
2058
+ }
2059
+ addOpenPositionClass();
2060
+ };
2061
+ const onBlurCalendar = event => {
2062
+ var _a;
2063
+ if (!((_a = calendarRef === null || calendarRef === void 0 ? void 0 : calendarRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.relatedTarget)) || !event.relatedTarget) {
2064
+ setIsCalendarOpen(false);
2065
+ }
2066
+ };
1963
2067
  return jsxRuntime.jsxs(InputWrapper, {
1964
2068
  disabled: !!disabled,
1965
2069
  "data-testid": _dataTestId,
1966
2070
  "$variant": _variant,
1967
2071
  ref: ref,
1968
- children: [jsxRuntime.jsx(Container, {
2072
+ children: [jsxRuntime.jsxs(Container, {
1969
2073
  id: `${_id}-container`,
1970
2074
  "data-testid": `${_dataTestId}-container`,
2075
+ ref: containerRef,
1971
2076
  "$hasError": !!errorMessage,
1972
2077
  "$hasValue": !!value && value !== '',
1973
2078
  "$variant": _variant,
1974
- children: jsxRuntime.jsxs(LeftContainer, {
2079
+ children: [jsxRuntime.jsxs(LeftContainer, {
1975
2080
  "$before": false,
1976
2081
  children: [label && jsxRuntime.jsx(Label, {
1977
2082
  id: `${_id}-label`,
@@ -1981,53 +2086,84 @@ const DateInput = /*#__PURE__*/react.forwardRef(({
1981
2086
  "$variant": _variant,
1982
2087
  children: label
1983
2088
  }), jsxRuntime.jsxs(LeftContainer, {
1984
- "$direction": 'row',
2089
+ "$direction": "row",
1985
2090
  "$variant": _variant,
1986
2091
  "$before": true,
1987
2092
  children: [jsxRuntime.jsx(Input, {
2093
+ ref: dayInputRef,
1988
2094
  id: `${_id}-input-day`,
1989
2095
  "data-testid": `${_dataTestId}-input-day`,
1990
- type: 'number',
2096
+ type: "number",
1991
2097
  pattern: "[0-9]*",
1992
2098
  disabled: disabled,
1993
2099
  value: day.current,
1994
2100
  required: required,
1995
2101
  "$variant": _variant,
1996
- "$width": '40px',
1997
- placeholder: 'DD',
2102
+ "$width": "40px",
2103
+ placeholder: "DD",
1998
2104
  onChange: handleDayChange,
1999
2105
  onBlur: handleBlur,
2106
+ onFocus: handleFocus,
2000
2107
  maxLength: 2
2001
2108
  }), jsxRuntime.jsx(Input, {
2002
2109
  id: `${_id}-input-month`,
2003
2110
  "data-testid": `${_dataTestId}-input-month`,
2004
- type: 'number',
2111
+ type: "number",
2005
2112
  pattern: "[0-9]*",
2006
2113
  disabled: disabled,
2007
2114
  value: month.current,
2008
2115
  required: required,
2009
2116
  "$variant": _variant,
2010
- "$width": '43px',
2011
- placeholder: 'MM',
2117
+ "$width": "43px",
2118
+ placeholder: "MM",
2012
2119
  onChange: handleMonthChange,
2013
2120
  onBlur: handleBlur,
2121
+ onFocus: handleFocus,
2014
2122
  maxLength: 2
2015
2123
  }), jsxRuntime.jsx(Input, {
2016
2124
  id: `${_id}-input-year`,
2017
2125
  "data-testid": `${_dataTestId}-input-year`,
2018
- type: 'number',
2126
+ type: "number",
2019
2127
  pattern: "[0-9]*",
2020
2128
  disabled: disabled,
2021
2129
  value: year.current,
2022
2130
  required: required,
2023
2131
  "$variant": _variant,
2024
- "$width": '60px',
2025
- placeholder: 'YYYY',
2132
+ "$width": "60px",
2133
+ placeholder: "YYYY",
2026
2134
  onChange: handleYearChange,
2027
2135
  onBlur: handleBlur,
2136
+ onFocus: handleFocus,
2028
2137
  maxLength: 4
2029
2138
  })]
2030
2139
  })]
2140
+ }), showDatepicker && jsxRuntime.jsx(Icon, {
2141
+ id: `${_id}-icon`,
2142
+ "data-testid": `${_dataTestId}-button-icon`,
2143
+ onClick: onClickIcon,
2144
+ "$hasError": !!errorMessage,
2145
+ "$variant": _variant,
2146
+ children: jsxRuntime.jsx(atomsIcon.Icon, {
2147
+ "data-testid": `${_dataTestId}-icon`,
2148
+ icon: 'calendar_month'
2149
+ })
2150
+ })]
2151
+ }), isCalendarOpen && jsxRuntime.jsx(CalendarContainer, {
2152
+ ref: calendarRef,
2153
+ onClick: event => event.stopPropagation(),
2154
+ tabIndex: 1,
2155
+ onBlur: onBlurCalendar,
2156
+ children: jsxRuntime.jsx(moleculesCalendar.Calendar, {
2157
+ id: `${_id}-calendar`,
2158
+ dataTestId: `${_dataTestId}-calendar`,
2159
+ locale: locale,
2160
+ min: min,
2161
+ max: max,
2162
+ value: value,
2163
+ cancel: cancel,
2164
+ confirm: confirm,
2165
+ onCancel: handleCancel,
2166
+ onChange: handleConfirm
2031
2167
  })
2032
2168
  }), !!errorMessage && jsxRuntime.jsx(Error, {
2033
2169
  id: `${_id}-error`,
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@bolttech/atoms-date-input",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "peerDependencies": {
5
- "@bolttech/atoms-input": "^0.26.1"
5
+ "@bolttech/atoms-input": "^0.26.1",
6
+ "@bolttech/molecules-calendar": "^0.25.1",
7
+ "@bolttech/ui-utils": "^0.5.0"
6
8
  },
7
9
  "main": "./index.cjs.js",
8
10
  "type": "commonjs",
9
11
  "dependencies": {
10
12
  "react": "18.2.0",
11
- "styled-components": "5.3.11"
13
+ "react-dom": "18.2.0",
14
+ "styled-components": "6.1.13"
12
15
  }
13
16
  }
package/src/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './lib/date-input';
2
+ export type { DateInputProps } from './lib/date-input.type';
@@ -1,16 +1,5 @@
1
1
  /// <reference types="react" />
2
- declare const DateInput: import("react").ForwardRefExoticComponent<import("@bolttech/ui-utils").DefaultProps & Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "className"> & {
3
- label?: string | undefined;
4
- errorMessage?: string | undefined;
5
- helperMessage?: string | undefined;
6
- variant?: import("@bolttech/atoms-input/src/lib/atoms-input.type").InputVariants | undefined;
7
- dataTestId?: string | undefined;
8
- icon?: string | undefined;
9
- required?: boolean | undefined;
10
- onClickIcon?: (() => void) | undefined;
11
- onBlur?: ((value: unknown) => void) | ((evt: import("react").FocusEvent<HTMLInputElement, Element>) => void) | undefined;
12
- onFocus?: ((value: unknown) => void) | ((evt: import("react").FocusEvent<HTMLInputElement, Element>) => void) | undefined;
13
- onChange?: ((value: unknown) => void) | ((evt: import("react").ChangeEvent<HTMLInputElement>) => void) | undefined;
14
- } & import("react").RefAttributes<HTMLInputElement>>;
2
+ import { DateInputProps } from './date-input.type';
3
+ declare const DateInput: React.ForwardRefExoticComponent<React.PropsWithoutRef<DateInputProps> & React.RefAttributes<HTMLInputElement>>;
15
4
  export default DateInput;
16
5
  export { DateInput };
@@ -29,3 +29,7 @@ export declare const Icon: import("styled-components/dist/types").IStyledCompone
29
29
  export declare const Error: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
30
30
  $variant: InputVariants;
31
31
  }>> & string;
32
+ export declare const DatePickerContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
33
+ disabled?: boolean | undefined;
34
+ }>> & string;
35
+ export declare const CalendarContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -0,0 +1,10 @@
1
+ import { InputProps } from '@bolttech/atoms-input';
2
+ export type DateInputProps = InputProps & {
3
+ max: Date;
4
+ min: Date;
5
+ value: string | undefined;
6
+ locale: string;
7
+ showDatepicker?: boolean;
8
+ cancel?: string;
9
+ confirm?: string;
10
+ };