@flipdish/ui-library 0.4.2 → 0.4.3
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 +9 -47
- package/dist/providers/UIProvider/index.cjs +29 -0
- package/dist/providers/UIProvider/index.cjs.map +1 -0
- package/dist/providers/UIProvider/index.d.ts +28 -0
- package/dist/providers/UIProvider/index.d.ts.map +1 -0
- package/dist/providers/UIProvider/index.js +27 -0
- package/dist/providers/UIProvider/index.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,12 +15,12 @@ Atomic-design React component library for Flipdish products, built on **Tailwind
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
pnpm add @flipdish/ui-library
|
|
18
|
+
pnpm add @flipdish/ui-library @flipdish/ui-tokens @flipdish/ui-icons
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
For the full setup walkthrough (Vite config, CSS entry, providers, first component), see [Getting Started → Installation](https://flipdishbytes.github.io/flipdish-design-system/?path=/docs/getting-started-installation--docs).
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
### Peer dependencies
|
|
24
24
|
|
|
25
25
|
**Shared — required on every platform:**
|
|
26
26
|
|
|
@@ -50,7 +50,7 @@ Install the peers for the platform(s) you target. Platform-specific peers are de
|
|
|
50
50
|
|
|
51
51
|
### Component-specific peer dependencies
|
|
52
52
|
|
|
53
|
-
A handful of components are backed by larger third-party libraries
|
|
53
|
+
A handful of components are backed by larger third-party libraries declared as **optional** peers — importing `Button` never pulls in the charting or rich-text stack. Install only the peer(s) for the components you actually use; a missing peer causes a build/runtime error.
|
|
54
54
|
|
|
55
55
|
| Component | Required peer(s) |
|
|
56
56
|
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -63,61 +63,23 @@ A handful of components are backed by larger third-party libraries. Those librar
|
|
|
63
63
|
| `CommandMenu` | `react-hotkeys-hook` |
|
|
64
64
|
| `FileUpload`, `SidebarNavigation` | `motion` |
|
|
65
65
|
|
|
66
|
-
For example, to use the rich-text editor:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
pnpm add @tiptap/core @tiptap/pm @tiptap/react @tiptap/starter-kit @tiptap/extension-image @tiptap/extension-placeholder @tiptap/extension-text-align @tiptap/extension-text-style
|
|
70
|
-
```
|
|
71
|
-
|
|
72
66
|
## Tailwind setup
|
|
73
67
|
|
|
74
|
-
|
|
68
|
+
Import the library's shared runtime from your CSS entry **in this exact layer order**:
|
|
75
69
|
|
|
76
70
|
```css
|
|
77
71
|
@layer theme, base, components, utilities;
|
|
78
72
|
|
|
79
73
|
@import "tailwindcss/theme.css" layer(theme);
|
|
80
|
-
@import "@flipdish/ui-tokens/css" layer(theme);
|
|
74
|
+
@import "@flipdish/ui-tokens/css" layer(theme);
|
|
81
75
|
@import "tailwindcss/preflight.css" layer(base);
|
|
82
|
-
@import "@flipdish/ui-library/styles";
|
|
76
|
+
@import "@flipdish/ui-library/styles";
|
|
83
77
|
@import "tailwindcss/utilities.css" layer(utilities);
|
|
84
78
|
```
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
## Usage
|
|
89
|
-
|
|
90
|
-
Components, providers, hooks, and utilities are imported from subpaths that mirror the atomic-design layers:
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
// Components — components/<atoms|molecules|organisms|templates>/<Name>
|
|
94
|
-
import { Button } from "@flipdish/ui-library/components/atoms/Button";
|
|
95
|
-
import { NotFoundPage } from "@flipdish/ui-library/components/templates/NotFoundPage";
|
|
96
|
-
|
|
97
|
-
// Providers — cross-cutting behavioural wrappers
|
|
98
|
-
import { ThemeProvider } from "@flipdish/ui-library/providers/ThemeProvider";
|
|
99
|
-
import { RouteProvider } from "@flipdish/ui-library/providers/RouteProvider";
|
|
100
|
-
import { ErrorBoundary } from "@flipdish/ui-library/providers/ErrorBoundary";
|
|
101
|
-
|
|
102
|
-
// Hooks
|
|
103
|
-
import { useBreakpoint } from "@flipdish/ui-library/hooks/useBreakpoints";
|
|
104
|
-
import { useClipboard } from "@flipdish/ui-library/hooks/useClipboard";
|
|
105
|
-
|
|
106
|
-
// Utilities
|
|
107
|
-
import { cx, sortCx } from "@flipdish/ui-library/utilities/cx";
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### Styling rules
|
|
111
|
-
|
|
112
|
-
Use **semantic** token utilities only (`bg-primary`, `text-secondary`, `border-primary`, `bg-brand-solid`, …) — never primitive ramp utilities (`bg-blue-500`) or raw `var(--…)` in `style`. Semantic tokens swap automatically under `[data-theme="dark"]`; primitives don't.
|
|
113
|
-
|
|
114
|
-
## Platform support (web + React Native)
|
|
115
|
-
|
|
116
|
-
The component API, `tailwind-variants` configs, and `cx`/`sortCx` are shared across platforms; primitives and accessibility libraries diverge via a `.tsx` (web) + `.native.tsx` (RN) file split.
|
|
117
|
-
|
|
118
|
-
`react-aria-components` (which Untitled UI is built on) is **web-only**, so a component is React Native-ready only once it ships an `index.native.tsx` sibling. The presence of that file is the source of truth — Metro resolves `index.native.tsx` automatically, while web bundlers use the `index.tsx`.
|
|
80
|
+
## Documentation
|
|
119
81
|
|
|
120
|
-
|
|
82
|
+
Full component docs, interactive examples, and design guidance live in the [Storybook](https://flipdishbytes.github.io/flipdish-design-system/).
|
|
121
83
|
|
|
122
84
|
## Changelog
|
|
123
85
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var RouteProvider = require('@flipdish/ui-library/providers/RouteProvider');
|
|
5
|
+
var ThemeProvider = require('@flipdish/ui-library/providers/ThemeProvider');
|
|
6
|
+
var reactRouter = require('react-router');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @summary single entry-point provider that composes the Flipdish UI providers (theme, routing, and — soon — translations)
|
|
10
|
+
*/
|
|
11
|
+
const UIProvider = ({ children, themeModeOverride, withBrowserRouter = true, withRouteProvider = true, }) => {
|
|
12
|
+
let tree = children;
|
|
13
|
+
// RouteProvider must sit inside a router; keep it innermost so it can bind to
|
|
14
|
+
// either our BrowserRouter or a host-owned one.
|
|
15
|
+
if (withRouteProvider) {
|
|
16
|
+
tree = jsxRuntime.jsx(RouteProvider.RouteProvider, { children: tree });
|
|
17
|
+
}
|
|
18
|
+
if (withBrowserRouter) {
|
|
19
|
+
tree = jsxRuntime.jsx(reactRouter.BrowserRouter, { children: tree });
|
|
20
|
+
}
|
|
21
|
+
// TODO(i18n): wrap `tree` in <TranslationProvider> once the translation layer lands.
|
|
22
|
+
// It will likely expose an async `useLoadTranslations(languageOverride)` hook (see
|
|
23
|
+
// FlipdishUI's FlipdishUIProvider) and a `languageOverride` prop forwarded from here.
|
|
24
|
+
// Order: ThemeProvider > [BrowserRouter > RouteProvider] > TranslationProvider > children.
|
|
25
|
+
return jsxRuntime.jsx(ThemeProvider.ThemeProvider, { themeModeOverride: themeModeOverride, children: tree });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.UIProvider = UIProvider;
|
|
29
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx","RouteProvider","BrowserRouter","ThemeProvider"],"mappings":";;;;;;;AA4BA;;AAEG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,GAAG,IAAI,EACxB,iBAAiB,GAAG,IAAI,GACW,KAAI;IACvC,IAAI,IAAI,GAAG,QAAQ;;;IAInB,IAAI,iBAAiB,EAAE;AACrB,QAAA,IAAI,GAAGA,cAAA,CAACC,2BAAa,EAAA,EAAA,QAAA,EAAE,IAAI,GAAiB;IAC9C;IAEA,IAAI,iBAAiB,EAAE;AACrB,QAAA,IAAI,GAAGD,cAAA,CAACE,yBAAa,EAAA,EAAA,QAAA,EAAE,IAAI,GAAiB;IAC9C;;;;;IAMA,OAAOF,cAAA,CAACG,2BAAa,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAA,QAAA,EAAG,IAAI,EAAA,CAAiB;AACpF;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
export interface UIProviderProps {
|
|
3
|
+
/**
|
|
4
|
+
* Controlled theme override. When set, the tree renders in this mode and theme
|
|
5
|
+
* persistence is skipped. Omit to use ThemeProvider's own light/dark/system logic.
|
|
6
|
+
*/
|
|
7
|
+
themeModeOverride?: 'light' | 'dark';
|
|
8
|
+
/**
|
|
9
|
+
* Render a `BrowserRouter`. Set `false` when a host/parent app already owns a
|
|
10
|
+
* router (e.g. a micro-frontend mounted in a shell, or an app using react-router's
|
|
11
|
+
* data APIs via `createBrowserRouter`) — a second router would fight over the URL.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
withBrowserRouter?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Wire react-aria-components navigation into react-router (so `<Link>`, etc. use
|
|
17
|
+
* client-side navigation). Keep `true` even when `withBrowserRouter` is `false`, so
|
|
18
|
+
* react-aria routing binds to the host's router. Set `false` only for non-routed
|
|
19
|
+
* surfaces (single-screen apps, some test/Storybook setups).
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
withRouteProvider?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @summary single entry-point provider that composes the Flipdish UI providers (theme, routing, and — soon — translations)
|
|
26
|
+
*/
|
|
27
|
+
export declare const UIProvider: ({ children, themeModeOverride, withBrowserRouter, withRouteProvider, }: PropsWithChildren<UIProviderProps>) => import("react").JSX.Element;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/UIProvider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,wEAKxB,iBAAiB,CAAC,eAAe,CAAC,gCAkBpC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { RouteProvider } from '@flipdish/ui-library/providers/RouteProvider';
|
|
3
|
+
import { ThemeProvider } from '@flipdish/ui-library/providers/ThemeProvider';
|
|
4
|
+
import { BrowserRouter } from 'react-router';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @summary single entry-point provider that composes the Flipdish UI providers (theme, routing, and — soon — translations)
|
|
8
|
+
*/
|
|
9
|
+
const UIProvider = ({ children, themeModeOverride, withBrowserRouter = true, withRouteProvider = true, }) => {
|
|
10
|
+
let tree = children;
|
|
11
|
+
// RouteProvider must sit inside a router; keep it innermost so it can bind to
|
|
12
|
+
// either our BrowserRouter or a host-owned one.
|
|
13
|
+
if (withRouteProvider) {
|
|
14
|
+
tree = jsx(RouteProvider, { children: tree });
|
|
15
|
+
}
|
|
16
|
+
if (withBrowserRouter) {
|
|
17
|
+
tree = jsx(BrowserRouter, { children: tree });
|
|
18
|
+
}
|
|
19
|
+
// TODO(i18n): wrap `tree` in <TranslationProvider> once the translation layer lands.
|
|
20
|
+
// It will likely expose an async `useLoadTranslations(languageOverride)` hook (see
|
|
21
|
+
// FlipdishUI's FlipdishUIProvider) and a `languageOverride` prop forwarded from here.
|
|
22
|
+
// Order: ThemeProvider > [BrowserRouter > RouteProvider] > TranslationProvider > children.
|
|
23
|
+
return jsx(ThemeProvider, { themeModeOverride: themeModeOverride, children: tree });
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { UIProvider };
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;AA4BA;;AAEG;AACI,MAAM,UAAU,GAAG,CAAC,EACzB,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,GAAG,IAAI,EACxB,iBAAiB,GAAG,IAAI,GACW,KAAI;IACvC,IAAI,IAAI,GAAG,QAAQ;;;IAInB,IAAI,iBAAiB,EAAE;AACrB,QAAA,IAAI,GAAGA,GAAA,CAAC,aAAa,EAAA,EAAA,QAAA,EAAE,IAAI,GAAiB;IAC9C;IAEA,IAAI,iBAAiB,EAAE;AACrB,QAAA,IAAI,GAAGA,GAAA,CAAC,aAAa,EAAA,EAAA,QAAA,EAAE,IAAI,GAAiB;IAC9C;;;;;IAMA,OAAOA,GAAA,CAAC,aAAa,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAA,QAAA,EAAG,IAAI,EAAA,CAAiB;AACpF;;;;"}
|