@mrshmllw/smores-react 12.2.2 → 12.3.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/dist/Icon/Icon.js +1 -1
- package/dist/Icon/Icon.js.map +1 -1
- package/dist/ProgressIndicator/ProgressIndicator.d.ts +14 -0
- package/dist/ProgressIndicator/ProgressIndicator.js +41 -0
- package/dist/ProgressIndicator/ProgressIndicator.js.map +1 -0
- package/dist/ProgressIndicator/components/StepItem.d.ts +12 -0
- package/dist/ProgressIndicator/components/StepItem.js +67 -0
- package/dist/ProgressIndicator/components/StepItem.js.map +1 -0
- package/dist/ProgressIndicator/helpers.d.ts +8 -0
- package/dist/ProgressIndicator/helpers.js +19 -0
- package/dist/ProgressIndicator/helpers.js.map +1 -0
- package/dist/ProgressIndicator/index.d.ts +2 -0
- package/dist/ProgressIndicator/index.js +2 -0
- package/dist/ProgressIndicator/index.js.map +1 -0
- package/dist/ProgressIndicator/types.d.ts +6 -0
- package/dist/ProgressIndicator/types.js +2 -0
- package/dist/ProgressIndicator/types.js.map +1 -0
- package/package.json +26 -26
package/dist/Icon/Icon.js
CHANGED
@@ -7,7 +7,7 @@ export const Icon = ({ className = '', render, size = 24, color = 'liquorice', r
|
|
7
7
|
if (!render || !iconList[render] || render.length === 0)
|
8
8
|
return null;
|
9
9
|
const IconComponent = iconList[render];
|
10
|
-
return (React.createElement(Container, { forwardedAs: "span", className: className, size: size, rotate: rotate, color: color, ...marginProps },
|
10
|
+
return (React.createElement(Container, { forwardedAs: "span", "data-testId": `${render}-container`, className: className, size: size, rotate: rotate, color: color, ...marginProps },
|
11
11
|
React.createElement(IconComponent, null)));
|
12
12
|
};
|
13
13
|
const Container = styled(Box)(({ size, rotate, color }) => css `
|
package/dist/Icon/Icon.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../src/Icon/Icon.tsx"],"names":[],"mappings":"AAAA,OAAO,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CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAEpE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;IAEtC,OAAO,CACL,oBAAC,SAAS,IACR,WAAW,EAAC,MAAM,iBACL,GAAG,MAAM,YAAY,EAClC,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,KACR,WAAW;QAEf,oBAAC,aAAa,OAAG,CACP,CACb,CAAA;AACH,CAAC,CAAA;AAQD,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAC3B,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,CAAA;;;;;aAKrB,IAAI;cACH,IAAI;wBACM,MAAM;;eAEf,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;;GAE/B,CACF,CAAA","sourcesContent":["import React, { FC } from 'react'\nimport styled, { css } from 'styled-components'\nimport { MarginProps } from '../utils/space'\n\nimport { Box } from '../Box'\nimport { Color, theme } from '../theme'\nimport { Icons, iconList } from './iconsList'\n\nexport type IconProps = {\n /** className attribute to apply classes from props */\n className?: string\n /** specify what Icon to render */\n render: Icons\n /** set size of the Icon */\n size?: number\n /** set color of the Icon */\n color?: Color\n /** rotation degrees */\n rotate?: number\n} & MarginProps\n\nexport const Icon: FC<IconProps> = ({\n className = '',\n render,\n size = 24,\n color = 'liquorice',\n rotate = 0,\n ...marginProps\n}) => {\n if (!render || !iconList[render] || render.length === 0) return null\n\n const IconComponent = iconList[render]\n\n return (\n <Container\n forwardedAs=\"span\"\n data-testId={`${render}-container`}\n className={className}\n size={size}\n rotate={rotate}\n color={color}\n {...marginProps}\n >\n <IconComponent />\n </Container>\n )\n}\n\ninterface IIcon extends MarginProps {\n size: number\n color: Color\n rotate: number\n}\n\nconst Container = styled(Box)<IIcon>(\n ({ size, rotate, color }) => css`\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n width: ${size}px;\n height: ${size}px;\n transform: rotate(${rotate}deg);\n svg {\n color: ${theme.colors[color]} !important;\n }\n `,\n)\n"]}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { StepData, StepState } from './types';
|
3
|
+
interface Props {
|
4
|
+
steps: ReadonlyArray<StepData>;
|
5
|
+
handleStepChange: (step: StepData) => void;
|
6
|
+
simpleStep?: boolean;
|
7
|
+
onStepClick?: (data: {
|
8
|
+
currentStepIndex: number;
|
9
|
+
currentStepState: StepState;
|
10
|
+
}) => void;
|
11
|
+
currentStep: string;
|
12
|
+
}
|
13
|
+
export declare const ProgressIndicator: ({ handleStepChange, onStepClick, simpleStep, steps, currentStep, }: Props) => React.JSX.Element;
|
14
|
+
export {};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { calculateStepState, calculateProgressWidths } from './helpers';
|
3
|
+
import styled from 'styled-components';
|
4
|
+
import { theme } from '../theme';
|
5
|
+
import { Box } from '../Box';
|
6
|
+
import { StepItem } from './components/StepItem';
|
7
|
+
export const ProgressIndicator = ({ handleStepChange, onStepClick, simpleStep = false, steps, currentStep, }) => {
|
8
|
+
const { totalWidth, stepWidth } = calculateProgressWidths(steps.length, simpleStep);
|
9
|
+
const visibleSteps = steps.filter((step) => !step.isHidden);
|
10
|
+
const currentStepIndex = visibleSteps.findIndex((step) => step.id === currentStep);
|
11
|
+
const lastCompletedStepIndex = visibleSteps.findLastIndex((step) => calculateStepState(visibleSteps.indexOf(step), currentStepIndex) ===
|
12
|
+
'completed');
|
13
|
+
const handleStepClick = (currentStepIndex, currentStepState, stepData) => {
|
14
|
+
if (onStepClick) {
|
15
|
+
onStepClick({ currentStepIndex, currentStepState });
|
16
|
+
}
|
17
|
+
if (currentStepState !== 'disabled') {
|
18
|
+
handleStepChange(stepData);
|
19
|
+
}
|
20
|
+
};
|
21
|
+
return (React.createElement(Wrapper, { width: `${totalWidth}px`, flex: true, alignItems: "center" },
|
22
|
+
React.createElement(DefaultProgress, { "$simpleStep": simpleStep }),
|
23
|
+
React.createElement(Box, { flex: true }, visibleSteps.map((step, index) => {
|
24
|
+
const stepState = calculateStepState(index, currentStepIndex);
|
25
|
+
return (React.createElement(StepItem, { key: step.id, isCompleted: stepState === 'completed', isCurrentStep: stepState === 'current', isLastCompleted: lastCompletedStepIndex === index, onClick: () => handleStepClick(index, stepState, step), stepWidth: `${stepWidth}px`, label: step.label, isSimple: simpleStep, isLastItem: index === visibleSteps.length - 1 }));
|
26
|
+
}))));
|
27
|
+
};
|
28
|
+
const Wrapper = styled(Box) `
|
29
|
+
position: relative;
|
30
|
+
`;
|
31
|
+
const DefaultProgress = styled(Box) `
|
32
|
+
z-index: 0;
|
33
|
+
content: '';
|
34
|
+
position: absolute;
|
35
|
+
background: ${theme.colors.matcha};
|
36
|
+
width: 100%;
|
37
|
+
height: 12px;
|
38
|
+
|
39
|
+
${({ $simpleStep }) => $simpleStep && `border-radius:100px;`}
|
40
|
+
`;
|
41
|
+
//# sourceMappingURL=ProgressIndicator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ProgressIndicator.js","sourceRoot":"","sources":["../../src/ProgressIndicator/ProgressIndicator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACvE,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAahD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,gBAAgB,EAChB,WAAW,EACX,UAAU,GAAG,KAAK,EAClB,KAAK,EACL,WAAW,GACL,EAAE,EAAE;I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a,EAAE,SAAS,KAAK,SAAS,EACtC,eAAe,EAAE,sBAAsB,KAAK,KAAK,EACjD,OAAO,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,EACtD,SAAS,EAAE,GAAG,SAAS,IAAI,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,UAAU,EACpB,UAAU,EAAE,KAAK,KAAK,YAAY,CAAC,MAAM,GAAG,CAAC,GAC7C,CACH,CAAA;QACH,CAAC,CAAC,CACE,CACE,CACX,CAAA;AACH,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;CAE1B,CAAA;AAED,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,CAA2B;;;;gBAI9C,KAAK,CAAC,MAAM,CAAC,MAAM;;;;IAI/B,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW,IAAI,sBAAsB;CAC7D,CAAA","sourcesContent":["import React from 'react'\nimport { StepData, StepState } from './types'\nimport { calculateStepState, calculateProgressWidths } from './helpers'\nimport styled from 'styled-components'\nimport { theme } from '../theme'\nimport { Box } from '../Box'\nimport { StepItem } from './components/StepItem'\n\ninterface Props {\n steps: ReadonlyArray<StepData>\n handleStepChange: (step: StepData) => void\n simpleStep?: boolean\n onStepClick?: (data: {\n currentStepIndex: number\n currentStepState: StepState\n }) => void\n currentStep: string\n}\n\nexport const ProgressIndicator = ({\n handleStepChange,\n onStepClick,\n simpleStep = false,\n steps,\n currentStep,\n}: Props) => {\n const { totalWidth, stepWidth } = calculateProgressWidths(\n steps.length,\n simpleStep,\n )\n\n const visibleSteps = steps.filter((step) => !step.isHidden)\n const currentStepIndex = visibleSteps.findIndex(\n (step) => step.id === currentStep,\n )\n const lastCompletedStepIndex = visibleSteps.findLastIndex(\n (step) =>\n calculateStepState(visibleSteps.indexOf(step), currentStepIndex) ===\n 'completed',\n )\n\n const handleStepClick = (\n currentStepIndex: number,\n currentStepState: StepState,\n stepData: StepData,\n ) => {\n if (onStepClick) {\n onStepClick({ currentStepIndex, currentStepState })\n }\n\n if (currentStepState !== 'disabled') {\n handleStepChange(stepData)\n }\n }\n\n return (\n <Wrapper width={`${totalWidth}px`} flex alignItems=\"center\">\n <DefaultProgress $simpleStep={simpleStep} />\n <Box flex>\n {visibleSteps.map((step, index) => {\n const stepState = calculateStepState(index, currentStepIndex)\n return (\n <StepItem\n key={step.id}\n isCompleted={stepState === 'completed'}\n isCurrentStep={stepState === 'current'}\n isLastCompleted={lastCompletedStepIndex === index}\n onClick={() => handleStepClick(index, stepState, step)}\n stepWidth={`${stepWidth}px`}\n label={step.label}\n isSimple={simpleStep}\n isLastItem={index === visibleSteps.length - 1}\n />\n )\n })}\n </Box>\n </Wrapper>\n )\n}\n\nconst Wrapper = styled(Box)`\n position: relative;\n`\n\nconst DefaultProgress = styled(Box)<{ $simpleStep?: boolean }>`\n z-index: 0;\n content: '';\n position: absolute;\n background: ${theme.colors.matcha};\n width: 100%;\n height: 12px;\n\n ${({ $simpleStep }) => $simpleStep && `border-radius:100px;`}\n`\n"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { StepData } from 'ProgressIndicator/types';
|
2
|
+
import React from 'react';
|
3
|
+
export interface StepItemProps extends Pick<StepData, 'label'> {
|
4
|
+
isCompleted?: boolean;
|
5
|
+
isLastCompleted?: boolean;
|
6
|
+
isCurrentStep: boolean;
|
7
|
+
isSimple?: boolean;
|
8
|
+
onClick: () => void;
|
9
|
+
stepWidth: string;
|
10
|
+
isLastItem: boolean;
|
11
|
+
}
|
12
|
+
export declare const StepItem: ({ label, isSimple, isCurrentStep, stepWidth, onClick, isCompleted, isLastCompleted, isLastItem, }: StepItemProps) => React.JSX.Element;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import { Box } from '../../Box';
|
2
|
+
import React from 'react';
|
3
|
+
import styled, { css } from 'styled-components';
|
4
|
+
import { theme } from '../../theme';
|
5
|
+
import { Text } from '../../Text';
|
6
|
+
import { Icon } from '../../Icon';
|
7
|
+
export const StepItem = ({ label, isSimple = false, isCurrentStep, stepWidth, onClick, isCompleted = false, isLastCompleted = false, isLastItem = false, }) => {
|
8
|
+
if (isSimple) {
|
9
|
+
return (React.createElement(SimpleItem, { "$completed": isCompleted, "$lastCompleted": isLastCompleted, width: stepWidth, height: "12px" }));
|
10
|
+
}
|
11
|
+
return (React.createElement(ProgressItem, { flex: true, "$completed": isCompleted, "$lastCompleted": isLastCompleted, width: stepWidth, onClick: onClick },
|
12
|
+
React.createElement(ProgressIndicator, { "$completed": isCompleted, "$currentStep": isCurrentStep, flex: true, alignItems: "center", justifyContent: "center" }, isCompleted && React.createElement(Icon, { render: "tick", size: 16, color: "cream" })),
|
13
|
+
isCompleted && !isLastItem && React.createElement(CompletedBar, null),
|
14
|
+
React.createElement(FloatingText, { typo: "caption" }, label)));
|
15
|
+
};
|
16
|
+
const lastCompleted = css `
|
17
|
+
border-radius: 0 100px 100px 0;
|
18
|
+
|
19
|
+
&:first-child {
|
20
|
+
border-radius: 100px;
|
21
|
+
}
|
22
|
+
`;
|
23
|
+
const borderRadiusCss = css `
|
24
|
+
&:first-child {
|
25
|
+
border-radius: 100px 0 0 100px;
|
26
|
+
}
|
27
|
+
|
28
|
+
${({ $lastCompleted }) => $lastCompleted && lastCompleted}
|
29
|
+
`;
|
30
|
+
const SimpleItem = styled(Box) `
|
31
|
+
position: relative;
|
32
|
+
z-index: 1;
|
33
|
+
${borderRadiusCss}
|
34
|
+
|
35
|
+
background: ${({ $completed }) => $completed ? theme.colors.pistachio : 'none'};
|
36
|
+
`;
|
37
|
+
const ProgressItem = styled(Box) `
|
38
|
+
position: relative;
|
39
|
+
z-index: 1;
|
40
|
+
`;
|
41
|
+
const ProgressIndicator = styled(Box) `
|
42
|
+
border-radius: 50%;
|
43
|
+
height: 24px;
|
44
|
+
width: 24px;
|
45
|
+
position: relative;
|
46
|
+
left: -2px;
|
47
|
+
z-index: 1;
|
48
|
+
background: ${({ $completed, $currentStep }) => $completed || $currentStep ? theme.colors.pistachio : theme.colors.matcha};
|
49
|
+
`;
|
50
|
+
const FloatingText = styled(Text) `
|
51
|
+
position: absolute;
|
52
|
+
top: 0;
|
53
|
+
transform: translateY(calc(-50% + 34px));
|
54
|
+
left: -6px;
|
55
|
+
font-weight: ${theme.font.weight.medium};
|
56
|
+
`;
|
57
|
+
const CompletedBar = styled(Box) `
|
58
|
+
position: absolute;
|
59
|
+
height: 12px;
|
60
|
+
width: 100%;
|
61
|
+
top: 0;
|
62
|
+
left: 0;
|
63
|
+
transform: translateY(calc(-50% + 12px));
|
64
|
+
background: ${theme.colors.pistachio};
|
65
|
+
z-index: 0;
|
66
|
+
`;
|
67
|
+
//# sourceMappingURL=StepItem.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"StepItem.js","sourceRoot":"","sources":["../../../src/ProgressIndicator/components/StepItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAE/B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAYjC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,aAAa,EACb,SAAS,EACT,OAAO,EACP,WAAW,GAAG,KAAK,EACnB,eAAe,GAAG,KAAK,EACvB,UAAU,GAAG,KAAK,GACJ,EAAE,EAAE;IAClB,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,CACL,oBAAC,UAAU,kBACG,WAAW,oBACP,eAAe,EAC/B,KAAK,EAAE,SAAS,EAChB,MAAM,E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AM;CAC5E,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;;;;;iBAKhB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;CACxC,CAAA;AAED,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;;;;;;;gBAOhB,KAAK,CAAC,MAAM,CAAC,SAAS;;CAErC,CAAA","sourcesContent":["import { Box } from '../../Box'\nimport { StepData } from 'ProgressIndicator/types'\nimport React from 'react'\nimport styled, { css } from 'styled-components'\nimport { theme } from '../../theme'\nimport { Text } from '../../Text'\nimport { Icon } from '../../Icon'\n\nexport interface StepItemProps extends Pick<StepData, 'label'> {\n isCompleted?: boolean\n isLastCompleted?: boolean\n isCurrentStep: boolean\n isSimple?: boolean\n onClick: () => void\n stepWidth: string\n isLastItem: boolean\n}\n\nexport const StepItem = ({\n label,\n isSimple = false,\n isCurrentStep,\n stepWidth,\n onClick,\n isCompleted = false,\n isLastCompleted = false,\n isLastItem = false,\n}: StepItemProps) => {\n if (isSimple) {\n return (\n <SimpleItem\n $completed={isCompleted}\n $lastCompleted={isLastCompleted}\n width={stepWidth}\n height=\"12px\"\n />\n )\n }\n\n return (\n <ProgressItem\n flex\n $completed={isCompleted}\n $lastCompleted={isLastCompleted}\n width={stepWidth}\n onClick={onClick}\n >\n <ProgressIndicator\n $completed={isCompleted}\n $currentStep={isCurrentStep}\n flex\n alignItems=\"center\"\n justifyContent=\"center\"\n >\n {isCompleted && <Icon render=\"tick\" size={16} color=\"cream\" />}\n </ProgressIndicator>\n {isCompleted && !isLastItem && <CompletedBar />}\n <FloatingText typo=\"caption\">{label}</FloatingText>\n </ProgressItem>\n )\n}\n\ninterface StyledComponentProps {\n $completed?: boolean\n $lastCompleted?: boolean\n $currentStep?: boolean\n $completedStep?: boolean\n}\n\nconst lastCompleted = css`\n border-radius: 0 100px 100px 0;\n\n &:first-child {\n border-radius: 100px;\n }\n`\n\nconst borderRadiusCss = css<StyledComponentProps>`\n &:first-child {\n border-radius: 100px 0 0 100px;\n }\n\n ${({ $lastCompleted }) => $lastCompleted && lastCompleted}\n`\n\nconst SimpleItem = styled(Box)<StyledComponentProps>`\n position: relative;\n z-index: 1;\n ${borderRadiusCss}\n\n background: ${({ $completed }) =>\n $completed ? theme.colors.pistachio : 'none'};\n`\n\nconst ProgressItem = styled(Box)<StyledComponentProps>`\n position: relative;\n z-index: 1;\n`\n\nconst ProgressIndicator = styled(Box)<StyledComponentProps>`\n border-radius: 50%;\n height: 24px;\n width: 24px;\n position: relative;\n left: -2px;\n z-index: 1;\n background: ${({ $completed, $currentStep }) =>\n $completed || $currentStep ? theme.colors.pistachio : theme.colors.matcha};\n`\n\nconst FloatingText = styled(Text)`\n position: absolute;\n top: 0;\n transform: translateY(calc(-50% + 34px));\n left: -6px;\n font-weight: ${theme.font.weight.medium};\n`\n\nconst CompletedBar = styled(Box)`\n position: absolute;\n height: 12px;\n width: 100%;\n top: 0;\n left: 0;\n transform: translateY(calc(-50% + 12px));\n background: ${theme.colors.pistachio};\n z-index: 0;\n`\n"]}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { StepState } from './types';
|
2
|
+
interface ReturnValue {
|
3
|
+
totalWidth: number;
|
4
|
+
stepWidth: number;
|
5
|
+
}
|
6
|
+
export declare const calculateProgressWidths: (stepCount: number, isSimpleSteps?: boolean) => ReturnValue;
|
7
|
+
export declare const calculateStepState: (index: number, currentStepIndex: number) => StepState;
|
8
|
+
export {};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
const TOTAL_WIDTH = 320;
|
2
|
+
export const calculateProgressWidths = (stepCount, isSimpleSteps) => {
|
3
|
+
// if not simple steps, we need to subtract 1 from the step count as the last item doesn't have a line
|
4
|
+
const stepsToUse = isSimpleSteps ? stepCount : stepCount - 1;
|
5
|
+
return {
|
6
|
+
totalWidth: TOTAL_WIDTH,
|
7
|
+
stepWidth: TOTAL_WIDTH / stepsToUse,
|
8
|
+
};
|
9
|
+
};
|
10
|
+
export const calculateStepState = (index, currentStepIndex) => {
|
11
|
+
if (index === currentStepIndex) {
|
12
|
+
return 'current';
|
13
|
+
}
|
14
|
+
else if (index < currentStepIndex || currentStepIndex === -1) {
|
15
|
+
return 'completed';
|
16
|
+
}
|
17
|
+
return 'disabled';
|
18
|
+
};
|
19
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/ProgressIndicator/helpers.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,GAAG,CAAA;AAOvB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,SAAiB,EACjB,aAAuB,EACV,EAAE;IACf,sGAAsG;IACtG,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAA;IAC5D,OAAO;QACL,UAAU,EAAE,WAAW;QACvB,SAAS,EAAE,WAAW,GAAG,UAAU;KACpC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAa,EACb,gBAAwB,EACb,EAAE;IACb,IAAI,KAAK,KAAK,gBAAgB,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAA;IAClB,CAAC;SAAM,IAAI,KAAK,GAAG,gBAAgB,IAAI,gBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/D,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA","sourcesContent":["import { StepState } from './types'\n\nconst TOTAL_WIDTH = 320\n\ninterface ReturnValue {\n totalWidth: number\n stepWidth: number\n}\n\nexport const calculateProgressWidths = (\n stepCount: number,\n isSimpleSteps?: boolean,\n): ReturnValue => {\n // if not simple steps, we need to subtract 1 from the step count as the last item doesn't have a line\n const stepsToUse = isSimpleSteps ? stepCount : stepCount - 1\n return {\n totalWidth: TOTAL_WIDTH,\n stepWidth: TOTAL_WIDTH / stepsToUse,\n }\n}\n\nexport const calculateStepState = (\n index: number,\n currentStepIndex: number,\n): StepState => {\n if (index === currentStepIndex) {\n return 'current'\n } else if (index < currentStepIndex || currentStepIndex === -1) {\n return 'completed'\n }\n\n return 'disabled'\n}\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ProgressIndicator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA","sourcesContent":["export { ProgressIndicator } from './ProgressIndicator'\nexport { StepData } from './types'\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ProgressIndicator/types.ts"],"names":[],"mappings":"","sourcesContent":["export type StepState = 'completed' | 'current' | 'disabled'\n\nexport interface StepData {\n label: string\n id: string\n isHidden?: boolean\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mrshmllw/smores-react",
|
3
|
-
"version": "12.
|
3
|
+
"version": "12.3.0",
|
4
4
|
"main": "./dist/index.js",
|
5
5
|
"description": "Collection of React components used by Marshmallow Technology",
|
6
6
|
"type": "module",
|
@@ -42,30 +42,30 @@
|
|
42
42
|
"@semantic-release/github": "^11.0.1",
|
43
43
|
"@semantic-release/npm": "^12.0.0",
|
44
44
|
"@snyk/protect": "^1.1296.1",
|
45
|
-
"@storybook/addon-a11y": "^8.6.
|
45
|
+
"@storybook/addon-a11y": "^8.6.12",
|
46
46
|
"@storybook/addon-coverage": "^1.0.5",
|
47
|
-
"@storybook/addon-essentials": "^8.6.
|
48
|
-
"@storybook/addon-interactions": "^8.6.
|
49
|
-
"@storybook/addon-links": "^8.6.
|
50
|
-
"@storybook/preview-api": "^8.6.
|
51
|
-
"@storybook/react": "^8.6.
|
52
|
-
"@storybook/react-vite": "^8.6.
|
47
|
+
"@storybook/addon-essentials": "^8.6.12",
|
48
|
+
"@storybook/addon-interactions": "^8.6.12",
|
49
|
+
"@storybook/addon-links": "^8.6.12",
|
50
|
+
"@storybook/preview-api": "^8.6.12",
|
51
|
+
"@storybook/react": "^8.6.12",
|
52
|
+
"@storybook/react-vite": "^8.6.12",
|
53
53
|
"@storybook/test": "^8.2.1",
|
54
54
|
"@storybook/test-runner": "^0.22.0",
|
55
|
-
"@testing-library/react": "^16.
|
55
|
+
"@testing-library/react": "^16.3.0",
|
56
56
|
"@types/body-scroll-lock": "^3.1.0",
|
57
57
|
"@types/dompurify": "^3.2.0",
|
58
|
-
"@types/node": "^22.
|
59
|
-
"@types/react": "^19.0
|
60
|
-
"@types/react-dom": "^19.
|
61
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
62
|
-
"@typescript-eslint/parser": "^8.
|
58
|
+
"@types/node": "^22.14.0",
|
59
|
+
"@types/react": "^19.1.0",
|
60
|
+
"@types/react-dom": "^19.1.1",
|
61
|
+
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
62
|
+
"@typescript-eslint/parser": "^8.29.1",
|
63
63
|
"axe-playwright": "^2.1.0",
|
64
64
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
65
|
-
"eslint": "^9.
|
65
|
+
"eslint": "^9.24.0",
|
66
66
|
"eslint-config-prettier": "^10.1.1",
|
67
|
-
"eslint-plugin-prettier": "^5.2.
|
68
|
-
"eslint-plugin-react": "^7.37.
|
67
|
+
"eslint-plugin-prettier": "^5.2.6",
|
68
|
+
"eslint-plugin-react": "^7.37.5",
|
69
69
|
"eslint-plugin-react-hooks": "^5.2.0",
|
70
70
|
"husky": "^9.1.7",
|
71
71
|
"jsdom": "^26.0.0",
|
@@ -77,20 +77,20 @@
|
|
77
77
|
"rimraf": "^6.0.1",
|
78
78
|
"semantic-release": "^24.2.3",
|
79
79
|
"storybook": "^8.0.4",
|
80
|
-
"styled-components": "^6.1.
|
81
|
-
"typescript": "^5.8.
|
82
|
-
"typescript-eslint": "^8.
|
83
|
-
"vite": "^6.2.
|
84
|
-
"vitest": "^3.
|
80
|
+
"styled-components": "^6.1.17",
|
81
|
+
"typescript": "^5.8.3",
|
82
|
+
"typescript-eslint": "^8.29.1",
|
83
|
+
"vite": "^6.2.5",
|
84
|
+
"vitest": "^3.1.1"
|
85
85
|
},
|
86
86
|
"dependencies": {
|
87
|
-
"@floating-ui/react": "0.27.
|
88
|
-
"@lexical/react": "^0.
|
87
|
+
"@floating-ui/react": "0.27.6",
|
88
|
+
"@lexical/react": "^0.30.0",
|
89
89
|
"body-scroll-lock": "^4.0.0-beta.0",
|
90
90
|
"date-fns": "^4.1.0",
|
91
|
-
"dompurify": "^3.2.
|
91
|
+
"dompurify": "^3.2.5",
|
92
92
|
"fuse.js": "^7.1.0",
|
93
|
-
"lexical": "^0.
|
93
|
+
"lexical": "^0.30.0",
|
94
94
|
"polished": "^4.1.3"
|
95
95
|
},
|
96
96
|
"peerDependencies": {
|