@vygruppen/spor-react 12.1.0 → 12.1.2
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/.turbo/turbo-typegen.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +3 -39
- package/dist/index.d.ts +3 -39
- package/dist/index.js +56 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/button/Button.tsx +65 -53
- package/src/link/TextLink.tsx +44 -9
- package/src/theme/recipes/button.ts +5 -0
package/.turbo/turbo-build.log
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
|
-
> @vygruppen/spor-react@12.1.
|
2
|
+
> @vygruppen/spor-react@12.1.2 build /home/runner/work/spor/spor/packages/spor-react
|
3
3
|
> pnpm typegen && tsup
|
4
4
|
|
5
5
|
|
6
|
-
> @vygruppen/spor-react@12.1.
|
6
|
+
> @vygruppen/spor-react@12.1.2 typegen /home/runner/work/spor/spor/packages/spor-react
|
7
7
|
> npx @chakra-ui/cli typegen src/theme/index.ts
|
8
8
|
|
9
9
|
[90m┌[39m Chakra CLI ⚡️
|
@@ -31,12 +31,12 @@ CLI Target: node16
|
|
31
31
|
CJS Build start
|
32
32
|
ESM Build start
|
33
33
|
DTS Build start
|
34
|
-
CJS dist/index.js
|
35
|
-
CJS dist/index.js.map
|
36
|
-
CJS ⚡️ Build success in
|
37
|
-
ESM dist/index.mjs
|
38
|
-
ESM dist/index.mjs.map
|
39
|
-
ESM ⚡️ Build success in
|
40
|
-
DTS ⚡️ Build success in
|
41
|
-
DTS dist/index.d.ts
|
42
|
-
DTS dist/index.d.mts
|
34
|
+
CJS dist/index.js 313.99 KB
|
35
|
+
CJS dist/index.js.map 622.57 KB
|
36
|
+
CJS ⚡️ Build success in 1209ms
|
37
|
+
ESM dist/index.mjs 294.38 KB
|
38
|
+
ESM dist/index.mjs.map 622.57 KB
|
39
|
+
ESM ⚡️ Build success in 1794ms
|
40
|
+
DTS ⚡️ Build success in 20993ms
|
41
|
+
DTS dist/index.d.ts 133.42 KB
|
42
|
+
DTS dist/index.d.mts 133.42 KB
|
package/.turbo/turbo-typegen.log
CHANGED
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @vygruppen/spor-react
|
2
2
|
|
3
|
+
## 12.1.2
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 4b8e4f4: `asChild` support for Button and TextLink #1669
|
8
|
+
|
9
|
+
## 12.1.1
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- Updated dependencies [5e6da7b]
|
14
|
+
- @vygruppen/spor-design-tokens@4.0.5
|
15
|
+
|
3
16
|
## 12.1.0
|
4
17
|
|
5
18
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
@@ -317,38 +317,11 @@ type ButtonProps = Exclude<ButtonProps$1, "size" | "variant" | "colorPalette"> &
|
|
317
317
|
loadingText?: React__default.ReactNode;
|
318
318
|
leftIcon?: React__default.ReactNode;
|
319
319
|
rightIcon?: React__default.ReactNode;
|
320
|
-
variant
|
320
|
+
variant?: "primary" | "secondary" | "tertiary" | "ghost" | "floating";
|
321
321
|
size?: "lg" | "md" | "sm" | "xs";
|
322
322
|
download?: string;
|
323
323
|
href?: string;
|
324
324
|
};
|
325
|
-
/**
|
326
|
-
* Buttons are used to trigger actions.
|
327
|
-
*
|
328
|
-
* There are several button variants. You can specify which one you want with the `variant` prop. The available variants are:
|
329
|
-
*
|
330
|
-
* - `primary`: This is our main button. It's used for the main actions in a view, like a call to action. There should only be a single primary button in each view.
|
331
|
-
* - `secondary`: Used for secondary actions in a view, and when you need to make several actions available at the same time.
|
332
|
-
* - `tertiary`: Used for additional choices, like a less important secondary action.
|
333
|
-
* - `ghost`: Used inside other interactive elements, like date pickers and input fields.
|
334
|
-
* - `floating`: Used for floating actions, like a menu button in a menu.
|
335
|
-
*
|
336
|
-
* ```tsx
|
337
|
-
* <Button variant="primary" onClick={confirmOrder}>
|
338
|
-
* Buy trip
|
339
|
-
* </Button>
|
340
|
-
* ```
|
341
|
-
*
|
342
|
-
* There are also different sizes. You can specify which one you want with the `size` prop. The available sizes are "lg", "md", "sm" and "xs".
|
343
|
-
*
|
344
|
-
* ```tsx
|
345
|
-
* <Button variant="secondary" size="sm" onClick={cancelOrder}>
|
346
|
-
* Cancel trip
|
347
|
-
* </Button>
|
348
|
-
* ```
|
349
|
-
*
|
350
|
-
* @see https://spor.vy.no/components/button
|
351
|
-
*/
|
352
325
|
declare const Button: React__default.ForwardRefExoticComponent<ButtonProps$1 & {
|
353
326
|
variant?: _chakra_ui_react.ConditionalValue<"floating" | "secondary" | "tertiary" | "ghost" | "primary" | undefined>;
|
354
327
|
size?: _chakra_ui_react.ConditionalValue<"sm" | "md" | "lg" | "xs" | undefined>;
|
@@ -359,7 +332,7 @@ declare const Button: React__default.ForwardRefExoticComponent<ButtonProps$1 & {
|
|
359
332
|
loadingText?: React__default.ReactNode;
|
360
333
|
leftIcon?: React__default.ReactNode;
|
361
334
|
rightIcon?: React__default.ReactNode;
|
362
|
-
variant
|
335
|
+
variant?: "primary" | "secondary" | "tertiary" | "ghost" | "floating";
|
363
336
|
size?: "lg" | "md" | "sm" | "xs";
|
364
337
|
download?: string;
|
365
338
|
href?: string;
|
@@ -395,7 +368,7 @@ declare const ClipboardButton: React$1.ForwardRefExoticComponent<_chakra_ui_reac
|
|
395
368
|
loadingText?: React$1.ReactNode;
|
396
369
|
leftIcon?: React$1.ReactNode;
|
397
370
|
rightIcon?: React$1.ReactNode;
|
398
|
-
variant
|
371
|
+
variant?: "primary" | "secondary" | "tertiary" | "ghost" | "floating";
|
399
372
|
size?: "lg" | "md" | "sm" | "xs";
|
400
373
|
download?: string;
|
401
374
|
href?: string;
|
@@ -2573,15 +2546,6 @@ type LinkProps = Exclude<LinkProps$1, "variant"> & PropsWithChildren<linkVariant
|
|
2573
2546
|
/** Define if the link shows an icon on the right that indicate it is an external link */
|
2574
2547
|
external?: boolean;
|
2575
2548
|
};
|
2576
|
-
/** Link to different sites or parts of site
|
2577
|
-
*
|
2578
|
-
* You can specify the `variant` prop to get different link designs.
|
2579
|
-
* * ```tsx
|
2580
|
-
* <TextLink href="/url-to-page" variant="primary" size="md">
|
2581
|
-
* text that is linked
|
2582
|
-
* </TextLink>
|
2583
|
-
* ```
|
2584
|
-
*/
|
2585
2549
|
declare const TextLink: React__default.ForwardRefExoticComponent<LinkProps$1 & {
|
2586
2550
|
variant?: _chakra_ui_react.ConditionalValue<"secondary" | "primary" | undefined>;
|
2587
2551
|
} & {
|
package/dist/index.d.ts
CHANGED
@@ -317,38 +317,11 @@ type ButtonProps = Exclude<ButtonProps$1, "size" | "variant" | "colorPalette"> &
|
|
317
317
|
loadingText?: React__default.ReactNode;
|
318
318
|
leftIcon?: React__default.ReactNode;
|
319
319
|
rightIcon?: React__default.ReactNode;
|
320
|
-
variant
|
320
|
+
variant?: "primary" | "secondary" | "tertiary" | "ghost" | "floating";
|
321
321
|
size?: "lg" | "md" | "sm" | "xs";
|
322
322
|
download?: string;
|
323
323
|
href?: string;
|
324
324
|
};
|
325
|
-
/**
|
326
|
-
* Buttons are used to trigger actions.
|
327
|
-
*
|
328
|
-
* There are several button variants. You can specify which one you want with the `variant` prop. The available variants are:
|
329
|
-
*
|
330
|
-
* - `primary`: This is our main button. It's used for the main actions in a view, like a call to action. There should only be a single primary button in each view.
|
331
|
-
* - `secondary`: Used for secondary actions in a view, and when you need to make several actions available at the same time.
|
332
|
-
* - `tertiary`: Used for additional choices, like a less important secondary action.
|
333
|
-
* - `ghost`: Used inside other interactive elements, like date pickers and input fields.
|
334
|
-
* - `floating`: Used for floating actions, like a menu button in a menu.
|
335
|
-
*
|
336
|
-
* ```tsx
|
337
|
-
* <Button variant="primary" onClick={confirmOrder}>
|
338
|
-
* Buy trip
|
339
|
-
* </Button>
|
340
|
-
* ```
|
341
|
-
*
|
342
|
-
* There are also different sizes. You can specify which one you want with the `size` prop. The available sizes are "lg", "md", "sm" and "xs".
|
343
|
-
*
|
344
|
-
* ```tsx
|
345
|
-
* <Button variant="secondary" size="sm" onClick={cancelOrder}>
|
346
|
-
* Cancel trip
|
347
|
-
* </Button>
|
348
|
-
* ```
|
349
|
-
*
|
350
|
-
* @see https://spor.vy.no/components/button
|
351
|
-
*/
|
352
325
|
declare const Button: React__default.ForwardRefExoticComponent<ButtonProps$1 & {
|
353
326
|
variant?: _chakra_ui_react.ConditionalValue<"floating" | "secondary" | "tertiary" | "ghost" | "primary" | undefined>;
|
354
327
|
size?: _chakra_ui_react.ConditionalValue<"sm" | "md" | "lg" | "xs" | undefined>;
|
@@ -359,7 +332,7 @@ declare const Button: React__default.ForwardRefExoticComponent<ButtonProps$1 & {
|
|
359
332
|
loadingText?: React__default.ReactNode;
|
360
333
|
leftIcon?: React__default.ReactNode;
|
361
334
|
rightIcon?: React__default.ReactNode;
|
362
|
-
variant
|
335
|
+
variant?: "primary" | "secondary" | "tertiary" | "ghost" | "floating";
|
363
336
|
size?: "lg" | "md" | "sm" | "xs";
|
364
337
|
download?: string;
|
365
338
|
href?: string;
|
@@ -395,7 +368,7 @@ declare const ClipboardButton: React$1.ForwardRefExoticComponent<_chakra_ui_reac
|
|
395
368
|
loadingText?: React$1.ReactNode;
|
396
369
|
leftIcon?: React$1.ReactNode;
|
397
370
|
rightIcon?: React$1.ReactNode;
|
398
|
-
variant
|
371
|
+
variant?: "primary" | "secondary" | "tertiary" | "ghost" | "floating";
|
399
372
|
size?: "lg" | "md" | "sm" | "xs";
|
400
373
|
download?: string;
|
401
374
|
href?: string;
|
@@ -2573,15 +2546,6 @@ type LinkProps = Exclude<LinkProps$1, "variant"> & PropsWithChildren<linkVariant
|
|
2573
2546
|
/** Define if the link shows an icon on the right that indicate it is an external link */
|
2574
2547
|
external?: boolean;
|
2575
2548
|
};
|
2576
|
-
/** Link to different sites or parts of site
|
2577
|
-
*
|
2578
|
-
* You can specify the `variant` prop to get different link designs.
|
2579
|
-
* * ```tsx
|
2580
|
-
* <TextLink href="/url-to-page" variant="primary" size="md">
|
2581
|
-
* text that is linked
|
2582
|
-
* </TextLink>
|
2583
|
-
* ```
|
2584
|
-
*/
|
2585
2549
|
declare const TextLink: React__default.ForwardRefExoticComponent<LinkProps$1 & {
|
2586
2550
|
variant?: _chakra_ui_react.ConditionalValue<"secondary" | "primary" | undefined>;
|
2587
2551
|
} & {
|
package/dist/index.js
CHANGED
@@ -573,22 +573,36 @@ var Skeleton = React67.forwardRef(
|
|
573
573
|
);
|
574
574
|
|
575
575
|
// src/button/Button.tsx
|
576
|
+
var ButtonContent = ({
|
577
|
+
leftIcon,
|
578
|
+
children,
|
579
|
+
rightIcon
|
580
|
+
}) => /* @__PURE__ */ React67__namespace.default.createElement(React67__namespace.default.Fragment, null, leftIcon, children, rightIcon && /* @__PURE__ */ React67__namespace.default.createElement(react.Span, { marginLeft: "auto" }, rightIcon));
|
581
|
+
var LoadingContent = ({
|
582
|
+
children,
|
583
|
+
loadingText
|
584
|
+
}) => /* @__PURE__ */ React67__namespace.default.createElement(React67__namespace.default.Fragment, null, /* @__PURE__ */ React67__namespace.default.createElement(react.Flex, { gap: "1", visibility: "hidden" }, children), /* @__PURE__ */ React67__namespace.default.createElement(react.Center, { position: "absolute", inset: "1px 0" }, /* @__PURE__ */ React67__namespace.default.createElement(ColorInlineLoader, { width: "80%", marginX: 2, marginY: 2 }), loadingText && /* @__PURE__ */ React67__namespace.default.createElement(react.Box, null, loadingText)));
|
576
585
|
var Button = React67.forwardRef(
|
577
|
-
(
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
} =
|
590
|
-
const ariaLabel =
|
591
|
-
const
|
586
|
+
({
|
587
|
+
loading,
|
588
|
+
disabled,
|
589
|
+
loadingText,
|
590
|
+
variant = "primary",
|
591
|
+
size = "md",
|
592
|
+
leftIcon,
|
593
|
+
rightIcon,
|
594
|
+
type = "button",
|
595
|
+
children,
|
596
|
+
...rest
|
597
|
+
}, ref) => {
|
598
|
+
const { t } = useTranslation();
|
599
|
+
const ariaLabel = loading ? String(loadingText ?? t(texts2.loadingText)) : rest["aria-label"];
|
600
|
+
const renderContent = () => {
|
601
|
+
const content = rest.asChild ? children.props.children : children;
|
602
|
+
if (loading)
|
603
|
+
return /* @__PURE__ */ React67__namespace.default.createElement(LoadingContent, { size, loadingText }, /* @__PURE__ */ React67__namespace.default.createElement(ButtonContent, { leftIcon, rightIcon }, content));
|
604
|
+
return /* @__PURE__ */ React67__namespace.default.createElement(ButtonContent, { leftIcon, rightIcon }, content);
|
605
|
+
};
|
592
606
|
return /* @__PURE__ */ React67__namespace.default.createElement(
|
593
607
|
react.Button,
|
594
608
|
{
|
@@ -602,38 +616,12 @@ var Button = React67.forwardRef(
|
|
602
616
|
size,
|
603
617
|
...rest
|
604
618
|
},
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
maxWidth: getLoaderWidth(size),
|
609
|
-
width: "80%",
|
610
|
-
marginX: 2,
|
611
|
-
marginY: 2
|
612
|
-
}
|
613
|
-
), loadingText && /* @__PURE__ */ React67__namespace.default.createElement(react.Box, null, loadingText))) : buttonContent
|
619
|
+
rest.asChild ? React67.cloneElement(children, {
|
620
|
+
children: renderContent()
|
621
|
+
}) : renderContent()
|
614
622
|
);
|
615
623
|
}
|
616
624
|
);
|
617
|
-
function getLoaderWidth(size) {
|
618
|
-
switch (size) {
|
619
|
-
case "xs":
|
620
|
-
return "4rem";
|
621
|
-
case "sm":
|
622
|
-
return "4rem";
|
623
|
-
case "md":
|
624
|
-
return "5rem";
|
625
|
-
case "lg":
|
626
|
-
default:
|
627
|
-
return "6rem";
|
628
|
-
}
|
629
|
-
}
|
630
|
-
function useCorrectAriaLabel(props) {
|
631
|
-
const { t } = useTranslation();
|
632
|
-
if (props.loading) {
|
633
|
-
return String(props.loadingText) ?? t(texts2.loadingText);
|
634
|
-
}
|
635
|
-
return props["aria-label"];
|
636
|
-
}
|
637
625
|
var texts2 = createTexts({
|
638
626
|
loadingText: {
|
639
627
|
nb: "Laster\u2026",
|
@@ -4763,14 +4751,29 @@ var getDeviationLevelIcon = ({
|
|
4763
4751
|
return null;
|
4764
4752
|
}
|
4765
4753
|
};
|
4754
|
+
var ExternalIcon = ({ label }) => /* @__PURE__ */ React67__namespace.default.createElement(React67__namespace.default.Fragment, null, /* @__PURE__ */ React67__namespace.default.createElement(sporIconReact.LinkOutOutline24Icon, { "aria-hidden": true }), /* @__PURE__ */ React67__namespace.default.createElement(react.VisuallyHidden, null, label));
|
4766
4755
|
var TextLink = React67.forwardRef(
|
4767
|
-
({ children, ...props }, ref) => {
|
4768
|
-
var _a5;
|
4756
|
+
({ children, external, href, ...props }, ref) => {
|
4769
4757
|
const { t } = useTranslation();
|
4770
|
-
const
|
4771
|
-
|
4758
|
+
const isExternal = external ?? Boolean((href == null ? void 0 : href.startsWith("http://")) || (href == null ? void 0 : href.startsWith("https://")));
|
4759
|
+
const externalLabel = t ? t(texts18.externalLink) : texts18.externalLink.en;
|
4760
|
+
if (props.asChild && React67.isValidElement(children)) {
|
4761
|
+
return /* @__PURE__ */ React67__namespace.default.createElement(react.Link, { href, ...props, ref }, React67.cloneElement(children, {
|
4762
|
+
...children.props,
|
4763
|
+
children: /* @__PURE__ */ React67__namespace.default.createElement(React67__namespace.default.Fragment, null, children.props.children, isExternal && /* @__PURE__ */ React67__namespace.default.createElement(ExternalIcon, { label: externalLabel }))
|
4764
|
+
}));
|
4765
|
+
}
|
4766
|
+
return /* @__PURE__ */ React67__namespace.default.createElement(react.Link, { href, ...props, ref }, children, isExternal && /* @__PURE__ */ React67__namespace.default.createElement(ExternalIcon, { label: externalLabel }));
|
4772
4767
|
}
|
4773
4768
|
);
|
4769
|
+
var texts18 = createTexts({
|
4770
|
+
externalLink: {
|
4771
|
+
nb: "Ekstern lenke",
|
4772
|
+
nn: "Ekstern lenke",
|
4773
|
+
sv: "Extern l\xE4nk",
|
4774
|
+
en: "External link"
|
4775
|
+
}
|
4776
|
+
});
|
4774
4777
|
var List = react.List.Root;
|
4775
4778
|
var ListItem2 = react.List.Item;
|
4776
4779
|
var ListIndicator = react.List.Indicator;
|
@@ -6222,6 +6225,7 @@ var buttonRecipe = react.defineRecipe({
|
|
6222
6225
|
transitionDuration: "normal",
|
6223
6226
|
cursor: "pointer",
|
6224
6227
|
textWrap: "wrap",
|
6228
|
+
width: "fit-content",
|
6225
6229
|
paddingX: 3,
|
6226
6230
|
paddingY: 1,
|
6227
6231
|
_disabled: {
|
@@ -6326,6 +6330,10 @@ var buttonRecipe = react.defineRecipe({
|
|
6326
6330
|
fontWeight: "bold"
|
6327
6331
|
}
|
6328
6332
|
}
|
6333
|
+
},
|
6334
|
+
defaultVariants: {
|
6335
|
+
variant: "primary",
|
6336
|
+
size: "md"
|
6329
6337
|
}
|
6330
6338
|
});
|
6331
6339
|
|