@infonomic/uikit 1.0.0 → 1.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 (35) hide show
  1. package/README.md +37 -0
  2. package/dist/components/avatar/avatar.d.ts +3 -1
  3. package/dist/components/avatar/avatar.d.ts.map +1 -1
  4. package/dist/components/avatar/avatar.js +2 -2
  5. package/dist/components/notifications/alert.d.ts.map +1 -1
  6. package/dist/components/notifications/alert.js +36 -40
  7. package/dist/components/notifications/toast.d.ts +1 -1
  8. package/dist/components/notifications/toast.d.ts.map +1 -1
  9. package/dist/components/notifications/toast.js +2 -2
  10. package/dist/components/scroll-area/scroll-area_module.css +1 -1
  11. package/dist/icons/close-icon.d.ts.map +1 -1
  12. package/dist/icons/danger-icon.d.ts +1 -1
  13. package/dist/icons/danger-icon.d.ts.map +1 -1
  14. package/dist/icons/danger-icon.js +2 -5
  15. package/dist/icons/info-icon.d.ts +1 -1
  16. package/dist/icons/info-icon.d.ts.map +1 -1
  17. package/dist/icons/info-icon.js +2 -5
  18. package/dist/icons/primary-icon.d.ts +1 -1
  19. package/dist/icons/primary-icon.d.ts.map +1 -1
  20. package/dist/icons/primary-icon.js +1 -1
  21. package/dist/icons/success-icon.d.ts +1 -1
  22. package/dist/icons/success-icon.d.ts.map +1 -1
  23. package/dist/icons/success-icon.js +2 -5
  24. package/dist/icons/types/icon.d.ts +0 -1
  25. package/dist/icons/types/icon.d.ts.map +1 -1
  26. package/dist/icons/warning-icon.d.ts +1 -1
  27. package/dist/icons/warning-icon.d.ts.map +1 -1
  28. package/dist/icons/warning-icon.js +2 -5
  29. package/dist/styles/styles.css +2592 -1
  30. package/dist/styles/styles.css.map +1 -0
  31. package/dist/styles/typography.css +394 -1
  32. package/dist/styles/typography.css.map +1 -0
  33. package/dist/tsconfig.build.tsbuildinfo +1 -1
  34. package/dist/widgets/datepicker/datepicker.js +23 -9
  35. package/package.json +9 -3
@@ -3,26 +3,32 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import classnames from "classnames";
4
4
  import { format } from "date-fns";
5
5
  import { Popover } from "radix-ui";
6
- import { useRef, useState } from "react";
7
- import { Button, IconButton } from "../../components/button/index.js";
6
+ import { useEffect, useRef, useState } from "react";
7
+ import { Button } from "../../components/button/button.js";
8
+ import { IconButton } from "../../components/button/icon-button.js";
8
9
  import { Calendar } from "../../components/calendar/calendar.js";
9
10
  import { Input, InputAdornment } from "../../components/input/index.js";
10
11
  import { ScrollArea } from "../../components/scroll-area/scroll-area.js";
11
12
  import { CalendarIcon } from "../../icons/calendar-icon.js";
12
13
  import { CloseIcon } from "../../icons/close-icon.js";
13
14
  import datepicker_module from "./datepicker.module.js";
