@vygruppen/spor-react 7.1.1 → 7.2.1
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +13 -0
- package/dist/{CountryCodeSelect-HHSDOINA.mjs → CountryCodeSelect-GE32ZZIY.mjs} +1 -1
- package/dist/{chunk-RPCU5IOH.mjs → chunk-LD6S2MKC.mjs} +23 -5
- package/dist/index.d.mts +23 -4
- package/dist/index.d.ts +23 -4
- package/dist/index.js +28 -3
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/stepper/Stepper.tsx +4 -4
- package/src/typography/Heading.tsx +17 -1
- package/src/util/index.tsx +1 -0
- package/src/util/slugify.tsx +36 -0
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> @vygruppen/spor-react@7.
|
2
|
+
> @vygruppen/spor-react@7.2.1 build
|
3
3
|
> tsup src/index.tsx --dts --treeshake --format cjs,esm
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
@@ -8,15 +8,15 @@
|
|
8
8
|
[34mCLI[39m Target: node16
|
9
9
|
[34mCJS[39m Build start
|
10
10
|
[34mESM[39m Build start
|
11
|
-
"Collapse" is imported from external module "@chakra-ui/react" but never used in "dist/chunk-RPCU5IOH.mjs".
|
12
|
-
[34mDTS[39m Build start
|
13
11
|
"Collapse" is imported from external module "@chakra-ui/react" but never used in "dist/index.js".
|
12
|
+
"Collapse" is imported from external module "@chakra-ui/react" but never used in "dist/chunk-LD6S2MKC.mjs".
|
13
|
+
[34mDTS[39m Build start
|
14
|
+
[32mCJS[39m [1mdist/index.js [22m[32m495.05 KB[39m
|
15
|
+
[32mCJS[39m ⚡️ Build success in 2219ms
|
14
16
|
[32mESM[39m [1mdist/index.mjs [22m[32m2.16 KB[39m
|
15
|
-
[32mESM[39m [1mdist/CountryCodeSelect-
|
16
|
-
[32mESM[39m [1mdist/chunk-
|
17
|
-
[32mESM[39m ⚡️ Build success in
|
18
|
-
[
|
19
|
-
[
|
20
|
-
[32mDTS[39m
|
21
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m264.83 KB[39m
|
22
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m264.83 KB[39m
|
17
|
+
[32mESM[39m [1mdist/CountryCodeSelect-GE32ZZIY.mjs [22m[32m1.19 KB[39m
|
18
|
+
[32mESM[39m [1mdist/chunk-LD6S2MKC.mjs [22m[32m387.65 KB[39m
|
19
|
+
[32mESM[39m ⚡️ Build success in 2229ms
|
20
|
+
[32mDTS[39m ⚡️ Build success in 10625ms
|
21
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m265.46 KB[39m
|
22
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m265.46 KB[39m
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @vygruppen/spor-react
|
2
2
|
|
3
|
+
## 7.2.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- a3159e5: Stepper: Change input to onBackButtonClick
|
8
|
+
|
9
|
+
## 7.2.0
|
10
|
+
|
11
|
+
### Minor Changes
|
12
|
+
|
13
|
+
- 672d254: Heading: New prop "autoId" lets you autogenerate an ID based on the content
|
14
|
+
slugify: New export that lets you slugify a string
|
15
|
+
|
3
16
|
## 7.1.1
|
4
17
|
|
5
18
|
### Patch Changes
|
@@ -1585,9 +1585,12 @@ var Code = forwardRef((props, ref) => /* @__PURE__ */ React69__default.createEle
|
|
1585
1585
|
var Heading = ({
|
1586
1586
|
as,
|
1587
1587
|
variant = "xl-display",
|
1588
|
+
autoId = false,
|
1589
|
+
id: externalId,
|
1588
1590
|
...props
|
1589
1591
|
}) => {
|
1590
|
-
|
1592
|
+
const id = externalId ?? (autoId && typeof props.children === "string") ? slugify(props.children) : void 0;
|
1593
|
+
return /* @__PURE__ */ React69__default.createElement(Text, { as, textStyle: variant, id, ...props });
|
1591
1594
|
};
|
1592
1595
|
var Text4 = forwardRef(
|
1593
1596
|
({ variant = "sm", ...props }, ref) => {
|
@@ -3417,7 +3420,7 @@ var texts14 = createTexts({
|
|
3417
3420
|
sv: "Telefonnummer"
|
3418
3421
|
}
|
3419
3422
|
});
|
3420
|
-
var LazyCountryCodeSelect = React69__default.lazy(() => import('./CountryCodeSelect-
|
3423
|
+
var LazyCountryCodeSelect = React69__default.lazy(() => import('./CountryCodeSelect-GE32ZZIY.mjs'));
|
3421
3424
|
var Radio = forwardRef((props, ref) => {
|
3422
3425
|
return /* @__PURE__ */ React69__default.createElement(Radio$1, { ...props, ref });
|
3423
3426
|
});
|
@@ -4308,10 +4311,11 @@ var Stepper = ({
|
|
4308
4311
|
size: "sm",
|
4309
4312
|
visibility: hideBackButtonOnFirstStep ? "hidden" : "visible",
|
4310
4313
|
onClick: () => {
|
4314
|
+
const stepToGoTo = activeStep - 1;
|
4311
4315
|
if (onBackButtonClick) {
|
4312
|
-
onBackButtonClick(
|
4316
|
+
onBackButtonClick(stepToGoTo);
|
4313
4317
|
}
|
4314
|
-
onClick(
|
4318
|
+
onClick(stepToGoTo);
|
4315
4319
|
}
|
4316
4320
|
}
|
4317
4321
|
),
|
@@ -13660,4 +13664,18 @@ function useSize(subject) {
|
|
13660
13664
|
return size2;
|
13661
13665
|
}
|
13662
13666
|
|
13663
|
-
|
13667
|
+
// src/util/slugify.tsx
|
13668
|
+
function slugify(text, maxLength = 50) {
|
13669
|
+
if (!text) {
|
13670
|
+
return text;
|
13671
|
+
}
|
13672
|
+
if (Array.isArray(text)) {
|
13673
|
+
text = text.join(" ");
|
13674
|
+
}
|
13675
|
+
if (maxLength < 1) {
|
13676
|
+
throw new Error("The maxLength parameter must be a positive number");
|
13677
|
+
}
|
13678
|
+
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[\u00C6\u00E6]/g, "ae").replace(/[\u00D8\u00F8]/g, "oe").replace(/[\u00C5\u00E5]/g, "aa").toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "").substring(0, maxLength);
|
13679
|
+
}
|
13680
|
+
|
13681
|
+
export { Accordion, AttachedInputs, Badge, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerContent, Expandable, ExpandableAlert, ExpandableItem, FloatingActionButton, FormControl, FormErrorMessage, FormLabel3 as FormLabel, Heading, IconButton, InfoSelect, InfoTag, Input, InputLeftElement2 as InputLeftElement, InputRightElement2 as InputRightElement, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightSpinner, LineIcon, ListBox, ModalHeader, NativeSelect, NumericStepper, PasswordInput, PhoneNumberInput, PlayPauseButton, PopoverWizardBody, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, SearchInput, SimpleDrawer, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Table, Tabs, Text4 as Text, TextLink, Textarea, TimePicker, TravelTag, VyLogo, WizardPopover, brandTheme, createTexts, fontFaces, slugify, theme, useSize, useToast, useTranslation };
|
package/dist/index.d.mts
CHANGED
@@ -1956,11 +1956,10 @@ type StepperProps = {
|
|
1956
1956
|
/** Callback for when a step is clicked */
|
1957
1957
|
onClick: (clickedStep: number) => void;
|
1958
1958
|
/** Callback for when the back button is clicked (on smaller screens).
|
1959
|
-
* A boolean indicating whether or not the user is on the first step is passed as an argument.
|
1960
1959
|
*
|
1961
1960
|
* If this is not provided, the back button will not be shown on smaller screens on the first step.
|
1962
1961
|
*/
|
1963
|
-
onBackButtonClick?: (
|
1962
|
+
onBackButtonClick?: (stepNumberToGoTo: number) => void;
|
1964
1963
|
/**
|
1965
1964
|
* Heading shown on smaller devices
|
1966
1965
|
* @deprecated Use `heading` instead
|
@@ -7487,6 +7486,8 @@ type HeadingProps = Omit<HeadingProps$1, "textStyle" | "as"> & {
|
|
7487
7486
|
as: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
7488
7487
|
/** The size and style of the heading. Defaults to xl-display */
|
7489
7488
|
variant?: keyof typeof textStyles;
|
7489
|
+
/** If true, generate an ID based on the children */
|
7490
|
+
autoId?: boolean;
|
7490
7491
|
};
|
7491
7492
|
/**
|
7492
7493
|
* Create your own fancy headings with this component.
|
@@ -7503,8 +7504,15 @@ type HeadingProps = Omit<HeadingProps$1, "textStyle" | "as"> & {
|
|
7503
7504
|
* ```tsx
|
7504
7505
|
* <Heading as="h1" variant="2xl">Look at me!</Heading>
|
7505
7506
|
* ```
|
7507
|
+
*
|
7508
|
+
* If you want to generate an ID based on the children, you can use the `autoId` prop.
|
7509
|
+
* Please note that this only works with string children (not JSX, nor arrays of strings).
|
7510
|
+
*
|
7511
|
+
* ```tsx
|
7512
|
+
* <Heading as="h1" autoId>Page heading</Heading> // Will set id="page-heading"
|
7513
|
+
* ```
|
7506
7514
|
*/
|
7507
|
-
declare const Heading: ({ as, variant, ...props }: HeadingProps) => React__default.JSX.Element;
|
7515
|
+
declare const Heading: ({ as, variant, autoId, id: externalId, ...props }: HeadingProps) => React__default.JSX.Element;
|
7508
7516
|
|
7509
7517
|
type TextProps = Omit<TextProps$1, "textStyle"> & {
|
7510
7518
|
/** The size and style of the text.
|
@@ -7521,4 +7529,15 @@ type TextProps = Omit<TextProps$1, "textStyle"> & {
|
|
7521
7529
|
*/
|
7522
7530
|
declare const Text: _chakra_ui_system_dist_system_types.ComponentWithAs<"p", TextProps>;
|
7523
7531
|
|
7524
|
-
|
7532
|
+
/**
|
7533
|
+
* Makes a slug-version of any string.
|
7534
|
+
*
|
7535
|
+
* By default, the maximum length of the slug is 50 characters. You can override this with the `maxLength` parameter.
|
7536
|
+
*
|
7537
|
+
* ```tsx
|
7538
|
+
* slugify("Hello, world!"); // hello-world
|
7539
|
+
* slugify("Hello, world!", 6); // hello-
|
7540
|
+
**/
|
7541
|
+
declare function slugify(text: string | string[], maxLength?: number): string;
|
7542
|
+
|
7543
|
+
export { Accordion, AccordionProps, AttachedInputs, Badge, BadgeProps, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, ButtonGroupProps, ButtonProps, Card, CardProps, CardSelect, Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, ChoiceChip, ChoiceChipProps, ClosableAlert, CloseButton, CloseButtonProps, Code, CodeProps, ColorInlineLoader, ColorInlineLoaderProps, ColorSpinner, ColorSpinnerProps, Combobox, ComboboxProps, ContentLoader, ContentLoaderProps, DarkFullScreenLoader, DarkInlineLoader, DarkInlineLoaderProps, DarkSpinner, DarkSpinnerProps, DatePicker, DateRangePicker, Divider, DividerProps, Drawer, DrawerContent, ModalHeader as DrawerHeader, Expandable, ExpandableAlert, ExpandableItem, ExpandableItemProps, FloatingActionButton, FormControl, FormControlProps, FormErrorMessage, FormErrorMessageProps, FormLabel, FormLabelProps, Heading, HeadingProps, IconButton, IconButtonProps, InfoSelect, InfoTag, InfoTagProps, Input, InputElementProps, InputLeftElement, InputProps, InputRightElement, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightInlineLoaderProps, LightSpinner, LightSpinnerProps, LineIcon, LineIconProps, ListBox, ModalHeader, ModalHeaderProps, NativeSelect, NativeSelectProps, NumericStepper, PasswordInput, PasswordInputProps, PhoneNumberInput, PlayPauseButton, PopoverWizardBody, PopoverWizardProps, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, RadioGroupProps, RadioProps, SearchInput, SearchInputProps, SimpleDrawer, SimpleDrawerProps, SimplePopover, Skeleton, SkeletonCircle, SkeletonCircleProps, SkeletonProps, SkeletonText, SkeletonTextProps, SkipButton, SpinnerProps, SporProvider, Stack, StackProps, StaticAlert, Stepper, StepperStep, Switch, SwitchProps, Table, TableProps, Tabs, TabsProps, Text, TextLink, TextProps, Textarea, TextareaProps, TimePicker, ToastOptions, Translations, TravelTag, TravelTagProps, VyLogo, VyLogoProps, WizardPopover, WizardPopoverProps, brandTheme, createTexts, fontFaces, slugify, theme, useToast, useTranslation };
|
package/dist/index.d.ts
CHANGED
@@ -1956,11 +1956,10 @@ type StepperProps = {
|
|
1956
1956
|
/** Callback for when a step is clicked */
|
1957
1957
|
onClick: (clickedStep: number) => void;
|
1958
1958
|
/** Callback for when the back button is clicked (on smaller screens).
|
1959
|
-
* A boolean indicating whether or not the user is on the first step is passed as an argument.
|
1960
1959
|
*
|
1961
1960
|
* If this is not provided, the back button will not be shown on smaller screens on the first step.
|
1962
1961
|
*/
|
1963
|
-
onBackButtonClick?: (
|
1962
|
+
onBackButtonClick?: (stepNumberToGoTo: number) => void;
|
1964
1963
|
/**
|
1965
1964
|
* Heading shown on smaller devices
|
1966
1965
|
* @deprecated Use `heading` instead
|
@@ -7487,6 +7486,8 @@ type HeadingProps = Omit<HeadingProps$1, "textStyle" | "as"> & {
|
|
7487
7486
|
as: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
7488
7487
|
/** The size and style of the heading. Defaults to xl-display */
|
7489
7488
|
variant?: keyof typeof textStyles;
|
7489
|
+
/** If true, generate an ID based on the children */
|
7490
|
+
autoId?: boolean;
|
7490
7491
|
};
|
7491
7492
|
/**
|
7492
7493
|
* Create your own fancy headings with this component.
|
@@ -7503,8 +7504,15 @@ type HeadingProps = Omit<HeadingProps$1, "textStyle" | "as"> & {
|
|
7503
7504
|
* ```tsx
|
7504
7505
|
* <Heading as="h1" variant="2xl">Look at me!</Heading>
|
7505
7506
|
* ```
|
7507
|
+
*
|
7508
|
+
* If you want to generate an ID based on the children, you can use the `autoId` prop.
|
7509
|
+
* Please note that this only works with string children (not JSX, nor arrays of strings).
|
7510
|
+
*
|
7511
|
+
* ```tsx
|
7512
|
+
* <Heading as="h1" autoId>Page heading</Heading> // Will set id="page-heading"
|
7513
|
+
* ```
|
7506
7514
|
*/
|
7507
|
-
declare const Heading: ({ as, variant, ...props }: HeadingProps) => React__default.JSX.Element;
|
7515
|
+
declare const Heading: ({ as, variant, autoId, id: externalId, ...props }: HeadingProps) => React__default.JSX.Element;
|
7508
7516
|
|
7509
7517
|
type TextProps = Omit<TextProps$1, "textStyle"> & {
|
7510
7518
|
/** The size and style of the text.
|
@@ -7521,4 +7529,15 @@ type TextProps = Omit<TextProps$1, "textStyle"> & {
|
|
7521
7529
|
*/
|
7522
7530
|
declare const Text: _chakra_ui_system_dist_system_types.ComponentWithAs<"p", TextProps>;
|
7523
7531
|
|
7524
|
-
|
7532
|
+
/**
|
7533
|
+
* Makes a slug-version of any string.
|
7534
|
+
*
|
7535
|
+
* By default, the maximum length of the slug is 50 characters. You can override this with the `maxLength` parameter.
|
7536
|
+
*
|
7537
|
+
* ```tsx
|
7538
|
+
* slugify("Hello, world!"); // hello-world
|
7539
|
+
* slugify("Hello, world!", 6); // hello-
|
7540
|
+
**/
|
7541
|
+
declare function slugify(text: string | string[], maxLength?: number): string;
|
7542
|
+
|
7543
|
+
export { Accordion, AccordionProps, AttachedInputs, Badge, BadgeProps, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, ButtonGroupProps, ButtonProps, Card, CardProps, CardSelect, Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, ChoiceChip, ChoiceChipProps, ClosableAlert, CloseButton, CloseButtonProps, Code, CodeProps, ColorInlineLoader, ColorInlineLoaderProps, ColorSpinner, ColorSpinnerProps, Combobox, ComboboxProps, ContentLoader, ContentLoaderProps, DarkFullScreenLoader, DarkInlineLoader, DarkInlineLoaderProps, DarkSpinner, DarkSpinnerProps, DatePicker, DateRangePicker, Divider, DividerProps, Drawer, DrawerContent, ModalHeader as DrawerHeader, Expandable, ExpandableAlert, ExpandableItem, ExpandableItemProps, FloatingActionButton, FormControl, FormControlProps, FormErrorMessage, FormErrorMessageProps, FormLabel, FormLabelProps, Heading, HeadingProps, IconButton, IconButtonProps, InfoSelect, InfoTag, InfoTagProps, Input, InputElementProps, InputLeftElement, InputProps, InputRightElement, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightInlineLoaderProps, LightSpinner, LightSpinnerProps, LineIcon, LineIconProps, ListBox, ModalHeader, ModalHeaderProps, NativeSelect, NativeSelectProps, NumericStepper, PasswordInput, PasswordInputProps, PhoneNumberInput, PlayPauseButton, PopoverWizardBody, PopoverWizardProps, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, RadioGroupProps, RadioProps, SearchInput, SearchInputProps, SimpleDrawer, SimpleDrawerProps, SimplePopover, Skeleton, SkeletonCircle, SkeletonCircleProps, SkeletonProps, SkeletonText, SkeletonTextProps, SkipButton, SpinnerProps, SporProvider, Stack, StackProps, StaticAlert, Stepper, StepperStep, Switch, SwitchProps, Table, TableProps, Tabs, TabsProps, Text, TextLink, TextProps, Textarea, TextareaProps, TimePicker, ToastOptions, Translations, TravelTag, TravelTagProps, VyLogo, VyLogoProps, WizardPopover, WizardPopoverProps, brandTheme, createTexts, fontFaces, slugify, theme, useToast, useTranslation };
|
package/dist/index.js
CHANGED
@@ -1175,12 +1175,16 @@ var init_Code = __esm({
|
|
1175
1175
|
exports.Heading = void 0;
|
1176
1176
|
var init_Heading = __esm({
|
1177
1177
|
"src/typography/Heading.tsx"() {
|
1178
|
+
init_src();
|
1178
1179
|
exports.Heading = ({
|
1179
1180
|
as,
|
1180
1181
|
variant = "xl-display",
|
1182
|
+
autoId = false,
|
1183
|
+
id: externalId,
|
1181
1184
|
...props
|
1182
1185
|
}) => {
|
1183
|
-
|
1186
|
+
const id = externalId ?? (autoId && typeof props.children === "string") ? slugify(props.children) : void 0;
|
1187
|
+
return /* @__PURE__ */ React69__namespace.default.createElement(react.Text, { as, textStyle: variant, id, ...props });
|
1184
1188
|
};
|
1185
1189
|
}
|
1186
1190
|
});
|
@@ -5180,10 +5184,11 @@ var init_Stepper = __esm({
|
|
5180
5184
|
size: "sm",
|
5181
5185
|
visibility: hideBackButtonOnFirstStep ? "hidden" : "visible",
|
5182
5186
|
onClick: () => {
|
5187
|
+
const stepToGoTo = activeStep - 1;
|
5183
5188
|
if (onBackButtonClick) {
|
5184
|
-
onBackButtonClick(
|
5189
|
+
onBackButtonClick(stepToGoTo);
|
5185
5190
|
}
|
5186
|
-
onClick(
|
5191
|
+
onClick(stepToGoTo);
|
5187
5192
|
}
|
5188
5193
|
}
|
5189
5194
|
),
|
@@ -15504,10 +15509,29 @@ var init_externals = __esm({
|
|
15504
15509
|
}
|
15505
15510
|
});
|
15506
15511
|
|
15512
|
+
// src/util/slugify.tsx
|
15513
|
+
function slugify(text, maxLength = 50) {
|
15514
|
+
if (!text) {
|
15515
|
+
return text;
|
15516
|
+
}
|
15517
|
+
if (Array.isArray(text)) {
|
15518
|
+
text = text.join(" ");
|
15519
|
+
}
|
15520
|
+
if (maxLength < 1) {
|
15521
|
+
throw new Error("The maxLength parameter must be a positive number");
|
15522
|
+
}
|
15523
|
+
return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[\u00C6\u00E6]/g, "ae").replace(/[\u00D8\u00F8]/g, "oe").replace(/[\u00C5\u00E5]/g, "aa").toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "").substring(0, maxLength);
|
15524
|
+
}
|
15525
|
+
var init_slugify = __esm({
|
15526
|
+
"src/util/slugify.tsx"() {
|
15527
|
+
}
|
15528
|
+
});
|
15529
|
+
|
15507
15530
|
// src/util/index.tsx
|
15508
15531
|
var init_util = __esm({
|
15509
15532
|
"src/util/index.tsx"() {
|
15510
15533
|
init_externals();
|
15534
|
+
init_slugify();
|
15511
15535
|
}
|
15512
15536
|
});
|
15513
15537
|
var init_src = __esm({
|
@@ -15867,5 +15891,6 @@ exports.LanguageProvider = LanguageProvider;
|
|
15867
15891
|
exports.ListBox = ListBox;
|
15868
15892
|
exports.NumericStepper = NumericStepper;
|
15869
15893
|
exports.createTexts = createTexts;
|
15894
|
+
exports.slugify = slugify;
|
15870
15895
|
exports.useSize = useSize;
|
15871
15896
|
exports.useTranslation = useTranslation;
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-
|
1
|
+
export { Accordion, AccordionButton, AccordionIcon, AccordionItem, AccordionPanel, AttachedInputs, Badge, Box, Brand, Breadcrumb, BreadcrumbItem, BreadcrumbLink, Button, ButtonGroup, Card, CardSelect, Center, Checkbox, CheckboxGroup, ChoiceChip, ClosableAlert, CloseButton, Code, ColorInlineLoader, ColorSpinner, Combobox, Container, ContentLoader, DarkFullScreenLoader, DarkInlineLoader, DarkMode, DarkSpinner, DatePicker, DateRangePicker, Divider, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerFooter, ModalHeader as DrawerHeader, DrawerOverlay, Expandable, ExpandableAlert, ExpandableItem, Fade, Flex, FloatingActionButton, FormControl, FormErrorMessage, FormHelperText, FormLabel, Grid, GridItem, HStack, Heading, IconButton, Image, Img, InfoSelect, InfoTag, Input, InputGroup, InputLeftElement, InputRightElement, Item, ItemDescription, ItemLabel, JumpButton, Language, LanguageProvider, LightFullScreenLoader, LightInlineLoader, LightMode, LightSpinner, LineIcon, ListBox, ListItem, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, NativeSelect, NumericStepper, OrderedList, PasswordInput, PhoneNumberInput, PlayPauseButton, Popover, PopoverAnchor, PopoverArrow, PopoverBody, PopoverCloseButton, PopoverContent, PopoverFooter, PopoverHeader, PopoverTrigger, PopoverWizardBody, Portal, ProgressBar, ProgressIndicator, ProgressLoader, Radio, RadioGroup, ScaleFade, SearchInput, Section, SimpleDrawer, SimpleGrid, SimplePopover, Skeleton, SkeletonCircle, SkeletonText, SkipButton, Slide, SlideFade, Spacer, SporProvider, Stack, StaticAlert, Stepper, StepperStep, Switch, Tab, TabList, TabPanel, TabPanels, Table, TableCaption, Tabs, Tbody, Td, Text, TextLink, Textarea, Tfoot, Th, Thead, Time, TimePicker, Tr, TravelTag, UnorderedList, VStack, VyLogo, WizardPopover, Wrap, WrapItem, brandTheme, createTexts, defineStyleConfig, extendTheme, fontFaces, slugify, theme, tokens, useBreakpointValue, useClipboard, useColorMode, useColorModePreference, useColorModeValue, useControllableProp, useDisclosure, useMediaQuery, useMergeRefs, useOutsideClick, usePrefersReducedMotion, useSize, useTheme, useToast, useToken, useTranslation } from './chunk-LD6S2MKC.mjs';
|
package/package.json
CHANGED
package/src/stepper/Stepper.tsx
CHANGED
@@ -9,11 +9,10 @@ type StepperProps = {
|
|
9
9
|
/** Callback for when a step is clicked */
|
10
10
|
onClick: (clickedStep: number) => void;
|
11
11
|
/** Callback for when the back button is clicked (on smaller screens).
|
12
|
-
* A boolean indicating whether or not the user is on the first step is passed as an argument.
|
13
12
|
*
|
14
13
|
* If this is not provided, the back button will not be shown on smaller screens on the first step.
|
15
14
|
*/
|
16
|
-
onBackButtonClick?: (
|
15
|
+
onBackButtonClick?: (stepNumberToGoTo: number) => void;
|
17
16
|
/**
|
18
17
|
* Heading shown on smaller devices
|
19
18
|
* @deprecated Use `heading` instead
|
@@ -92,10 +91,11 @@ export const Stepper = ({
|
|
92
91
|
size="sm"
|
93
92
|
visibility={hideBackButtonOnFirstStep ? "hidden" : "visible"}
|
94
93
|
onClick={() => {
|
94
|
+
const stepToGoTo = activeStep - 1;
|
95
95
|
if (onBackButtonClick) {
|
96
|
-
onBackButtonClick(
|
96
|
+
onBackButtonClick(stepToGoTo);
|
97
97
|
}
|
98
|
-
onClick(
|
98
|
+
onClick(stepToGoTo);
|
99
99
|
}}
|
100
100
|
/>
|
101
101
|
{shownHeading && (
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { HeadingProps as ChakraHeadingProps, Text } from "@chakra-ui/react";
|
2
2
|
import React from "react";
|
3
|
+
import { slugify } from "..";
|
3
4
|
import type { textStyles } from "../theme/foundations";
|
4
5
|
|
5
6
|
export type HeadingProps = Omit<ChakraHeadingProps, "textStyle" | "as"> & {
|
@@ -7,6 +8,8 @@ export type HeadingProps = Omit<ChakraHeadingProps, "textStyle" | "as"> & {
|
|
7
8
|
as: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
8
9
|
/** The size and style of the heading. Defaults to xl-display */
|
9
10
|
variant?: keyof typeof textStyles;
|
11
|
+
/** If true, generate an ID based on the children */
|
12
|
+
autoId?: boolean;
|
10
13
|
};
|
11
14
|
/**
|
12
15
|
* Create your own fancy headings with this component.
|
@@ -23,11 +26,24 @@ export type HeadingProps = Omit<ChakraHeadingProps, "textStyle" | "as"> & {
|
|
23
26
|
* ```tsx
|
24
27
|
* <Heading as="h1" variant="2xl">Look at me!</Heading>
|
25
28
|
* ```
|
29
|
+
*
|
30
|
+
* If you want to generate an ID based on the children, you can use the `autoId` prop.
|
31
|
+
* Please note that this only works with string children (not JSX, nor arrays of strings).
|
32
|
+
*
|
33
|
+
* ```tsx
|
34
|
+
* <Heading as="h1" autoId>Page heading</Heading> // Will set id="page-heading"
|
35
|
+
* ```
|
26
36
|
*/
|
27
37
|
export const Heading = ({
|
28
38
|
as,
|
29
39
|
variant = "xl-display",
|
40
|
+
autoId = false,
|
41
|
+
id: externalId,
|
30
42
|
...props
|
31
43
|
}: HeadingProps) => {
|
32
|
-
|
44
|
+
const id =
|
45
|
+
externalId ?? (autoId && typeof props.children === "string")
|
46
|
+
? slugify(props.children as string)
|
47
|
+
: undefined;
|
48
|
+
return <Text as={as} textStyle={variant} id={id} {...props} />;
|
33
49
|
};
|
package/src/util/index.tsx
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
/**
|
2
|
+
* Makes a slug-version of any string.
|
3
|
+
*
|
4
|
+
* By default, the maximum length of the slug is 50 characters. You can override this with the `maxLength` parameter.
|
5
|
+
*
|
6
|
+
* ```tsx
|
7
|
+
* slugify("Hello, world!"); // hello-world
|
8
|
+
* slugify("Hello, world!", 6); // hello-
|
9
|
+
**/
|
10
|
+
export function slugify(text: string | string[], maxLength = 50): string {
|
11
|
+
if (!text) {
|
12
|
+
return text;
|
13
|
+
}
|
14
|
+
if (Array.isArray(text)) {
|
15
|
+
text = text.join(" ");
|
16
|
+
}
|
17
|
+
if (maxLength < 1) {
|
18
|
+
throw new Error("The maxLength parameter must be a positive number");
|
19
|
+
}
|
20
|
+
return (
|
21
|
+
text
|
22
|
+
.normalize("NFD") // Normalize to NFD Unicode form
|
23
|
+
.replace(/[\u0300-\u036f]/g, "") // Remove diacritics
|
24
|
+
.replace(/[\u00C6\u00E6]/g, "ae") // Replace Æ, æ
|
25
|
+
.replace(/[\u00D8\u00F8]/g, "oe") // Replace Ø, ø
|
26
|
+
.replace(/[\u00C5\u00E5]/g, "aa") // Replace Å, å
|
27
|
+
// Extend the replacement rules as needed
|
28
|
+
.toLowerCase()
|
29
|
+
.replace(/\s+/g, "-") // Replace spaces with -
|
30
|
+
.replace(/[^\w-]+/g, "") // Remove all non-word chars
|
31
|
+
.replace(/--+/g, "-") // Replace multiple - with single -
|
32
|
+
.replace(/^-+/, "") // Trim - from start of text
|
33
|
+
.replace(/-+$/, "")
|
34
|
+
.substring(0, maxLength)
|
35
|
+
);
|
36
|
+
}
|