@corva/ui 3.76.0-9 → 3.77.0-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/MCP_README.md +86 -36
- package/README.md +8 -5
- package/cjs-bundle/componentsV2/AppPanel/AppPanelDisplay.js +1 -1
- package/cjs-bundle/componentsV2/AppPanel/AppPanelDisplay.js.map +1 -1
- package/cjs-bundle/componentsV2/DatePicker/TimePicker/TimePicker.js +1 -1
- package/cjs-bundle/componentsV2/DatePicker/TimePicker/TimePicker.js.map +1 -1
- package/cjs-bundle/componentsV2/DatePicker/utils.js +1 -1
- package/cjs-bundle/componentsV2/DatePicker/utils.js.map +1 -1
- package/cjs-bundle/componentsV2/Modal/Modal.js +1 -1
- package/cjs-bundle/componentsV2/Modal/Modal.js.map +1 -1
- package/cjs-bundle/componentsV2/TemplatesControl/Store/hooks/useInitialize.js +1 -1
- package/cjs-bundle/componentsV2/TemplatesControl/Store/hooks/useInitialize.js.map +1 -1
- package/cjs-bundle/effects/useDevCenterApp.js +1 -1
- package/cjs-bundle/effects/useDevCenterApp.js.map +1 -1
- package/componentsV2/AppHeader/__tests__/AppHeaderEmbedded.test.d.ts +2 -0
- package/componentsV2/AppHeader/__tests__/AppHeaderEmbedded.test.d.ts.map +1 -0
- package/componentsV2/AppPanel/AppPanelDisplay.d.ts.map +1 -1
- package/componentsV2/AppPanel/AppPanelDisplay.js +1 -1
- package/componentsV2/AppPanel/AppPanelDisplay.js.map +1 -1
- package/componentsV2/DatePicker/TimePicker/TimePicker.js +1 -1
- package/componentsV2/DatePicker/TimePicker/TimePicker.js.map +1 -1
- package/componentsV2/DatePicker/utils.js +1 -1
- package/componentsV2/DatePicker/utils.js.map +1 -1
- package/componentsV2/Modal/Modal.d.ts.map +1 -1
- package/componentsV2/Modal/Modal.js +1 -1
- package/componentsV2/Modal/Modal.js.map +1 -1
- package/componentsV2/TemplatesControl/Store/hooks/useInitialize.d.ts.map +1 -1
- package/componentsV2/TemplatesControl/Store/hooks/useInitialize.js +1 -1
- package/componentsV2/TemplatesControl/Store/hooks/useInitialize.js.map +1 -1
- package/effects/useDevCenterApp.d.ts.map +1 -1
- package/effects/useDevCenterApp.js +1 -1
- package/effects/useDevCenterApp.js.map +1 -1
- package/mcp-server/server.mjs +10 -10
- package/package.json +1 -1
- package/styles/common.scss +0 -14
- package/styles/mixins.scss +0 -14
- package/tsconfig.tsbuildinfo +1 -1
package/MCP_README.md
CHANGED
|
@@ -22,9 +22,10 @@ supports Claude Code, Cursor, and Codex CLI.
|
|
|
22
22
|
|
|
23
23
|
### Available Tools
|
|
24
24
|
|
|
25
|
-
- `search_corva_ui` - Search components, hooks, utils by name or description. When
|
|
26
|
-
`
|
|
27
|
-
discovers a candidate.
|
|
25
|
+
- `search_corva_ui` - Search components, hooks, utils by name or description. When a search restricted to one
|
|
26
|
+
`category` (`v2` or `v1`) returns nothing at all and components from the other version do match, the response
|
|
27
|
+
surfaces them in a labeled fallback block so a single search still discovers a candidate. Any hook or util hit
|
|
28
|
+
already counts as a result and suppresses the fallback.
|
|
28
29
|
- `get_component_docs` - Get detailed component documentation with props and examples
|
|
29
30
|
- `get_hook_docs` - Get hook documentation
|
|
30
31
|
- `get_theme_docs` - Get theme/styling documentation
|
|
@@ -62,7 +63,7 @@ MCP prompts are surfaced as slash commands in clients that support them. In Clau
|
|
|
62
63
|
`/mcp__corva-ui__<name>`.
|
|
63
64
|
|
|
64
65
|
- `figma_to_code` — Translate a Figma node into React components that follow `@corva/ui` conventions. Orchestrates the
|
|
65
|
-
Figma
|
|
66
|
+
Figma MCP server (for design context and Code Connect mappings) and the `@corva/ui` MCP tools above (for component,
|
|
66
67
|
icon, theme, and hook lookups).
|
|
67
68
|
|
|
68
69
|
**Argument** (optional; the assistant asks if missing):
|
|
@@ -81,9 +82,12 @@ MCP prompts are surfaced as slash commands in clients that support them. In Clau
|
|
|
81
82
|
/mcp__corva-ui__figma_to_code https://www.figma.com/design/ABC/Sample?node-id=1-2 create under src/apps/drilling/RigStatusCard.tsx
|
|
82
83
|
```
|
|
83
84
|
|
|
84
|
-
**Prerequisite:**
|
|
85
|
-
`
|
|
86
|
-
|
|
85
|
+
**Prerequisite:** a Figma MCP server must be connected in the same client session so the prompt can call its
|
|
86
|
+
`get_design_context` tool (the prompt detects the server alias itself). Either connect Figma's remote server
|
|
87
|
+
(`https://mcp.figma.com/mcp`, browser OAuth — Figma's recommended option) or enable the desktop one: open the file in
|
|
88
|
+
Figma Desktop, switch to Dev Mode (`Shift+D`) and click **Enable desktop MCP server** in the MCP server section of the
|
|
89
|
+
inspect panel, then register `http://127.0.0.1:3845/mcp` as an HTTP MCP server in your client — enabling it in Figma
|
|
90
|
+
alone does not connect it. Reconnect or restart your client afterwards.
|
|
87
91
|
|
|
88
92
|
**Scope:** primarily consumer mode — app repos that depend on `@corva/ui` and import from its entry points. Authoring
|
|
89
93
|
mode (inside the `@corva/ui` repo itself) is auto-detected from `package.json` and adjusts output conventions.
|
|
@@ -190,7 +194,14 @@ stays scoped and minimal, and raw sample values are never pasted into committed
|
|
|
190
194
|
> to [Verifying It Works](#verifying-it-works). Older projects scaffolded before MCP was added to the template still
|
|
191
195
|
> need the setup below.
|
|
192
196
|
|
|
193
|
-
> **Minimum Version:**
|
|
197
|
+
> **Minimum Version:** the `npx … corva-ui-mcp` configs work from `@corva/ui` **3.44.0**; the Quick Setup command and
|
|
198
|
+
> the direct `server.mjs` paths need **3.46.0** or newer. Tool and prompt descriptions in this document match current
|
|
199
|
+
> releases.
|
|
200
|
+
|
|
201
|
+
> **Node:** `@corva/ui` declares `engines.node: ^24`, so use Node 24.x for the setup command and the server. Other
|
|
202
|
+
> majors are outside that range: npm prints an unsupported-engine warning when it installs the package, and Yarn
|
|
203
|
+
> classic normally rejects the install unless engine checks are disabled. The nvm examples below assume a Node 24
|
|
204
|
+
> install.
|
|
194
205
|
|
|
195
206
|
### Quick Setup
|
|
196
207
|
|
|
@@ -204,7 +215,12 @@ This creates `.mcp.json` (Claude Code), `.cursor/mcp.json` (Cursor), and `.codex
|
|
|
204
215
|
Restart your IDE or reload MCP servers afterward.
|
|
205
216
|
|
|
206
217
|
> If any of these files already exist, the setup command **extends** them — your existing MCP server entries are
|
|
207
|
-
> preserved, and only the `corva-ui` entry is added or updated.
|
|
218
|
+
> preserved, and only the `corva-ui` entry (`corva_ui` in the Codex TOML) is added or updated. "Updated" means replaced
|
|
219
|
+
> with the stock entry: anything you added to it by hand, such as an `env` block with
|
|
220
|
+
> `CORVA_UI_MCP_TELEMETRY_DISABLED`, is dropped and has to be re-added. The files are re-serialized on write, so
|
|
221
|
+
> comments and hand formatting in the TOML do not survive either. A file that fails to parse is overwritten from
|
|
222
|
+
> scratch (the command warns when it does that). On native Windows the generated entry uses plain `npx`; if your client
|
|
223
|
+
> cannot spawn it, apply the `cmd /c` form from the Native Windows note under [Local Setup](#local-setup-recommended).
|
|
208
224
|
|
|
209
225
|
> **Monorepo:** Run the setup command from the monorepo root, not from individual
|
|
210
226
|
> `apps/*` directories. See [Monorepo Setup](#monorepo-setup) for details.
|
|
@@ -277,11 +293,12 @@ issues, always in sync with your project's `@corva/ui` version.
|
|
|
277
293
|
}
|
|
278
294
|
```
|
|
279
295
|
|
|
280
|
-
2. Restart Cursor or
|
|
296
|
+
2. Restart Cursor (or toggle the `corva-ui` server off and on under **Customize** in the sidebar)
|
|
281
297
|
|
|
282
|
-
3.
|
|
298
|
+
3. Servers from `.cursor/mcp.json` show up under **Customize** in the sidebar, where they can be enabled or disabled.
|
|
299
|
+
If one fails to start, its output is in the Output panel under "MCP Logs".
|
|
283
300
|
|
|
284
|
-
4. Verify: In
|
|
301
|
+
4. Verify: In the agent chat, ask about a @corva/ui component
|
|
285
302
|
|
|
286
303
|
#### OpenAI Codex CLI
|
|
287
304
|
|
|
@@ -380,8 +397,8 @@ issues ([reference](https://github.com/modelcontextprotocol/servers/issues/64)).
|
|
|
380
397
|
1. Find your paths:
|
|
381
398
|
|
|
382
399
|
```bash
|
|
383
|
-
nvm which current # e.g., /Users/you/.nvm/versions/node/
|
|
384
|
-
which corva-ui-mcp # e.g., /Users/you/.nvm/versions/node/
|
|
400
|
+
nvm which current # e.g., /Users/you/.nvm/versions/node/v24.15.0/bin/node
|
|
401
|
+
which corva-ui-mcp # e.g., /Users/you/.nvm/versions/node/v24.15.0/bin/corva-ui-mcp
|
|
385
402
|
```
|
|
386
403
|
|
|
387
404
|
2. Add the `mcpServers` entry to your `~/.claude.json` (create the file if it doesn't exist, or merge into existing
|
|
@@ -391,9 +408,9 @@ which corva-ui-mcp # e.g., /Users/you/.nvm/versions/node/v22.12.0/bin/corva-
|
|
|
391
408
|
{
|
|
392
409
|
"mcpServers": {
|
|
393
410
|
"corva-ui": {
|
|
394
|
-
"command": "/Users/you/.nvm/versions/node/
|
|
411
|
+
"command": "/Users/you/.nvm/versions/node/v24.15.0/bin/node",
|
|
395
412
|
"args": [
|
|
396
|
-
"/Users/you/.nvm/versions/node/
|
|
413
|
+
"/Users/you/.nvm/versions/node/v24.15.0/bin/corva-ui-mcp"
|
|
397
414
|
]
|
|
398
415
|
}
|
|
399
416
|
}
|
|
@@ -469,7 +486,7 @@ got from `npm prefix -g`):
|
|
|
469
486
|
"corva-ui": {
|
|
470
487
|
"command": "C:/Program Files/nodejs/node.exe",
|
|
471
488
|
"args": [
|
|
472
|
-
"C:/Users/you/AppData/Roaming/nvm/
|
|
489
|
+
"C:/Users/you/AppData/Roaming/nvm/v24.15.0/node_modules/@corva/ui/mcp-server/server.mjs"
|
|
473
490
|
]
|
|
474
491
|
}
|
|
475
492
|
}
|
|
@@ -520,9 +537,9 @@ the config to `~/.cursor/mcp.json`.
|
|
|
520
537
|
{
|
|
521
538
|
"mcpServers": {
|
|
522
539
|
"corva-ui": {
|
|
523
|
-
"command": "/Users/you/.nvm/versions/node/
|
|
540
|
+
"command": "/Users/you/.nvm/versions/node/v24.15.0/bin/node",
|
|
524
541
|
"args": [
|
|
525
|
-
"/Users/you/.nvm/versions/node/
|
|
542
|
+
"/Users/you/.nvm/versions/node/v24.15.0/bin/corva-ui-mcp"
|
|
526
543
|
]
|
|
527
544
|
}
|
|
528
545
|
}
|
|
@@ -564,14 +581,15 @@ Find your paths with `where.exe node` and `npm prefix -g` as described in the
|
|
|
564
581
|
"corva-ui": {
|
|
565
582
|
"command": "C:/Program Files/nodejs/node.exe",
|
|
566
583
|
"args": [
|
|
567
|
-
"C:/Users/you/AppData/Roaming/nvm/
|
|
584
|
+
"C:/Users/you/AppData/Roaming/nvm/v24.15.0/node_modules/@corva/ui/mcp-server/server.mjs"
|
|
568
585
|
]
|
|
569
586
|
}
|
|
570
587
|
}
|
|
571
588
|
}
|
|
572
589
|
```
|
|
573
590
|
|
|
574
|
-
> **Note:**
|
|
591
|
+
> **Note:** the server shows up under **Customize** in the sidebar, where it can be enabled or disabled; if it fails to
|
|
592
|
+
> start, its output is in the Output panel under "MCP Logs".
|
|
575
593
|
|
|
576
594
|
#### Cursor (without nvm)
|
|
577
595
|
|
|
@@ -597,14 +615,15 @@ Add to `~/.cursor/mcp.json` (merge into existing config):
|
|
|
597
615
|
> `cmd /c` workaround from the [Native Windows note](#claude-code) under Local Setup. WSL users running
|
|
598
616
|
> native-Windows Cursor should follow the `wsl.exe` config from [Cursor Windows + WSL](#windows--wsl-1) instead.
|
|
599
617
|
|
|
600
|
-
> **Note:**
|
|
618
|
+
> **Note:** the server shows up under **Customize** in the sidebar, where it can be enabled or disabled; if it fails to
|
|
619
|
+
> start, its output is in the Output panel under "MCP Logs".
|
|
601
620
|
|
|
602
621
|
#### Troubleshooting: Direct Node Path
|
|
603
622
|
|
|
604
623
|
If `npx` isn't viable (offline, corporate proxy blocking the registry, or you need a strictly pinned version
|
|
605
624
|
regardless of npm cache state), point Node directly at the global install's `server.mjs`. This shape requires
|
|
606
|
-
Step 1 above and works for any IDE — drop it into `~/.claude.json
|
|
607
|
-
`~/.codex/config.toml
|
|
625
|
+
Step 1 above and works for any IDE — drop it into `~/.claude.json` or `~/.cursor/mcp.json`; the Codex CLI equivalent
|
|
626
|
+
for `~/.codex/config.toml` follows the JSON.
|
|
608
627
|
|
|
609
628
|
Find your global install's path with `npm prefix -g`, then substitute it below:
|
|
610
629
|
|
|
@@ -621,6 +640,12 @@ Find your global install's path with `npm prefix -g`, then substitute it below:
|
|
|
621
640
|
}
|
|
622
641
|
```
|
|
623
642
|
|
|
643
|
+
```toml
|
|
644
|
+
[mcp_servers.corva_ui]
|
|
645
|
+
command = "node"
|
|
646
|
+
args = ["<npm-prefix>/lib/node_modules/@corva/ui/mcp-server/server.mjs"]
|
|
647
|
+
```
|
|
648
|
+
|
|
624
649
|
Native-Windows substitution (default nodejs.org installer): `command` becomes `"C:/Program Files/nodejs/node.exe"`,
|
|
625
650
|
`args` becomes `["C:/Users/you/AppData/Roaming/npm/node_modules/@corva/ui/mcp-server/server.mjs"]`. nvm-windows
|
|
626
651
|
users should use the [Native Windows (nvm-windows)](#native-windows-nvm-windows) shape above instead — its
|
|
@@ -643,30 +668,55 @@ This runs the `get_diagnostics` tool under the hood. Clients without slash-comma
|
|
|
643
668
|
If the AI doesn't pick up the MCP tools, restart your IDE / reload MCP servers, and confirm the config file is at the
|
|
644
669
|
location listed in the [Local Setup](#local-setup-recommended) table for your IDE.
|
|
645
670
|
|
|
646
|
-
|
|
671
|
+
If the very first connection times out, the cause is usually the download. `npx -p @corva/ui corva-ui-mcp` reuses the
|
|
672
|
+
`@corva/ui` installed under the directory the client starts the server from; when it finds none — a repo that doesn't
|
|
673
|
+
depend on it, a workspace root where it isn't hoisted, or a project whose dependencies aren't installed yet — it first
|
|
674
|
+
installs `@corva/ui` with its full dependency tree into npx's cache. One cold-cache run measured roughly 40 seconds and
|
|
675
|
+
about 1 GB on a fast connection; timings vary, but that is past the default MCP startup timeouts of Claude Code (30 s)
|
|
676
|
+
and Codex CLI (10 s). npx then reuses that cache until a newer `@corva/ui` is published. Install `@corva/ui` in the
|
|
677
|
+
project, or run the Quick Setup command once from the same user account (it fills the same npx cache), then
|
|
678
|
+
reconnect. If neither is an option, raise the client's timeout instead: `MCP_TIMEOUT=90000 claude` in a POSIX shell
|
|
679
|
+
for Claude Code, or `startup_timeout_sec = 90` under `[mcp_servers.corva_ui]` in the Codex config.
|
|
647
680
|
|
|
648
|
-
|
|
649
|
-
name/version — when a telemetry endpoint is configured at build time. No hostnames, usernames, IP addresses, or other
|
|
650
|
-
direct machine/user identifiers are collected.
|
|
681
|
+
## Telemetry and Privacy
|
|
651
682
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
683
|
+
The MCP server may collect usage telemetry when it is configured to: for every tool call, the tool name, arguments,
|
|
684
|
+
result, latency and MCP client name/version; for every prompt invocation (slash command), the prompt name, arguments,
|
|
685
|
+
latency and the size of the response. Each run also carries a random instance id, the server and `@corva/ui` versions
|
|
686
|
+
and `NODE_ENV`. No hostnames, usernames, IP addresses, or other direct machine/user identifiers are collected — but
|
|
687
|
+
arguments and results are not scrubbed, so they can contain identifying information you typed.
|
|
688
|
+
|
|
689
|
+
When your client reports workspace roots, the session is also tagged with the **project identity**, so the
|
|
690
|
+
maintainers can tell which app the queries come from: the `name` from the nearest `package.json` and, in Corva apps,
|
|
691
|
+
the `application.key` from the nearest `manifest.json`, each searched upward from the first root. Either may be
|
|
692
|
+
absent. `/mcp__corva-ui__healthcheck` shows the resolved values.
|
|
693
|
+
|
|
694
|
+
**Tool arguments, tool results and prompt arguments are exported in full, without redaction or truncation.** Span
|
|
695
|
+
payloads may therefore contain content from your queries (file paths, source snippets, component names, or other text
|
|
696
|
+
you sent to the tool) alongside the documentation responses. This includes anything you send via the `feedback` prompt
|
|
697
|
+
/ `submit_feedback` tool — the free-text message is recorded verbatim and is intended for the `@corva/ui` maintainers.
|
|
698
|
+
|
|
699
|
+
Data goes to Corva's Uptrace project over fixed OTLP endpoints (`otlp.uptrace.dev`). The credentials and the sampling
|
|
700
|
+
rate are not hard-coded: after checking the opt-out below, the server reads `mcp-server/telemetry-config.local.json`
|
|
701
|
+
under its working directory (a development override — a valid file wins, an invalid or disabled one turns telemetry
|
|
702
|
+
off) and otherwise fetches the DSN and sampling rate from a Corva-hosted URL baked in at build time, with a 10-second
|
|
703
|
+
timeout. If that URL is unset, the fetch fails, or the fetched configuration is disabled, telemetry stays off for the
|
|
704
|
+
session.
|
|
656
705
|
|
|
657
706
|
To check whether telemetry is currently active for your install, run `/mcp__corva-ui__healthcheck` (or call the
|
|
658
|
-
`get_diagnostics` tool directly) — it reports the resolved telemetry status
|
|
659
|
-
endpoint is configured.
|
|
707
|
+
`get_diagnostics` tool directly) — it reports the resolved telemetry status and sampling rate.
|
|
660
708
|
|
|
661
709
|
To opt out entirely, set `CORVA_UI_MCP_TELEMETRY_DISABLED=1` in the server's environment (e.g. in the `env` block of
|
|
662
710
|
your MCP config file) — any non-empty value other than `0` or `false` works. The switch is honored at runtime before
|
|
663
|
-
any telemetry configuration is read.
|
|
711
|
+
any telemetry configuration is read. Feedback travels over the same channel and is subject to the same sampling rate:
|
|
712
|
+
`submit_feedback` and the `feedback` prompt always confirm the message, but with telemetry off nothing reaches the
|
|
713
|
+
maintainers, and with a sampling rate below 1 some messages are dropped.
|
|
664
714
|
|
|
665
715
|
## FAQ
|
|
666
716
|
|
|
667
717
|
### Does this affect my application bundle or runtime?
|
|
668
718
|
|
|
669
|
-
No. The MCP server adds ~
|
|
719
|
+
No. The MCP server adds ~3 MB unpacked to the published `@corva/ui` npm package (bundled server, setup CLI, and pre-generated
|
|
670
720
|
documentation data). These files live in `node_modules/@corva/ui/mcp-server/` and are only used when running the CLI binaries (
|
|
671
721
|
`corva-ui-mcp`, `corva-ui-mcp-setup`). Consuming app bundlers resolve imports from the library's ESM/CJS entry points,
|
|
672
722
|
which don't reference MCP files — so they are never included in application bundles or executed at runtime.
|
package/README.md
CHANGED
|
@@ -48,11 +48,14 @@ Quick setup (run from your project root):
|
|
|
48
48
|
npx -p @corva/ui corva-ui-mcp-setup
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
entries are preserved, and only the `corva-ui` entry is
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
This writes `.mcp.json` (Claude Code), `.cursor/mcp.json` (Cursor), and `.codex/config.toml` (Codex CLI). If a file
|
|
52
|
+
already exists, the command extends it — existing MCP server entries are preserved, and only the `corva-ui` entry is
|
|
53
|
+
added or updated. Restart your IDE (or reload its MCP servers) afterward, then ask your AI agent about any `@corva/ui`
|
|
54
|
+
component to confirm the tools are picked up.
|
|
55
|
+
|
|
56
|
+
The full MCP docs (all tools and prompts, per-IDE local / monorepo / global setup, troubleshooting, telemetry and
|
|
57
|
+
privacy) ship inside the package as `node_modules/@corva/ui/MCP_README.md`. The latest published copy is also readable
|
|
58
|
+
online: <https://cdn.jsdelivr.net/npm/@corva/ui/MCP_README.md>.
|
|
56
59
|
|
|
57
60
|
## Figma Code Connect
|
|
58
61
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("classnames"),s=require("../AppSizeProvider/AppSizeProvider.js");require("../../clients/subscriptions/constants.js"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/subscriptions.v1.js"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions/subscriptions-client.factory.js");var n=require("../../effects/useOutsideClick.js");require("immutable"),require("query-string"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/appPackages.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../constants/corvaCompanyId.js"),require("../../components/GradientManager/configuration/constants.js"),require("../../utils/index.js"),require("uuid"),require("jsona"),require("../../utils/env.js"),require("../../components/StatusBadge/constants.js"),require("@babel/runtime/helpers/toConsumableArray"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js"),require("../../clients/sso/auth0.js"),require("../../clients/sso/oauth2.js"),require("../../clients/api/rateLimiter.js"),require("lodash/isEmpty"),require("lodash/sortBy"),require("../../constants/streamSourceType.js"),require("../../components/DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js"),require("../AppCommonsProvider/AppCommonsProvider.js"),require("../AppCommonsProvider/AppCommonsContext.js");var t=require("./AppPanelsContext.js"),i=require("../Paper/Paper.js"),o=require("../PopoverPanel/PopoverPanel.js"),a=require("./AppPanelIdContext.js"),u=require("../AppContainer/AppContainer.constants.scss.js"),p=require("./AppPanelDisplay.scss.js"),l=require("react/jsx-runtime");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=c(r),d=Number(u.sidePadding.replace(/[^.0-9]/g,""));exports.AppPanelDisplay=function(r){var u=r.anchorRef,c=r.id,m=t.useAppPanelInternal(c),j=m.isOpen,h=m.isPinned,v=m.close,P=m.isAnimated,b=m.width,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("classnames"),s=require("../AppSizeProvider/AppSizeProvider.js");require("../../clients/subscriptions/constants.js"),require("@babel/runtime/helpers/slicedToArray"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/subscriptions.v1.js"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions/subscriptions-client.factory.js");var n=require("../../effects/useOutsideClick.js");require("immutable"),require("query-string"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/appPackages.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../constants/corvaCompanyId.js"),require("../../components/GradientManager/configuration/constants.js"),require("../../utils/index.js"),require("uuid"),require("jsona"),require("../../utils/env.js"),require("../../components/StatusBadge/constants.js"),require("@babel/runtime/helpers/toConsumableArray"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js"),require("../../clients/sso/auth0.js"),require("../../clients/sso/oauth2.js"),require("../../clients/api/rateLimiter.js"),require("lodash/isEmpty"),require("lodash/sortBy"),require("../../constants/streamSourceType.js"),require("../../components/DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js"),require("../AppCommonsProvider/AppCommonsProvider.js"),require("../AppCommonsProvider/AppCommonsContext.js");var t=require("./AppPanelsContext.js"),i=require("../Paper/Paper.js"),o=require("../PopoverPanel/PopoverPanel.js"),a=require("./AppPanelIdContext.js"),u=require("../AppContainer/AppContainer.constants.scss.js"),p=require("./AppPanelDisplay.scss.js"),l=require("react/jsx-runtime");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=c(r),d=Number(u.sidePadding.replace(/[^.0-9]/g,""));exports.AppPanelDisplay=function(r){var u=r.anchorRef,c=r.id,m=t.useAppPanelInternal(c),j=m.isOpen,h=m.isPinned,v=m.close,P=m.isAnimated,b=m.width,f=m.component,A=m.opener,C=m.isExpanded,x=m.placement,y=e.useRef(null),g=s.useAppSize()||{},S=g.height,w=g.width,D=e.useMemo((function(){return{maxHeight:"min(".concat(S||0,"px, 100vh)"),maxWidth:w?w-2*d:0,width:C&&w?w-2*d:b}}),[w,S,C,b]);return n(y,v,[A,'[role="tooltip"]','[role="presentation"]']),f?l.jsxs(a.AppPanelIdProvider,{value:c,children:[u.current&&!h&&l.jsx(o.PopoverPanel,{flip:!1,ref:y,open:j,placement:"start"===x?"bottom-start":"bottom-end",anchorEl:u.current,onClose:v,className:p.popover,preventScroll:!1,backdrop:!1,animate:P,style:D,preventOverflow:!0,children:l.jsx(f,{})}),h&&l.jsx(i.Paper,{className:q.default(p.pinned,"start"===x?p.pinnedStart:p.pinnedEnd),style:D,children:l.jsx(f,{})})]}):null};
|
|
2
2
|
//# sourceMappingURL=AppPanelDisplay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppPanelDisplay.js","sources":["../../../../src/componentsV2/AppPanel/AppPanelDisplay.tsx"],"sourcesContent":["import { CSSProperties, RefObject, useMemo, useRef } from 'react';\nimport classNames from 'classnames';\n\nimport { useAppSize } from '../AppSizeProvider';\nimport { useOutsideClick } from '../../effects';\nimport { Paper } from '../Paper';\nimport { PopoverPanel } from '../PopoverPanel';\n\nimport { useAppPanelInternal } from './AppPanelsContext';\nimport { AppPanelIdProvider } from './AppPanelIdContext';\n\nimport styleConstants from '../AppContainer/AppContainer.constants.scss';\nimport styles from './AppPanelDisplay.scss';\n\nconst sidePadding = Number(styleConstants.sidePadding.replace(/[^.0-9]/g, ''));\n\nexport type PanelProps = {\n id: string | symbol;\n anchorRef: RefObject<HTMLDivElement>;\n};\n\nexport const AppPanelDisplay = ({ anchorRef, id }: PanelProps) => {\n const {\n isOpen,\n isPinned,\n close,\n isAnimated,\n width: panelWidth,\n component: Component,\n opener,\n isExpanded,\n placement,\n } = useAppPanelInternal(id);\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const { height, width: appWidth } = useAppSize() || {};\n\n const wrapperStyle = useMemo<CSSProperties>(\n () => ({\n maxHeight: height
|
|
1
|
+
{"version":3,"file":"AppPanelDisplay.js","sources":["../../../../src/componentsV2/AppPanel/AppPanelDisplay.tsx"],"sourcesContent":["import { CSSProperties, RefObject, useMemo, useRef } from 'react';\nimport classNames from 'classnames';\n\nimport { useAppSize } from '../AppSizeProvider';\nimport { useOutsideClick } from '../../effects';\nimport { Paper } from '../Paper';\nimport { PopoverPanel } from '../PopoverPanel';\n\nimport { useAppPanelInternal } from './AppPanelsContext';\nimport { AppPanelIdProvider } from './AppPanelIdContext';\n\nimport styleConstants from '../AppContainer/AppContainer.constants.scss';\nimport styles from './AppPanelDisplay.scss';\n\nconst sidePadding = Number(styleConstants.sidePadding.replace(/[^.0-9]/g, ''));\n\nexport type PanelProps = {\n id: string | symbol;\n anchorRef: RefObject<HTMLDivElement>;\n};\n\nexport const AppPanelDisplay = ({ anchorRef, id }: PanelProps) => {\n const {\n isOpen,\n isPinned,\n close,\n isAnimated,\n width: panelWidth,\n component: Component,\n opener,\n isExpanded,\n placement,\n } = useAppPanelInternal(id);\n const popoverRef = useRef<HTMLDivElement>(null);\n\n const { height, width: appWidth } = useAppSize() || {};\n\n const wrapperStyle = useMemo<CSSProperties>(\n () => ({\n maxHeight: `min(${height || 0}px, 100vh)`,\n maxWidth: appWidth ? appWidth - sidePadding * 2 : 0,\n width: isExpanded && appWidth ? appWidth - sidePadding * 2 : panelWidth,\n }),\n [appWidth, height, isExpanded, panelWidth]\n );\n\n useOutsideClick(popoverRef, close, [\n opener,\n // Do not react on clicks inside popovers/modals/autocomplete dropdowns, etc\n '[role=\"tooltip\"]',\n '[role=\"presentation\"]',\n ]);\n\n if (!Component) {\n return null;\n }\n\n return (\n <AppPanelIdProvider value={id}>\n {anchorRef.current && !isPinned && (\n <PopoverPanel\n flip={false}\n ref={popoverRef}\n open={isOpen}\n placement={placement === 'start' ? 'bottom-start' : 'bottom-end'}\n anchorEl={anchorRef.current}\n onClose={close}\n className={styles.popover}\n preventScroll={false}\n backdrop={false}\n animate={isAnimated}\n style={wrapperStyle}\n preventOverflow={true}\n >\n <Component />\n </PopoverPanel>\n )}\n\n {isPinned && (\n <Paper\n className={classNames(\n styles.pinned,\n placement === 'start' ? styles.pinnedStart : styles.pinnedEnd\n )}\n style={wrapperStyle}\n >\n <Component />\n </Paper>\n )}\n </AppPanelIdProvider>\n );\n};\n"],"names":["sidePadding","Number","styleConstants","replace","_ref","anchorRef","id","useAppPanelInternal","isOpen","isPinned","close","isAnimated","panelWidth","width","Component","component","opener","isExpanded","placement","popoverRef","useRef","_ref2","useAppSize","height","appWidth","wrapperStyle","useMemo","maxHeight","maxWidth","useOutsideClick","_jsxs","AppPanelIdProvider","value","children","current","_jsx","PopoverPanel","flip","ref","open","anchorEl","onClose","className","styles","popover","preventScroll","backdrop","animate","style","preventOverflow","jsx","Paper","classNames","pinned","pinnedStart","pinnedEnd"],"mappings":"g1EAcMA,EAAcC,OAAOC,EAAeF,YAAYG,QAAQ,WAAY,6BAO3C,SAAmCC,GAAA,IAAhCC,IAAAA,UAAWC,IAAAA,GAWvCC,EAAAA,EAAmBA,oBAACD,GATtBE,IAAAA,OACAC,IAAAA,SACAC,IAAAA,MACAC,IAAAA,WACOC,IAAPC,MACWC,IAAXC,UACAC,IAAAA,OACAC,IAAAA,WACAC,IAAAA,UAEIC,EAAaC,SAAuB,MAE1CC,EAAoCC,EAAUA,cAAM,CAAE,EAA9CC,IAAAA,OAAeC,IAAPX,MAEVY,EAAeC,EAAAA,SACnB,WAAA,MAAO,CACLC,UAAkBJ,OAAAA,OAAAA,GAAU,EAAa,cACzCK,SAAUJ,EAAWA,EAAyB,EAAdxB,EAAkB,EAClDa,MAAOI,GAAcO,EAAWA,EAAyB,EAAdxB,EAAkBY,EAC7D,GACF,CAACY,EAAUD,EAAQN,EAAYL,IAUjC,OAPAiB,EAAgBV,EAAYT,EAAO,CACjCM,EAEA,mBACA,0BAGGF,EAKHgB,EAAAA,KAACC,EAAAA,mBAAkB,CAACC,MAAO1B,EAAG2B,SAC3B5B,CAAAA,EAAU6B,UAAYzB,GACrB0B,MAACC,eAAY,CACXC,MAAM,EACNC,IAAKnB,EACLoB,KAAM/B,EACNU,UAAyB,UAAdA,EAAwB,eAAiB,aACpDsB,SAAUnC,EAAU6B,QACpBO,QAAS/B,EACTgC,UAAWC,EAAOC,QAClBC,eAAe,EACfC,UAAU,EACVC,QAASpC,EACTqC,MAAOvB,EACPwB,iBAAiB,EAAKhB,SAEtBE,EAAAA,IAACrB,EAAS,MAIbL,GACC0B,EAAAe,IAACC,QAAK,CACJT,UAAWU,EAAAA,QACTT,EAAOU,OACO,UAAdnC,EAAwByB,EAAOW,YAAcX,EAAOY,WAEtDP,MAAOvB,EAAaQ,SAEpBE,EAAAA,IAACrB,EAAS,SAhCT,IAqCX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var s=require("@babel/runtime/helpers/defineProperty"),e=require("@babel/runtime/helpers/slicedToArray"),o=require("react"),n=require("classnames"),c=require("moment-timezone"),r=require("lodash"),i=require("../../TextInputNext/TextInputNext.js"),t=require("../../Text/Text.js"),u=require("../../ToggleButtons/ToggleButtons.js"),a=require("../utils.js"),l=require("../../Button/Button.js"),m=require("./TimePicker.scss.js"),d=require("../../../icons/iconParkIcons.js");require("../../../icons/customIcons/icons/AddMessage.js"),require("../../../icons/customIcons/icons/DragOne.js"),require("../../../icons/customIcons/icons/Attention.js"),require("../../../icons/customIcons/icons/Collapse.js"),require("../../../icons/customIcons/icons/Dashboard.js"),require("../../../icons/customIcons/icons/Expand.js"),require("../../../icons/customIcons/icons/FolderClosed.js"),require("../../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../../icons/customIcons/icons/FolderOpened.js"),require("../../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../../icons/customIcons/icons/LessOrEqual.js"),require("../../../icons/customIcons/icons/Search.js"),require("../../../icons/customIcons/icons/SearchOne.js"),require("../../../icons/customIcons/icons/Wellhub.js"),require("../../../icons/customIcons/icons/MultiRuler.js"),require("../../../icons/customIcons/icons/Checkbox.js"),require("../../../icons/customIcons/icons/CheckboxChecked.js"),require("../../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../../icons/customIcons/icons/Radio.js"),require("../../../icons/customIcons/icons/RadioChecked.js"),require("../../../icons/customIcons/icons/SimulFrac.js"),require("../../../icons/customIcons/icons/ZipperFrac.js"),require("../../../icons/customIcons/icons/CautionFilled.js"),require("../../../icons/customIcons/icons/InfoRounded.js"),require("../../../icons/customIcons/icons/FlameFilled.js"),require("../../../icons/customIcons/icons/MoreApp.js"),require("../../../icons/customIcons/icons/Pad.js"),require("../../../icons/customIcons/icons/DrilloutUnit.js"),require("../../../icons/customIcons/icons/FracFleet.js"),require("../../../icons/customIcons/icons/Global.js"),require("../../../icons/customIcons/icons/Program.js"),require("../../../icons/customIcons/icons/Rig.js"),require("../../../icons/customIcons/icons/Well.js"),require("../../../icons/customIcons/icons/Gap.js"),require("../../../icons/customIcons/icons/Pin.js"),require("../../../icons/customIcons/icons/PinOne.js"),require("../../../icons/customIcons/icons/PinOneCrossed.js"),require("../../../icons/customIcons/icons/CloseOneFilled.js"),require("../../../icons/customIcons/icons/AttentionFilled.js"),require("../../../icons/customIcons/icons/CheckOneFilled.js"),require("../../../icons/customIcons/icons/Archive.js"),require("../../../icons/customIcons/icons/ArchiveCancel.js"),require("../../../icons/customIcons/icons/Unarchive.js"),require("../../../icons/customIcons/icons/Archived.js"),require("../../../icons/customIcons/icons/InterventionUnit.js"),require("../../../icons/customIcons/icons/CloudDelete.js"),require("../../../icons/customIcons/icons/Lasso.js"),require("../../../icons/customIcons/icons/Radius.js"),require("../../../icons/customIcons/icons/ErrorOps.js"),require("../../../icons/customIcons/icons/DataTypeOps.js"),require("../../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../../icons/customIcons/icons/CalibrationOps.js"),require("../../../icons/customIcons/icons/CriticalOps.js"),require("../../../icons/customIcons/icons/Company.js"),require("../../../icons/customIcons/icons/ArchiveOne.js"),require("../../../icons/customIcons/icons/ParseBotFusion.js"),require("../../../icons/customIcons/icons/Connect.js"),require("../../../icons/customIcons/icons/PuzzleOne.js"),require("../../../icons/customIcons/icons/Feed.js"),require("../../../icons/customIcons/icons/Prompt.js"),require("../../../icons/customIcons/icons/Companies.js"),require("../../../icons/customIcons/icons/ClipboardAi.js"),require("../../../icons/customIcons/icons/Key.js"),require("../../../icons/customIcons/icons/AtSignCrossed.js"),require("../../../icons/customIcons/icons/MappingManual.js"),require("../../../icons/customIcons/icons/Mapping.js"),require("../../../icons/customIcons/icons/Metrics.js"),require("../../../icons/customIcons/icons/Drops.js"),require("../../../icons/customIcons/icons/ClipboardSearch.js"),require("../../../icons/customIcons/icons/Template.js"),require("../../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../../icons/customIcons/icons/UnitConversion.js"),require("../../../icons/customIcons/icons/NPT.js"),require("../../../icons/customIcons/icons/GuidedFrac.js");var j=require("react/jsx-runtime");function q(s){return s&&"object"==typeof s&&"default"in s?s:{default:s}}var I=q(s),p=q(e),f=q(n),h=q(c);function v(s,e){var o=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),o.push.apply(o,n)}return o}function b(s){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?v(Object(o),!0).forEach((function(e){I.default(s,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach((function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(o,e))}))}return s}var g=[{value:"am",label:"AM"},{value:"pm",label:"PM"}],C=function(s){return s.replace(/[^\d]/g,"").substring(0,2)},x=function(s){return Number(s)>=0&&Number(s)<=12},O=function(s){return Number(s)>=0&&Number(s)<60},y=O,T=function(s){return s.getTime()-h.default(s).startOf("day").toDate().getTime()},N=function(s){return void 0!==s?r.padStart(String(s),2,"0"):""},P=function(s){return"12"===s?"00":s};exports.TimePicker=function(s){var e=s.value,n=s.onChange,c=s.minDate,r=s.maxDate,q=s.saveTime,I=s.goToToday,v=s.clear,D=!e,F=o.useRef(null),k=o.useRef(null),S=o.useRef(null),M=o.useRef(),A=o.useMemo((function(){var s=e?T(e)>=432e5?"pm":"am":void 0,o="pm"===s?12:0,n=e?e.getHours()-o:void 0;return{hours:N(void 0!==n&&
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var s=require("@babel/runtime/helpers/defineProperty"),e=require("@babel/runtime/helpers/slicedToArray"),o=require("react"),n=require("classnames"),c=require("moment-timezone"),r=require("lodash"),i=require("../../TextInputNext/TextInputNext.js"),t=require("../../Text/Text.js"),u=require("../../ToggleButtons/ToggleButtons.js"),a=require("../utils.js"),l=require("../../Button/Button.js"),m=require("./TimePicker.scss.js"),d=require("../../../icons/iconParkIcons.js");require("../../../icons/customIcons/icons/AddMessage.js"),require("../../../icons/customIcons/icons/DragOne.js"),require("../../../icons/customIcons/icons/Attention.js"),require("../../../icons/customIcons/icons/Collapse.js"),require("../../../icons/customIcons/icons/Dashboard.js"),require("../../../icons/customIcons/icons/Expand.js"),require("../../../icons/customIcons/icons/FolderClosed.js"),require("../../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../../icons/customIcons/icons/FolderOpened.js"),require("../../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../../icons/customIcons/icons/LessOrEqual.js"),require("../../../icons/customIcons/icons/Search.js"),require("../../../icons/customIcons/icons/SearchOne.js"),require("../../../icons/customIcons/icons/Wellhub.js"),require("../../../icons/customIcons/icons/MultiRuler.js"),require("../../../icons/customIcons/icons/Checkbox.js"),require("../../../icons/customIcons/icons/CheckboxChecked.js"),require("../../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../../icons/customIcons/icons/Radio.js"),require("../../../icons/customIcons/icons/RadioChecked.js"),require("../../../icons/customIcons/icons/SimulFrac.js"),require("../../../icons/customIcons/icons/ZipperFrac.js"),require("../../../icons/customIcons/icons/CautionFilled.js"),require("../../../icons/customIcons/icons/InfoRounded.js"),require("../../../icons/customIcons/icons/FlameFilled.js"),require("../../../icons/customIcons/icons/MoreApp.js"),require("../../../icons/customIcons/icons/Pad.js"),require("../../../icons/customIcons/icons/DrilloutUnit.js"),require("../../../icons/customIcons/icons/FracFleet.js"),require("../../../icons/customIcons/icons/Global.js"),require("../../../icons/customIcons/icons/Program.js"),require("../../../icons/customIcons/icons/Rig.js"),require("../../../icons/customIcons/icons/Well.js"),require("../../../icons/customIcons/icons/Gap.js"),require("../../../icons/customIcons/icons/Pin.js"),require("../../../icons/customIcons/icons/PinOne.js"),require("../../../icons/customIcons/icons/PinOneCrossed.js"),require("../../../icons/customIcons/icons/CloseOneFilled.js"),require("../../../icons/customIcons/icons/AttentionFilled.js"),require("../../../icons/customIcons/icons/CheckOneFilled.js"),require("../../../icons/customIcons/icons/Archive.js"),require("../../../icons/customIcons/icons/ArchiveCancel.js"),require("../../../icons/customIcons/icons/Unarchive.js"),require("../../../icons/customIcons/icons/Archived.js"),require("../../../icons/customIcons/icons/InterventionUnit.js"),require("../../../icons/customIcons/icons/CloudDelete.js"),require("../../../icons/customIcons/icons/Lasso.js"),require("../../../icons/customIcons/icons/Radius.js"),require("../../../icons/customIcons/icons/ErrorOps.js"),require("../../../icons/customIcons/icons/DataTypeOps.js"),require("../../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../../icons/customIcons/icons/CalibrationOps.js"),require("../../../icons/customIcons/icons/CriticalOps.js"),require("../../../icons/customIcons/icons/Company.js"),require("../../../icons/customIcons/icons/ArchiveOne.js"),require("../../../icons/customIcons/icons/ParseBotFusion.js"),require("../../../icons/customIcons/icons/Connect.js"),require("../../../icons/customIcons/icons/PuzzleOne.js"),require("../../../icons/customIcons/icons/Feed.js"),require("../../../icons/customIcons/icons/Prompt.js"),require("../../../icons/customIcons/icons/Companies.js"),require("../../../icons/customIcons/icons/ClipboardAi.js"),require("../../../icons/customIcons/icons/Key.js"),require("../../../icons/customIcons/icons/AtSignCrossed.js"),require("../../../icons/customIcons/icons/MappingManual.js"),require("../../../icons/customIcons/icons/Mapping.js"),require("../../../icons/customIcons/icons/Metrics.js"),require("../../../icons/customIcons/icons/Drops.js"),require("../../../icons/customIcons/icons/ClipboardSearch.js"),require("../../../icons/customIcons/icons/Template.js"),require("../../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../../icons/customIcons/icons/UnitConversion.js"),require("../../../icons/customIcons/icons/NPT.js"),require("../../../icons/customIcons/icons/GuidedFrac.js");var j=require("react/jsx-runtime");function q(s){return s&&"object"==typeof s&&"default"in s?s:{default:s}}var I=q(s),p=q(e),f=q(n),h=q(c);function v(s,e){var o=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable}))),o.push.apply(o,n)}return o}function b(s){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?v(Object(o),!0).forEach((function(e){I.default(s,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(o)):v(Object(o)).forEach((function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(o,e))}))}return s}var g=[{value:"am",label:"AM"},{value:"pm",label:"PM"}],C=function(s){return s.replace(/[^\d]/g,"").substring(0,2)},x=function(s){return Number(s)>=0&&Number(s)<=12},O=function(s){return Number(s)>=0&&Number(s)<60},y=O,T=function(s){return s.getTime()-h.default(s).startOf("day").toDate().getTime()},N=function(s){return void 0!==s?r.padStart(String(s),2,"0"):""},P=function(s){return"12"===s?"00":s};exports.TimePicker=function(s){var e=s.value,n=s.onChange,c=s.minDate,r=s.maxDate,q=s.saveTime,I=s.goToToday,v=s.clear,D=!e,F=o.useRef(null),k=o.useRef(null),S=o.useRef(null),M=o.useRef(),A=o.useMemo((function(){var s=e?T(e)>=432e5?"pm":"am":void 0,o="pm"===s?12:0,n=e?e.getHours()-o:void 0;return{hours:N(void 0!==n&&12===n?0:n),minutes:N(null==e?void 0:e.getMinutes()),seconds:N(null==e?void 0:e.getSeconds()),partOfDay:s}}),[e]),B=o.useState(A.hours),R=p.default(B,2),z=R[0],w=R[1],E=o.useState(A.minutes),H=p.default(E,2),G=H[0],U=H[1],L=o.useState(A.seconds),W=p.default(L,2),_=W[0],K=W[1];o.useEffect((function(){M.current!==F.current&&w(A.hours),M.current!==k.current&&U(A.minutes),M.current!==S.current&&K(A.seconds)}),[A.hours,A.minutes,A.seconds]);var Z=o.useMemo((function(){var s=a.isSameDay(c,e)&&h.default(c).format("hh:mm:ss A"),o=a.isSameDay(r,e)&&h.default(r).format("hh:mm:ss A");return s&&o?"In ".concat(s," - ").concat(o," range"):s?"Can’t be earlier than ".concat(s):o?"Can’t be later than ".concat(o):void 0}),[r,c,e]),J=o.useMemo((function(){return g.map((function(s){var o="am"===s.value&&!!c&&a.isSameDay(e,c)&&T(c)>=432e5,n="pm"===s.value&&!!r&&a.isSameDay(e,r)&&T(r)<432e5;return b(b({},s),{},{disabled:D||o||n})}))}),[D,r,c,e]),Q=o.useCallback((function(s,o){if(e){var c=new Date(e);if("hours"===s&&x(o)){var r="pm"===A.partOfDay?12:0;c.setHours(r+Number(o))}else if("minutes"===s&&O(o))c.setMinutes(Number(o));else if("seconds"===s&&y(o))c.setSeconds(Number(o));else if("partOfDay"===s&&("am"===o||"pm"===o)){var i=c.getHours()%12;c.setHours(("pm"===o?12:0)+i)}Math.floor(c.getTime()/1e3)!==Math.floor(e.getTime()/1e3)&&n(c)}}),[A.partOfDay,n,e]),V=o.useCallback((function(s){s.target.select(),M.current=s.target}),[]),X=o.useCallback((function(s){var e=C(s.target.value);if(s.target===F.current){var o=P(e),n=x(o)?N(o):A.hours;w(n),Q("hours",n)}if(s.target===k.current){var c=O(e)?N(e):A.minutes;U(c),Q("minutes",c)}if(s.target===S.current){var r=y(e)?N(e):A.seconds;K(r),Q("seconds",r)}M.current=void 0}),[A.hours,A.minutes,A.seconds,Q]),Y=o.useCallback((function(s){var e,o=C(s),n=P(o);(w(o),2===o.length&&x(o))&&(Q("hours",n),null===(e=k.current)||void 0===e||e.focus())}),[Q]),$=o.useCallback((function(s){var e,o=C(s);(U(o),2===o.length&&O(o))&&(Q("minutes",o),null===(e=S.current)||void 0===e||e.focus())}),[Q]),ss=o.useCallback((function(s){var e=C(s);K(e),y(e)&&Q("seconds",e)}),[Q]),es=o.useCallback((function(s){Q("partOfDay",s)}),[Q]),os=Number(null==e?void 0:e.getTime())>Number(null==r?void 0:r.getTime())||Number(null==e?void 0:e.getTime())<Number(null==c?void 0:c.getTime()),ns=!x(z)||os,cs=!O(G)||os,rs=!y(_)||os;return j.jsxs(j.Fragment,{children:[j.jsxs("div",{className:f.default(m.timePicker),children:[j.jsxs(t.Text,{className:m.header,size:14,children:[j.jsx("span",{className:f.default(m.headerText,D&&m.disabled),children:"Time"}),Z&&j.jsxs(j.Fragment,{children:[j.jsx(d.InfoIcon,{className:m.constraintIcon,size:16}),Z]})]}),j.jsx(i.TextInputNext,{placeholder:"HH",className:m.input,disabled:D,value:z,onChange:Y,status:ns?"error":void 0,inputRef:F,onFocus:V,onBlur:X}),j.jsx(t.Text,{color:"T9",size:14,children:":"}),j.jsx(i.TextInputNext,{placeholder:"MM",className:m.input,disabled:D,value:G,onChange:$,status:cs?"error":void 0,inputRef:k,onFocus:V,onBlur:X}),j.jsx(t.Text,{color:"T9",size:14,children:":"}),j.jsx(i.TextInputNext,{placeholder:"SS",className:m.input,disabled:D,value:_,onChange:ss,status:rs?"error":void 0,inputRef:S,onFocus:V,onBlur:X}),j.jsx(u.ToggleButtons,{options:J,className:m.tabs,size:"small",value:A.partOfDay,onChange:es})]}),j.jsxs("div",{className:m.footer,children:[I&&j.jsx(l.Button,{onClick:I,type:"tertiary",size:"small",children:"Today"}),j.jsxs("div",{className:m.actions,children:[v&&j.jsx(l.Button,{onClick:v,type:"tertiary",size:"small",disabled:!e,children:"Clear"}),j.jsx(l.Button,{onClick:q,type:"secondary",size:"small",disabled:!e||ns||cs||rs,children:"Save"})]})]})]})};
|
|
2
2
|
//# sourceMappingURL=TimePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimePicker.js","sources":["../../../../../src/componentsV2/DatePicker/TimePicker/TimePicker.tsx"],"sourcesContent":["import { FocusEventHandler, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport moment from 'moment-timezone';\nimport { padStart } from 'lodash';\n\nimport { TextInputNext } from '../../TextInputNext';\nimport { Text } from '../../Text';\nimport { ToggleButtons } from '../../ToggleButtons';\nimport { isSameDay } from '../utils';\nimport { Button } from '../../Button';\n\nimport styles from './TimePicker.scss';\n\nimport { InfoIcon } from '~/icons';\n\ntype AmPm = 'am' | 'pm';\n\nconst HalfOfDayMs = 12 * 60 * 60 * 1000;\n\nconst ToggleButtonsOptions: { value: AmPm; label: string }[] = [\n { value: 'am', label: 'AM' },\n { value: 'pm', label: 'PM' },\n];\n\nexport type TimePickerProps = {\n value?: Date;\n onChange: (date: Date) => void;\n saveTime: () => void;\n maxDate?: Date;\n minDate?: Date;\n\n goToToday?: () => void;\n clear?: () => void;\n};\n\nconst sanitize = (value: string) => value.replace(/[^\\d]/g, '').substring(0, 2);\nconst validateHours = (value?: string) => Number(value) >= 0 && Number(value) <= 12;\nconst validateMinutes = (value?: string) => Number(value) >= 0 && Number(value) < 60;\nconst validateSeconds = validateMinutes;\n\nconst getOffsetFromDayStart = (date: Date) => {\n return date.getTime() - moment(date).startOf('day').toDate().getTime();\n};\n\nconst formatTimePart = (part?: string | number) =>\n part !== undefined ? padStart(String(part), 2, '0') : '';\n\nconst getPartOfDay = (date: Date) => {\n return getOffsetFromDayStart(date) >= HalfOfDayMs ? 'pm' : 'am';\n};\n\nconst getActualHours = (sanitized: string) => (sanitized === '12' ? '00' : sanitized);\n\nexport const TimePicker = ({\n value,\n onChange,\n minDate,\n maxDate,\n saveTime,\n goToToday,\n clear,\n}: TimePickerProps) => {\n const disabled = !value;\n\n const hoursInputRef = useRef<HTMLInputElement>(null);\n const minutesInputRef = useRef<HTMLInputElement>(null);\n const secondsInputRef = useRef<HTMLInputElement>(null);\n\n const focusedInputRef = useRef<HTMLInputElement>();\n\n const timeParts = useMemo(() => {\n const partOfDay = value ? getPartOfDay(value) : undefined;\n\n const hourOffset = partOfDay === 'pm' ? 12 : 0;\n\n const hours = value ? value.getHours() - hourOffset : undefined;\n\n const hoursAmPm = hours !== undefined && hours === 0 ? 12 : hours;\n\n return {\n hours: formatTimePart(hoursAmPm),\n minutes: formatTimePart(value?.getMinutes()),\n seconds: formatTimePart(value?.getSeconds()),\n partOfDay,\n };\n }, [value]);\n\n const [hours, setHours] = useState(timeParts.hours);\n const [minutes, setMinutes] = useState(timeParts.minutes);\n const [seconds, setSeconds] = useState(timeParts.seconds);\n\n useEffect(() => {\n if (focusedInputRef.current !== hoursInputRef.current) {\n setHours(timeParts.hours);\n }\n if (focusedInputRef.current !== minutesInputRef.current) {\n setMinutes(timeParts.minutes);\n }\n if (focusedInputRef.current !== secondsInputRef.current) {\n setSeconds(timeParts.seconds);\n }\n }, [timeParts.hours, timeParts.minutes, timeParts.seconds]);\n\n const constraintText = useMemo(() => {\n const minValue = isSameDay(minDate, value) && moment(minDate).format('hh:mm:ss A');\n const maxValue = isSameDay(maxDate, value) && moment(maxDate).format('hh:mm:ss A');\n\n if (minValue && maxValue) {\n return `In ${minValue} - ${maxValue} range`;\n } else if (minValue) {\n return `Can’t be earlier than ${minValue}`;\n } else if (maxValue) {\n return `Can’t be later than ${maxValue}`;\n }\n return undefined;\n }, [maxDate, minDate, value]);\n\n const amPmOptions = useMemo(\n () =>\n ToggleButtonsOptions.map(item => {\n const isAmDisabled =\n item.value === 'am' &&\n !!minDate &&\n isSameDay(value, minDate) &&\n getOffsetFromDayStart(minDate) >= HalfOfDayMs;\n\n const isPmDisabled =\n item.value === 'pm' &&\n !!maxDate &&\n isSameDay(value, maxDate) &&\n getOffsetFromDayStart(maxDate) < HalfOfDayMs;\n\n return { ...item, disabled: disabled || isAmDisabled || isPmDisabled };\n }),\n [disabled, maxDate, minDate, value]\n );\n\n const updateValue = useCallback(\n (type: 'hours' | 'minutes' | 'seconds' | 'partOfDay', newValue: string) => {\n if (!value) {\n return;\n }\n\n const newDate = new Date(value);\n\n if (type === 'hours' && validateHours(newValue)) {\n const partOfDayOffset = timeParts.partOfDay === 'pm' ? 12 : 0;\n newDate.setHours(partOfDayOffset + Number(newValue));\n } else if (type === 'minutes' && validateMinutes(newValue)) {\n newDate.setMinutes(Number(newValue));\n } else if (type === 'seconds' && validateSeconds(newValue)) {\n newDate.setSeconds(Number(newValue));\n } else if (type === 'partOfDay' && (newValue === 'am' || newValue === 'pm')) {\n const hoursOffset = newDate.getHours() % 12;\n newDate.setHours((newValue === 'pm' ? 12 : 0) + hoursOffset);\n }\n\n if (Math.floor(newDate.getTime() / 1000) !== Math.floor(value.getTime() / 1000)) {\n onChange(newDate);\n }\n },\n [timeParts.partOfDay, onChange, value]\n );\n\n const onFieldFocus = useCallback<FocusEventHandler<HTMLInputElement>>(e => {\n e.target.select();\n focusedInputRef.current = e.target;\n }, []);\n\n const onFieldBlur = useCallback<FocusEventHandler<HTMLInputElement>>(\n e => {\n const fieldValue = sanitize(e.target.value);\n\n if (e.target === hoursInputRef.current) {\n const actualHours = getActualHours(fieldValue);\n const newHours = validateHours(actualHours) ? formatTimePart(actualHours) : timeParts.hours;\n setHours(newHours);\n updateValue('hours', newHours);\n }\n if (e.target === minutesInputRef.current) {\n const newMinutes = validateMinutes(fieldValue)\n ? formatTimePart(fieldValue)\n : timeParts.minutes;\n setMinutes(newMinutes);\n updateValue('minutes', newMinutes);\n }\n if (e.target === secondsInputRef.current) {\n const newSeconds = validateSeconds(fieldValue)\n ? formatTimePart(fieldValue)\n : timeParts.seconds;\n setSeconds(newSeconds);\n updateValue('seconds', newSeconds);\n }\n\n focusedInputRef.current = undefined;\n },\n [timeParts.hours, timeParts.minutes, timeParts.seconds, updateValue]\n );\n\n const onChangeHours = useCallback(\n (newValue: string) => {\n const sanitized = sanitize(newValue);\n const actualHours = getActualHours(sanitized);\n setHours(sanitized);\n if (sanitized.length === 2 && validateHours(sanitized)) {\n updateValue('hours', actualHours);\n minutesInputRef.current?.focus();\n }\n },\n [updateValue]\n );\n\n const onChangeMinutes = useCallback(\n (newValue: string) => {\n const sanitized = sanitize(newValue);\n setMinutes(sanitized);\n if (sanitized.length === 2 && validateMinutes(sanitized)) {\n updateValue('minutes', sanitized);\n secondsInputRef.current?.focus();\n }\n },\n [updateValue]\n );\n\n const onChangeSeconds = useCallback(\n (newValue: string) => {\n const sanitized = sanitize(newValue);\n setSeconds(sanitized);\n if (validateSeconds(sanitized)) {\n updateValue('seconds', sanitized);\n }\n },\n [updateValue]\n );\n\n const setPartOfDay = useCallback(\n (newValue: string) => {\n updateValue('partOfDay', newValue);\n },\n [updateValue]\n );\n\n const outOfBounds =\n Number(value?.getTime()) > Number(maxDate?.getTime()) ||\n Number(value?.getTime()) < Number(minDate?.getTime());\n\n const hoursInvalid = !validateHours(hours) || outOfBounds;\n const minutesInvalid = !validateMinutes(minutes) || outOfBounds;\n const secondsInvalid = !validateSeconds(seconds) || outOfBounds;\n\n return (\n <>\n <div className={classNames(styles.timePicker)}>\n <Text className={styles.header} size={14}>\n <span className={classNames(styles.headerText, disabled && styles.disabled)}>Time</span>\n {constraintText && (\n <>\n <InfoIcon className={styles.constraintIcon} size={16} />\n {constraintText}\n </>\n )}\n </Text>\n\n <TextInputNext\n placeholder=\"HH\"\n className={styles.input}\n disabled={disabled}\n value={hours}\n onChange={onChangeHours}\n status={hoursInvalid ? 'error' : undefined}\n inputRef={hoursInputRef}\n onFocus={onFieldFocus}\n onBlur={onFieldBlur}\n />\n\n <Text color=\"T9\" size={14}>\n :\n </Text>\n\n <TextInputNext\n placeholder=\"MM\"\n className={styles.input}\n disabled={disabled}\n value={minutes}\n onChange={onChangeMinutes}\n status={minutesInvalid ? 'error' : undefined}\n inputRef={minutesInputRef}\n onFocus={onFieldFocus}\n onBlur={onFieldBlur}\n />\n\n <Text color=\"T9\" size={14}>\n :\n </Text>\n\n <TextInputNext\n placeholder=\"SS\"\n className={styles.input}\n disabled={disabled}\n value={seconds}\n onChange={onChangeSeconds}\n status={secondsInvalid ? 'error' : undefined}\n inputRef={secondsInputRef}\n onFocus={onFieldFocus}\n onBlur={onFieldBlur}\n />\n\n <ToggleButtons\n options={amPmOptions}\n className={styles.tabs}\n size=\"small\"\n value={timeParts.partOfDay}\n onChange={setPartOfDay}\n />\n </div>\n <div className={styles.footer}>\n {goToToday && (\n <Button onClick={goToToday} type=\"tertiary\" size=\"small\">\n Today\n </Button>\n )}\n\n <div className={styles.actions}>\n {clear && (\n <Button onClick={clear} type=\"tertiary\" size=\"small\" disabled={!value}>\n Clear\n </Button>\n )}\n\n <Button\n onClick={saveTime}\n type=\"secondary\"\n size=\"small\"\n disabled={!value || hoursInvalid || minutesInvalid || secondsInvalid}\n >\n Save\n </Button>\n </div>\n </div>\n </>\n );\n};\n"],"names":["ToggleButtonsOptions","value","label","sanitize","replace","substring","validateHours","Number","validateMinutes","validateSeconds","getOffsetFromDayStart","date","getTime","moment","startOf","toDate","formatTimePart","part","undefined","padStart","String","getActualHours","sanitized","_ref","onChange","minDate","maxDate","saveTime","goToToday","clear","disabled","hoursInputRef","useRef","minutesInputRef","secondsInputRef","focusedInputRef","timeParts","useMemo","partOfDay","hourOffset","hours","getHours","minutes","getMinutes","seconds","getSeconds","_useState","useState","_useState2","_slicedToArray","setHours","_useState3","_useState4","setMinutes","_useState5","_useState6","setSeconds","useEffect","current","constraintText","minValue","isSameDay","format","maxValue","concat","amPmOptions","map","item","isAmDisabled","isPmDisabled","_objectSpread","updateValue","useCallback","type","newValue","newDate","Date","partOfDayOffset","hoursOffset","Math","floor","onFieldFocus","e","target","select","onFieldBlur","fieldValue","actualHours","newHours","newMinutes","newSeconds","onChangeHours","_minutesInputRef$curr","length","focus","onChangeMinutes","_secondsInputRef$curr","onChangeSeconds","setPartOfDay","outOfBounds","hoursInvalid","minutesInvalid","secondsInvalid","_jsxs","_Fragment","children","jsxs","className","classNames","styles","timePicker","Text","header","size","_jsx","jsx","headerText","InfoIcon","constraintIcon","TextInputNext","placeholder","input","status","inputRef","onFocus","onBlur","color","ToggleButtons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CAACC,QAASxG,EAAW6C,KAAK,WAAWwC,KAAK,QAAOR,SAAA,UAK1DF,EAAAG,KAAA,MAAA,CAAKC,UAAWE,EAAOwB,QAAQ5B,SAC5B5E,CAAAA,GACCqF,EAAAC,IAACgB,SAAM,CAACC,QAASvG,EAAO4C,KAAK,WAAWwC,KAAK,QAAQnF,UAAW7B,EAAMwG,SAAA,UAKxES,MAACiB,SAAM,CACLC,QAASzG,EACT8C,KAAK,YACLwC,KAAK,QACLnF,UAAW7B,GAASmG,IAAgBC,IAAkBC,GAAeG,SAAA,iBAQjF"}
|
|
1
|
+
{"version":3,"file":"TimePicker.js","sources":["../../../../../src/componentsV2/DatePicker/TimePicker/TimePicker.tsx"],"sourcesContent":["import { FocusEventHandler, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport moment from 'moment-timezone';\nimport { padStart } from 'lodash';\n\nimport { TextInputNext } from '../../TextInputNext';\nimport { Text } from '../../Text';\nimport { ToggleButtons } from '../../ToggleButtons';\nimport { isSameDay } from '../utils';\nimport { Button } from '../../Button';\n\nimport styles from './TimePicker.scss';\n\nimport { InfoIcon } from '~/icons';\n\ntype AmPm = 'am' | 'pm';\n\nconst HalfOfDayMs = 12 * 60 * 60 * 1000;\n\nconst ToggleButtonsOptions: { value: AmPm; label: string }[] = [\n { value: 'am', label: 'AM' },\n { value: 'pm', label: 'PM' },\n];\n\nexport type TimePickerProps = {\n value?: Date;\n onChange: (date: Date) => void;\n saveTime: () => void;\n maxDate?: Date;\n minDate?: Date;\n\n goToToday?: () => void;\n clear?: () => void;\n};\n\nconst sanitize = (value: string) => value.replace(/[^\\d]/g, '').substring(0, 2);\nconst validateHours = (value?: string) => Number(value) >= 0 && Number(value) <= 12;\nconst validateMinutes = (value?: string) => Number(value) >= 0 && Number(value) < 60;\nconst validateSeconds = validateMinutes;\n\nconst getOffsetFromDayStart = (date: Date) => {\n return date.getTime() - moment(date).startOf('day').toDate().getTime();\n};\n\nconst formatTimePart = (part?: string | number) =>\n part !== undefined ? padStart(String(part), 2, '0') : '';\n\nconst getPartOfDay = (date: Date) => {\n return getOffsetFromDayStart(date) >= HalfOfDayMs ? 'pm' : 'am';\n};\n\nconst getActualHours = (sanitized: string) => (sanitized === '12' ? '00' : sanitized);\n\nexport const TimePicker = ({\n value,\n onChange,\n minDate,\n maxDate,\n saveTime,\n goToToday,\n clear,\n}: TimePickerProps) => {\n const disabled = !value;\n\n const hoursInputRef = useRef<HTMLInputElement>(null);\n const minutesInputRef = useRef<HTMLInputElement>(null);\n const secondsInputRef = useRef<HTMLInputElement>(null);\n\n const focusedInputRef = useRef<HTMLInputElement>();\n\n const timeParts = useMemo(() => {\n const partOfDay = value ? getPartOfDay(value) : undefined;\n\n const hourOffset = partOfDay === 'pm' ? 12 : 0;\n\n const hours = value ? value.getHours() - hourOffset : undefined;\n\n const hoursAmPm = hours !== undefined && hours === 12 ? 0 : hours;\n\n return {\n hours: formatTimePart(hoursAmPm),\n minutes: formatTimePart(value?.getMinutes()),\n seconds: formatTimePart(value?.getSeconds()),\n partOfDay,\n };\n }, [value]);\n\n const [hours, setHours] = useState(timeParts.hours);\n const [minutes, setMinutes] = useState(timeParts.minutes);\n const [seconds, setSeconds] = useState(timeParts.seconds);\n\n useEffect(() => {\n if (focusedInputRef.current !== hoursInputRef.current) {\n setHours(timeParts.hours);\n }\n if (focusedInputRef.current !== minutesInputRef.current) {\n setMinutes(timeParts.minutes);\n }\n if (focusedInputRef.current !== secondsInputRef.current) {\n setSeconds(timeParts.seconds);\n }\n }, [timeParts.hours, timeParts.minutes, timeParts.seconds]);\n\n const constraintText = useMemo(() => {\n const minValue = isSameDay(minDate, value) && moment(minDate).format('hh:mm:ss A');\n const maxValue = isSameDay(maxDate, value) && moment(maxDate).format('hh:mm:ss A');\n\n if (minValue && maxValue) {\n return `In ${minValue} - ${maxValue} range`;\n } else if (minValue) {\n return `Can’t be earlier than ${minValue}`;\n } else if (maxValue) {\n return `Can’t be later than ${maxValue}`;\n }\n return undefined;\n }, [maxDate, minDate, value]);\n\n const amPmOptions = useMemo(\n () =>\n ToggleButtonsOptions.map(item => {\n const isAmDisabled =\n item.value === 'am' &&\n !!minDate &&\n isSameDay(value, minDate) &&\n getOffsetFromDayStart(minDate) >= HalfOfDayMs;\n\n const isPmDisabled =\n item.value === 'pm' &&\n !!maxDate &&\n isSameDay(value, maxDate) &&\n getOffsetFromDayStart(maxDate) < HalfOfDayMs;\n\n return { ...item, disabled: disabled || isAmDisabled || isPmDisabled };\n }),\n [disabled, maxDate, minDate, value]\n );\n\n const updateValue = useCallback(\n (type: 'hours' | 'minutes' | 'seconds' | 'partOfDay', newValue: string) => {\n if (!value) {\n return;\n }\n\n const newDate = new Date(value);\n\n if (type === 'hours' && validateHours(newValue)) {\n const partOfDayOffset = timeParts.partOfDay === 'pm' ? 12 : 0;\n newDate.setHours(partOfDayOffset + Number(newValue));\n } else if (type === 'minutes' && validateMinutes(newValue)) {\n newDate.setMinutes(Number(newValue));\n } else if (type === 'seconds' && validateSeconds(newValue)) {\n newDate.setSeconds(Number(newValue));\n } else if (type === 'partOfDay' && (newValue === 'am' || newValue === 'pm')) {\n const hoursOffset = newDate.getHours() % 12;\n newDate.setHours((newValue === 'pm' ? 12 : 0) + hoursOffset);\n }\n\n if (Math.floor(newDate.getTime() / 1000) !== Math.floor(value.getTime() / 1000)) {\n onChange(newDate);\n }\n },\n [timeParts.partOfDay, onChange, value]\n );\n\n const onFieldFocus = useCallback<FocusEventHandler<HTMLInputElement>>(e => {\n e.target.select();\n focusedInputRef.current = e.target;\n }, []);\n\n const onFieldBlur = useCallback<FocusEventHandler<HTMLInputElement>>(\n e => {\n const fieldValue = sanitize(e.target.value);\n\n if (e.target === hoursInputRef.current) {\n const actualHours = getActualHours(fieldValue);\n const newHours = validateHours(actualHours) ? formatTimePart(actualHours) : timeParts.hours;\n setHours(newHours);\n updateValue('hours', newHours);\n }\n if (e.target === minutesInputRef.current) {\n const newMinutes = validateMinutes(fieldValue)\n ? formatTimePart(fieldValue)\n : timeParts.minutes;\n setMinutes(newMinutes);\n updateValue('minutes', newMinutes);\n }\n if (e.target === secondsInputRef.current) {\n const newSeconds = validateSeconds(fieldValue)\n ? formatTimePart(fieldValue)\n : timeParts.seconds;\n setSeconds(newSeconds);\n updateValue('seconds', newSeconds);\n }\n\n focusedInputRef.current = undefined;\n },\n [timeParts.hours, timeParts.minutes, timeParts.seconds, updateValue]\n );\n\n const onChangeHours = useCallback(\n (newValue: string) => {\n const sanitized = sanitize(newValue);\n const actualHours = getActualHours(sanitized);\n setHours(sanitized);\n if (sanitized.length === 2 && validateHours(sanitized)) {\n updateValue('hours', actualHours);\n minutesInputRef.current?.focus();\n }\n },\n [updateValue]\n );\n\n const onChangeMinutes = useCallback(\n (newValue: string) => {\n const sanitized = sanitize(newValue);\n setMinutes(sanitized);\n if (sanitized.length === 2 && validateMinutes(sanitized)) {\n updateValue('minutes', sanitized);\n secondsInputRef.current?.focus();\n }\n },\n [updateValue]\n );\n\n const onChangeSeconds = useCallback(\n (newValue: string) => {\n const sanitized = sanitize(newValue);\n setSeconds(sanitized);\n if (validateSeconds(sanitized)) {\n updateValue('seconds', sanitized);\n }\n },\n [updateValue]\n );\n\n const setPartOfDay = useCallback(\n (newValue: string) => {\n updateValue('partOfDay', newValue);\n },\n [updateValue]\n );\n\n const outOfBounds =\n Number(value?.getTime()) > Number(maxDate?.getTime()) ||\n Number(value?.getTime()) < Number(minDate?.getTime());\n\n const hoursInvalid = !validateHours(hours) || outOfBounds;\n const minutesInvalid = !validateMinutes(minutes) || outOfBounds;\n const secondsInvalid = !validateSeconds(seconds) || outOfBounds;\n\n return (\n <>\n <div className={classNames(styles.timePicker)}>\n <Text className={styles.header} size={14}>\n <span className={classNames(styles.headerText, disabled && styles.disabled)}>Time</span>\n {constraintText && (\n <>\n <InfoIcon className={styles.constraintIcon} size={16} />\n {constraintText}\n </>\n )}\n </Text>\n\n <TextInputNext\n placeholder=\"HH\"\n className={styles.input}\n disabled={disabled}\n value={hours}\n onChange={onChangeHours}\n status={hoursInvalid ? 'error' : undefined}\n inputRef={hoursInputRef}\n onFocus={onFieldFocus}\n onBlur={onFieldBlur}\n />\n\n <Text color=\"T9\" size={14}>\n :\n </Text>\n\n <TextInputNext\n placeholder=\"MM\"\n className={styles.input}\n disabled={disabled}\n value={minutes}\n onChange={onChangeMinutes}\n status={minutesInvalid ? 'error' : undefined}\n inputRef={minutesInputRef}\n onFocus={onFieldFocus}\n onBlur={onFieldBlur}\n />\n\n <Text color=\"T9\" size={14}>\n :\n </Text>\n\n <TextInputNext\n placeholder=\"SS\"\n className={styles.input}\n disabled={disabled}\n value={seconds}\n onChange={onChangeSeconds}\n status={secondsInvalid ? 'error' : undefined}\n inputRef={secondsInputRef}\n onFocus={onFieldFocus}\n onBlur={onFieldBlur}\n />\n\n <ToggleButtons\n options={amPmOptions}\n className={styles.tabs}\n size=\"small\"\n value={timeParts.partOfDay}\n onChange={setPartOfDay}\n />\n </div>\n <div className={styles.footer}>\n {goToToday && (\n <Button onClick={goToToday} type=\"tertiary\" size=\"small\">\n Today\n </Button>\n )}\n\n <div className={styles.actions}>\n {clear && (\n <Button onClick={clear} type=\"tertiary\" size=\"small\" disabled={!value}>\n Clear\n </Button>\n )}\n\n <Button\n onClick={saveTime}\n type=\"secondary\"\n size=\"small\"\n disabled={!value || hoursInvalid || minutesInvalid || secondsInvalid}\n >\n Save\n </Button>\n </div>\n </div>\n </>\n );\n};\n"],"names":["ToggleButtonsOptions","value","label","sanitize","replace","substring","validateHours","Number","validateMinutes","validateSeconds","getOffsetFromDayStart","date","getTime","moment","startOf","toDate","formatTimePart","part","undefined","padStart","String","getActualHours","sanitized","_ref","onChange","minDate","maxDate","saveTime","goToToday","clear","disabled","hoursInputRef","useRef","minutesInputRef","secondsInputRef","focusedInputRef","timeParts","useMemo","partOfDay","hourOffset","hours","getHours","minutes","getMinutes","seconds","getSeconds","_useState","useState","_useState2","_slicedToArray","setHours","_useState3","_useState4","setMinutes","_useState5","_useState6","setSeconds","useEffect","current","constraintText","minValue","isSameDay","format","maxValue","concat","amPmOptions","map","item","isAmDisabled","isPmDisabled","_objectSpread","updateValue","useCallback","type","newValue","newDate","Date","partOfDayOffset","hoursOffset","Math","floor","onFieldFocus","e","target","select","onFieldBlur","fieldValue","actualHours","newHours","newMinutes","newSeconds","onChangeHours","_minutesInputRef$curr","length","focus","onChangeMinutes","_secondsInputRef$curr","onChangeSeconds","setPartOfDay","outOfBounds","hoursInvalid","minutesInvalid","secondsInvalid","_jsxs","_Fragment","children","jsxs","className","classNames","styles","timePicker","Text","header","size","_jsx","jsx","headerText","InfoIcon","constraintIcon","TextInputNext","placeholder","input","status","inputRef","onFocus","onBlur","color","ToggleButtons","options","tabs","footer","Button","onClick","actions"],"mappings":"+8KAiBA,IAEMA,EAAyD,CAC7D,CAAEC,MAAO,KAAMC,MAAO,MACtB,CAAED,MAAO,KAAMC,MAAO,OAclBC,EAAW,SAACF,GAAa,OAAKA,EAAMG,QAAQ,SAAU,IAAIC,UAAU,EAAG,EAAE,EACzEC,EAAgB,SAACL,GAAc,OAAKM,OAAON,IAAU,GAAKM,OAAON,IAAU,EAAE,EAC7EO,EAAkB,SAACP,GAAc,OAAKM,OAAON,IAAU,GAAKM,OAAON,GAAS,EAAE,EAC9EQ,EAAkBD,EAElBE,EAAwB,SAACC,GAC7B,OAAOA,EAAKC,UAAYC,EAAAA,QAAOF,GAAMG,QAAQ,OAAOC,SAASH,SAC/D,EAEMI,EAAiB,SAACC,GAAsB,YACnCC,IAATD,EAAqBE,EAAAA,SAASC,OAAOH,GAAO,EAAG,KAAO,EAAE,EAMpDI,EAAiB,SAACC,GAAiB,MAAoB,OAAdA,EAAqB,KAAOA,CAAS,qBAE1D,SAQHC,GAAA,IAPrBtB,IAAAA,MACAuB,IAAAA,SACAC,IAAAA,QACAC,IAAAA,QACAC,IAAAA,SACAC,IAAAA,UACAC,IAAAA,MAEMC,GAAY7B,EAEZ8B,EAAgBC,SAAyB,M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IAGV6B,MAACH,OAAI,CAACe,MAAM,KAAKb,KAAM,GAAGR,SAAA,MAI1BS,MAACK,gBAAa,CACZC,YAAY,KACZb,UAAWE,EAAOY,MAClB3F,SAAUA,EACV7B,MAAO2C,EACPpB,SAAUyE,GACVyB,OAAQpB,GAAiB,aAAUpF,EACnCyG,SAAUzF,EACV0F,QAAS3C,EACT4C,OAAQxC,IAGV6B,MAACa,gBAAa,CACZC,QAAS/D,EACT0C,UAAWE,EAAOoB,KAClBhB,KAAK,QACLhH,MAAOmC,EAAUE,UACjBd,SAAU0E,QAGdK,EAAAG,KAAA,MAAA,CAAKC,UAAWE,EAAOqB,OAAOzB,SAC3B7E,CAAAA,GACCsF,EAAAC,IAACgB,SAAM,CAACC,QAASxG,EAAW6C,KAAK,WAAWwC,KAAK,QAAOR,SAAA,UAK1DF,EAAAG,KAAA,MAAA,CAAKC,UAAWE,EAAOwB,QAAQ5B,SAC5B5E,CAAAA,GACCqF,EAAAC,IAACgB,SAAM,CAACC,QAASvG,EAAO4C,KAAK,WAAWwC,KAAK,QAAQnF,UAAW7B,EAAMwG,SAAA,UAKxES,MAACiB,SAAM,CACLC,QAASzG,EACT8C,KAAK,YACLwC,KAAK,QACLnF,UAAW7B,GAASmG,IAAgBC,IAAkBC,GAAeG,SAAA,iBAQjF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={date:"DD
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={date:"MMM DD YYYY",dateTime:"MMM DD YYYY hh:mm A",month:"MMMM YYYY"},e={date:"MM/DD/YYYY",dateTime:"MM/DD/YYYY hh:mm A",month:"MMM YYYY"},l=["D","M","Y","h","m","s","S"],n=[].concat(l,["A"]),i=new RegExp("^([^".concat(n.join(""),"]+)"),"gi"),r={month:"MM/YYYY",date:"MM/DD/YYYY",dateTime:"MM/DD/YYYY hh:mm A"},o={month:[r.month,"MMMM YYYY","MMM YYYY"],date:[r.date,"M/D/YYYY"],dateTime:[r.dateTime,"M/D/YYYY hh:mm A"]},u=function(t,e){return!!t&&!!e&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()};exports.DefaultFormatByType=t,exports.DefaultFormatByTypeRange=e,exports.InputAutocompleteFormats=r,exports.InputParseFormats=o,exports.MonthOptions=[{id:1,title:"Jan",fullTitle:"January"},{id:2,title:"Feb",fullTitle:"February"},{id:3,title:"Mar",fullTitle:"March"},{id:4,title:"Apr",fullTitle:"April"},{id:5,title:"May",fullTitle:"May"},{id:6,title:"Jun",fullTitle:"June"},{id:7,title:"Jul",fullTitle:"July"},{id:8,title:"Aug",fullTitle:"August"},{id:9,title:"Sep",fullTitle:"September"},{id:10,title:"Oct",fullTitle:"October"},{id:11,title:"Nov",fullTitle:"November"},{id:12,title:"Dec",fullTitle:"December"}],exports.autocompleteValue=function(t){var e=t.value,n=t.type,o=t.range,u=t.prevValue,a=r[n],Y=o?"".concat(a," - ").concat(a):a,M=e.toLocaleLowerCase().replace(/([ap])m/gi,"$1");if(e.length<=u.length||!function(t,e){return e.length<=t.length&&e.split("").every((function(e,n){var i,r=t[n];if(l.includes(r))return null==(i=e)?void 0:i.match(/\d/);if("A"===r){var o=e.toLocaleLowerCase();return"a"===o||"p"===o}return r===e}))}(Y,M)||Y.length<=M.length)return e;var c=function(t,e){var l;return(null===(l=t.substring(e).match(i))||void 0===l?void 0:l[0])||""}(Y,M.length);return"".concat(e).concat(c)},exports.getDateWithSameTime=function(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate(),(null==e?void 0:e.getHours())||0,(null==e?void 0:e.getMinutes())||0,(null==e?void 0:e.getSeconds())||0)},exports.getDefaultFormat=function(l,n){return(n?e:t)[l]},exports.getMaxDate=function(t,e){return t&&e?t>e?t:e:t||e},exports.getMinDate=function(t,e){return t&&e?t<e?t:e:t||e},exports.isSameDay=function(t,e){return u(t,e)&&(null==t?void 0:t.getDate())===(null==e?void 0:e.getDate())},exports.isSameMonth=u;
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/componentsV2/DatePicker/utils.tsx"],"sourcesContent":["export type DatePickerType = 'date' | 'dateTime' | 'month';\n\nexport type DatePickerValue<IsRange extends boolean | undefined = false> = IsRange extends\n | undefined\n | false\n ? Date | undefined\n : [Date, Date] | undefined;\n\nexport type DatePickerChangeHandler<IsRange extends boolean | undefined = false> = (\n value: DatePickerValue<IsRange>\n) => void;\n\n// startDate - initial state, no start date selected\n// endDate - start done, no end date selected\nexport type RangeSelectionStep = 'startDate' | 'endDate';\n\nexport const DefaultFormatByType: Record<DatePickerType, string> = {\n date: 'DD
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/componentsV2/DatePicker/utils.tsx"],"sourcesContent":["export type DatePickerType = 'date' | 'dateTime' | 'month';\n\nexport type DatePickerValue<IsRange extends boolean | undefined = false> = IsRange extends\n | undefined\n | false\n ? Date | undefined\n : [Date, Date] | undefined;\n\nexport type DatePickerChangeHandler<IsRange extends boolean | undefined = false> = (\n value: DatePickerValue<IsRange>\n) => void;\n\n// startDate - initial state, no start date selected\n// endDate - start done, no end date selected\nexport type RangeSelectionStep = 'startDate' | 'endDate';\n\nexport const DefaultFormatByType: Record<DatePickerType, string> = {\n date: 'MMM DD YYYY',\n dateTime: 'MMM DD YYYY hh:mm A',\n month: 'MMMM YYYY',\n};\n\nexport const DefaultFormatByTypeRange: Record<DatePickerType, string> = {\n date: 'MM/DD/YYYY',\n dateTime: 'MM/DD/YYYY hh:mm A',\n month: 'MMM YYYY',\n};\n\nexport const getDefaultFormat = (type: DatePickerType, range?: boolean) => {\n const map = range ? DefaultFormatByTypeRange : DefaultFormatByType;\n return map[type];\n};\n\nconst NumericLetters = ['D', 'M', 'Y', 'h', 'm', 's', 'S'];\nconst AllLetters = [...NumericLetters, 'A'];\nconst GetSeparatorRegex = new RegExp(`^([^${AllLetters.join('')}]+)`, 'gi');\n\n// These formats should be composed only of `AllLetters` as placeholders only\nexport const InputAutocompleteFormats: Record<DatePickerType, string> = {\n month: 'MM/YYYY',\n date: 'MM/DD/YYYY',\n dateTime: 'MM/DD/YYYY hh:mm A',\n};\n\nexport const InputParseFormats: Record<DatePickerType, string[]> = {\n month: [InputAutocompleteFormats.month, 'MMMM YYYY', 'MMM YYYY'],\n date: [InputAutocompleteFormats.date, 'M/D/YYYY'],\n dateTime: [InputAutocompleteFormats.dateTime, 'M/D/YYYY hh:mm A'],\n};\n\nconst isDigit = (symbol?: string) => symbol?.match(/\\d/);\n\nconst isInFormatSoFar = (format: string, value: string) => {\n if (value.length <= format.length) {\n const valueArr = value.split('');\n\n return valueArr.every((valueChar, pos) => {\n const formatChar = format[pos];\n\n if (NumericLetters.includes(formatChar)) {\n return isDigit(valueChar);\n }\n\n if (formatChar === 'A') {\n const lcChar = valueChar.toLocaleLowerCase();\n return lcChar === 'a' || lcChar === 'p';\n }\n\n return formatChar === valueChar;\n });\n }\n\n return false;\n};\n\nconst getSeparator = (format: string, startIndex: number) => {\n return format.substring(startIndex).match(GetSeparatorRegex)?.[0] || '';\n};\n\nexport const autocompleteValue = ({\n value,\n type,\n range,\n prevValue,\n}: {\n type: DatePickerType;\n range?: boolean;\n value: string;\n prevValue: string;\n}) => {\n const formatPart = InputAutocompleteFormats[type];\n const format = range ? `${formatPart} - ${formatPart}` : formatPart;\n\n const preparedValue = value.toLocaleLowerCase().replace(/([ap])m/gi, '$1');\n\n if (\n value.length <= prevValue.length ||\n !isInFormatSoFar(format, preparedValue) ||\n format.length <= preparedValue.length\n ) {\n return value;\n }\n\n // Only autocomplete if user types something\n // Check if conforms to format so far\n // Adding separators if needed\n const separator = getSeparator(format, preparedValue.length);\n\n return `${value}${separator}`;\n};\n\nexport const isSameMonth = (a?: Date, b?: Date) =>\n !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();\n\nexport const isSameDay = (a?: Date, b?: Date) => isSameMonth(a, b) && a?.getDate() === b?.getDate();\n\nexport const getMinDate = (a?: Date, b?: Date) => {\n if (a && b) {\n return a < b ? a : b;\n }\n\n return a || b;\n};\n\nexport const getMaxDate = (a?: Date, b?: Date) => {\n if (a && b) {\n return a > b ? a : b;\n }\n\n return a || b;\n};\n\nexport const MonthOptions = [\n { id: 1, title: 'Jan', fullTitle: 'January' },\n { id: 2, title: 'Feb', fullTitle: 'February' },\n { id: 3, title: 'Mar', fullTitle: 'March' },\n { id: 4, title: 'Apr', fullTitle: 'April' },\n { id: 5, title: 'May', fullTitle: 'May' },\n { id: 6, title: 'Jun', fullTitle: 'June' },\n { id: 7, title: 'Jul', fullTitle: 'July' },\n { id: 8, title: 'Aug', fullTitle: 'August' },\n { id: 9, title: 'Sep', fullTitle: 'September' },\n { id: 10, title: 'Oct', fullTitle: 'October' },\n { id: 11, title: 'Nov', fullTitle: 'November' },\n { id: 12, title: 'Dec', fullTitle: 'December' },\n];\n\nexport type DatePickerCalendarView = 'year' | 'month';\n\nexport const getDateWithSameTime = (date: Date, timeDate?: Date) =>\n new Date(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n timeDate?.getHours() || 0,\n timeDate?.getMinutes() || 0,\n timeDate?.getSeconds() || 0\n );\n"],"names":["DefaultFormatByType","date","dateTime","month","DefaultFormatByTypeRange","NumericLetters","AllLetters","concat","GetSeparatorRegex","RegExp","join","InputAutocompleteFormats","InputParseFormats","isSameMonth","a","b","getFullYear","getMonth","id","title","fullTitle","_ref","value","type","range","prevValue","formatPart","format","preparedValue","toLocaleLowerCase","replace","length","split","every","valueChar","pos","symbol","formatChar","includes","match","lcChar","isInFormatSoFar","separator","startIndex","_format$substring$mat","substring","getSeparator","timeDate","Date","getDate","getHours","getMinutes","getSeconds"],"mappings":"oEAgBO,IAAMA,EAAsD,CACjEC,KAAM,cACNC,SAAU,sBACVC,MAAO,aAGIC,EAA2D,CACtEH,KAAM,aACNC,SAAU,qBACVC,MAAO,YAQH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EAAGkC,UAAS"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/objectWithoutProperties"),o=require("@material-ui/core"),n=require("react"),t=require("classnames"),s=require("../../effects/useDelayedDcFullscreenElemOpen.js"),c=require("../../components/DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/IsInsideDcFullscreenElemProvider.js"),l=require("../../components/DevCenter/DevCenterAppContainer/components/IsInsideIsolatedDcAppProvider.js"),i=require("../ModalWindow/ModalWindow.js"),u=require("./constants.js"),a=require("./Modal.scss.js"),p=require("react/jsx-runtime");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(e),O=d(r),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/objectWithoutProperties"),o=require("@material-ui/core"),n=require("react"),t=require("classnames"),s=require("../../effects/useDelayedDcFullscreenElemOpen.js"),c=require("../../components/DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/IsInsideDcFullscreenElemProvider.js"),l=require("../../components/DevCenter/DevCenterAppContainer/components/IsInsideIsolatedDcAppProvider.js"),i=require("../ModalWindow/ModalWindow.js"),u=require("./constants.js"),a=require("./Modal.scss.js"),p=require("react/jsx-runtime");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(e),O=d(r),b=d(t),j=["open","onClose","size","showCloseButton","closeOnBackdropClick","closeOnEscape"],v=["open"];function C(e,r){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),o.push.apply(o,n)}return o}function m(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?C(Object(o),!0).forEach((function(r){f.default(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):C(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}var D=function(e){var r=e.open,t=e.onClose,s=e.size,c=void 0===s?"medium":s,l=e.showCloseButton,d=void 0===l||l,f=e.closeOnBackdropClick,v=void 0===f||f,C=e.closeOnEscape,D=void 0===C||C,y=O.default(e,j),P=n.useCallback((function(e,r){t&&("backdropClick"===r&&v&&t("backdropClick"),"escapeKeyDown"===r&&D&&t("escapeKey"))}),[t,v,D]),w=n.useCallback((function(){null==t||t("closeButtonClick")}),[t]);return p.jsx(o.Modal,{open:r,className:b.default(u.MODAL_ROOT_CLASS,a.root),onClose:P,disableEnforceFocus:!0,children:p.jsx(i.ModalWindow,m(m({},y),{},{onClose:w,showCloseButton:d,size:c}))})},y=function(e){var r=e.open,o=O.default(e,v),n=s.useDelayedDcFullscreenElemOpen({isOpen:r},!0).delayedIsOpen;return p.jsx(c.IsInsideDcFullscreenElemProvider,{children:p.jsx(D,m({open:n},o))})};exports.Modal=function(e){var r=l.useIsInsideIsolatedDcApp(),o=c.useIsInsideDcFullscreenElem(),n=r&&!o?y:D;return p.jsx(n,m({},e))};
|
|
2
2
|
//# sourceMappingURL=Modal.js.map
|