14
- function DatePicker({ id, name, initialValue, mode = 'datetime', yearsInFuture = 1, yearsInPast = 10, variant, intent, inputSize, inputClassName, inputWrapperClassName, containerClassName, onClear = ()=>{}, onDateChange = ()=>{}, validatorFn, helpText, errorText, placeHolderText = 'Date', ariaLabelForSearch = 'date', ariaLabelForClear = 'clear', ...rest }) {
15
+ function DatePicker({ id, name, label, required, initialValue, mode = 'datetime', yearsInFuture = 1, yearsInPast = 10, variant, intent, inputSize, inputClassName, inputWrapperClassName, containerClassName, onClear = ()=>{}, onDateChange = ()=>{}, validatorFn, helpText, errorText, placeHolderText = '', ariaLabelForSearch = 'date', ariaLabelForClear = 'clear', ...rest }) {
15
16
  const [isOpen, setIsOpen] = useState(false);
16
17
  const [time, setTime] = useState('08:00');
17
- const [date, setDate] = useState(initialValue ?? new Date());
18
+ const [date, setDate] = useState(()=>{
19
+ if (initialValue) return initialValue;
20
+ if (null == initialValue && true === required) return new Date();
21
+ return null;
22
+ });
18
23
  const [month, setMonth] = useState(date);
19
24
  const calendarRef = useRef(null);
20
25
  const inputRef = useRef(null);
26
+ const hasInitialized = useRef(false);
21
27
  const handleClear = ()=>{
22
- setDate(void 0);
23
28
  if ((null == inputRef ? void 0 : inputRef.current) != null) inputRef.current.value = '';
29
+ setDate(null);
30
+ onDateChange(null);
24
31
  onClear();
25
- onDateChange(void 0);
26
32
  };
27
33
  const handleOnDateChange = (value)=>{
28
34
  if (null != onDateChange && 'function' == typeof onDateChange) onDateChange(value);
@@ -33,6 +39,12 @@ function DatePicker({ id, name, initialValue, mode = 'datetime', yearsInFuture =
33
39
  setIsOpen(true);
34
40
  }
35
41
  };
42
+ useEffect(()=>{
43
+ if (null == initialValue && null != date && true === required && false === hasInitialized.current) {
44
+ hasInitialized.current = true;
45
+ onDateChange(date);
46
+ }
47
+ });
36
48
  return /*#__PURE__*/ jsxs("div", {
37
49
  className: classnames(datepicker_module.container, containerClassName),
38
50
  children: [
@@ -44,7 +56,9 @@ function DatePicker({ id, name, initialValue, mode = 'datetime', yearsInFuture =
44
56
  },
45
57
  children: /*#__PURE__*/ jsx(Input, {
46
58
  id: id,
59
+ label: label,
47
60
  readOnly: true,
61
+ required: required,
48
62
  name: name,
49
63
  variant: variant,
50
64
  intent: intent,
@@ -58,7 +72,7 @@ function DatePicker({ id, name, initialValue, mode = 'datetime', yearsInFuture =
58
72
  e.stopPropagation();
59
73
  setIsOpen(true);
60
74
  },
61
- value: date ? `${format(date, 'PP HH:mm')}` : 'Pick a date',
75
+ value: date ? `${format(date, 'PP HH:mm')}` : '',
62
76
  placeHolder: placeHolderText,
63
77
  helpText: helpText,
64
78
  disabled: false,
@@ -130,8 +144,8 @@ function DatePicker({ id, name, initialValue, mode = 'datetime', yearsInFuture =
130
144
  mode: "single",
131
145
  required: true,
132
146
  captionLayout: "dropdown",
133
- selected: date,
134
- month: month,
147
+ selected: date ?? void 0,
148
+ month: month ?? void 0,
135
149
  onMonthChange: setMonth,
136
150
  onSelect: (selectedDate)=>{
137
151
  if (selectedDate) {
package/package.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "name": "@infonomic/uikit",
3
3
  "private": false,
4
4
  "license": "MIT",
5
- "version": "1.0.0",
5
+ "version": "1.0.2",
6
+ "type": "module",
6
7
  "description": "Infonomic UI kit is a collection of reusable UI components and utilities for React and Astro.",
7
8
  "keywords": [
8
9
  "uikit",
@@ -22,7 +23,7 @@
22
23
  "module": "./dist/react.js",
23
24
  "main": "./dist/react.js",
24
25
  "files": [
25
- "dist/",
26
+ "dist",
26
27
  "src/astro.js"
27
28
  ],
28
29
  "exports": {
@@ -30,6 +31,7 @@
30
31
  "./react": {
31
32
  "types": "./dist/react.d.ts",
32
33
  "import": "./dist/react.js",
34
+ "main": "./dist/react.js",
33
35
  "default": "./dist/react.js"
34
36
  },
35
37
  "./styles.css": {
@@ -86,7 +88,11 @@
86
88
  "vitest": "^3.2.4"
87
89
  },
88
90
  "publishConfig": {
89
- "access": "public"
91
+ "access": "public",
92
+ "files": [
93
+ "dist/",
94
+ "src/astro.js"
95
+ ]
90
96
  },
91
97
  "scripts": {
92
98
  "dev": "run-p dev:*",