@melv1c/ui-kit 1.4.0 → 1.5.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ This library provides a collection of reusable, accessible UI components that fo
12
12
 
13
13
  ## Stack
14
14
 
15
- - **React 18** - JavaScript library for building UI
15
+ - **React 19** - JavaScript library for building UI
16
16
  - **TypeScript** - Type-safe JavaScript
17
17
  - **Tailwind CSS** - Utility-first CSS framework
18
18
  - **Storybook** - Component documentation and testing
@@ -22,7 +22,7 @@ This library provides a collection of reusable, accessible UI components that fo
22
22
 
23
23
  ### Prerequisites
24
24
 
25
- - Node.js 18+
25
+ - Node.js 22+
26
26
  - npm
27
27
 
28
28
  ### Setup
@@ -33,33 +33,3 @@ npm run dev
33
33
  ```
34
34
 
35
35
  This starts the Storybook dev server on `http://localhost:6006`.
36
-
37
- ### Available Scripts
38
-
39
- | Command | Description |
40
- | ------------------------- | --------------------------------------- |
41
- | `npm run dev` | Start Storybook dev server on port 6006 |
42
- | `npm run build` | Build the library with tsup |
43
- | `npm run build:watch` | Build in watch mode |
44
- | `npm run lint` | Run ESLint |
45
- | `npm run lint:fix` | Fix ESLint issues |
46
- | `npm run format` | Format code with Prettier |
47
- | `npm run format:check` | Check code formatting |
48
- | `npm run build-storybook` | Build static Storybook |
49
-
50
- ## Contributing
51
-
52
- Contributions are welcome! Please follow these steps:
53
-
54
- 1. Create a feature branch (`git checkout -b feature/your-feature`)
55
- 2. Make your changes and commit (`git commit -m 'Add feature'`)
56
- 3. Push to the branch (`git push origin feature/your-feature`)
57
- 4. Open a pull request
58
-
59
- When adding components:
60
-
61
- 1. Create your component in the appropriate folder under `src/components/`
62
- 2. Add a `.stories.tsx` file for Storybook documentation
63
- 3. Export the component from the folder's `index.ts`
64
- 4. Run `npm run lint:fix` and `npm run format` before submitting
65
- 5. Ensure all tests pass
package/dist/index.cjs CHANGED
@@ -4404,6 +4404,7 @@ function DateTimePicker({
4404
4404
  placeholder = "Select date and time",
4405
4405
  showClear = true,
4406
4406
  disabled = false,
4407
+ disabledDates,
4407
4408
  className,
4408
4409
  formatDateTime
4409
4410
  }) {
@@ -4496,7 +4497,7 @@ function DateTimePicker({
4496
4497
  selected: date,
4497
4498
  captionLayout: "dropdown",
4498
4499
  onSelect: handleDateChange,
4499
- disabled
4500
+ disabled: disabledDates
4500
4501
  }
4501
4502
  ),
4502
4503
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t p-3", children: [
@@ -4509,7 +4510,7 @@ function DateTimePicker({
4509
4510
  step: "60",
4510
4511
  value: formatTimeValue(date),
4511
4512
  onChange: handleTimeChange,
4512
- disabled,
4513
+ disabled: !date || disabled,
4513
4514
  className: "bg-background h-8 appearance-none [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none"
4514
4515
  }
4515
4516
  )
@@ -4518,65 +4519,69 @@ function DateTimePicker({
4518
4519
  ] })
4519
4520
  ] });
4520
4521
  }
