@ornikar/kitt-universal 4.6.1 → 5.0.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.
Files changed (31) hide show
  1. package/dist/definitions/Button/AnimatedButtonPressable.web.d.ts +3 -4
  2. package/dist/definitions/Button/AnimatedButtonPressable.web.d.ts.map +1 -1
  3. package/dist/definitions/forms/Checkbox/Checkbox.d.ts.map +1 -1
  4. package/dist/definitions/forms/DatePicker/DatePicker.d.ts +2 -28
  5. package/dist/definitions/forms/DatePicker/DatePicker.d.ts.map +1 -1
  6. package/dist/definitions/forms/DatePicker/DatePicker.web.d.ts +4 -0
  7. package/dist/definitions/forms/DatePicker/DatePicker.web.d.ts.map +1 -0
  8. package/dist/definitions/forms/DatePicker/DatePickerAndroid.d.ts +12 -0
  9. package/dist/definitions/forms/DatePicker/DatePickerAndroid.d.ts.map +1 -0
  10. package/dist/definitions/forms/DatePicker/DatePickerInputs.d.ts +9 -0
  11. package/dist/definitions/forms/DatePicker/DatePickerInputs.d.ts.map +1 -0
  12. package/dist/definitions/forms/DatePicker/types.d.ts +34 -0
  13. package/dist/definitions/forms/DatePicker/types.d.ts.map +1 -0
  14. package/dist/definitions/index.d.ts +1 -1
  15. package/dist/definitions/index.d.ts.map +1 -1
  16. package/dist/index-browser-all.es.android.js +214 -142
  17. package/dist/index-browser-all.es.android.js.map +1 -1
  18. package/dist/index-browser-all.es.ios.js +214 -142
  19. package/dist/index-browser-all.es.ios.js.map +1 -1
  20. package/dist/index-browser-all.es.js +214 -142
  21. package/dist/index-browser-all.es.js.map +1 -1
  22. package/dist/index-browser-all.es.web.js +529 -667
  23. package/dist/index-browser-all.es.web.js.map +1 -1
  24. package/dist/index-node-14.17.cjs.js +160 -95
  25. package/dist/index-node-14.17.cjs.js.map +1 -1
  26. package/dist/index-node-14.17.cjs.web.css +1 -1
  27. package/dist/index-node-14.17.cjs.web.js +409 -525
  28. package/dist/index-node-14.17.cjs.web.js.map +1 -1
  29. package/dist/styles.css +1 -1
  30. package/dist/tsbuildinfo +1 -1
  31. package/package.json +4 -4
@@ -10,9 +10,9 @@ const jsxRuntime = require('react/jsx-runtime');
10
10
  const Animated = require('react-native-reanimated');
11
11
  const twemojiParser = require('twemoji-parser');
12
12
  const WebBrowser = require('expo-web-browser');
13
+ const DateTimePicker = require('@react-native-community/datetimepicker');
13
14
  const reactIntl = require('react-intl');
14
15
  const react$1 = require('@linaria/react');
15
- const DateTimePicker = require('@react-native-community/datetimepicker');
16
16
  const reactNativeSafeAreaContext = require('react-native-safe-area-context');
17
17
  const expoLinearGradient = require('expo-linear-gradient');
18
18
  const reactNative$1 = require('@floating-ui/react-native');
