@toptal/picasso-link 3.0.7-alpha-1757603192867.0 → 3.0.7-alpha-FF-49-enhance-publishing-6b5d306f0.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.
@@ -0,0 +1,52 @@
1
+ import type { ReactNode, AnchorHTMLAttributes, ElementType } from 'react';
2
+ import React from 'react';
3
+ import type { BaseProps, OverridableComponent } from '@toptal/picasso-shared';
4
+ declare const supportedColors: readonly ["white", "blue"];
5
+ declare const supportedVariants: readonly ["action", "anchor"];
6
+ declare type VariantType = (typeof supportedVariants)[number];
7
+ declare type ColorType = (typeof supportedColors)[number];
8
+ export declare type Props = BaseProps & AnchorHTMLAttributes<HTMLAnchorElement> & {
9
+ /** Content of the component */
10
+ children?: ReactNode;
11
+ /** Destination the link points to */
12
+ href?: string;
13
+ /** Callback invoked when component is clicked */
14
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
15
+ /**
16
+ * The component used for the root node.
17
+ * Either a string to use a DOM element or a component.
18
+ */
19
+ as?: ElementType<React.HTMLAttributes<HTMLElement>>;
20
+ /** Either it's a regular hyperlink or an _action_ */
21
+ variant?: VariantType;
22
+ /** Controls color of the link */
23
+ color?: ColorType;
24
+ /** Indicates the order of receiving focus. If not set will not receive focus. */
25
+ tabIndex?: number;
26
+ /** Indicates that the user cannot interact with the Link or its children */
27
+ disabled?: boolean;
28
+ visited?: boolean;
29
+ /**
30
+ * If true, underline decoration never applies
31
+ */
32
+ noUnderline?: boolean;
33
+ 'aria-disabled'?: boolean;
34
+ };
35
+ declare type ViewModel = {
36
+ className: string;
37
+ href?: string;
38
+ target?: string;
39
+ color?: 'inherit';
40
+ rel?: string;
41
+ onClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void;
42
+ weight: 'inherit' | 'semibold';
43
+ style?: React.CSSProperties;
44
+ tabIndex?: number;
45
+ as: Props['as'];
46
+ ariaDisabled?: boolean;
47
+ nativeHTMLAttributes: Omit<Props, keyof BaseProps>;
48
+ };
49
+ export declare const calculateViewModel: (props: Props) => ViewModel;
50
+ export declare const Link: OverridableComponent<Props>;
51
+ export default Link;
52
+ //# sourceMappingURL=Link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../../src/Link/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAG7E,QAAA,MAAM,eAAe,4BAA6B,CAAA;AAClD,QAAA,MAAM,iBAAiB,+BAAgC,CAAA;AAEvD,aAAK,WAAW,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AACrD,aAAK,SAAS,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AA0CjD,oBAAY,KAAK,GAAG,SAAS,GAC3B,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IACxC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iDAAiD;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;IAC9D;;;OAGG;IACH,EAAE,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;IACnD,qDAAqD;IACrD,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,iCAAiC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,eAAe,CAAC,EAAE,OAAO,CAAA;CAC1B,CAAA;AAKH,aAAK,SAAS,GAAG;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;IAC9D,MAAM,EAAE,SAAS,GAAG,UAAU,CAAA;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,oBAAoB,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,SAAS,CAAC,CAAA;CACnD,CAAA;AAGD,eAAO,MAAM,kBAAkB,UAAW,KAAK,KAAG,SAqDjD,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,oBAAoB,CAAC,KAAK,CA0B3C,CAAA;AAWF,eAAe,IAAI,CAAA"}
@@ -0,0 +1,93 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { forwardRef } from 'react';
13
+ import { twMerge } from '@toptal/picasso-tailwind-merge';
14
+ import { Typography } from '@toptal/picasso-typography';
15
+ const supportedColors = ['white', 'blue'];
16
+ const supportedVariants = ['action', 'anchor'];
17
+ const sanitizeRel = (rel, target) => {
18
+ if (target !== '_blank') {
19
+ return rel;
20
+ }
21
+ if (!rel) {
22
+ return 'noopener';
23
+ }
24
+ const isRelSafe = rel.includes('noreferrer') || rel.includes('noopener');
25
+ return isRelSafe ? rel : rel.concat(' noopener');
26
+ };
27
+ const COLOR_DISABLED_MAP = {
28
+ blue: {
29
+ action: {
30
+ disabled: 'text-blue-500 no-underline opacity-50 hover:!no-underline',
31
+ normal: 'text-blue-500 visited:text-purple-500 no-underline',
32
+ },
33
+ anchor: {
34
+ disabled: 'text-gray-600 underline',
35
+ normal: 'text-blue-500 visited:text-purple-500 no-underline',
36
+ },
37
+ },
38
+ white: {
39
+ action: {
40
+ disabled: 'text-gray-600',
41
+ normal: 'inherit',
42
+ },
43
+ anchor: {
44
+ disabled: 'text-gray-600 visited:text-gray-500 underline',
45
+ normal: 'inherit text-white visited:text-gray-500 underline',
46
+ },
47
+ },
48
+ };
49
+ const defaultColor = 'blue';
50
+ const defaultVariant = 'anchor';
51
+ /* eslint-disable complexity */
52
+ export const calculateViewModel = (props) => {
53
+ const { href, onClick, className, as = 'a', color: inputColor = 'blue', style, variant: inputVariant = 'anchor', tabIndex, target, rel, disabled, visited = false, noUnderline, 'aria-disabled': ariaDisabled } = props, nativeHTMLAttributes = __rest(props, ["href", "onClick", "className", "as", "color", "style", "variant", "tabIndex", "target", "rel", "disabled", "visited", "noUnderline", 'aria-disabled']);
54
+ const sanitizedRel = sanitizeRel(rel, target);
55
+ // When Link is used as={Link}, TypeScript can't ensure the input to the Link is compatible with its Props type.
56
+ const color = supportedColors.includes(inputColor) ? inputColor : defaultColor;
57
+ const variant = supportedVariants.includes(inputVariant)
58
+ ? inputVariant
59
+ : defaultVariant;
60
+ return {
61
+ className: twMerge('focus:outline-none hover:underline leading-[inherit]', COLOR_DISABLED_MAP[color][variant][disabled ? 'disabled' : 'normal'], disabled ? 'cursor-not-allowed' : '', noUnderline ? '!no-underline' : '', visited
62
+ ? color === 'blue'
63
+ ? 'visited text-purple-500'
64
+ : 'visited text-gray-500'
65
+ : '', onClick || href ? 'cursor-pointer' : '', className),
66
+ href: disabled ? undefined : href,
67
+ target: disabled ? undefined : target,
68
+ rel: sanitizedRel,
69
+ onClick: disabled ? undefined : onClick,
70
+ weight: variant === 'action' ? 'semibold' : 'inherit',
71
+ color: 'inherit',
72
+ style,
73
+ tabIndex,
74
+ as,
75
+ ariaDisabled: disabled || ariaDisabled,
76
+ nativeHTMLAttributes,
77
+ };
78
+ };
79
+ export const Link = forwardRef(function Link(props, ref) {
80
+ const viewModel = calculateViewModel(props);
81
+ return (React.createElement(Typography, Object.assign({}, viewModel.nativeHTMLAttributes, { ref: ref, as: viewModel.as,
82
+ // @ts-expect-error Typography is incompatible with href prop
83
+ href: viewModel.href, target: viewModel.target, rel: viewModel.rel, onClick: viewModel.onClick, color: viewModel.color, weight: viewModel.weight, className: viewModel.className, style: viewModel.style, tabIndex: viewModel.tabIndex, "aria-disabled": viewModel.ariaDisabled }), props.children));
84
+ });
85
+ Link.defaultProps = {
86
+ as: 'a',
87
+ color: 'blue',
88
+ variant: 'anchor',
89
+ noUnderline: false,
90
+ };
91
+ Link.displayName = 'Link';
92
+ export default Link;
93
+ //# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/Link/Link.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAEvD,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAA;AAClD,M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AC,UAAU,CAAC,CAAC,CAAC,SAAS;QACrD,KAAK,EAAE,SAAS;QAChB,KAAK;QACL,QAAQ;QACR,EAAE;QACF,YAAY,EAAE,QAAQ,IAAI,YAAY;QACtC,oBAAoB;KACrB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAgC,UAAU,CAGzD,SAAS,IAAI,CAAC,KAAK,EAAE,GAAG;IACxB,MAAM,SAAS,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAE3C,OAAO,CACL,oBAAC,UAAU,oBACL,SAAS,CAAC,oBAAoB,IAClC,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,CAAC,EAAE;QAChB,6DAA6D;QAC7D,IAAI,EAAE,SAAS,CAAC,IAAI,EACpB,MAAM,EAAE,SAAS,CAAC,MAAM,EACxB,GAAG,EAAE,SAAS,CAAC,GAAG,EAClB,OAAO,EAAE,SAAS,CAAC,OAAO,EAC1B,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,MAAM,EAAE,SAAS,CAAC,MAAM,EACxB,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,QAAQ,EAAE,SAAS,CAAC,QAAQ,mBACb,SAAS,CAAC,YAAY,KAEpC,KAAK,CAAC,QAAQ,CACJ,CACd,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,YAAY,GAAG;IAClB,EAAE,EAAE,GAAG;IACP,KAAK,EAAE,MAAM;IACb,OAAO,EAAE,QAAQ;IACjB,WAAW,EAAE,KAAK;CACnB,CAAA;AAED,IAAI,CAAC,WAAW,GAAG,MAAM,CAAA;AAEzB,eAAe,IAAI,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { OmitInternalProps } from '@toptal/picasso-shared';
2
+ import type { Props } from './Link';
3
+ export { default as Link } from './Link';
4
+ export declare type LinkProps = OmitInternalProps<Props>;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Link/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA;AACxC,oBAAY,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { default as Link } from './Link';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Link/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './Link';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './Link';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/picasso-link",
3
- "version": "3.0.7-alpha-1757603192867.0",
3
+ "version": "3.0.7-alpha-FF-49-enhance-publishing-6b5d306f0.0",
4
4
  "description": "Toptal UI components library - Link",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -23,26 +23,26 @@