4521
- function LocaleProvider({
4522
+ function UIKitProvider({
4522
4523
  children,
4523
- language,
4524
- overrides
4524
+ hasToaster = true,
4525
+ i18nConfig = { locale: "en" },
4526
+ loadingComponent = null
4525
4527
  }) {
4526
4528
  const [isReady, setIsReady] = React9.useState(false);
4527
- const instance = React9.useMemo(() => i18n__default.default.createInstance(), []);
4529
+ const i18nRef = React9.useRef(!i18nConfig.instance ? i18n__default.default.createInstance() : null);
4530
+ const instance = i18nConfig.instance || i18nRef.current;
4528
4531
  React9.useEffect(() => {
4529
- const baseTranslations = chunkH4O6RXFK_cjs.locales_exports[language] ?? {};
4530
- const mergedTranslations = overrides ? { ...baseTranslations, ...overrides } : baseTranslations;
4531
- instance.use(reactI18next.initReactI18next).init({
4532
- lng: language,
4533
- fallbackLng: language,
4534
- defaultNS: "ui",
4535
- resources: {
4536
- [language]: {
4537
- ui: mergedTranslations
4532
+ if (i18nConfig.locale && !instance.isInitialized) {
4533
+ instance.use(reactI18next.initReactI18next).init({
4534
+ lng: i18nConfig.locale,
4535
+ fallbackLng: i18nConfig.locale,
4536
+ defaultNS: "ui",
4537
+ resources: {},
4538
+ interpolation: {
4539
+ escapeValue: false
4538
4540
  }
4539
- },
4540
- interpolation: {
4541
- escapeValue: false
4542
- }
4543
- }).then(() => setIsReady(true));
4544
- }, [instance, language, overrides]);
4545
- if (!isReady) {
4546
- return null;
4547
- }
4548
- return /* @__PURE__ */ jsxRuntime.jsx(reactI18next.I18nextProvider, { i18n: instance, children });
4549
- }
4550
- function TranslationProvider({
4551
- i18n: i18n2,
4552
- children,
4553
- fallback = null,
4554
- overrides
4555
- }) {
4556
- const [isReady, setIsReady] = React9.useState(false);
4541
+ }).then(() => {
4542
+ setIsReady(true);
4543
+ });
4544
+ } else {
4545
+ setIsReady(true);
4546
+ }
4547
+ }, [i18nConfig, instance]);
4557
4548
  React9.useEffect(() => {
4558
- for (const [lng, resources] of Object.entries(chunkH4O6RXFK_cjs.locales_exports)) {
4559
- const language = lng;
4560
- const languageOverrides = overrides?.[language];
4561
- if (i18n2.hasResourceBundle(language, "ui") && !languageOverrides) {
4562
- continue;
4549
+ if (i18nConfig.locale) {
4550
+ const baseTranslations = chunkH4O6RXFK_cjs.locales_exports[i18nConfig.locale] ?? {};
4551
+ const mergedTranslations = i18nConfig.overrides ? { ...baseTranslations, ...i18nConfig.overrides } : baseTranslations;
4552
+ instance.addResourceBundle(
4553
+ i18nConfig.locale,
4554
+ "ui",
4555
+ mergedTranslations,
4556
+ true,
4557
+ true
4558
+ );
4559
+ instance.changeLanguage(i18nConfig.locale);
4560
+ } else if (i18nConfig.instance) {
4561
+ for (const [lng, resources] of Object.entries(chunkH4O6RXFK_cjs.locales_exports)) {
4562
+ const languageOverrides = i18nConfig.overrides?.[lng];
4563
+ if (instance.hasResourceBundle(lng, "ui") && !languageOverrides) {
4564
+ continue;
4565
+ }
4566
+ const mergedResources = languageOverrides ? { ...resources, ...languageOverrides } : resources;
4567
+ instance.addResourceBundle(lng, "ui", mergedResources, true, true);
4563
4568
  }
4564
- const mergedResources = languageOverrides ? { ...resources, ...languageOverrides } : resources;
4565
- i18n2.addResourceBundle(language, "ui", mergedResources, true, true);
4566
- }
4567
- if (overrides) {
4568
- const supportedLanguages = Object.keys(chunkH4O6RXFK_cjs.locales_exports);
4569
- for (const [lng, resources] of Object.entries(overrides)) {
4570
- if (supportedLanguages.includes(lng)) continue;
4571
- i18n2.addResourceBundle(lng, "ui", resources, true, true);
4569
+ if (i18nConfig.overrides) {
4570
+ const supportedLanguages = Object.keys(chunkH4O6RXFK_cjs.locales_exports);
4571
+ for (const [lng, resources] of Object.entries(i18nConfig.overrides)) {
4572
+ if (supportedLanguages.includes(lng)) continue;
4573
+ instance.addResourceBundle(lng, "ui", resources, true, true);
4574
+ }
4572
4575
  }
4573
4576
  }
4574
- setIsReady(true);
4575
- }, [i18n2, overrides]);
4576
- if (!isReady) {
4577
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
4577
+ }, [i18nConfig, instance]);
4578
+ if (!isReady || !instance.isInitialized) {
4579
+ return loadingComponent;
4578
4580
  }
4579
- return /* @__PURE__ */ jsxRuntime.jsx(reactI18next.I18nextProvider, { i18n: i18n2, children });
4581
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactI18next.I18nextProvider, { i18n: instance, children: [
4582
+ children,
4583
+ hasToaster && /* @__PURE__ */ jsxRuntime.jsx(Toaster, {})
4584
+ ] });
4580
4585
  }
4581
4586
 
4582
4587
  Object.defineProperty(exports, "Skeleton", {
@@ -4760,7 +4765,6 @@ exports.HoverCard = HoverCard;
4760
4765
  exports.HoverCardContent = HoverCardContent;
4761
4766
  exports.HoverCardTrigger = HoverCardTrigger;
4762
4767
  exports.Label = Label3;
4763
- exports.LocaleProvider = LocaleProvider;
4764
4768
  exports.LoginForm = LoginForm;
4765
4769
  exports.Menubar = Menubar;
4766
4770
  exports.MenubarCheckboxItem = MenubarCheckboxItem;
@@ -4862,7 +4866,7 @@ exports.Tooltip = Tooltip;
4862
4866
  exports.TooltipContent = TooltipContent;
4863
4867
  exports.TooltipProvider = TooltipProvider;
4864
4868
  exports.TooltipTrigger = TooltipTrigger;
4865
- exports.TranslationProvider = TranslationProvider;
4869
+ exports.UIKitProvider = UIKitProvider;
4866
4870
  exports.appleIconVariants = appleIconVariants;
4867
4871
  exports.badgeVariants = badgeVariants;
4868
4872
  exports.buttonGroupVariants = buttonGroupVariants;