@@ -1484,7 +1484,7 @@ function useKittTheme() {
1484
1484
  const CheckboxAndLabelPressableWrapper = /*#__PURE__*/styled__default.Pressable.withConfig({
1485
1485
  displayName: "Checkbox__CheckboxAndLabelPressableWrapper",
1486
1486
  componentId: "kitt-universal__sc-1sav1n6-0"
1487
- })(["display:flex;flex-direction:row;align-items:center;"]);
1487
+ })(["display:flex;flex-direction:row;"]);
1488
1488
  const CheckboxContainer = /*#__PURE__*/styled__default.View.withConfig({
1489
1489
  displayName: "Checkbox__CheckboxContainer",
1490
1490
  componentId: "kitt-universal__sc-1sav1n6-1"
@@ -1624,6 +1624,129 @@ function DatePickerInputPart({
1624
1624
  });
1625
1625
  }
1626
1626
 
1627
+ function prefixWithZero(value) {
1628
+ return `${value}`.padStart(2, '0');
1629
+ }
1630
+
1631
+ const PartContainer = /*#__PURE__*/styled__default.View.withConfig({
1632
+ displayName: "DatePickerInputs__PartContainer",
1633
+ componentId: "kitt-universal__sc-j9hin5-0"
1634
+ })(["margin-right:", ";", ";"], ({
1635
+ theme,
1636
+ $isLast
1637
+ }) => !$isLast ? `${theme.kitt.spacing * 2}px` : 0, ({
1638
+ $isStretch
1639
+ }) => $isStretch ? styled.css(["flex:0.33;flex-grow:1;"]) : undefined);
1640
+ const DatePickerPressable = /*#__PURE__*/styled__default.Pressable.withConfig({
1641
+ displayName: "DatePickerInputs__DatePickerPressable",
1642
+ componentId: "kitt-universal__sc-j9hin5-1"
1643
+ })(["display:flex;flex-direction:row;", ";"], ({
1644
+ $isStretch
1645
+ }) => {
1646
+ if ($isStretch) {
1647
+ return styled.css(["width:100%;"]);
1648
+ }
1649
+
1650
+ return styled.css(["align-self:baseline;"]);
1651
+ });
1652
+ function DatePickerInputs({
1653
+ state,
1654
+ internalForceState,
1655
+ isFocused,
1656
+ disabled,
1657
+ stretch,
1658
+ id,
1659
+ testID,
1660
+ handleModalOpen,
1661
+ currentValue,
1662
+ placeholder
1663
+ }) {
1664
+ const currentState = internalForceState || getInputUIState({
1665
+ isFocused,
1666
+ isDisabled: Boolean(disabled),
1667
+ formState: state
1668
+ });
1669
+ const sharedPartProps = {
1670
+ disabled,
1671
+ $state: currentState
1672
+ };
1673
+ return /*#__PURE__*/jsxRuntime.jsxs(DatePickerPressable, {
1674
+ $isStretch: stretch,
1675
+ nativeID: id,
1676
+ disabled: disabled,
1677
+ testID: testID,
1678
+ onPress: handleModalOpen,
1679
+ children: [/*#__PURE__*/jsxRuntime.jsx(PartContainer, {
1680
+ $isStretch: stretch,
1681
+ children: /*#__PURE__*/jsxRuntime.jsx(DatePickerInputPart, { ...sharedPartProps,
1682
+ partName: "day",
1683
+ value: currentValue ? prefixWithZero(currentValue.getDate()) : undefined,
1684
+ placeholder: placeholder?.day
1685
+ })
1686
+ }), /*#__PURE__*/jsxRuntime.jsx(PartContainer, {
1687
+ $isStretch: stretch,
1688
+ children: /*#__PURE__*/jsxRuntime.jsx(DatePickerInputPart, { ...sharedPartProps,
1689
+ partName: "month",
1690
+ value: currentValue ? prefixWithZero(currentValue.getMonth() + 1) : undefined,
1691
+ placeholder: placeholder?.month
1692
+ })
1693
+ }), /*#__PURE__*/jsxRuntime.jsx(PartContainer, {
1694
+ $isLast: true,
1695
+ $isStretch: stretch,
1696
+ children: /*#__PURE__*/jsxRuntime.jsx(DatePickerInputPart, { ...sharedPartProps,
1697
+ partName: "year",
1698
+ value: currentValue ? currentValue.getFullYear() : undefined,
1699
+ placeholder: placeholder?.year
1700
+ })
1701
+ })]
1702
+ });
1703
+ }
1704
+
1705
+ function DatePickerAndroid({
1706
+ onBlur,
1707
+ onFocus,
1708
+ pickerDefaultDate,
1709
+ pickerUITestID,
1710
+ setIsFocused,
1711
+ currentValue,
1712
+ setCurrentValue,
1713
+ onChange,
1714
+ isFocused,
1715
+ ...props
1716
+ }) {
1717
+ const handleClose = () => {
1718
+ if (onBlur) onBlur();
1719
+ };
1720
+
1721
+ return /*#__PURE__*/jsxRuntime.jsx(DatePickerInputs, {
1722
+ handleModalOpen: () => {
1723
+ setIsFocused(true);
1724
+ if (onFocus) onFocus();
1725
+ DateTimePicker.DateTimePickerAndroid.open({
1726
+ testID: pickerUITestID,
1727
+ value: currentValue || pickerDefaultDate || new Date(Date.now()),
1728
+ onChange: e => {
1729
+ setIsFocused(false);
1730
+ const {
1731
+ timestamp
1732
+ } = e.nativeEvent;
1733
+
1734
+ if (timestamp) {
1735
+ const date = new Date(timestamp);
1736
+ setCurrentValue(date);
1737
+ onChange(date);
1738
+ handleClose();
1739
+ }
1740
+ },
1741
+ onTouchCancel: handleClose
1742
+ });
1743
+ },
1744
+ currentValue: currentValue,
1745
+ isFocused: isFocused,
1746
+ ...props
1747
+ });
1748
+ }
1749
+
1627
1750
  // Don't use styled.Pressable here - babel-plugin-styled-components-react-native-web only supports tagged templates
1628
1751
  const OverlayPressable = /*#__PURE__*/styled__default(reactNative.Pressable).withConfig({
1629
1752
  displayName: "Overlay__OverlayPressable",
@@ -2154,122 +2277,64 @@ function ModalPlatformDateTimePicker({
2154
2277
  });
2155
2278
  }
2156
2279
 
2157
- function prefixWithZero(value) {
2158
- return `${value}`.padStart(2, '0');
2159
- }
2160
-
2161
- const PartContainer = /*#__PURE__*/styled__default.View.withConfig({
2162
- displayName: "DatePicker__PartContainer",
2163
- componentId: "kitt-universal__sc-ebllsn-0"
2164
- })(["margin-right:", ";", ";"], ({
2165
- theme,
2166
- $isLast
2167
- }) => !$isLast ? `${theme.kitt.spacing * 2}px` : 0, ({
2168
- $isStretch
2169
- }) => $isStretch ? styled.css(["flex:0.33;flex-grow:1;"]) : undefined);
2170
- const DatePickerPressable = /*#__PURE__*/styled__default.Pressable.withConfig({
2171
- displayName: "DatePicker__DatePickerPressable",
2172
- componentId: "kitt-universal__sc-ebllsn-1"
2173
- })(["display:flex;flex-direction:row;", ";"], ({
2174
- $isStretch
2175
- }) => {
2176
- if ($isStretch) {
2177
- return styled.css(["width:100%;"]);
2178
- }
2179
-
2180
- return styled.css(["align-self:baseline;"]);
2181
- });
2182
2280
  function DatePicker({
2183
2281
  value,
2184
- id,
2185
- disabled,
2186
- placeholder,
2187
- state,
2188
- internalForceState,
2189
- testID,
2190
- stretch,
2191
- pickerDefaultDate,
2192
2282
  pickerUITestID,
2193
2283
  pickerUITitle,
2194
2284
  pickerUIValidateButtonLabel,
2195
2285
  onChange,
2196
2286
  onFocus,
2197
- onBlur
2287
+ onBlur,
2288
+ pickerDefaultDate,
2289
+ ...props
2198
2290
  }) {
2199
2291
  const [isPickerUIVisible, setIsPickerUIVisible] = react.useState(false);
2200
2292
  const [isFocused, setIsFocused] = react.useState(false);
2201
2293
  const [currentValue, setCurrentValue] = react.useState(value);
2202
2294
 
2295
+ if (reactNative.Platform.OS === 'android') {
2296
+ return /*#__PURE__*/jsxRuntime.jsx(DatePickerAndroid, {
2297
+ pickerDefaultDate: pickerDefaultDate,
2298
+ pickerUITestID: pickerUITestID,
2299
+ currentValue: currentValue,
2300
+ setCurrentValue: setCurrentValue,
2301
+ isFocused: isFocused,
2302
+ setIsFocused: setIsFocused,
2303
+ onChange: onChange,
2304
+ onBlur: onBlur,
2305
+ ...props
2306
+ });
2307
+ }
2308
+
2203
2309
  const handleModalClose = () => {
2204
2310
  if (onBlur) onBlur();
2205
2311
  setIsPickerUIVisible(false);
2206
2312
  setIsFocused(false);
2207
2313
  };
2208
2314
 
2209
- const handleChange = newDate => {
2210
- setCurrentValue(newDate);
2211
- onChange(newDate);
2212
- handleModalClose();
2213
- };
2214
-
2215
- const currentState = internalForceState || getInputUIState({
2216
- isFocused,
2217
- isDisabled: Boolean(disabled),
2218
- formState: state
2219
- });
2220
- const sharedPickerProps = {
2221
- testID: pickerUITestID,
2222
- value: currentValue,
2223
- onChange: handleChange
2224
- };
2225
- const sharedPartProps = {
2226
- disabled,
2227
- $state: currentState,
2228
- defaultDate: pickerDefaultDate
2229
- };
2230
2315
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2231
- children: [/*#__PURE__*/jsxRuntime.jsxs(DatePickerPressable, {
2232
- $isStretch: stretch,
2233
- nativeID: id,
2234
- disabled: disabled,
2235
- testID: testID,
2236
- onPress: () => {
2316
+ children: [/*#__PURE__*/jsxRuntime.jsx(DatePickerInputs, {
2317
+ handleModalOpen: () => {
2237
2318
  if (onFocus) onFocus();
2238
2319
  setIsPickerUIVisible(true);
2239
2320
  setIsFocused(true);
2240
2321
  },
2241
- children: [/*#__PURE__*/jsxRuntime.jsx(PartContainer, {
2242
- $isStretch: stretch,
2243
- children: /*#__PURE__*/jsxRuntime.jsx(DatePickerInputPart, { ...sharedPartProps,
2244
- partName: "day",
2245
- value: currentValue ? prefixWithZero(currentValue.getDate()) : undefined,
2246
- placeholder: placeholder?.day
2247
- })
2248
- }), /*#__PURE__*/jsxRuntime.jsx(PartContainer, {
2249
- $isStretch: stretch,
2250
- children: /*#__PURE__*/jsxRuntime.jsx(DatePickerInputPart, { ...sharedPartProps,
2251
- partName: "month",
2252
- value: currentValue ? prefixWithZero(currentValue.getMonth() + 1) : undefined,
2253
- placeholder: placeholder?.month
2254
- })
2255
- }), /*#__PURE__*/jsxRuntime.jsx(PartContainer, {
2256
- $isLast: true,
2257
- $isStretch: stretch,
2258
- children: /*#__PURE__*/jsxRuntime.jsx(DatePickerInputPart, { ...sharedPartProps,
2259
- partName: "year",
2260
- value: currentValue ? currentValue.getFullYear() : undefined,
2261
- placeholder: placeholder?.year
2262
- })
2263
- })]
2264
- }), /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
2265
- children: [reactNative.Platform.OS === 'android' && isPickerUIVisible ? /*#__PURE__*/jsxRuntime.jsx(PlatformDateTimePicker, { ...sharedPickerProps
2266
- }) : null, reactNative.Platform.OS !== 'android' ? /*#__PURE__*/jsxRuntime.jsx(ModalPlatformDateTimePicker, { ...sharedPickerProps,
2267
- isVisible: isPickerUIVisible,
2268
- title: pickerUITitle,
2269
- validateButtonLabel: pickerUIValidateButtonLabel,
2270
- onClose: handleModalClose,
2271
- onChange: handleChange
2272
- }) : null]
2322
+ currentValue: currentValue,
2323
+ isFocused: isFocused,
2324
+ ...props
2325
+ }), /*#__PURE__*/jsxRuntime.jsx(ModalPlatformDateTimePicker, {
2326
+ testID: pickerUITestID,
2327
+ value: currentValue,
2328
+ isVisible: isPickerUIVisible,
2329
+ title: pickerUITitle,
2330
+ validateButtonLabel: pickerUIValidateButtonLabel,
2331
+ defaultDate: pickerDefaultDate,
2332
+ onClose: handleModalClose,
2333
+ onChange: newDate => {
2334
+ setCurrentValue(newDate);
2335
+ onChange(newDate);
2336
+ handleModalClose();
2337
+ }
2273
2338
  })]
2274
2339
  });
2275
2340
  }