@nova-design-system/nova-react 3.12.0 → 3.14.0-beta.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 +27 -58
- package/dist/cjs/collapse.animation-6e0b08df-AHWzNGm_.js +217 -0
- package/dist/cjs/{constants-a857c476-Cj2b-su0.js → constants-69bafca2-DpB_ghPF.js} +14 -0
- package/dist/cjs/fade.animation-9b939939-DV--bM4S.js +724 -0
- package/dist/cjs/{index-jBgPO7HC.js → index-CJDePE8Z.js} +2322 -1657
- package/dist/cjs/index.js +14 -1
- package/dist/cjs/{nv-accordion-item.entry-BUb_Apy8.js → nv-accordion-item.entry-Begcz9SZ.js} +75 -40
- package/dist/cjs/nv-accordion.entry-DQAkheHY.js +179 -0
- package/dist/cjs/{nv-alert.entry-nzJu8E5h.js → nv-alert.entry-CEzR0iu0.js} +21 -20
- package/dist/cjs/{nv-avatar.entry-BPp1d-QO.js → nv-avatar.entry-B-u7r30l.js} +8 -7
- package/dist/cjs/{nv-badge_2.entry-Bk56p4jv.js → nv-badge_2.entry-0vhTS5D7.js} +15 -14
- package/dist/cjs/{nv-breadcrumb.entry-DB3zR7FC.js → nv-breadcrumb.entry-BkWs1x-W.js} +2 -1
- package/dist/cjs/{nv-breadcrumbs.entry-CoGgEsro.js → nv-breadcrumbs.entry-DglL-1Ed.js} +2 -1
- package/dist/cjs/{nv-button.entry-psZ3_t6i.js → nv-button.entry-BbT0aeQI.js} +8 -7
- package/dist/cjs/{nv-buttongroup.entry-cNenBx1F.js → nv-buttongroup.entry-wlJma4qm.js} +2 -1
- package/dist/cjs/{nv-calendar.entry-nkrORr_V.js → nv-calendar.entry-wIPDRk0B.js} +21 -16
- package/dist/cjs/{nv-col.entry-D4mInxLU.js → nv-col.entry-Btsenp2c.js} +2 -1
- package/dist/cjs/{nv-datagrid.entry-D50O7eyc.js → nv-datagrid.entry-Dae8YlRu.js} +7 -6
- package/dist/cjs/{nv-datagridcolumn.entry-BuGX-3ev.js → nv-datagridcolumn.entry-D918Vo_U.js} +2 -1
- package/dist/cjs/{nv-dialog.entry-yiZIq-TV.js → nv-dialog.entry--cGTlgDZ.js} +4 -3
- package/dist/cjs/{nv-dialogfooter_2.entry-C9ykJQK6.js → nv-dialogfooter_2.entry-CXYjGHc5.js} +11 -7
- package/dist/cjs/{nv-fieldcheckbox.entry-CCRvvFJ3.js → nv-fieldcheckbox.entry-9b_kDQGz.js} +3 -2
- package/dist/cjs/{nv-fielddate.entry-C4k6k980.js → nv-fielddate.entry-CRRTthds.js} +2 -1
- package/dist/cjs/{nv-fielddaterange.entry-BhfV2KCd.js → nv-fielddaterange.entry-BAVePsLs.js} +2 -1
- package/dist/cjs/{nv-fielddropdown.entry-Xkkvl_gb.js → nv-fielddropdown.entry-Dy8sZyze.js} +2 -1
- package/dist/cjs/{nv-fielddropdownitem.entry-Ckwq6k6r.js → nv-fielddropdownitem.entry-CuPocgsF.js} +2 -1
- package/dist/cjs/{nv-fieldmultiselect.entry-D4PgRSFv.js → nv-fieldmultiselect.entry-HWSDowQH.js} +2 -31
- package/dist/cjs/{nv-fieldnumber.entry-BEnJ81XX.js → nv-fieldnumber.entry-fObgOYJX.js} +3 -2
- package/dist/cjs/{nv-fieldpassword.entry-elzveqP8.js → nv-fieldpassword.entry-BRhKH_Mb.js} +2 -1
- package/dist/cjs/{nv-fieldradio.entry-xJpdsXGo.js → nv-fieldradio.entry-D74Mlgjc.js} +2 -1
- package/dist/cjs/{nv-fieldselect.entry-DVyO7LMD.js → nv-fieldselect.entry-BS81ItZs.js} +2 -1
- package/dist/cjs/{nv-fieldslider.entry-O4TFO-Rl.js → nv-fieldslider.entry-xyqrZxYj.js} +26 -17
- package/dist/cjs/{nv-fieldtext.entry-p-9GEp1g.js → nv-fieldtext.entry-BVUKbv4b.js} +2 -1
- package/dist/cjs/{nv-fieldtextarea.entry-Cvik8cci.js → nv-fieldtextarea.entry-B7hb1so-.js} +2 -1
- package/dist/cjs/{nv-fieldtime.entry-mnsDon9M.js → nv-fieldtime.entry-DvCbKaOO.js} +61 -60
- package/dist/cjs/nv-icon.entry-DP715dyH.js +80 -0
- package/dist/cjs/{nv-iconbutton_2.entry-M5EY3-1s.js → nv-iconbutton_2.entry-FpzwxZe_.js} +2 -1
- package/dist/cjs/{nv-menu.entry-D7bORqXp.js → nv-menu.entry-ryMNpTHW.js} +2 -1
- package/dist/cjs/{nv-menuitem.entry-CaN6qNoB.js → nv-menuitem.entry-SQBrWIYf.js} +2 -1
- package/dist/cjs/nv-notification.entry-DnCew-lG.js +262 -0
- package/dist/cjs/nv-notificationcontainer.entry-Dwlv9s1v.js +41 -0
- package/dist/cjs/{nv-popover.entry-DGeXSyhZ.js → nv-popover.entry-DOu6rhco.js} +10 -9
- package/dist/cjs/{nv-row.entry-B17DsCjM.js → nv-row.entry-Tx_yvWTJ.js} +3 -2
- package/dist/cjs/{nv-stack.entry-Dv3YU4nJ.js → nv-stack.entry-Cn0JrM2N.js} +3 -2
- package/dist/cjs/{nv-table.entry-BILyG-43.js → nv-table.entry-D-uKGKnp.js} +4 -3
- package/dist/cjs/{nv-tablecolumn.entry-II6Z_gdO.js → nv-tablecolumn.entry-BsJzXKCk.js} +2 -1
- package/dist/cjs/{nv-toggle.entry-5Wmww2Cd.js → nv-toggle.entry-DuDRh-Ww.js} +4 -3
- package/dist/cjs/{nv-togglebutton.entry-Dnmfrj0O.js → nv-togglebutton.entry-DAlky3tO.js} +3 -2
- package/dist/cjs/{nv-togglebuttongroup.entry-C9mplQcb.js → nv-togglebuttongroup.entry-DTadjqMQ.js} +3 -2
- package/dist/cjs/{nv-tooltip.entry-CcUQrjAv.js → nv-tooltip.entry-BWzlP6gC.js} +3 -2
- package/dist/cjs/{stylefire.es-74da334a-y0piPjlz.js → style-value-types.es-f5d10b79-D0QCM8OB.js} +50 -694
- package/dist/cjs/{timeline.animation-adf35ecb-CE6Dsdxr.js → timeline.animation-79215cd4-KteJaZPb.js} +19 -0
- package/dist/generated/components.js +16 -0
- package/dist/generated/components.server.js +25 -1
- package/dist/index.js +1 -0
- package/dist/providers/NotificationProvider.js +83 -0
- package/dist/types/generated/components.d.ts +8 -0
- package/dist/types/generated/components.server.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/providers/NotificationProvider.d.ts +36 -0
- package/package.json +4 -1
- package/dist/cjs/collapse.animation-16e3af45-CChx_tQJ.js +0 -84
- package/dist/cjs/fade.animation-71e8e34c-BAw_TYsB.js +0 -68
- package/dist/cjs/nv-accordion.entry-hi3M0POV.js +0 -164
- package/dist/cjs/nv-icon.entry-CrgnozDL.js +0 -79
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
- [Nova Components React](#nova-components-react)
|
|
6
6
|
- [Key Features](#key-features)
|
|
7
7
|
- [Installation](#installation)
|
|
8
|
-
- [
|
|
8
|
+
- [Setting up Tailwind](#setting-up-tailwind)
|
|
9
|
+
- [About Tailwind and the Nova Plugin](#about-tailwind-and-the-nova-plugin)
|
|
9
10
|
- [1. Install Tailwind CSS and the Vite Plugin](#1-install-tailwind-css-and-the-vite-plugin)
|
|
10
11
|
- [2. Configure the Vite Plugin](#2-configure-the-vite-plugin)
|
|
11
12
|
- [3. Create `tailwind.config.ts`](#3-create-tailwindconfigts)
|
|
@@ -14,9 +15,6 @@
|
|
|
14
15
|
- [6. Use Nova Components with Tailwind Utilities](#6-use-nova-components-with-tailwind-utilities)
|
|
15
16
|
- [7. Setup the Nova Font](#7-setup-the-nova-font)
|
|
16
17
|
- [Creating Your Own Style Components with Tailwind](#creating-your-own-style-components-with-tailwind)
|
|
17
|
-
- [Setup Without Tailwind (Not Recommended)](#setup-without-tailwind-not-recommended)
|
|
18
|
-
- [1. Include Nova Tokens and Nova Utilities](#1-include-nova-tokens-and-nova-utilities)
|
|
19
|
-
- [2. Use Nova Components](#2-use-nova-components)
|
|
20
18
|
- [Nova Font Pro Integration](#nova-font-pro-integration)
|
|
21
19
|
- [Option 1: Import in Global CSS (Recommended)](#option-1-import-in-global-css-recommended)
|
|
22
20
|
- [Option 2: HTML Integration](#option-2-html-integration)
|
|
@@ -27,7 +25,7 @@
|
|
|
27
25
|
## Key Features
|
|
28
26
|
|
|
29
27
|
- **Lightweight Integration**: Leverage Nova Web Components with minimal configuration in React.
|
|
30
|
-
- **Customizable Styling**: Use Tailwind
|
|
28
|
+
- **Customizable Styling**: Use Tailwind’s utility classes with the Nova Tailwind theme and plugin for token-driven styling and layouts.
|
|
31
29
|
- **Dark Mode Ready**: Toggle dark mode by adding the `dark` class to your `body` element.
|
|
32
30
|
- **Nova Font Pro Support**: Easily integrate Nova’s custom font for a consistent design experience.
|
|
33
31
|
|
|
@@ -59,13 +57,27 @@ npm config set strict-ssl false
|
|
|
59
57
|
|
|
60
58
|
---
|
|
61
59
|
|
|
62
|
-
##
|
|
60
|
+
## Setting up Tailwind
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
Nova React requires Tailwind CSS for styling. Tailwind provides a powerful utility-first workflow and an optimized bundle size. Nova includes a dedicated Tailwind theme and plugin that map Nova’s design tokens to Tailwind’s theme and utilities, enabling consistent, token-driven styling across your app.
|
|
65
63
|
|
|
66
64
|
> **Tailwind Version**
|
|
67
65
|
> This guide is written for Tailwind v4. While compatible with v3, some features may not work as expected.
|
|
68
66
|
|
|
67
|
+
### About Tailwind and the Nova Plugin
|
|
68
|
+
|
|
69
|
+
- **What is Tailwind?** A utility-first CSS framework with low-level, composable classes (flex, grid, spacing, color, typography) to rapidly build UIs.
|
|
70
|
+
- **Nova Tokens**: Nova ships design tokens as CSS variables (via the Spark and Ocean themes) covering colors, spacing, typography, radii, shadows, and more.
|
|
71
|
+
- **Integration**:
|
|
72
|
+
- `novaTailwindTheme` wires Nova tokens into Tailwind’s theme scales.
|
|
73
|
+
- The Nova Tailwind plugin exposes utilities and variants that reference those tokens, so your Tailwind classes resolve to Nova’s token values at runtime.
|
|
74
|
+
- **Why import tokens CSS?** Import one token CSS file (`spark.css` or `ocean.css`) so the underlying CSS variables exist at runtime. The Tailwind utilities generated by the plugin read from these variables.
|
|
75
|
+
- **How to use**:
|
|
76
|
+
- Build responsive layouts with standard Tailwind utilities (flex, grid, gap, spacing).
|
|
77
|
+
- Customize Nova components by applying classes to `nv-*` elements and their slotted content.
|
|
78
|
+
- Centralize repeated patterns using Tailwind’s `@apply`.
|
|
79
|
+
- **Do not mix with legacy utilities**: When using Tailwind, do not import `@nova-design-system/nova-base/dist/css/nova-utils.css` to avoid redundant CSS and larger bundles.
|
|
80
|
+
|
|
69
81
|
Below is an example setup using Vite + React. If you’re using another framework or bundler, please refer to the [Tailwind Installation Guide](https://tailwindcss.com/docs/installation).
|
|
70
82
|
|
|
71
83
|
### 1. Install Tailwind CSS and the Vite Plugin
|
|
@@ -137,6 +149,8 @@ createRoot(document.getElementById('root')!).render(
|
|
|
137
149
|
)
|
|
138
150
|
```
|
|
139
151
|
|
|
152
|
+
> When using Tailwind, do not import `@nova-design-system/nova-base/dist/css/nova-utils.css`.
|
|
153
|
+
|
|
140
154
|
### 6. Use Nova Components with Tailwind Utilities
|
|
141
155
|
|
|
142
156
|
```tsx
|
|
@@ -158,6 +172,9 @@ const MyComponent: React.FC = () => {
|
|
|
158
172
|
export default MyComponent
|
|
159
173
|
```
|
|
160
174
|
|
|
175
|
+
- Apply Tailwind classes to build layouts (e.g., `flex`, `grid`, `gap-*`, `p-*`, `m-*`).
|
|
176
|
+
- Compose classes to customize the look and spacing of Nova components and their content.
|
|
177
|
+
|
|
161
178
|
### 7. Setup the Nova Font
|
|
162
179
|
|
|
163
180
|
Follow the steps in the [Nova Font Pro Integration](#nova-font-pro-integration) section below.
|
|
@@ -201,59 +218,11 @@ This ensures consistent styling and keeps your markup clean. Any colors or spaci
|
|
|
201
218
|
|
|
202
219
|
---
|
|
203
220
|
|
|
204
|
-
## Setup Without Tailwind (Not Recommended)
|
|
205
|
-
|
|
206
|
-
If you don’t plan to use Tailwind, Nova provides a large utility CSS file for quick prototyping. Be aware that this approach will increase your CSS bundle size, offer less options, and lacks the flexibility and optimizations of Tailwind.
|
|
207
|
-
|
|
208
|
-
### 1. Include Nova Tokens and Nova Utilities
|
|
209
|
-
|
|
210
|
-
In your entry point (`main.tsx`):
|
|
211
|
-
|
|
212
|
-
```ts
|
|
213
|
-
import { StrictMode } from 'react'
|
|
214
|
-
import { createRoot } from 'react-dom/client'
|
|
215
|
-
|
|
216
|
-
import '@nova-design-system/nova-base/dist/css/spark.css' // or ocean.css
|
|
217
|
-
import '@nova-design-system/nova-base/dist/css/nova-utils.css'
|
|
218
|
-
import './index.css'
|
|
219
|
-
|
|
220
|
-
import App from './App.tsx'
|
|
221
|
-
|
|
222
|
-
createRoot(document.getElementById('root')!).render(
|
|
223
|
-
<StrictMode>
|
|
224
|
-
<App />
|
|
225
|
-
</StrictMode>
|
|
226
|
-
)
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### 2. Use Nova Components
|
|
230
|
-
|
|
231
|
-
```tsx
|
|
232
|
-
import { useState } from 'react'
|
|
233
|
-
import { NvButton } from "@nova-design-system/nova-react"
|
|
234
|
-
|
|
235
|
-
const MyComponent: React.FC = () => {
|
|
236
|
-
const [count, setCount] = useState(0)
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<div className="flex items-center justify-center">
|
|
240
|
-
<NvButton danger onClick={() => setCount(count + 1)}>
|
|
241
|
-
Count is {count}
|
|
242
|
-
</NvButton>
|
|
243
|
-
</div>
|
|
244
|
-
)
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export default MyComponent
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
221
|
## Nova Font Pro Integration
|
|
253
222
|
|
|
254
223
|
> [!WARNING]
|
|
255
224
|
> Nova Fonts is a protected asset and is not included in the Nova Base package. You need to include the Nova Fonts CSS file in your project.
|
|
256
|
-
> To get the Nova Fonts URL, please contact us via Teams or get the URL in the Nova Design System [internal wiki](https://dev.azure.com/elia-digitization/Nova/_wiki/wikis/Nova.wiki/30245/Nova-Font-Pro).
|
|
225
|
+
> To get the Nova Fonts URL, **please contact us via Teams** or get the URL in the Nova Design System [internal wiki](https://dev.azure.com/elia-digitization/Nova/_wiki/wikis/Nova.wiki/30245/Nova-Font-Pro).
|
|
257
226
|
|
|
258
227
|
Once you have the URL, you can integrate it using any of these methods:
|
|
259
228
|
|
|
@@ -261,7 +230,7 @@ export default MyComponent
|
|
|
261
230
|
In your main CSS file (e.g., `src/index.css`):
|
|
262
231
|
|
|
263
232
|
```css
|
|
264
|
-
@import url('
|
|
233
|
+
@import url('contact-us-for-URL/nova-fonts-pro.css');
|
|
265
234
|
```
|
|
266
235
|
|
|
267
236
|
### Option 2: HTML Integration
|
|
@@ -271,7 +240,7 @@ In your `index.html`:
|
|
|
271
240
|
<!DOCTYPE html>
|
|
272
241
|
<html>
|
|
273
242
|
<head>
|
|
274
|
-
<link rel="stylesheet" href="
|
|
243
|
+
<link rel="stylesheet" href="contact-us-for-URL/nova-fonts-pro.css">
|
|
275
244
|
</head>
|
|
276
245
|
<body>
|
|
277
246
|
<div id="root"></div>
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styleValueTypes_esF5d10b79 = require('./style-value-types.es-f5d10b79-D0QCM8OB.js');
|
|
4
|
+
|
|
5
|
+
const a = (a1, a2) => 1.0 - 3.0 * a2 + 3.0 * a1;
|
|
6
|
+
const b = (a1, a2) => 3.0 * a2 - 6.0 * a1;
|
|
7
|
+
const c = (a1) => 3.0 * a1;
|
|
8
|
+
const calcBezier = (t, a1, a2) => ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t;
|
|
9
|
+
const getSlope = (t, a1, a2) => 3.0 * a(a1, a2) * t * t + 2.0 * b(a1, a2) * t + c(a1);
|
|
10
|
+
const subdivisionPrecision = 0.0000001;
|
|
11
|
+
const subdivisionMaxIterations = 10;
|
|
12
|
+
function binarySubdivide(aX, aA, aB, mX1, mX2) {
|
|
13
|
+
let currentX;
|
|
14
|
+
let currentT;
|
|
15
|
+
let i = 0;
|
|
16
|
+
do {
|
|
17
|
+
currentT = aA + (aB - aA) / 2.0;
|
|
18
|
+
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
19
|
+
if (currentX > 0.0) {
|
|
20
|
+
aB = currentT;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
aA = currentT;
|
|
24
|
+
}
|
|
25
|
+
} while (Math.abs(currentX) > subdivisionPrecision &&
|
|
26
|
+
++i < subdivisionMaxIterations);
|
|
27
|
+
return currentT;
|
|
28
|
+
}
|
|
29
|
+
const newtonIterations = 8;
|
|
30
|
+
const newtonMinSlope = 0.001;
|
|
31
|
+
function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
|
|
32
|
+
for (let i = 0; i < newtonIterations; ++i) {
|
|
33
|
+
const currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
34
|
+
if (currentSlope === 0.0) {
|
|
35
|
+
return aGuessT;
|
|
36
|
+
}
|
|
37
|
+
const currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
38
|
+
aGuessT -= currentX / currentSlope;
|
|
39
|
+
}
|
|
40
|
+
return aGuessT;
|
|
41
|
+
}
|
|
42
|
+
const kSplineTableSize = 11;
|
|
43
|
+
const kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
|
|
44
|
+
function cubicBezier(mX1, mY1, mX2, mY2) {
|
|
45
|
+
const sampleValues = new Float32Array(kSplineTableSize);
|
|
46
|
+
for (let i = 0; i < kSplineTableSize; ++i) {
|
|
47
|
+
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
|
|
48
|
+
}
|
|
49
|
+
function getTForX(aX) {
|
|
50
|
+
let intervalStart = 0.0;
|
|
51
|
+
let currentSample = 1;
|
|
52
|
+
const lastSample = kSplineTableSize - 1;
|
|
53
|
+
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
|
|
54
|
+
intervalStart += kSampleStepSize;
|
|
55
|
+
}
|
|
56
|
+
--currentSample;
|
|
57
|
+
const dist = (aX - sampleValues[currentSample]) /
|
|
58
|
+
(sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
59
|
+
const guessForT = intervalStart + dist * kSampleStepSize;
|
|
60
|
+
const initialSlope = getSlope(guessForT, mX1, mX2);
|
|
61
|
+
if (initialSlope >= newtonMinSlope) {
|
|
62
|
+
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
63
|
+
}
|
|
64
|
+
else if (initialSlope === 0.0) {
|
|
65
|
+
return guessForT;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Read current box metrics (height + vertical margins).
|
|
76
|
+
* @param {HTMLElement} node - The element to measure.
|
|
77
|
+
* @returns {object} The box metrics.
|
|
78
|
+
*/
|
|
79
|
+
function getBoxMetrics(node) {
|
|
80
|
+
const rectHeight = node.getBoundingClientRect().height;
|
|
81
|
+
const style = getComputedStyle(node);
|
|
82
|
+
const marginTop = parseFloat(style.marginTop) || 0;
|
|
83
|
+
const marginBottom = parseFloat(style.marginBottom) || 0;
|
|
84
|
+
const total = rectHeight + marginTop + marginBottom;
|
|
85
|
+
return { height: rectHeight, marginTop, marginBottom, total };
|
|
86
|
+
}
|
|
87
|
+
const useCollapse = (node, { duration = 200, overflow = 'hidden' } = {}) => {
|
|
88
|
+
let currentAnimation = null;
|
|
89
|
+
const stop = () => {
|
|
90
|
+
if (currentAnimation) {
|
|
91
|
+
currentAnimation.stop();
|
|
92
|
+
currentAnimation = null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const setStyle = (styles) => {
|
|
96
|
+
for (const [k, v] of Object.entries(styles)) {
|
|
97
|
+
node.style[k] = v;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/** Instantly apply collapsed styles (no animation). */
|
|
101
|
+
function setCollapsed() {
|
|
102
|
+
stop();
|
|
103
|
+
setStyle({
|
|
104
|
+
height: '0px',
|
|
105
|
+
marginTop: '0px',
|
|
106
|
+
marginBottom: '0px',
|
|
107
|
+
overflow,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** Instantly apply expanded styles (no animation). */
|
|
111
|
+
function setExpanded() {
|
|
112
|
+
stop();
|
|
113
|
+
setStyle({
|
|
114
|
+
height: '',
|
|
115
|
+
marginTop: '',
|
|
116
|
+
marginBottom: '',
|
|
117
|
+
overflow: '',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Collapse: animate from current box (height + margins) down to 0.
|
|
122
|
+
*/
|
|
123
|
+
function collapse() {
|
|
124
|
+
stop();
|
|
125
|
+
return new Promise(resolve => {
|
|
126
|
+
const { height, marginTop, marginBottom, total } = getBoxMetrics(node);
|
|
127
|
+
// Lock current box
|
|
128
|
+
setStyle({
|
|
129
|
+
height: `${height}px`,
|
|
130
|
+
marginTop: `${marginTop}px`,
|
|
131
|
+
marginBottom: `${marginBottom}px`,
|
|
132
|
+
overflow,
|
|
133
|
+
willChange: 'height, margin',
|
|
134
|
+
});
|
|
135
|
+
const denom = total > 0 ? total : 0.0001; // avoid divide-by-zero
|
|
136
|
+
currentAnimation = styleValueTypes_esF5d10b79.animate({
|
|
137
|
+
from: total,
|
|
138
|
+
to: 0,
|
|
139
|
+
duration,
|
|
140
|
+
ease: cubicBezier(0.2, 0, 0, 1),
|
|
141
|
+
onUpdate: v => {
|
|
142
|
+
const ratio = v / denom;
|
|
143
|
+
setStyle({
|
|
144
|
+
height: `${height * ratio}px`,
|
|
145
|
+
marginTop: `${marginTop * ratio}px`,
|
|
146
|
+
marginBottom: `${marginBottom * ratio}px`,
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
onComplete: () => {
|
|
150
|
+
setStyle({
|
|
151
|
+
height: '0px',
|
|
152
|
+
marginTop: '0px',
|
|
153
|
+
marginBottom: '0px',
|
|
154
|
+
willChange: '',
|
|
155
|
+
});
|
|
156
|
+
resolve();
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Expand: animate from 0 box to the element's natural box (height + margins),
|
|
163
|
+
* then restore `height: auto` and computed margins.
|
|
164
|
+
*/
|
|
165
|
+
async function expand() {
|
|
166
|
+
stop();
|
|
167
|
+
// Make sure any pending screen updates are done
|
|
168
|
+
await new Promise(resolve => requestAnimationFrame(resolve));
|
|
169
|
+
return new Promise(resolve => {
|
|
170
|
+
// Let the element size naturally to measure the target box
|
|
171
|
+
// await next animation frame
|
|
172
|
+
setStyle({
|
|
173
|
+
height: '',
|
|
174
|
+
marginTop: '',
|
|
175
|
+
marginBottom: '',
|
|
176
|
+
overflow,
|
|
177
|
+
});
|
|
178
|
+
const { height, marginTop, marginBottom, total } = getBoxMetrics(node);
|
|
179
|
+
// Start locked at zero box
|
|
180
|
+
setStyle({
|
|
181
|
+
height: '0px',
|
|
182
|
+
marginTop: '0px',
|
|
183
|
+
marginBottom: '0px',
|
|
184
|
+
willChange: 'height, margin',
|
|
185
|
+
});
|
|
186
|
+
const denom = total > 0 ? total : 0.0001;
|
|
187
|
+
currentAnimation = styleValueTypes_esF5d10b79.animate({
|
|
188
|
+
from: 0,
|
|
189
|
+
to: total,
|
|
190
|
+
duration,
|
|
191
|
+
ease: cubicBezier(0.2, 0, 0, 1),
|
|
192
|
+
onUpdate: v => {
|
|
193
|
+
const ratio = v / denom;
|
|
194
|
+
setStyle({
|
|
195
|
+
height: `${height * ratio}px`,
|
|
196
|
+
marginTop: `${marginTop * ratio}px`,
|
|
197
|
+
marginBottom: `${marginBottom * ratio}px`,
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
onComplete: () => {
|
|
201
|
+
// Restore natural layout
|
|
202
|
+
setStyle({
|
|
203
|
+
height: '',
|
|
204
|
+
marginTop: '',
|
|
205
|
+
marginBottom: '',
|
|
206
|
+
overflow: '',
|
|
207
|
+
willChange: '',
|
|
208
|
+
});
|
|
209
|
+
resolve();
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return { collapse, expand, setCollapsed, setExpanded };
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
exports.useCollapse = useCollapse;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
exports.NotificationPosition = void 0;
|
|
4
|
+
(function (NotificationPosition) {
|
|
5
|
+
NotificationPosition["TopRight"] = "top-right";
|
|
6
|
+
NotificationPosition["TopLeft"] = "top-left";
|
|
7
|
+
NotificationPosition["TopCenter"] = "top-center";
|
|
8
|
+
NotificationPosition["BottomRight"] = "bottom-right";
|
|
9
|
+
NotificationPosition["BottomLeft"] = "bottom-left";
|
|
10
|
+
NotificationPosition["BottomCenter"] = "bottom-center";
|
|
11
|
+
})(exports.NotificationPosition || (exports.NotificationPosition = {}));
|
|
3
12
|
exports.FeedbackColors = void 0;
|
|
4
13
|
(function (FeedbackColors) {
|
|
5
14
|
FeedbackColors["Information"] = "information";
|
|
@@ -44,6 +53,11 @@ exports.ButtonType = void 0;
|
|
|
44
53
|
ButtonType["Reset"] = "reset";
|
|
45
54
|
ButtonType["Button"] = "button";
|
|
46
55
|
})(exports.ButtonType || (exports.ButtonType = {}));
|
|
56
|
+
var NotificationEmphasis;
|
|
57
|
+
(function (NotificationEmphasis) {
|
|
58
|
+
NotificationEmphasis["Medium"] = "medium";
|
|
59
|
+
NotificationEmphasis["High"] = "high";
|
|
60
|
+
})(NotificationEmphasis || (NotificationEmphasis = {}));
|
|
47
61
|
var ToggleButtonEmphasis;
|
|
48
62
|
(function (ToggleButtonEmphasis) {
|
|
49
63
|
ToggleButtonEmphasis["High"] = "high";
|