23
23
  },
24
24
  "homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
25
25
  "dependencies": {
26
- "@toptal/picasso-utils": "3.1.1-alpha-1757603192867.0",
27
- "@toptal/picasso-typography": "4.0.5-alpha-1757603192867.0"
26
+ "@toptal/picasso-utils": "3.1.1-alpha-FF-49-enhance-publishing-6b5d306f0.0",
27
+ "@toptal/picasso-typography": "4.0.5-alpha-FF-49-enhance-publishing-6b5d306f0.0"
28
28
  },
29
29
  "sideEffects": [
30
30
  "**/styles.ts",
31
31
  "**/styles.js"
32
32
  ],
33
33
  "peerDependencies": {
34
- "@toptal/picasso-tailwind-merge": "2.0.4-alpha-1757603192867.0",
35
- "@toptal/picasso-tailwind": "3.0.1-alpha-1757603192867.0",
36
- "@toptal/picasso-provider": "5.0.2-alpha-1757603192867.0",
34
+ "@toptal/picasso-tailwind-merge": "2.0.4-alpha-FF-49-enhance-publishing-6b5d306f0.0",
35
+ "@toptal/picasso-tailwind": "3.0.1-alpha-FF-49-enhance-publishing-6b5d306f0.0",
36
+ "@toptal/picasso-provider": "5.0.2-alpha-FF-49-enhance-publishing-6b5d306f0.0",
37
37
  "react": ">=16.12.0 < 19.0.0"
38
38
  },
39
39
  "exports": {
40
40
  ".": "./dist-package/src/index.js"
41
41
  },
42
42
  "devDependencies": {
43
- "@toptal/picasso-tailwind-merge": "2.0.4-alpha-1757603192867.0",
44
- "@toptal/picasso-provider": "5.0.2-alpha-1757603192867.0",
45
- "@toptal/picasso-test-utils": "1.1.2-alpha-1757603192867.0"
43
+ "@toptal/picasso-tailwind-merge": "2.0.4-alpha-FF-49-enhance-publishing-6b5d306f0.0",
44
+ "@toptal/picasso-provider": "5.0.2-alpha-FF-49-enhance-publishing-6b5d306f0.0",
45
+ "@toptal/picasso-test-utils": "1.1.2-alpha-FF-49-enhance-publishing-6b5d306f0.0"
46
46
  },
47
47
  "files": [
48
48
  "dist-package/**",