@semcore/link 17.0.0-prerelease.27 → 17.0.0-prerelease.30
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/CHANGELOG.md +1 -1
- package/lib/cjs/Link.js +17 -4
- package/lib/cjs/Link.js.map +1 -1
- package/lib/es6/Link.js +17 -4
- package/lib/es6/Link.js.map +1 -1
- package/lib/esm/Link.mjs +17 -4
- package/lib/types/Link.d.ts +10 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
package/lib/cjs/Link.js
CHANGED
|
@@ -51,6 +51,21 @@ class RootLink extends _core.Component {
|
|
|
51
51
|
}, 0);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
getTextProps(props) {
|
|
55
|
+
if ('hintProps' in props) {
|
|
56
|
+
return {
|
|
57
|
+
'use:hintProps': {
|
|
58
|
+
triggerRef: this.containerRef,
|
|
59
|
+
...props.hintProps
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
'use:hintProps': {
|
|
65
|
+
triggerRef: this.containerRef
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
54
69
|
render() {
|
|
55
70
|
var _ref = this.asProps,
|
|
56
71
|
_ref4;
|
|
@@ -83,7 +98,7 @@ class RootLink extends _core.Component {
|
|
|
83
98
|
"text-color": resolveColor(color),
|
|
84
99
|
"tag": 'a',
|
|
85
100
|
"ref": this.containerRef,
|
|
86
|
-
"__excludeProps": ['disabled', 'aria-disabled'],
|
|
101
|
+
"__excludeProps": ['disabled', 'aria-disabled', 'title'],
|
|
87
102
|
"aria-label": showHint ? hintContent : undefined
|
|
88
103
|
}, _ref)
|
|
89
104
|
}), /*#__PURE__*/_react.default.createElement(SInner, _ref4.cn("SInner", {
|
|
@@ -107,9 +122,7 @@ function LinkText(props) {
|
|
|
107
122
|
styles
|
|
108
123
|
} = props;
|
|
109
124
|
return _ref5 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SText, _ref5.cn("SText", {
|
|
110
|
-
...(0, _core.assignProps)({
|
|
111
|
-
"tag": 'span'
|
|
112
|
-
}, _ref2)
|
|
125
|
+
...(0, _core.assignProps)({}, _ref2)
|
|
113
126
|
}));
|
|
114
127
|
}
|
|
115
128
|
function Addon(props) {
|
package/lib/cjs/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_resolveColorEnhance","_hasLabels","_logger","_typography","_react","style","sstyled","insert","RootLink","Component","constructor","args","_defineProperty2","default","React","createRef","ariaLabelledByContent","componentDidMount","process","env","NODE_ENV","logger","warn","containerRef","current","hasLabels","asProps","displayName","setTimeout","setState","document","getElementById","textContent","render","_ref","_ref4","styles","color","resolveColor","disabled","href","children","addonLeft","AddonLeft","addonRight","AddonRight","Children","title","ariaLabel","hintPlacement","Link","CORE_INSTANCE","SLink","Text","SInner","Box","hintContent","state","showHint","undefined","createElement","Fragment","cn","assignProps","Addon","addonTextChildren","Hint","resolveColorEnhance","LinkText","
|
|
1
|
+
{"version":3,"file":"Link.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_resolveColorEnhance","_hasLabels","_logger","_typography","_react","style","sstyled","insert","RootLink","Component","constructor","args","_defineProperty2","default","React","createRef","ariaLabelledByContent","componentDidMount","process","env","NODE_ENV","logger","warn","containerRef","current","hasLabels","asProps","displayName","setTimeout","setState","document","getElementById","textContent","getTextProps","props","triggerRef","hintProps","render","_ref","_ref4","styles","color","resolveColor","disabled","href","children","addonLeft","AddonLeft","addonRight","AddonRight","Children","title","ariaLabel","hintPlacement","Link","CORE_INSTANCE","SLink","Text","SInner","Box","hintContent","state","showHint","undefined","createElement","Fragment","cn","assignProps","Addon","addonTextChildren","Hint","resolveColorEnhance","LinkText","_ref2","arguments[0]","_ref5","SText","_ref3","_ref6","SAddon","createComponent","_default","exports"],"sources":["../../src/Link.tsx"],"sourcesContent":["import type { BoxProps } from '@semcore/base-components';\nimport { Box, Hint } from '@semcore/base-components';\nimport type { Intergalactic, IRootComponentProps } from '@semcore/core';\nimport { createComponent, Component, Root, sstyled, CORE_INSTANCE } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport hasLabels from '@semcore/core/lib/utils/hasLabels';\nimport logger from '@semcore/core/lib/utils/logger';\nimport type { TextProps } from '@semcore/typography';\nimport { Text } from '@semcore/typography';\nimport React from 'react';\n\nimport type { LinkProps } from './Link.types';\nimport style from './style/link.shadow.css';\n\ntype State = {\n ariaLabelledByContent: string;\n};\n\nclass RootLink extends Component<LinkProps, typeof RootLink.enhance, never, {}, State> {\n static displayName = 'Link';\n\n static style = style;\n static enhance = [resolveColorEnhance()] as const;\n containerRef = React.createRef<HTMLElement | null>();\n\n state: State = {\n ariaLabelledByContent: '',\n };\n\n componentDidMount() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n this.containerRef.current && !hasLabels(this.containerRef.current),\n `'title' or 'aria-label' or 'aria-labelledby' are required props for links without text content`,\n this.asProps['data-ui-name'] || RootLink.displayName,\n );\n }\n\n if (this.asProps['aria-labelledby']) {\n setTimeout(() => {\n this.setState({\n ariaLabelledByContent:\n document.getElementById(this.asProps['aria-labelledby'])?.textContent ?? '',\n });\n }, 0);\n }\n }\n\n getTextProps(props: TextProps) {\n if ('hintProps' in props) {\n return {\n 'use:hintProps': { triggerRef: this.containerRef, ...props.hintProps },\n };\n }\n\n return {\n 'use:hintProps': { triggerRef: this.containerRef },\n };\n }\n\n render() {\n const {\n styles,\n color,\n resolveColor,\n disabled,\n href,\n children,\n addonLeft: AddonLeft,\n addonRight: AddonRight,\n Children,\n title,\n 'aria-label': ariaLabel,\n hintPlacement,\n } = this.asProps;\n // @ts-ignore\n const Link = this[CORE_INSTANCE];\n const SLink = Root;\n const SInner = Box;\n const hintContent = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';\n const showHint = children === undefined || title;\n return sstyled(styles)(\n <>\n <SLink\n role='link'\n tabIndex={disabled ? -1 : 0}\n use:href={disabled ? undefined : href}\n visually-disabled={disabled}\n render={Text}\n text-color={resolveColor(color)}\n tag='a'\n ref={this.containerRef}\n __excludeProps={['disabled', 'aria-disabled', 'title']}\n aria-label={showHint ? hintContent : undefined}\n >\n <SInner\n tag='span'\n data-ui-name={`${this.asProps['data-ui-name']}.InnerWrapper`}\n >\n {AddonLeft\n ? (\n <Link.Addon>\n <AddonLeft />\n </Link.Addon>\n )\n : null}\n {addonTextChildren(Children, Link.Text, Link.Addon)}\n {AddonRight\n ? (\n <Link.Addon>\n <AddonRight />\n </Link.Addon>\n )\n : null}\n </SInner>\n </SLink>\n {showHint && (\n <Hint\n triggerRef={this.containerRef}\n timeout={[250, 50]}\n placement={hintPlacement}\n >\n {hintContent}\n </Hint>\n )}\n </>,\n );\n }\n}\n\nfunction LinkText(props: IRootComponentProps) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Text} />);\n}\n\nfunction Addon(props: IRootComponentProps) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Link = createComponent(RootLink, {\n Text: LinkText,\n Addon,\n}) as Intergalactic.Component<'a', LinkProps, {}, typeof RootLink.enhance> & {\n Text: Intergalactic.Component<'span', TextProps>;\n Addon: Intergalactic.Component<'span', BoxProps>;\n};\n\nexport default Link;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,UAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,OAAA,GAAAH,sBAAA,CAAAH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,CAACtC,KAA0B,EAAE;EAAA,IAAAuC,KAAA,GAAAC,YAAA;IAAAC,KAAA;EAC5C,MAAMC,KAAK,GAE2BnB,gBAAI;EAD1C,MAAM;IAAEjB;EAAO,CAAC,GAAGN,KAAK;EACxB,OAAAyC,KAAA,GAAO,IAAArE,aAAO,EAACkC,MAAM,CAAC,eAACpC,MAAA,CAAAS,OAAA,CAAAmD,aAAA,CAACY,KAAK,EAAAD,KAAA,CAAAT,EAAA;IAAA,OAAAvE,KAAA,CAAAwE,WAAA,MAAAM,KAAA;EAAA,EAAgB,CAAC;AAChD;AAEA,SAASL,KAAKA,CAAClC,KAA0B,EAAE;EAAA,IAAA2C,KAAA,GAAAH,YAAA;IAAAI,KAAA;EACzC,MAAMC,MAAM,GAE2BpB,mBAAG;EAD1C,MAAM;IAAEnB;EAAO,CAAC,GAAGN,KAAK;EACxB,OAAA4C,KAAA,GAAO,IAAAxE,aAAO,EAACkC,MAAM,CAAC,eAACpC,MAAA,CAAAS,OAAA,CAAAmD,aAAA,CAACe,MAAM,EAAAD,KAAA,CAAAZ,EAAA;IAAA,OAAAvE,KAAA,CAAAwE,WAAA;MAAA,OAAkB;IAAM,GAAAU,KAAA;EAAA,EAAE,CAAC;AAC3D;AAEA,MAAMvB,IAAI,GAAG,IAAA0B,qBAAe,EAACxE,QAAQ,EAAE;EACrCiD,IAAI,EAAEe,QAAQ;EACdJ;AACF,CAAC,CAGA;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAArE,OAAA,GAEayC,IAAI","ignoreList":[]}
|
package/lib/es6/Link.js
CHANGED
|
@@ -48,6 +48,21 @@ class RootLink extends Component {
|
|
|
48
48
|
}, 0);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
getTextProps(props) {
|
|
52
|
+
if ('hintProps' in props) {
|
|
53
|
+
return {
|
|
54
|
+
'use:hintProps': {
|
|
55
|
+
triggerRef: this.containerRef,
|
|
56
|
+
...props.hintProps
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
'use:hintProps': {
|
|
62
|
+
triggerRef: this.containerRef
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
51
66
|
render() {
|
|
52
67
|
var _ref = this.asProps,
|
|
53
68
|
_ref4;
|
|
@@ -80,7 +95,7 @@ class RootLink extends Component {
|
|
|
80
95
|
"text-color": resolveColor(color),
|
|
81
96
|
"tag": 'a',
|
|
82
97
|
"ref": this.containerRef,
|
|
83
|
-
"__excludeProps": ['disabled', 'aria-disabled'],
|
|
98
|
+
"__excludeProps": ['disabled', 'aria-disabled', 'title'],
|
|
84
99
|
"aria-label": showHint ? hintContent : undefined
|
|
85
100
|
}, _ref)
|
|
86
101
|
}), /*#__PURE__*/React.createElement(SInner, _ref4.cn("SInner", {
|
|
@@ -104,9 +119,7 @@ function LinkText(props) {
|
|
|
104
119
|
styles
|
|
105
120
|
} = props;
|
|
106
121
|
return _ref5 = sstyled(styles), /*#__PURE__*/React.createElement(SText, _ref5.cn("SText", {
|
|
107
|
-
..._assignProps2({
|
|
108
|
-
"tag": 'span'
|
|
109
|
-
}, _ref2)
|
|
122
|
+
..._assignProps2({}, _ref2)
|
|
110
123
|
}));
|
|
111
124
|
}
|
|
112
125
|
function Addon(props) {
|
package/lib/es6/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","names":["Box","Hint","createComponent","Component","Root","sstyled","CORE_INSTANCE","addonTextChildren","resolveColorEnhance","hasLabels","logger","Text","React","style","_sstyled","insert","RootLink","constructor","args","_defineProperty","createRef","ariaLabelledByContent","componentDidMount","process","env","NODE_ENV","warn","containerRef","current","asProps","displayName","setTimeout","setState","document","getElementById","textContent","render","_ref","_ref4","styles","color","resolveColor","disabled","href","children","addonLeft","AddonLeft","addonRight","AddonRight","Children","title","ariaLabel","hintPlacement","Link","SLink","SInner","hintContent","state","showHint","undefined","createElement","Fragment","cn","_assignProps","Addon","LinkText","
|
|
1
|
+
{"version":3,"file":"Link.js","names":["Box","Hint","createComponent","Component","Root","sstyled","CORE_INSTANCE","addonTextChildren","resolveColorEnhance","hasLabels","logger","Text","React","style","_sstyled","insert","RootLink","constructor","args","_defineProperty","createRef","ariaLabelledByContent","componentDidMount","process","env","NODE_ENV","warn","containerRef","current","asProps","displayName","setTimeout","setState","document","getElementById","textContent","getTextProps","props","triggerRef","hintProps","render","_ref","_ref4","styles","color","resolveColor","disabled","href","children","addonLeft","AddonLeft","addonRight","AddonRight","Children","title","ariaLabel","hintPlacement","Link","SLink","SInner","hintContent","state","showHint","undefined","createElement","Fragment","cn","_assignProps","Addon","LinkText","_ref2","arguments[0]","_ref5","SText","_assignProps2","_ref3","_ref6","SAddon","_assignProps3"],"sources":["../../src/Link.tsx"],"sourcesContent":["import type { BoxProps } from '@semcore/base-components';\nimport { Box, Hint } from '@semcore/base-components';\nimport type { Intergalactic, IRootComponentProps } from '@semcore/core';\nimport { createComponent, Component, Root, sstyled, CORE_INSTANCE } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport resolveColorEnhance from '@semcore/core/lib/utils/enhances/resolveColorEnhance';\nimport hasLabels from '@semcore/core/lib/utils/hasLabels';\nimport logger from '@semcore/core/lib/utils/logger';\nimport type { TextProps } from '@semcore/typography';\nimport { Text } from '@semcore/typography';\nimport React from 'react';\n\nimport type { LinkProps } from './Link.types';\nimport style from './style/link.shadow.css';\n\ntype State = {\n ariaLabelledByContent: string;\n};\n\nclass RootLink extends Component<LinkProps, typeof RootLink.enhance, never, {}, State> {\n static displayName = 'Link';\n\n static style = style;\n static enhance = [resolveColorEnhance()] as const;\n containerRef = React.createRef<HTMLElement | null>();\n\n state: State = {\n ariaLabelledByContent: '',\n };\n\n componentDidMount() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n this.containerRef.current && !hasLabels(this.containerRef.current),\n `'title' or 'aria-label' or 'aria-labelledby' are required props for links without text content`,\n this.asProps['data-ui-name'] || RootLink.displayName,\n );\n }\n\n if (this.asProps['aria-labelledby']) {\n setTimeout(() => {\n this.setState({\n ariaLabelledByContent:\n document.getElementById(this.asProps['aria-labelledby'])?.textContent ?? '',\n });\n }, 0);\n }\n }\n\n getTextProps(props: TextProps) {\n if ('hintProps' in props) {\n return {\n 'use:hintProps': { triggerRef: this.containerRef, ...props.hintProps },\n };\n }\n\n return {\n 'use:hintProps': { triggerRef: this.containerRef },\n };\n }\n\n render() {\n const {\n styles,\n color,\n resolveColor,\n disabled,\n href,\n children,\n addonLeft: AddonLeft,\n addonRight: AddonRight,\n Children,\n title,\n 'aria-label': ariaLabel,\n hintPlacement,\n } = this.asProps;\n // @ts-ignore\n const Link = this[CORE_INSTANCE];\n const SLink = Root;\n const SInner = Box;\n const hintContent = title ?? ariaLabel ?? this.state.ariaLabelledByContent ?? '';\n const showHint = children === undefined || title;\n return sstyled(styles)(\n <>\n <SLink\n role='link'\n tabIndex={disabled ? -1 : 0}\n use:href={disabled ? undefined : href}\n visually-disabled={disabled}\n render={Text}\n text-color={resolveColor(color)}\n tag='a'\n ref={this.containerRef}\n __excludeProps={['disabled', 'aria-disabled', 'title']}\n aria-label={showHint ? hintContent : undefined}\n >\n <SInner\n tag='span'\n data-ui-name={`${this.asProps['data-ui-name']}.InnerWrapper`}\n >\n {AddonLeft\n ? (\n <Link.Addon>\n <AddonLeft />\n </Link.Addon>\n )\n : null}\n {addonTextChildren(Children, Link.Text, Link.Addon)}\n {AddonRight\n ? (\n <Link.Addon>\n <AddonRight />\n </Link.Addon>\n )\n : null}\n </SInner>\n </SLink>\n {showHint && (\n <Hint\n triggerRef={this.containerRef}\n timeout={[250, 50]}\n placement={hintPlacement}\n >\n {hintContent}\n </Hint>\n )}\n </>,\n );\n }\n}\n\nfunction LinkText(props: IRootComponentProps) {\n const SText = Root;\n const { styles } = props;\n return sstyled(styles)(<SText render={Text} />);\n}\n\nfunction Addon(props: IRootComponentProps) {\n const SAddon = Root;\n const { styles } = props;\n return sstyled(styles)(<SAddon render={Box} tag='span' />);\n}\n\nconst Link = createComponent(RootLink, {\n Text: LinkText,\n Addon,\n}) as Intergalactic.Component<'a', LinkProps, {}, typeof RootLink.enhance> & {\n Text: Intergalactic.Component<'span', TextProps>;\n Addon: Intergalactic.Component<'span', BoxProps>;\n};\n\nexport default Link;\n"],"mappings":";;;;;AACA,SAASA,GAAG,EAAEC,IAAI,QAAQ,0BAA0B;AAEpD,SAASC,eAAe,EAAEC,SAAS,EAAEC,IAAI,EAAEC,OAAO,EAAEC,aAAa,QAAQ,eAAe;AACxF,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,mBAAmB,MAAM,sDAAsD;AACtF,OAAOC,SAAS,MAAM,mCAAmC;AACzD,OAAOC,MAAM,MAAM,gCAAgC;AAEnD,SAASC,IAAI,QAAQ,qBAAqB;AAC1C,OAAOC,KAAK,MAAM,OAAO;AAAC;AAAA,MAAAC,KAAA,8BAAAC,QAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAS1B,MAAMC,QAAQ,SAASb,SAAS,CAAuD;EAAAc,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,oCAKtEP,KAAK,CAACQ,SAAS,CAAqB,CAAC;IAAAD,eAAA,gBAErC;MACbE,qBAAqB,EAAE;IACzB,CAAC;EAAA;EAEDC,iBAAiBA,CAAA,EAAG;IAClB,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;MACzCf,MAAM,CAACgB,IAAI,CACT,IAAI,CAACC,YAAY,CAACC,OAAO,IAAI,CAACnB,SAAS,CAAC,IAAI,CAACkB,YAAY,CAACC,OAAO,CAAC,EAClE,gGAAgG,EAChG,IAAI,CAACC,OAAO,CAAC,cAAc,CAAC,IAAIb,QAAQ,CAACc,WAC3C,CAAC;IACH;IAEA,IAAI,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AAC;EAEP;AACF;AAACzC,eAAA,CA9GKH,QAAQ,iBACS,MAAM;AAAAG,eAAA,CADvBH,QAAQ,WAGGH,KAAK;AAAAM,eAAA,CAHhBH,QAAQ,aAIK,CAACR,mBAAmB,CAAC,CAAC,CAAC;AA4G1C,SAAS6D,QAAQA,CAAChC,KAA0B,EAAE;EAAA,IAAAiC,KAAA,GAAAC,YAAA;IAAAC,KAAA;EAC5C,MAAMC,KAAK,GAE2B9D,IAAI;EAD1C,MAAM;IAAEgC;EAAO,CAAC,GAAGN,KAAK;EACxB,OAAAmC,KAAA,GAAOnE,OAAO,CAACsC,MAAM,CAAC,eAAC/B,KAAA,CAAAoD,aAAA,CAACS,KAAK,EAAAD,KAAA,CAAAN,EAAA;IAAA,GAAAQ,aAAA,KAAAJ,KAAA;EAAA,EAAgB,CAAC;AAChD;AAEA,SAASF,KAAKA,CAAC/B,KAA0B,EAAE;EAAA,IAAAsC,KAAA,GAAAJ,YAAA;IAAAK,KAAA;EACzC,MAAMC,MAAM,GAE2B7E,GAAG;EAD1C,MAAM;IAAE2C;EAAO,CAAC,GAAGN,KAAK;EACxB,OAAAuC,KAAA,GAAOvE,OAAO,CAACsC,MAAM,CAAC,eAAC/B,KAAA,CAAAoD,aAAA,CAACa,MAAM,EAAAD,KAAA,CAAAV,EAAA;IAAA,GAAAY,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AAC3D;AAEA,MAAMlB,IAAI,GAAGvD,eAAe,CAACc,QAAQ,EAAE;EACrCL,IAAI,EAAE0D,QAAQ;EACdD;AACF,CAAC,CAGA;AAED,eAAeX,IAAI","ignoreList":[]}
|
package/lib/esm/Link.mjs
CHANGED
|
@@ -52,6 +52,21 @@ class RootLink extends Component {
|
|
|
52
52
|
}, 0);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
getTextProps(props) {
|
|
56
|
+
if ("hintProps" in props) {
|
|
57
|
+
return {
|
|
58
|
+
"use:hintProps": {
|
|
59
|
+
triggerRef: this.containerRef,
|
|
60
|
+
...props.hintProps
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
"use:hintProps": {
|
|
66
|
+
triggerRef: this.containerRef
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
55
70
|
render() {
|
|
56
71
|
var _ref = this.asProps, _ref4;
|
|
57
72
|
const {
|
|
@@ -82,7 +97,7 @@ class RootLink extends Component {
|
|
|
82
97
|
"text-color": resolveColor(color),
|
|
83
98
|
"tag": "a",
|
|
84
99
|
"ref": this.containerRef,
|
|
85
|
-
"__excludeProps": ["disabled", "aria-disabled"],
|
|
100
|
+
"__excludeProps": ["disabled", "aria-disabled", "title"],
|
|
86
101
|
"aria-label": showHint ? hintContent : void 0
|
|
87
102
|
}, _ref)
|
|
88
103
|
}), /* @__PURE__ */ React.createElement(SInner, _ref4.cn("SInner", {
|
|
@@ -105,9 +120,7 @@ function LinkText(props) {
|
|
|
105
120
|
styles
|
|
106
121
|
} = props;
|
|
107
122
|
return _ref5 = sstyled(styles), /* @__PURE__ */ React.createElement(SText, _ref5.cn("SText", {
|
|
108
|
-
...assignProps({
|
|
109
|
-
"tag": "span"
|
|
110
|
-
}, _ref2)
|
|
123
|
+
...assignProps({}, _ref2)
|
|
111
124
|
}));
|
|
112
125
|
}
|
|
113
126
|
function Addon(props) {
|
package/lib/types/Link.d.ts
CHANGED
|
@@ -16,6 +16,16 @@ declare class RootLink extends Component<LinkProps, typeof RootLink.enhance, nev
|
|
|
16
16
|
containerRef: React.RefObject<HTMLElement | null>;
|
|
17
17
|
state: State;
|
|
18
18
|
componentDidMount(): void;
|
|
19
|
+
getTextProps(props: TextProps): {
|
|
20
|
+
'use:hintProps': {
|
|
21
|
+
placement?: import("@floating-ui/dom").Placement;
|
|
22
|
+
triggerRef: React.RefObject<HTMLElement | null>;
|
|
23
|
+
timeout?: number | [number, number];
|
|
24
|
+
visible?: boolean;
|
|
25
|
+
defaultVisible?: boolean;
|
|
26
|
+
onVisibleChange?: (visible: boolean, e?: Event) => boolean | void;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
19
29
|
render(): React.ReactNode;
|
|
20
30
|
}
|
|
21
31
|
declare const Link: Intergalactic.Component<"a", LinkProps, {}, typeof RootLink.enhance> & {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/link",
|
|
3
3
|
"description": "Semrush Link Component",
|
|
4
|
-
"version": "17.0.0-prerelease.
|
|
4
|
+
"version": "17.0.0-prerelease.30",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/tooltip": "^17.0.0-prerelease.
|
|
18
|
-
"@semcore/typography": "^17.0.0-prerelease.
|
|
17
|
+
"@semcore/tooltip": "^17.0.0-prerelease.30",
|
|
18
|
+
"@semcore/typography": "^17.0.0-prerelease.30"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@semcore/base-components": "^17.0.0 || ^17.0.0-0"
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"directory": "semcore/link"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@semcore/
|
|
30
|
-
"@semcore/
|
|
31
|
-
"@semcore/
|
|
32
|
-
"@semcore/
|
|
29
|
+
"@semcore/core": "17.0.0-prerelease.30",
|
|
30
|
+
"@semcore/base-components": "17.0.0-prerelease.30",
|
|
31
|
+
"@semcore/icon": "16.7.2-prerelease.30",
|
|
32
|
+
"@semcore/testing-utils": "1.0.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "pnpm semcore-builder && pnpm vite build"
|