@react-fabric/core 1.0.0-beta.58 → 1.0.0-beta.59
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/css/components/_stepper.css +86 -0
- package/css/components/index.css +1 -0
- package/dist/cjs/hooks/useStepper.js +75 -0
- package/dist/cjs/index.js +2 -0
- package/dist/esm/hooks/useStepper.js +75 -0
- package/dist/esm/index.js +1 -0
- package/dist/types/hooks/useStepper.d.ts +15 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +3 -3
- package/src/hooks/useStepper.tsx +68 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2025 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
@layer components {
|
|
25
|
+
.fabric-stepper {
|
|
26
|
+
& .fabric-stepper--pill {
|
|
27
|
+
position: relative;
|
|
28
|
+
|
|
29
|
+
flex: 0 0 auto;
|
|
30
|
+
|
|
31
|
+
color: var(--color-primary-600);
|
|
32
|
+
|
|
33
|
+
background-color: var(--color-primary-50);
|
|
34
|
+
border-radius: var(--radius);
|
|
35
|
+
|
|
36
|
+
& .fabric-icon {
|
|
37
|
+
padding: 0.125rem;
|
|
38
|
+
font-size: 1.5rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
& label {
|
|
42
|
+
display: inline-block;
|
|
43
|
+
|
|
44
|
+
padding: 0.125rem 0.5rem;
|
|
45
|
+
|
|
46
|
+
font-size: 0.875rem;
|
|
47
|
+
font-weight: 500;
|
|
48
|
+
line-height: 1.5rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:not(:last-child) {
|
|
52
|
+
margin-inline-end: 3rem;
|
|
53
|
+
|
|
54
|
+
&::after {
|
|
55
|
+
content: "";
|
|
56
|
+
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: 50%;
|
|
59
|
+
right: calc(-3rem - 1px);
|
|
60
|
+
transform: translateY(-50%);
|
|
61
|
+
|
|
62
|
+
width: 3rem;
|
|
63
|
+
height: 2px;
|
|
64
|
+
|
|
65
|
+
background-color: var(--color-primary-50);
|
|
66
|
+
|
|
67
|
+
transition: background-color 0.3s var(--ease-in-out);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&[data-state="active"] {
|
|
72
|
+
color: var(--color-primary-50);
|
|
73
|
+
background-color: var(--color-primary-600);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&[data-state="completed"] {
|
|
77
|
+
color: var(--color-primary-50);
|
|
78
|
+
background-color: var(--color-primary-700);
|
|
79
|
+
|
|
80
|
+
&::after {
|
|
81
|
+
background-color: var(--color-primary-700);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
package/css/components/index.css
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('@babel/runtime/helpers/objectWithoutProperties');
|
|
7
|
+
require('classnames');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
require('@react-fabric/utilities');
|
|
10
|
+
require('./useEffectDebugger.js');
|
|
11
|
+
require('boring-avatars');
|
|
12
|
+
var Icon = require('../components/icon/Icon.js');
|
|
13
|
+
require('@floating-ui/react');
|
|
14
|
+
require('../hotkeys/HotKeyWrapper.js');
|
|
15
|
+
require('react-i18next');
|
|
16
|
+
require('../types/icons.js');
|
|
17
|
+
require('@babel/runtime/helpers/toConsumableArray');
|
|
18
|
+
require('@babel/runtime/helpers/classCallCheck');
|
|
19
|
+
require('@babel/runtime/helpers/createClass');
|
|
20
|
+
require('@babel/runtime/helpers/possibleConstructorReturn');
|
|
21
|
+
require('@babel/runtime/helpers/getPrototypeOf');
|
|
22
|
+
require('@babel/runtime/helpers/inherits');
|
|
23
|
+
require('i18next');
|
|
24
|
+
require('@babel/runtime/helpers/asyncToGenerator');
|
|
25
|
+
require('@babel/runtime/regenerator');
|
|
26
|
+
require('react-dom');
|
|
27
|
+
require('../components/media/Media.js');
|
|
28
|
+
require('@babel/runtime/helpers/toArray');
|
|
29
|
+
|
|
30
|
+
var useStepper = function useStepper(_ref) {
|
|
31
|
+
var steps = _ref.steps,
|
|
32
|
+
_ref$activeStep = _ref.activeStep,
|
|
33
|
+
_initialActiveStep = _ref$activeStep === void 0 ? 0 : _ref$activeStep;
|
|
34
|
+
var _useState = react.useState(_initialActiveStep),
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
activeStep = _useState2[0],
|
|
37
|
+
setActiveStep = _useState2[1];
|
|
38
|
+
var maxSteps = react.useMemo(function () {
|
|
39
|
+
return steps.length - 1;
|
|
40
|
+
}, [steps]);
|
|
41
|
+
var stepper = react.useMemo(function () {
|
|
42
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
43
|
+
className: "fabric-stepper bg-base flex-1 flex justify-center py-1 px-2 overflow-x-auto",
|
|
44
|
+
children: steps.map(function (child, index) {
|
|
45
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
46
|
+
className: "fabric-stepper--pill",
|
|
47
|
+
"data-state": index === activeStep ? "active" : index < activeStep ? "completed" : undefined,
|
|
48
|
+
children: [child.icon && /*#__PURE__*/jsxRuntime.jsx(Icon.Icon, {
|
|
49
|
+
icon: child.icon
|
|
50
|
+
}), child.label && /*#__PURE__*/jsxRuntime.jsx("label", {
|
|
51
|
+
children: child.label
|
|
52
|
+
})]
|
|
53
|
+
}, index);
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}, [steps]);
|
|
57
|
+
return {
|
|
58
|
+
stepper: stepper,
|
|
59
|
+
activeStep: activeStep,
|
|
60
|
+
firstStep: activeStep === 0,
|
|
61
|
+
lastStep: activeStep === maxSteps,
|
|
62
|
+
next: function next() {
|
|
63
|
+
return setActiveStep(function (s) {
|
|
64
|
+
return Math.min(s + 1, maxSteps);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
prev: function prev() {
|
|
68
|
+
return setActiveStep(function (s) {
|
|
69
|
+
return Math.max(s - 1, 0);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.useStepper = useStepper;
|
package/dist/cjs/index.js
CHANGED
|
@@ -72,6 +72,7 @@ var useNavigator = require('./hooks/useNavigator.js');
|
|
|
72
72
|
var useOverlayService = require('./hooks/useOverlayService.js');
|
|
73
73
|
var useResize = require('./hooks/useResize.js');
|
|
74
74
|
var useResizeObserver = require('./hooks/useResizeObserver.js');
|
|
75
|
+
var useStepper = require('./hooks/useStepper.js');
|
|
75
76
|
var useStorage = require('./hooks/useStorage.js');
|
|
76
77
|
var HotKey = require('./hotkeys/HotKey.js');
|
|
77
78
|
var HotKeyLabel = require('./hotkeys/HotKeyLabel.js');
|
|
@@ -160,6 +161,7 @@ exports.useNavigator = useNavigator.useNavigator;
|
|
|
160
161
|
exports.useOverlayService = useOverlayService.useOverlayService;
|
|
161
162
|
exports.useResize = useResize.useResize;
|
|
162
163
|
exports.useResizeObserver = useResizeObserver.useResizeObserver;
|
|
164
|
+
exports.useStepper = useStepper.useStepper;
|
|
163
165
|
exports.useLocalStorage = useStorage.useLocalStorage;
|
|
164
166
|
exports.useSessionStorage = useStorage.useSessionStorage;
|
|
165
167
|
exports.HotKey = HotKey.HotKey;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
+
import { useState, useMemo } from 'react';
|
|
5
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
6
|
+
import '@babel/runtime/helpers/objectWithoutProperties';
|
|
7
|
+
import 'classnames';
|
|
8
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
|
+
import '@react-fabric/utilities';
|
|
10
|
+
import './useEffectDebugger.js';
|
|
11
|
+
import 'boring-avatars';
|
|
12
|
+
import { Icon } from '../components/icon/Icon.js';
|
|
13
|
+
import '@floating-ui/react';
|
|
14
|
+
import '../hotkeys/HotKeyWrapper.js';
|
|
15
|
+
import 'react-i18next';
|
|
16
|
+
import '../types/icons.js';
|
|
17
|
+
import '@babel/runtime/helpers/toConsumableArray';
|
|
18
|
+
import '@babel/runtime/helpers/classCallCheck';
|
|
19
|
+
import '@babel/runtime/helpers/createClass';
|
|
20
|
+
import '@babel/runtime/helpers/possibleConstructorReturn';
|
|
21
|
+
import '@babel/runtime/helpers/getPrototypeOf';
|
|
22
|
+
import '@babel/runtime/helpers/inherits';
|
|
23
|
+
import 'i18next';
|
|
24
|
+
import '@babel/runtime/helpers/asyncToGenerator';
|
|
25
|
+
import '@babel/runtime/regenerator';
|
|
26
|
+
import 'react-dom';
|
|
27
|
+
import '../components/media/Media.js';
|
|
28
|
+
import '@babel/runtime/helpers/toArray';
|
|
29
|
+
|
|
30
|
+
var useStepper = function useStepper(_ref) {
|
|
31
|
+
var steps = _ref.steps,
|
|
32
|
+
_ref$activeStep = _ref.activeStep,
|
|
33
|
+
_initialActiveStep = _ref$activeStep === void 0 ? 0 : _ref$activeStep;
|
|
34
|
+
var _useState = useState(_initialActiveStep),
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
activeStep = _useState2[0],
|
|
37
|
+
setActiveStep = _useState2[1];
|
|
38
|
+
var maxSteps = useMemo(function () {
|
|
39
|
+
return steps.length - 1;
|
|
40
|
+
}, [steps]);
|
|
41
|
+
var stepper = useMemo(function () {
|
|
42
|
+
return /*#__PURE__*/jsx("div", {
|
|
43
|
+
className: "fabric-stepper bg-base flex-1 flex justify-center py-1 px-2 overflow-x-auto",
|
|
44
|
+
children: steps.map(function (child, index) {
|
|
45
|
+
return /*#__PURE__*/jsxs("div", {
|
|
46
|
+
className: "fabric-stepper--pill",
|
|
47
|
+
"data-state": index === activeStep ? "active" : index < activeStep ? "completed" : undefined,
|
|
48
|
+
children: [child.icon && /*#__PURE__*/jsx(Icon, {
|
|
49
|
+
icon: child.icon
|
|
50
|
+
}), child.label && /*#__PURE__*/jsx("label", {
|
|
51
|
+
children: child.label
|
|
52
|
+
})]
|
|
53
|
+
}, index);
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}, [steps]);
|
|
57
|
+
return {
|
|
58
|
+
stepper: stepper,
|
|
59
|
+
activeStep: activeStep,
|
|
60
|
+
firstStep: activeStep === 0,
|
|
61
|
+
lastStep: activeStep === maxSteps,
|
|
62
|
+
next: function next() {
|
|
63
|
+
return setActiveStep(function (s) {
|
|
64
|
+
return Math.min(s + 1, maxSteps);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
prev: function prev() {
|
|
68
|
+
return setActiveStep(function (s) {
|
|
69
|
+
return Math.max(s - 1, 0);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export { useStepper };
|
package/dist/esm/index.js
CHANGED
|
@@ -72,6 +72,7 @@ export { useNavigator } from './hooks/useNavigator.js';
|
|
|
72
72
|
export { useOverlayService } from './hooks/useOverlayService.js';
|
|
73
73
|
export { useResize } from './hooks/useResize.js';
|
|
74
74
|
export { useResizeObserver } from './hooks/useResizeObserver.js';
|
|
75
|
+
export { useStepper } from './hooks/useStepper.js';
|
|
75
76
|
export { useLocalStorage, useSessionStorage } from './hooks/useStorage.js';
|
|
76
77
|
export { HotKey } from './hotkeys/HotKey.js';
|
|
77
78
|
export { HotKeyLabel } from './hotkeys/HotKeyLabel.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export declare const useStepper: ({ steps, activeStep: _initialActiveStep, }: {
|
|
3
|
+
steps: Array<{
|
|
4
|
+
label?: ReactNode;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
activeStep?: number;
|
|
8
|
+
}) => {
|
|
9
|
+
stepper: import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
activeStep: number;
|
|
11
|
+
firstStep: boolean;
|
|
12
|
+
lastStep: boolean;
|
|
13
|
+
next: () => void;
|
|
14
|
+
prev: () => void;
|
|
15
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from "./hooks/useNavigator";
|
|
|
12
12
|
export * from "./hooks/useOverlayService";
|
|
13
13
|
export * from "./hooks/useResize";
|
|
14
14
|
export * from "./hooks/useResizeObserver";
|
|
15
|
+
export * from "./hooks/useStepper";
|
|
15
16
|
export * from "./hooks/useStorage";
|
|
16
17
|
export { HotKey } from "./hotkeys/HotKey";
|
|
17
18
|
export { HotKeyLabel } from "./hotkeys/HotKeyLabel";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/core",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.59",
|
|
4
4
|
"description": "RUF: Core package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@floating-ui/react": "~0.27.16",
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.59",
|
|
40
40
|
"@tailwindcss/postcss": "~4.1.16",
|
|
41
41
|
"boring-avatars": "~1.11.2",
|
|
42
42
|
"classnames": "~2.5.1",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"node": ">=18.12.0",
|
|
55
55
|
"npm": ">=8.19.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "74efd06c9c5ac629b6ef5cdc6d53ecb1c356f2eb"
|
|
58
58
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* React Fabric
|
|
3
|
+
* @version: 1.0.0
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* The MIT License (MIT)
|
|
7
|
+
* Copyright (c) 2025 Adarsh Pastakia
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
10
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
11
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
12
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
16
|
+
* portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
19
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
20
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { ReactNode, useMemo, useState } from "react";
|
|
25
|
+
import { Icon } from "../components";
|
|
26
|
+
|
|
27
|
+
export const useStepper = ({
|
|
28
|
+
steps,
|
|
29
|
+
activeStep: _initialActiveStep = 0,
|
|
30
|
+
}: {
|
|
31
|
+
steps: Array<{ label?: ReactNode; icon?: ReactNode }>;
|
|
32
|
+
activeStep?: number;
|
|
33
|
+
}) => {
|
|
34
|
+
const [activeStep, setActiveStep] = useState(_initialActiveStep);
|
|
35
|
+
const maxSteps = useMemo(() => steps.length - 1, [steps]);
|
|
36
|
+
|
|
37
|
+
const stepper = useMemo(() => {
|
|
38
|
+
return (
|
|
39
|
+
<div className="fabric-stepper bg-base flex-1 flex justify-center py-1 px-2 overflow-x-auto">
|
|
40
|
+
{steps.map((child: any, index) => (
|
|
41
|
+
<div
|
|
42
|
+
className="fabric-stepper--pill"
|
|
43
|
+
key={index}
|
|
44
|
+
data-state={
|
|
45
|
+
index === activeStep
|
|
46
|
+
? "active"
|
|
47
|
+
: index < activeStep
|
|
48
|
+
? "completed"
|
|
49
|
+
: undefined
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
{child.icon && <Icon icon={child.icon} />}
|
|
53
|
+
{child.label && <label>{child.label}</label>}
|
|
54
|
+
</div>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}, [steps]);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
stepper,
|
|
62
|
+
activeStep,
|
|
63
|
+
firstStep: activeStep === 0,
|
|
64
|
+
lastStep: activeStep === maxSteps,
|
|
65
|
+
next: () => setActiveStep((s) => Math.min(s + 1, maxSteps)),
|
|
66
|
+
prev: () => setActiveStep((s) => Math.max(s - 1, 0)),
|
|
67
|
+
};
|
|
68
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ export * from "./hooks/useNavigator";
|
|
|
36
36
|
export * from "./hooks/useOverlayService";
|
|
37
37
|
export * from "./hooks/useResize";
|
|
38
38
|
export * from "./hooks/useResizeObserver";
|
|
39
|
+
export * from "./hooks/useStepper";
|
|
39
40
|
export * from "./hooks/useStorage";
|
|
40
41
|
|
|
41
42
|
export { HotKey } from "./hotkeys/HotKey";
|