@pallamart/pm-core-components 2.0.0 → 2.1.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.
@@ -17,6 +17,7 @@ export * from './file-picker/index.js';
17
17
  export * from './input/index.js';
18
18
  export * from './kbd/index.js';
19
19
  export * from './label/index.js';
20
+ export * from './navigation-progress/index.js';
20
21
  export * from './not-found/index.js';
21
22
  export * from './popover/index.js';
22
23
  export * from './progress/index.js';
@@ -17,6 +17,7 @@ export * from './file-picker/index.js';
17
17
  export * from './input/index.js';
18
18
  export * from './kbd/index.js';
19
19
  export * from './label/index.js';
20
+ export * from './navigation-progress/index.js';
20
21
  export * from './not-found/index.js';
21
22
  export * from './popover/index.js';
22
23
  export * from './progress/index.js';
@@ -0,0 +1 @@
1
+ export * from './pm-navigation-progress.js';
@@ -0,0 +1 @@
1
+ export * from './pm-navigation-progress.js';
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import type { PmNavigationProgressProps } from '../../../models/internal/navigation-progress/pm-navigation-progress-props.js';
3
+ export declare const PmNavigationProgress: ({ className, state }: PmNavigationProgressProps) => React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { PallamartClassNameService } from '@pallamart/pm-design-system';
4
+ import { PmNavigationProgressConfig } from '../../../constants/internal/pm-navigation-progress-config.js';
5
+ import { PmNavigationState } from '../../../constants/internal/pm-navigation-state.js';
6
+ import { PmProgress } from '../progress/pm-progress.js';
7
+ export const PmNavigationProgress = ({ className, state }) => {
8
+ const [value, setValue] = React.useState(PmNavigationProgressConfig.startValue);
9
+ const [isVisible, setIsVisible] = React.useState(false);
10
+ React.useEffect(() => {
11
+ if (state === PmNavigationState.Idle) {
12
+ if (!isVisible)
13
+ return;
14
+ setValue(PmNavigationProgressConfig.completeValue);
15
+ const hideTimer = window.setTimeout(() => setIsVisible(false), PmNavigationProgressConfig.hideDelayMs);
16
+ const resetTimer = window.setTimeout(() => setValue(PmNavigationProgressConfig.startValue), PmNavigationProgressConfig.resetDelayMs);
17
+ return () => {
18
+ window.clearTimeout(hideTimer);
19
+ window.clearTimeout(resetTimer);
20
+ };
21
+ }
22
+ setIsVisible(true);
23
+ setValue(state === PmNavigationState.Submitting
24
+ ? PmNavigationProgressConfig.submittingValue
25
+ : PmNavigationProgressConfig.loadingValue);
26
+ }, [isVisible, state]);
27
+ return (_jsx(PmProgress, { "aria-hidden": !isVisible, className: PallamartClassNameService.merge('pointer-events-none fixed inset-x-0 top-0 z-[999] h-0.5 rounded-none bg-transparent transition-opacity', isVisible ? 'opacity-100' : 'opacity-0', className), value: value }));
28
+ };
@@ -4,6 +4,8 @@ export * from './pm-badge-variants.js';
4
4
  export * from './pm-button-variants.js';
5
5
  export * from './pm-field-orientation.js';
6
6
  export * from './pm-label-variants.js';
7
+ export * from './pm-navigation-progress-config.js';
8
+ export * from './pm-navigation-state.js';
7
9
  export * from './pm-root-status-messages.js';
8
10
  export * from './pm-sheet-variants.js';
9
11
  export * from './pm-toggle-variants.js';
@@ -4,6 +4,8 @@ export * from './pm-badge-variants.js';
4
4
  export * from './pm-button-variants.js';
5
5
  export * from './pm-field-orientation.js';
6
6
  export * from './pm-label-variants.js';
7
+ export * from './pm-navigation-progress-config.js';
8
+ export * from './pm-navigation-state.js';
7
9
  export * from './pm-root-status-messages.js';
8
10
  export * from './pm-sheet-variants.js';
9
11
  export * from './pm-toggle-variants.js';
@@ -0,0 +1,8 @@
1
+ export declare const PmNavigationProgressConfig: {
2
+ readonly completeValue: 100;
3
+ readonly hideDelayMs: 200;
4
+ readonly loadingValue: 75;
5
+ readonly resetDelayMs: 450;
6
+ readonly startValue: 0;
7
+ readonly submittingValue: 40;
8
+ };
@@ -0,0 +1,8 @@
1
+ export const PmNavigationProgressConfig = {
2
+ completeValue: 100,
3
+ hideDelayMs: 200,
4
+ loadingValue: 75,
5
+ resetDelayMs: 450,
6
+ startValue: 0,
7
+ submittingValue: 40,
8
+ };
@@ -0,0 +1,5 @@
1
+ export declare enum PmNavigationState {
2
+ Idle = "idle",
3
+ Loading = "loading",
4
+ Submitting = "submitting"
5
+ }
@@ -0,0 +1,6 @@
1
+ export var PmNavigationState;
2
+ (function (PmNavigationState) {
3
+ PmNavigationState["Idle"] = "idle";
4
+ PmNavigationState["Loading"] = "loading";
5
+ PmNavigationState["Submitting"] = "submitting";
6
+ })(PmNavigationState || (PmNavigationState = {}));
@@ -17,6 +17,7 @@ export * from './file-picker/index.js';
17
17
  export * from './input/index.js';
18
18
  export * from './kbd/index.js';
19
19
  export * from './label/index.js';
20
+ export * from './navigation-progress/index.js';
20
21
  export * from './not-found/index.js';
21
22
  export * from './popover/index.js';
22
23
  export * from './progress/index.js';
@@ -17,6 +17,7 @@ export * from './file-picker/index.js';
17
17
  export * from './input/index.js';
18
18
  export * from './kbd/index.js';
19
19
  export * from './label/index.js';
20
+ export * from './navigation-progress/index.js';
20
21
  export * from './not-found/index.js';
21
22
  export * from './popover/index.js';
22
23
  export * from './progress/index.js';
@@ -0,0 +1 @@
1
+ export * from './pm-navigation-progress-props.js';
@@ -0,0 +1 @@
1
+ export * from './pm-navigation-progress-props.js';
@@ -0,0 +1,5 @@
1
+ import type { PmNavigationState } from '../../../constants/internal/pm-navigation-state.js';
2
+ export interface PmNavigationProgressProps {
3
+ className?: string;
4
+ state: PmNavigationState;
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallamart/pm-core-components",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",