@semcore/pills 17.1.0-prerelease.3 → 17.2.0-prerelease.3
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 +6 -0
- package/lib/cjs/Pills.js +19 -13
- package/lib/cjs/Pills.js.map +1 -1
- package/lib/cjs/Pills.type.js.map +1 -1
- package/lib/es6/Pills.js +19 -13
- package/lib/es6/Pills.js.map +1 -1
- package/lib/es6/Pills.type.js.map +1 -1
- package/lib/esm/Pills.mjs +15 -15
- package/lib/types/Pills.d.ts +5 -0
- package/lib/types/Pills.type.d.ts +6 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/lib/cjs/Pills.js
CHANGED
|
@@ -12,20 +12,20 @@ var _addonTextChildren = _interopRequireDefault(require("@semcore/core/lib/utils
|
|
|
12
12
|
var _a11yEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/a11yEnhance"));
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
/*!__reshadow-styles__:"./style/pills.shadow.css"*/
|
|
15
|
-
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
15
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SPills_167np_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded,6px)}.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,#0051ff0a);border-color:var(--intergalactic-border-info-active,#8796ef);z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,#0051ff0a)}@media (color-gamut:p3){.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,color(display-p3 .12567 .31309 .96324/.039))}}}.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_,.___SPills_167np_gg_ .___SPill_167np_gg_:focus-visible{z-index:3}.___SPills_167np_gg_ .___SPill_167np_gg_:active{z-index:2}@media (hover:hover){.___SPills_167np_gg_ .___SPill_167np_gg_:hover{z-index:2}}.___SPill_167np_gg_{display:inline-flex;align-items:center;justify-content:center;line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;background:var(--intergalactic-bg-primary-neutral,#fff);border:1px solid var(--intergalactic-border-primary,#000c0829);border-radius:var(--intergalactic-control-rounded,6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_167np_gg_{border:1px solid var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___SPill_167np_gg_{border:1px solid var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}.___SPill_167np_gg_::-moz-focus-inner{border:none;padding:0}.___SPill_167np_gg_:active{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPill_167np_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover,#f8f9f8)}}.___SPill_167np_gg_.__disabled_167np_gg_{cursor:default;pointer-events:none}.___SPill_167np_gg_.__disabled_167np_gg_>*{opacity:var(--intergalactic-disabled-opacity,.4)}.___SText_167np_gg_{color:var(--intergalactic-text-primary,#010500e5);display:inline-flex}.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,#00030095);display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,#00030095)}@media (color-gamut:p3){.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,color(display-p3 .00228 .01289 .00252/.583))}}}.___SPill_167np_gg_._size_m_167np_gg_{height:var(--intergalactic-form-control-m,28px);min-width:var(--intergalactic-form-control-m,28px);font-size:var(--intergalactic-fs-200,14px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SText_167np_gg_{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_l_167np_gg_{height:var(--intergalactic-form-control-l,40px);min-width:var(--intergalactic-form-control-l,40px);font-size:var(--intergalactic-fs-300,16px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SText_167np_gg_{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SText_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-3x,12px);margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-3x,12px);margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._neighborLocation_right_167np_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_167np_gg_._neighborLocation_both_167np_gg_{border-radius:0;margin-left:-1px}.___SPill_167np_gg_._neighborLocation_left_167np_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}", /*__inner_css_end__*/"167np_gg_"),
|
|
16
16
|
/*__reshadow_css_end__*/
|
|
17
17
|
{
|
|
18
|
-
"__SText": "
|
|
19
|
-
"__SAddon": "
|
|
20
|
-
"__SPill": "
|
|
21
|
-
"_neighborLocation_right": "
|
|
22
|
-
"_neighborLocation_both": "
|
|
23
|
-
"_neighborLocation_left": "
|
|
24
|
-
"__SPills": "
|
|
25
|
-
"_selected": "
|
|
26
|
-
"_disabled": "
|
|
27
|
-
"_size_m": "
|
|
28
|
-
"_size_l": "
|
|
18
|
+
"__SText": "___SText_167np_gg_",
|
|
19
|
+
"__SAddon": "___SAddon_167np_gg_",
|
|
20
|
+
"__SPill": "___SPill_167np_gg_",
|
|
21
|
+
"_neighborLocation_right": "_neighborLocation_right_167np_gg_",
|
|
22
|
+
"_neighborLocation_both": "_neighborLocation_both_167np_gg_",
|
|
23
|
+
"_neighborLocation_left": "_neighborLocation_left_167np_gg_",
|
|
24
|
+
"__SPills": "___SPills_167np_gg_",
|
|
25
|
+
"_selected": "__selected_167np_gg_",
|
|
26
|
+
"_disabled": "__disabled_167np_gg_",
|
|
27
|
+
"_size_m": "_size_m_167np_gg_",
|
|
28
|
+
"_size_l": "_size_l_167np_gg_"
|
|
29
29
|
});
|
|
30
30
|
class RootPills extends _core.Component {
|
|
31
31
|
constructor(...args) {
|
|
@@ -43,7 +43,7 @@ class RootPills extends _core.Component {
|
|
|
43
43
|
}
|
|
44
44
|
uncontrolledProps() {
|
|
45
45
|
return {
|
|
46
|
-
value:
|
|
46
|
+
value: null
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
getItemProps(props, index) {
|
|
@@ -168,6 +168,12 @@ function Addon(props) {
|
|
|
168
168
|
}));
|
|
169
169
|
}
|
|
170
170
|
const wrapPills = wrapper => wrapper;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Pills
|
|
174
|
+
*
|
|
175
|
+
* {@link https://developer.semrush.com/intergalactic/components/pills/pills-api/|API} | {@link https://developer.semrush.com/intergalactic/components/pills/pills-code/|Examples}
|
|
176
|
+
*/
|
|
171
177
|
exports.wrapPills = wrapPills;
|
|
172
178
|
const Pills = (0, _core.createComponent)(RootPills, {
|
|
173
179
|
Item: [Pill, {
|
package/lib/cjs/Pills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pills.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_react","style","sstyled","insert","RootPills","Component","constructor","args","_defineProperty2","default","value","e","handlers","key","preventDefault","uncontrolledProps","getItemProps","props","index","size","disabled","behavior","asProps","isSelected","itemValues","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","Box","Children","styles","controlsLength","createElement","cn","assignProps","NeighborLocation","defaultValue","a11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","selector","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","useNeighborLocationDetect","roleAreaProps","undefined","Pills","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","SText","_ref4","_ref8","SAddon","wrapPills","wrapper","exports","createComponent","_default"],"sources":["../../src/Pills.tsx"],"sourcesContent":["import { NeighborLocation, Box, useNeighborLocationDetect } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport React from 'react';\n\nimport type { NSPills } from './Pills.type';\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>,\n typeof RootPills.enhance,\n NSPills.Handlers\n> {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }: NSPills.Props) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'auto',\n });\n\n itemValues: Array<NSPills.Pill.Props['value']> = [];\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) => {\n const selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];\n\n return selector as [string, string];\n },\n })] as const;\n\n uncontrolledProps() {\n return {\n value: (value: NSPills.Pill.Props['value'], e: React.SyntheticEvent) => value,\n };\n }\n\n bindHandlerClick = (value: NSPills.Pill.Props['value']) => (e: React.MouseEvent) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value: NSPills.Pill.Props['value']) => (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.handlers.value(value, e);\n }\n };\n\n getItemProps(props: NSPills.Pill.Props, index: number) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props: Intergalactic.InternalTypings.InferChildComponentProps<NSPills.Pill.Component, typeof RootPills, 'Item'>) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n\n const roleAreaProps = {\n 'role': behavior === 'auto' ? 'radio' : 'tab',\n 'aria-checked': behavior === 'auto' ? selected : undefined,\n 'aria-selected': behavior !== 'auto' ? selected : undefined,\n };\n\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\n {...roleAreaProps}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nfunction Text(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Text.Component>) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Addon.Component>) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nexport const wrapPills = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSPills.WrapComponent<PropsExtending>;\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n}) as unknown as NSPills.Component;\n\nexport default Pills;\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA0B;AAAA,MAAAM,KAAA,8BAAAP,KAAA,CAAAQ,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAK1B,MAAMC,SAAS,SAASC,eAAS,CAI/B;EAAAC,YAAA,GAAAC,IAAA;I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+BC,OAKjC,IAAKA,OAAgD;AAACC,OAAA,CAAAF,SAAA,GAAAA,SAAA;AAE1E,MAAMZ,KAAK,GAAG,IAAAe,qBAAe,EAACzE,SAAS,EAAE;EACvC2D,IAAI,EAAE,CAACZ,IAAI,EAAE;IAAEgB,IAAI;IAAEH;EAAM,CAAC;AAC9B,CAAC,CAAiC;AAAC,IAAAc,QAAA,GAAAF,OAAA,CAAAnE,OAAA,GAEpBqD,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Pills.js","names":["_core","require","_baseComponents","_addonTextChildren","_interopRequireDefault","_a11yEnhance","_react","style","sstyled","insert","RootPills","Component","constructor","args","_defineProperty2","default","value","e","handlers","key","preventDefault","uncontrolledProps","getItemProps","props","index","size","disabled","behavior","asProps","isSelected","itemValues","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","Box","Children","styles","controlsLength","createElement","cn","assignProps","NeighborLocation","defaultValue","a11yEnhance","onNeighborChange","neighborElement","focus","click","childSelector","selector","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","useNeighborLocationDetect","roleAreaProps","undefined","Pills","Item","Addon","tag","addonTextChildren","Text","_ref3","_ref7","SText","_ref4","_ref8","SAddon","wrapPills","wrapper","exports","createComponent","_default"],"sources":["../../src/Pills.tsx"],"sourcesContent":["import { NeighborLocation, Box, useNeighborLocationDetect } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport React from 'react';\n\nimport type { NSPills } from './Pills.type';\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>,\n typeof RootPills.enhance,\n NSPills.Handlers,\n {},\n {},\n NSPills.DefaultProps\n> {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }: Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'auto',\n } as const);\n\n itemValues: Array<NSPills.Pill.Props['value']> = [];\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) => {\n const selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];\n\n return selector as [string, string];\n },\n })] as const;\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value: NSPills.Pill.Props['value']) => (e: React.MouseEvent) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value: NSPills.Pill.Props['value']) => (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.handlers.value(value, e);\n }\n };\n\n getItemProps(props: NSPills.Pill.Props, index: number) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props: Intergalactic.InternalTypings.InferChildComponentProps<NSPills.Pill.Component, typeof RootPills, 'Item'>) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n\n const roleAreaProps = {\n 'role': behavior === 'auto' ? 'radio' : 'tab',\n 'aria-checked': behavior === 'auto' ? selected : undefined,\n 'aria-selected': behavior !== 'auto' ? selected : undefined,\n };\n\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\n {...roleAreaProps}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nfunction Text(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Text.Component>) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Addon.Component>) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nexport const wrapPills = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSPills.WrapComponent<PropsExtending>;\n\n/**\n * Pills\n *\n * {@link https://developer.semrush.com/intergalactic/components/pills/pills-api/|API} | {@link https://developer.semrush.com/intergalactic/components/pills/pills-code/|Examples}\n */\nconst Pills = createComponent<\n NSPills.Component,\n typeof RootPills\n>(RootPills, {\n Item: [Pill, { Text, Addon }],\n});\n\nexport default Pills;\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAF,sBAAA,CAAAH,OAAA;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AAAS,OAAA,CAAA8B,aAAA,CAACkC,MAAM,EAAAD,KAAA,CAAAhC,EAAA;IAAA,OAAA9C,KAAA,CAAA+C,WAAA;MAAA,OAAkB;IAAM,GAAA8B,KAAA;EAAA,EAAE,CAAC;AACjE;AAEO,MAAMG,SAAS,GAA+BC,OAKjC,IAAKA,OAAgD;;AAEzE;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAF,SAAA,GAAAA,SAAA;AAKA,MAAMZ,KAAK,GAAG,IAAAe,qBAAe,EAG3BzE,SAAS,EAAE;EACX2D,IAAI,EAAE,CAACZ,IAAI,EAAE;IAAEgB,IAAI;IAAEH;EAAM,CAAC;AAC9B,CAAC,CAAC;AAAC,IAAAc,QAAA,GAAAF,OAAA,CAAAnE,OAAA,GAEYqD,KAAK","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pills.type.js","names":[],"sources":["../../src/Pills.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\ndeclare namespace NSPills {\n // TODO: It looks like the value isn't accurate. Revise and align it with the component's logic.\n type Value = string | number | boolean | null;\n type Props<T extends NSPills.Value = NSPills.Value> = NeighborLocationProps & BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n /** Sets semantic role for corresponding behavior,\n * when set to `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n | 'auto'\n | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value:
|
|
1
|
+
{"version":3,"file":"Pills.type.js","names":[],"sources":["../../src/Pills.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\ndeclare namespace NSPills {\n // TODO: It looks like the value isn't accurate. Revise and align it with the component's logic.\n type Value = string | number | boolean | null;\n type Props<T extends NSPills.Value = NSPills.Value> = NeighborLocationProps & BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n /** Sets semantic role for corresponding behavior,\n * when set to `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n | 'auto'\n | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: null;\n };\n type DefaultProps = {\n size: 'm';\n defaultValue: null;\n behavior: Props['behavior'];\n };\n namespace Pill {\n type Props = BoxProps & NeighborItemProps & {\n /** Pill value */\n value?: NSPills.Value;\n /** Disabled state */\n disabled?: boolean;\n /** Selected state */\n selected?: boolean;\n /** Left addon text */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n namespace Text {\n type Component = typeof Box;\n }\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'button', Props, [handlers: Handlers]>;\n }\n\n type WrapComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapComponent & {\n Item: Pill.Component & {\n Text: Pill.Text.Component;\n Addon: Pill.Addon.Component;\n };\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type PillsValue = NSPills.Value;\n/** @deprecated It will be removed in v18. */\nexport type PillsProps<T extends PillsValue = PillsValue> = NSPills.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type PillProps = NSPills.Pill.Props;\n/** @deprecated It will be removed in v18. */\nexport type PillsContext = NSPills.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type PillsHandlers = NSPills.Handlers;\n\nexport type { NSPills };\n"],"mappings":"","ignoreList":[]}
|
package/lib/es6/Pills.js
CHANGED
|
@@ -10,20 +10,20 @@ import addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';
|
|
|
10
10
|
import a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';
|
|
11
11
|
import React from 'react';
|
|
12
12
|
/*!__reshadow-styles__:"./style/pills.shadow.css"*/
|
|
13
|
-
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
13
|
+
const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SPills_167np_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded,6px)}.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,#0051ff0a);border-color:var(--intergalactic-border-info-active,#8796ef);z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,#0051ff0a)}@media (color-gamut:p3){.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,color(display-p3 .12567 .31309 .96324/.039))}}}.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_,.___SPills_167np_gg_ .___SPill_167np_gg_:focus-visible{z-index:3}.___SPills_167np_gg_ .___SPill_167np_gg_:active{z-index:2}@media (hover:hover){.___SPills_167np_gg_ .___SPill_167np_gg_:hover{z-index:2}}.___SPill_167np_gg_{display:inline-flex;align-items:center;justify-content:center;line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;background:var(--intergalactic-bg-primary-neutral,#fff);border:1px solid var(--intergalactic-border-primary,#000c0829);border-radius:var(--intergalactic-control-rounded,6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_167np_gg_{border:1px solid var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___SPill_167np_gg_{border:1px solid var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}.___SPill_167np_gg_::-moz-focus-inner{border:none;padding:0}.___SPill_167np_gg_:active{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPill_167np_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover,#f8f9f8)}}.___SPill_167np_gg_.__disabled_167np_gg_{cursor:default;pointer-events:none}.___SPill_167np_gg_.__disabled_167np_gg_>*{opacity:var(--intergalactic-disabled-opacity,.4)}.___SText_167np_gg_{color:var(--intergalactic-text-primary,#010500e5);display:inline-flex}.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,#00030095);display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,#00030095)}@media (color-gamut:p3){.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,color(display-p3 .00228 .01289 .00252/.583))}}}.___SPill_167np_gg_._size_m_167np_gg_{height:var(--intergalactic-form-control-m,28px);min-width:var(--intergalactic-form-control-m,28px);font-size:var(--intergalactic-fs-200,14px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SText_167np_gg_{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_l_167np_gg_{height:var(--intergalactic-form-control-l,40px);min-width:var(--intergalactic-form-control-l,40px);font-size:var(--intergalactic-fs-300,16px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SText_167np_gg_{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SText_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-3x,12px);margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-3x,12px);margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._neighborLocation_right_167np_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_167np_gg_._neighborLocation_both_167np_gg_{border-radius:0;margin-left:-1px}.___SPill_167np_gg_._neighborLocation_left_167np_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}", /*__inner_css_end__*/"167np_gg_"),
|
|
14
14
|
/*__reshadow_css_end__*/
|
|
15
15
|
{
|
|
16
|
-
"__SText": "
|
|
17
|
-
"__SAddon": "
|
|
18
|
-
"__SPill": "
|
|
19
|
-
"_neighborLocation_right": "
|
|
20
|
-
"_neighborLocation_both": "
|
|
21
|
-
"_neighborLocation_left": "
|
|
22
|
-
"__SPills": "
|
|
23
|
-
"_selected": "
|
|
24
|
-
"_disabled": "
|
|
25
|
-
"_size_m": "
|
|
26
|
-
"_size_l": "
|
|
16
|
+
"__SText": "___SText_167np_gg_",
|
|
17
|
+
"__SAddon": "___SAddon_167np_gg_",
|
|
18
|
+
"__SPill": "___SPill_167np_gg_",
|
|
19
|
+
"_neighborLocation_right": "_neighborLocation_right_167np_gg_",
|
|
20
|
+
"_neighborLocation_both": "_neighborLocation_both_167np_gg_",
|
|
21
|
+
"_neighborLocation_left": "_neighborLocation_left_167np_gg_",
|
|
22
|
+
"__SPills": "___SPills_167np_gg_",
|
|
23
|
+
"_selected": "__selected_167np_gg_",
|
|
24
|
+
"_disabled": "__disabled_167np_gg_",
|
|
25
|
+
"_size_m": "_size_m_167np_gg_",
|
|
26
|
+
"_size_l": "_size_l_167np_gg_"
|
|
27
27
|
});
|
|
28
28
|
class RootPills extends Component {
|
|
29
29
|
constructor(...args) {
|
|
@@ -41,7 +41,7 @@ class RootPills extends Component {
|
|
|
41
41
|
}
|
|
42
42
|
uncontrolledProps() {
|
|
43
43
|
return {
|
|
44
|
-
value:
|
|
44
|
+
value: null
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
getItemProps(props, index) {
|
|
@@ -166,6 +166,12 @@ function Addon(props) {
|
|
|
166
166
|
}));
|
|
167
167
|
}
|
|
168
168
|
export const wrapPills = wrapper => wrapper;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Pills
|
|
172
|
+
*
|
|
173
|
+
* {@link https://developer.semrush.com/intergalactic/components/pills/pills-api/|API} | {@link https://developer.semrush.com/intergalactic/components/pills/pills-code/|Examples}
|
|
174
|
+
*/
|
|
169
175
|
const Pills = createComponent(RootPills, {
|
|
170
176
|
Item: [Pill, {
|
|
171
177
|
Text,
|
package/lib/es6/Pills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pills.js","names":["NeighborLocation","Box","useNeighborLocationDetect","createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","React","style","_sstyled","insert","RootPills","constructor","args","_defineProperty","value","e","handlers","key","preventDefault","uncontrolledProps","getItemProps","props","index","size","disabled","behavior","asProps","isSelected","itemValues","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","Children","styles","controlsLength","createElement","cn","_assignProps","defaultValue","onNeighborChange","neighborElement","focus","click","childSelector","selector","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","roleAreaProps","undefined","_assignProps2","Pills","Item","Addon","tag","Text","_ref3","_ref7","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapPills","wrapper"],"sources":["../../src/Pills.tsx"],"sourcesContent":["import { NeighborLocation, Box, useNeighborLocationDetect } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport React from 'react';\n\nimport type { NSPills } from './Pills.type';\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>,\n typeof RootPills.enhance,\n NSPills.Handlers\n> {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }: NSPills.Props) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'auto',\n });\n\n itemValues: Array<NSPills.Pill.Props['value']> = [];\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) => {\n const selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];\n\n return selector as [string, string];\n },\n })] as const;\n\n uncontrolledProps() {\n return {\n value: (value: NSPills.Pill.Props['value'], e: React.SyntheticEvent) => value,\n };\n }\n\n bindHandlerClick = (value: NSPills.Pill.Props['value']) => (e: React.MouseEvent) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value: NSPills.Pill.Props['value']) => (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.handlers.value(value, e);\n }\n };\n\n getItemProps(props: NSPills.Pill.Props, index: number) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props: Intergalactic.InternalTypings.InferChildComponentProps<NSPills.Pill.Component, typeof RootPills, 'Item'>) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n\n const roleAreaProps = {\n 'role': behavior === 'auto' ? 'radio' : 'tab',\n 'aria-checked': behavior === 'auto' ? selected : undefined,\n 'aria-selected': behavior !== 'auto' ? selected : undefined,\n };\n\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\n {...roleAreaProps}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nfunction Text(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Text.Component>) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Addon.Component>) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nexport const wrapPills = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSPills.WrapComponent<PropsExtending>;\n\nconst Pills = createComponent(RootPills, {\n Item: [Pill, { Text, Addon }],\n}) as unknown as NSPills.Component;\n\nexport default Pills;\n"],"mappings":";;;;;;AAAA,SAASA,gBAAgB,EAAEC,GAAG,EAAEC,yBAAyB,QAAQ,0BAA0B;AAE3F,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,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;AAAA;AAK1B,MAAMC,SAAS,SAAST,SAAS,CAI/B;EAAAU,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAA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C,EAC9DP,UAAU,gBAAGpD,KAAA,CAAAoC,aAAA,CAACqB,KAAK,CAACC,IAAI,CAACC,KAAK;IAACC,GAAG,EAAER;EAAW,CAAE,CAAC,GAAG,IACjD,CAAC;AAEZ;AAEA,SAASS,IAAIA,CAAC9C,KAAqF,EAAE;EAAA,IAAA+C,KAAA,GAAAd,YAAA;IAAAe,KAAA;EACnG,MAAMC,KAAK,GACiCxE,GAAG;EAA/C,OAAAuE,KAAA,GAAOnE,OAAO,CAACmB,KAAK,CAACmB,MAAM,CAAC,eAAClC,KAAA,CAAAoC,aAAA,CAAC4B,KAAK,EAAAD,KAAA,CAAA1B,EAAA;IAAA,GAAA4B,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AAChE;AAEA,SAASH,KAAKA,CAAC5C,KAAsF,EAAE;EAAA,IAAAmD,KAAA,GAAAlB,YAAA;IAAAmB,KAAA;EACrG,MAAMC,MAAM,GACiC5E,GAAG;EAAhD,OAAA2E,KAAA,GAAOvE,OAAO,CAACmB,KAAK,CAACmB,MAAM,CAAC,eAAClC,KAAA,CAAAoC,aAAA,CAACgC,MAAM,EAAAD,KAAA,CAAA9B,EAAA;IAAA,GAAAgC,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AACjE;AAEA,OAAO,MAAMI,SAAS,GAA+BC,OAKjC,IAAKA,OAAgD;AAEzE,MAAMd,KAAK,GAAG/D,eAAe,CAACU,SAAS,EAAE;EACvCsD,IAAI,EAAE,CAACZ,IAAI,EAAE;IAAEe,IAAI;IAAEF;EAAM,CAAC;AAC9B,CAAC,CAAiC;AAElC,eAAeF,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Pills.js","names":["NeighborLocation","Box","useNeighborLocationDetect","createComponent","Component","sstyled","Root","addonTextChildren","a11yEnhance","React","style","_sstyled","insert","RootPills","constructor","args","_defineProperty","value","e","handlers","key","preventDefault","uncontrolledProps","getItemProps","props","index","size","disabled","behavior","asProps","isSelected","itemValues","selected","tabIndex","onClick","bindHandlerClick","onKeyDown","bindHandleKeyDown","render","_ref","_ref5","SPills","Children","styles","controlsLength","createElement","cn","_assignProps","defaultValue","onNeighborChange","neighborElement","focus","click","childSelector","selector","Pill","_ref2","arguments[0]","_ref6","SPill","addonLeft","addonRight","neighborLocation","roleAreaProps","undefined","_assignProps2","Pills","Item","Addon","tag","Text","_ref3","_ref7","SText","_assignProps3","_ref4","_ref8","SAddon","_assignProps4","wrapPills","wrapper"],"sources":["../../src/Pills.tsx"],"sourcesContent":["import { NeighborLocation, Box, useNeighborLocationDetect } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { createComponent, Component, sstyled, Root } from '@semcore/core';\nimport addonTextChildren from '@semcore/core/lib/utils/addonTextChildren';\nimport a11yEnhance from '@semcore/core/lib/utils/enhances/a11yEnhance';\nimport React from 'react';\n\nimport type { NSPills } from './Pills.type';\nimport style from './style/pills.shadow.css';\n\nclass RootPills extends Component<\n Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>,\n typeof RootPills.enhance,\n NSPills.Handlers,\n {},\n {},\n NSPills.DefaultProps\n> {\n static displayName = 'Pills';\n static style = style;\n static defaultProps = ({ behavior }: Intergalactic.InternalTypings.InferComponentProps<NSPills.Component>) => ({\n size: 'm',\n defaultValue: null,\n behavior: behavior ?? 'auto',\n } as const);\n\n itemValues: Array<NSPills.Pill.Props['value']> = [];\n\n static enhance = [a11yEnhance({\n onNeighborChange: (neighborElement, props) => {\n if (neighborElement) {\n neighborElement.focus();\n if (props.behavior === 'auto') {\n neighborElement.click();\n }\n }\n },\n childSelector: (props) => {\n const selector = props.behavior === 'auto' ? ['role', 'radio'] : ['role', 'tab'];\n\n return selector as [string, string];\n },\n })] as const;\n\n uncontrolledProps() {\n return {\n value: null,\n };\n }\n\n bindHandlerClick = (value: NSPills.Pill.Props['value']) => (e: React.MouseEvent) => {\n this.handlers.value(value, e);\n };\n\n bindHandleKeyDown = (value: NSPills.Pill.Props['value']) => (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n this.handlers.value(value, e);\n }\n };\n\n getItemProps(props: NSPills.Pill.Props, index: number) {\n const { value, size, disabled, behavior } = this.asProps;\n const isSelected = value === props.value;\n\n this.itemValues[index] = props.value;\n\n return {\n index: index,\n size,\n disabled,\n selected: isSelected,\n behavior,\n tabIndex: isSelected ? 0 : -1,\n onClick: this.bindHandlerClick(props.value),\n onKeyDown: this.bindHandleKeyDown(props.value),\n };\n }\n\n render() {\n const SPills = Root;\n const { Children, styles, controlsLength, disabled, behavior, value } = this.asProps;\n\n return sstyled(styles)(\n <SPills\n render={Box}\n role={behavior === 'auto' ? 'radiogroup' : 'tablist'}\n aria-disabled={disabled}\n use:tabIndex={value !== null ? -1 : 0}\n >\n <NeighborLocation controlsLength={controlsLength}>\n <Children />\n </NeighborLocation>\n </SPills>,\n );\n }\n}\n\nfunction Pill(props: Intergalactic.InternalTypings.InferChildComponentProps<NSPills.Pill.Component, typeof RootPills, 'Item'>) {\n const SPill = Root;\n const { Children, styles, addonLeft, addonRight, selected, disabled, index, behavior } = props;\n const neighborLocation = useNeighborLocationDetect(index);\n\n const roleAreaProps = {\n 'role': behavior === 'auto' ? 'radio' : 'tab',\n 'aria-checked': behavior === 'auto' ? selected : undefined,\n 'aria-selected': behavior !== 'auto' ? selected : undefined,\n };\n\n return sstyled(styles)(\n <SPill\n render={Box}\n tag='button'\n type='button'\n tabIndex={0}\n neighborLocation={neighborLocation}\n aria-disabled={disabled}\n {...roleAreaProps}\n >\n {addonLeft ? <Pills.Item.Addon tag={addonLeft} /> : null}\n {addonTextChildren(Children, Pills.Item.Text, Pills.Item.Addon)}\n {addonRight ? <Pills.Item.Addon tag={addonRight} /> : null}\n </SPill>,\n );\n}\n\nfunction Text(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Text.Component>) {\n const SText = Root;\n return sstyled(props.styles)(<SText render={Box} tag='span' />);\n}\n\nfunction Addon(props: Intergalactic.InternalTypings.InferComponentProps<NSPills.Pill.Addon.Component>) {\n const SAddon = Root;\n return sstyled(props.styles)(<SAddon render={Box} tag='span' />);\n}\n\nexport const wrapPills = <PropsExtending extends {}>(wrapper: (\n props: Intergalactic.InternalTypings.UntypeRefAndTag<\n Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>\n > &\n PropsExtending,\n) => React.ReactNode) => wrapper as NSPills.WrapComponent<PropsExtending>;\n\n/**\n * Pills\n *\n * {@link https://developer.semrush.com/intergalactic/components/pills/pills-api/|API} | {@link https://developer.semrush.com/intergalactic/components/pills/pills-code/|Examples}\n */\nconst Pills = createComponent<\n NSPills.Component,\n typeof RootPills\n>(RootPills, {\n Item: [Pill, { Text, Addon }],\n});\n\nexport default Pills;\n"],"mappings":";;;;;;AAAA,SAASA,gBAAgB,EAAEC,GAAG,EAAEC,yBAAyB,QAAQ,0BAA0B;AAE3F,SAASC,eAAe,EAAEC,SAAS,EAAEC,OAAO,EAAEC,IAAI,QAAQ,eAAe;AACzE,OAAOC,iBAAiB,MAAM,2CAA2C;AACzE,OAAOC,WAAW,MAAM,8CAA8C;AACtE,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;AAAA;AAK1B,MAAMC,SAAS,SAAST,SAAS,CAO/B;EAAAU,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA,qBASiD,EAAE;IAAAA,eAAA,2BAwB/BC,KAAkC,IAAMC,CAAmB,IAAK;MAClF,IAAI,CAACC,QAAQ,CAACF,KAAK,CAACA,KAAK,EAAEC,CAAC,CAAC;IAC/B,CAAC;IAAAF,eAAA,4BAEoBC,KAAkC,IAAMC,CAAsB,IAAK;MACtF,IAAIA,CAAC,CAACE,GAAG,K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A/C,OAAAuE,KAAA,GAAOnE,OAAO,CAACmB,KAAK,CAACmB,MAAM,CAAC,eAAClC,KAAA,CAAAoC,aAAA,CAAC4B,KAAK,EAAAD,KAAA,CAAA1B,EAAA;IAAA,GAAA4B,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AAChE;AAEA,SAASH,KAAKA,CAAC5C,KAAsF,EAAE;EAAA,IAAAmD,KAAA,GAAAlB,YAAA;IAAAmB,KAAA;EACrG,MAAMC,MAAM,GACiC5E,GAAG;EAAhD,OAAA2E,KAAA,GAAOvE,OAAO,CAACmB,KAAK,CAACmB,MAAM,CAAC,eAAClC,KAAA,CAAAoC,aAAA,CAACgC,MAAM,EAAAD,KAAA,CAAA9B,EAAA;IAAA,GAAAgC,aAAA;MAAA,OAAkB;IAAM,GAAAH,KAAA;EAAA,EAAE,CAAC;AACjE;AAEA,OAAO,MAAMI,SAAS,GAA+BC,OAKjC,IAAKA,OAAgD;;AAEzE;AACA;AACA;AACA;AACA;AACA,MAAMd,KAAK,GAAG/D,eAAe,CAG3BU,SAAS,EAAE;EACXsD,IAAI,EAAE,CAACZ,IAAI,EAAE;IAAEe,IAAI;IAAEF;EAAM,CAAC;AAC9B,CAAC,CAAC;AAEF,eAAeF,KAAK","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pills.type.js","names":[],"sources":["../../src/Pills.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\ndeclare namespace NSPills {\n // TODO: It looks like the value isn't accurate. Revise and align it with the component's logic.\n type Value = string | number | boolean | null;\n type Props<T extends NSPills.Value = NSPills.Value> = NeighborLocationProps & BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n /** Sets semantic role for corresponding behavior,\n * when set to `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n | 'auto'\n | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value:
|
|
1
|
+
{"version":3,"file":"Pills.type.js","names":[],"sources":["../../src/Pills.type.ts"],"sourcesContent":["import type { Box, BoxProps, NeighborItemProps, NeighborLocationProps } from '@semcore/base-components';\nimport type { PropGetterFn, Intergalactic } from '@semcore/core';\nimport type React from 'react';\n\ndeclare namespace NSPills {\n // TODO: It looks like the value isn't accurate. Revise and align it with the component's logic.\n type Value = string | number | boolean | null;\n type Props<T extends NSPills.Value = NSPills.Value> = NeighborLocationProps & BoxProps & {\n /** Pills size */\n size?: 'l' | 'm';\n /** Disabled state */\n disabled?: boolean;\n /** Called when the selection is changed */\n onChange?:\n | ((value: T, e?: React.SyntheticEvent<HTMLSpanElement>) => void)\n | React.Dispatch<React.SetStateAction<T>>;\n /** Value for the selected pill */\n value?: T;\n /** Default value for the selected pill */\n defaultValue?: T;\n /** Sets semantic role for corresponding behavior,\n * when set to `auto` pressing left and right arrows\n * selects corresponding sibling pill.\n *\n * It's recommended to use `auto` behavior in forms\n * while `manual` behavior for navigation and layout.\n * @default tabs\n */\n behavior?:\n | 'auto'\n | 'manual';\n };\n type Ctx = {\n getItemProps: PropGetterFn;\n };\n type Handlers = {\n value: null;\n };\n type DefaultProps = {\n size: 'm';\n defaultValue: null;\n behavior: Props['behavior'];\n };\n namespace Pill {\n type Props = BoxProps & NeighborItemProps & {\n /** Pill value */\n value?: NSPills.Value;\n /** Disabled state */\n disabled?: boolean;\n /** Selected state */\n selected?: boolean;\n /** Left addon text */\n addonLeft?: React.ElementType;\n /** Right addon tag */\n addonRight?: React.ElementType;\n };\n namespace Text {\n type Component = typeof Box;\n }\n namespace Addon {\n type Component = typeof Box;\n }\n\n type Component = Intergalactic.Component<'button', Props, [handlers: Handlers]>;\n }\n\n type WrapComponent<PropsExtending = {}> = (<\n V extends Value,\n Tag extends Intergalactic.Tag = 'div',\n >(\n props: Intergalactic.InternalTypings.ComponentProps<\n Tag,\n 'div',\n Props<V>,\n Ctx,\n [handlers: Handlers]\n > &\n PropsExtending,\n ) => Intergalactic.InternalTypings.ComponentRenderingResults) &\n Intergalactic.InternalTypings.ComponentAdditive<'div', 'div', Props>;\n\n type Component = WrapComponent & {\n Item: Pill.Component & {\n Text: Pill.Text.Component;\n Addon: Pill.Addon.Component;\n };\n };\n}\n\n/** @deprecated It will be removed in v18. */\nexport type PillsValue = NSPills.Value;\n/** @deprecated It will be removed in v18. */\nexport type PillsProps<T extends PillsValue = PillsValue> = NSPills.Props<T>;\n/** @deprecated It will be removed in v18. */\nexport type PillProps = NSPills.Pill.Props;\n/** @deprecated It will be removed in v18. */\nexport type PillsContext = NSPills.Ctx;\n/** @deprecated It will be removed in v18. */\nexport type PillsHandlers = NSPills.Handlers;\n\nexport type { NSPills };\n"],"mappings":"","ignoreList":[]}
|
package/lib/esm/Pills.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { sstyled, Component, assignProps, createComponent } from "@semcore/core";
|
|
3
3
|
import { Box, NeighborLocation, useNeighborLocationDetect } from "@semcore/base-components";
|
|
4
4
|
import addonTextChildren from "@semcore/core/lib/utils/addonTextChildren";
|
|
@@ -9,22 +9,22 @@ const style = (
|
|
|
9
9
|
/*__reshadow_css_start__*/
|
|
10
10
|
(sstyled.insert(
|
|
11
11
|
/*__inner_css_start__*/
|
|
12
|
-
".
|
|
12
|
+
".___SPills_167np_gg_{display:inline-flex;align-items:center;justify-content:center;isolation:isolate;border-radius:var(--intergalactic-control-rounded,6px)}.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,#0051ff0a);border-color:var(--intergalactic-border-info-active,#8796ef);z-index:3}@supports (color:color(display-p3 0 0 0%)){.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,#0051ff0a)}@media (color-gamut:p3){.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_{background:var(--intergalactic-control-secondary-info,color(display-p3 .12567 .31309 .96324/.039))}}}.___SPills_167np_gg_ .___SPill_167np_gg_.__selected_167np_gg_,.___SPills_167np_gg_ .___SPill_167np_gg_:focus-visible{z-index:3}.___SPills_167np_gg_ .___SPill_167np_gg_:active{z-index:2}@media (hover:hover){.___SPills_167np_gg_ .___SPill_167np_gg_:hover{z-index:2}}.___SPill_167np_gg_{display:inline-flex;align-items:center;justify-content:center;line-height:normal;position:relative;touch-action:manipulation;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;user-select:none;box-sizing:border-box;padding:0;margin:0;box-shadow:none;-webkit-text-decoration:none;text-decoration:none;-webkit-tap-highlight-color:transparent;overflow:visible;text-align:center;vertical-align:middle;font-family:inherit;cursor:pointer;background:var(--intergalactic-bg-primary-neutral,#fff);border:1px solid var(--intergalactic-border-primary,#000c0829);border-radius:var(--intergalactic-control-rounded,6px)}@supports (color:color(display-p3 0 0 0%)){.___SPill_167np_gg_{border:1px solid var(--intergalactic-border-primary,#000c0829)}@media (color-gamut:p3){.___SPill_167np_gg_{border:1px solid var(--intergalactic-border-primary,color(display-p3 .00798 .04498 .03219/.161))}}}.___SPill_167np_gg_::-moz-focus-inner{border:none;padding:0}.___SPill_167np_gg_:active{outline:0;-webkit-text-decoration:none;text-decoration:none}@media (hover:hover){.___SPill_167np_gg_:hover{background:var(--intergalactic-bg-primary-neutral-hover,#f8f9f8)}}.___SPill_167np_gg_.__disabled_167np_gg_{cursor:default;pointer-events:none}.___SPill_167np_gg_.__disabled_167np_gg_>*{opacity:var(--intergalactic-disabled-opacity,.4)}.___SText_167np_gg_{color:var(--intergalactic-text-primary,#010500e5);display:inline-flex}.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,#00030095);display:inline-flex;align-items:center;justify-content:center}@supports (color:color(display-p3 0 0 0%)){.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,#00030095)}@media (color-gamut:p3){.___SAddon_167np_gg_{color:var(--intergalactic-text-secondary,color(display-p3 .00228 .01289 .00252/.583))}}}.___SPill_167np_gg_._size_m_167np_gg_{height:var(--intergalactic-form-control-m,28px);min-width:var(--intergalactic-form-control-m,28px);font-size:var(--intergalactic-fs-200,14px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SText_167np_gg_{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_m_167np_gg_ .___SAddon_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_l_167np_gg_{height:var(--intergalactic-form-control-l,40px);min-width:var(--intergalactic-form-control-l,40px);font-size:var(--intergalactic-fs-300,16px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SText_167np_gg_{margin-left:var(--intergalactic-spacing-2x,8px);margin-right:var(--intergalactic-spacing-2x,8px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SText_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-3x,12px);margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:not(:only-child):first-child{margin-left:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:not(:only-child):last-child{margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._size_l_167np_gg_ .___SAddon_167np_gg_:only-child{margin-left:var(--intergalactic-spacing-3x,12px);margin-right:var(--intergalactic-spacing-3x,12px)}.___SPill_167np_gg_._neighborLocation_right_167np_gg_{border-top-right-radius:0;border-bottom-right-radius:0}.___SPill_167np_gg_._neighborLocation_both_167np_gg_{border-radius:0;margin-left:-1px}.___SPill_167np_gg_._neighborLocation_left_167np_gg_{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}",
|
|
13
13
|
/*__inner_css_end__*/
|
|
14
|
-
"
|
|
14
|
+
"167np_gg_"
|
|
15
15
|
), /*__reshadow_css_end__*/
|
|
16
16
|
{
|
|
17
|
-
"__SText": "
|
|
18
|
-
"__SAddon": "
|
|
19
|
-
"__SPill": "
|
|
20
|
-
"_neighborLocation_right": "
|
|
21
|
-
"_neighborLocation_both": "
|
|
22
|
-
"_neighborLocation_left": "
|
|
23
|
-
"__SPills": "
|
|
24
|
-
"_selected": "
|
|
25
|
-
"_disabled": "
|
|
26
|
-
"_size_m": "
|
|
27
|
-
"_size_l": "
|
|
17
|
+
"__SText": "___SText_167np_gg_",
|
|
18
|
+
"__SAddon": "___SAddon_167np_gg_",
|
|
19
|
+
"__SPill": "___SPill_167np_gg_",
|
|
20
|
+
"_neighborLocation_right": "_neighborLocation_right_167np_gg_",
|
|
21
|
+
"_neighborLocation_both": "_neighborLocation_both_167np_gg_",
|
|
22
|
+
"_neighborLocation_left": "_neighborLocation_left_167np_gg_",
|
|
23
|
+
"__SPills": "___SPills_167np_gg_",
|
|
24
|
+
"_selected": "__selected_167np_gg_",
|
|
25
|
+
"_disabled": "__disabled_167np_gg_",
|
|
26
|
+
"_size_m": "_size_m_167np_gg_",
|
|
27
|
+
"_size_l": "_size_l_167np_gg_"
|
|
28
28
|
})
|
|
29
29
|
);
|
|
30
30
|
class RootPills extends Component {
|
|
@@ -43,7 +43,7 @@ class RootPills extends Component {
|
|
|
43
43
|
}
|
|
44
44
|
uncontrolledProps() {
|
|
45
45
|
return {
|
|
46
|
-
value:
|
|
46
|
+
value: null
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
getItemProps(props, index) {
|
package/lib/types/Pills.d.ts
CHANGED
|
@@ -2,5 +2,10 @@ import type { Intergalactic } from '@semcore/core';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { NSPills } from './Pills.type';
|
|
4
4
|
export declare const wrapPills: <PropsExtending extends {}>(wrapper: (props: Intergalactic.InternalTypings.UntypeRefAndTag<Intergalactic.InternalTypings.ComponentPropsNesting<NSPills.WrapComponent>> & PropsExtending) => React.ReactNode) => NSPills.WrapComponent<PropsExtending>;
|
|
5
|
+
/**
|
|
6
|
+
* Pills
|
|
7
|
+
*
|
|
8
|
+
* {@link https://developer.semrush.com/intergalactic/components/pills/pills-api/|API} | {@link https://developer.semrush.com/intergalactic/components/pills/pills-code/|Examples}
|
|
9
|
+
*/
|
|
5
10
|
declare const Pills: NSPills.Component;
|
|
6
11
|
export default Pills;
|
|
@@ -28,7 +28,12 @@ declare namespace NSPills {
|
|
|
28
28
|
getItemProps: PropGetterFn;
|
|
29
29
|
};
|
|
30
30
|
type Handlers = {
|
|
31
|
-
value:
|
|
31
|
+
value: null;
|
|
32
|
+
};
|
|
33
|
+
type DefaultProps = {
|
|
34
|
+
size: 'm';
|
|
35
|
+
defaultValue: null;
|
|
36
|
+
behavior: Props['behavior'];
|
|
32
37
|
};
|
|
33
38
|
namespace Pill {
|
|
34
39
|
type Props = BoxProps & NeighborItemProps & {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/pills",
|
|
3
3
|
"description": "Semrush Pills Component",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.2.0-prerelease.3",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"require": "./lib/cjs/index.js"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@semcore/base-components": "^17.0
|
|
17
|
+
"@semcore/base-components": "^17.2.0"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"directory": "semcore/pills"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@semcore/
|
|
26
|
-
"@semcore/
|
|
27
|
-
"@semcore/
|
|
25
|
+
"@semcore/core": "17.2.0-prerelease.3",
|
|
26
|
+
"@semcore/base-components": "17.2.0-prerelease.3",
|
|
27
|
+
"@semcore/badge": "17.2.0-prerelease.3",
|
|
28
28
|
"@semcore/testing-utils": "1.0.0",
|
|
29
29
|
"@semcore/icon": "17.1.0"
|
|
30
30
|
},
|