@melv1c/ui-kit 1.3.0 → 1.5.0

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
@@ -4518,65 +4518,69 @@ function DateTimePicker({
4518
4518
  ] })
4519
4519
  ] });
4520
4520
  }
4521
- function LocaleProvider({
4521
+ function UIKitProvider({
4522
4522
  children,
4523
- language,
4524
- overrides
4523
+ hasToaster = true,
4524
+ i18nConfig = { locale: "en" },
4525
+ loadingComponent = null
4525
4526
  }) {
4526
4527
  const [isReady, setIsReady] = React9.useState(false);
4527
- const instance = React9.useMemo(() => i18n__default.default.createInstance(), []);
4528
+ const i18nRef = React9.useRef(!i18nConfig.instance ? i18n__default.default.createInstance() : null);
4529
+ const instance = i18nConfig.instance || i18nRef.current;
4528
4530
  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
4531
+ if (i18nConfig.locale && !instance.isInitialized) {
4532
+ instance.use(reactI18next.initReactI18next).init({
4533
+ lng: i18nConfig.locale,
4534
+ fallbackLng: i18nConfig.locale,
4535
+ defaultNS: "ui",
4536
+ resources: {},
4537
+ interpolation: {
4538
+ escapeValue: false
4538
4539
  }
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);
4540
+ }).then(() => {
4541
+ setIsReady(true);
4542
+ });
4543
+ } else {
4544
+ setIsReady(true);
4545
+ }
4546
+ }, [i18nConfig, instance]);
4557
4547
  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;
4548
+ if (i18nConfig.locale) {
4549
+ const baseTranslations = chunkH4O6RXFK_cjs.locales_exports[i18nConfig.locale] ?? {};
4550
+ const mergedTranslations = i18nConfig.overrides ? { ...baseTranslations, ...i18nConfig.overrides } : baseTranslations;
4551
+ instance.addResourceBundle(
4552
+ i18nConfig.locale,
4553
+ "ui",
4554
+ mergedTranslations,
4555
+ true,
4556
+ true
4557
+ );
4558
+ instance.changeLanguage(i18nConfig.locale);
4559
+ } else if (i18nConfig.instance) {
4560
+ for (const [lng, resources] of Object.entries(chunkH4O6RXFK_cjs.locales_exports)) {
4561
+ const languageOverrides = i18nConfig.overrides?.[lng];
4562
+ if (instance.hasResourceBundle(lng, "ui") && !languageOverrides) {
4563
+ continue;
4564
+ }
4565
+ const mergedResources = languageOverrides ? { ...resources, ...languageOverrides } : resources;
4566
+ instance.addResourceBundle(lng, "ui", mergedResources, true, true);
4563
4567
  }
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);
4568
+ if (i18nConfig.overrides) {
4569
+ const supportedLanguages = Object.keys(chunkH4O6RXFK_cjs.locales_exports);
4570
+ for (const [lng, resources] of Object.entries(i18nConfig.overrides)) {
4571
+ if (supportedLanguages.includes(lng)) continue;
4572
+ instance.addResourceBundle(lng, "ui", resources, true, true);
4573
+ }
4572
4574
  }
4573
4575
  }
4574
- setIsReady(true);
4575
- }, [i18n2, overrides]);
4576
- if (!isReady) {
4577
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
4576
+ }, [i18nConfig, instance]);
4577
+ if (!isReady || !instance.isInitialized) {
4578
+ return loadingComponent;
4578
4579
  }
4579
- return /* @__PURE__ */ jsxRuntime.jsx(reactI18next.I18nextProvider, { i18n: i18n2, children });
4580
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactI18next.I18nextProvider, { i18n: instance, children: [
4581
+ children,
4582
+ hasToaster && /* @__PURE__ */ jsxRuntime.jsx(Toaster, {})
4583
+ ] });
4580
4584
  }
4581
4585
 
4582
4586
  Object.defineProperty(exports, "Skeleton", {
@@ -4760,7 +4764,6 @@ exports.HoverCard = HoverCard;
4760
4764
  exports.HoverCardContent = HoverCardContent;
4761
4765
  exports.HoverCardTrigger = HoverCardTrigger;
4762
4766
  exports.Label = Label3;
4763
- exports.LocaleProvider = LocaleProvider;
4764
4767
  exports.LoginForm = LoginForm;
4765
4768
  exports.Menubar = Menubar;
4766
4769
  exports.MenubarCheckboxItem = MenubarCheckboxItem;
@@ -4862,7 +4865,7 @@ exports.Tooltip = Tooltip;
4862
4865
  exports.TooltipContent = TooltipContent;
4863
4866
  exports.TooltipProvider = TooltipProvider;
4864
4867
  exports.TooltipTrigger = TooltipTrigger;
4865
- exports.TranslationProvider = TranslationProvider;
4868
+ exports.UIKitProvider = UIKitProvider;
4866
4869
  exports.appleIconVariants = appleIconVariants;
4867
4870
  exports.badgeVariants = badgeVariants;
4868
4871
  exports.buttonGroupVariants = buttonGroupVariants;