@sproutsocial/seeds-react-token-input 1.1.0 → 1.3.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.
@@ -8,14 +8,14 @@ CLI Target: es2022
8
8
  CLI Cleaning output folder
9
9
  CJS Build start
10
10
  ESM Build start
11
- CJS dist/index.js 14.85 KB
12
- CJS dist/index.js.map 26.74 KB
13
- CJS ⚡️ Build success in 303ms
14
- ESM dist/esm/index.js 12.21 KB
15
- ESM dist/esm/index.js.map 26.58 KB
16
- ESM ⚡️ Build success in 315ms
11
+ CJS dist/index.js 14.89 KB
12
+ CJS dist/index.js.map 26.83 KB
13
+ CJS ⚡️ Build success in 253ms
14
+ ESM dist/esm/index.js 12.24 KB
15
+ ESM dist/esm/index.js.map 26.67 KB
16
+ ESM ⚡️ Build success in 246ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 25909ms
19
- DTS dist/index.d.ts 5.10 KB
20
- DTS dist/index.d.mts 5.10 KB
21
- Done in 33.14s.
18
+ DTS ⚡️ Build success in 21166ms
19
+ DTS dist/index.d.ts 5.12 KB
20
+ DTS dist/index.d.mts 5.12 KB
21
+ Done in 28.15s.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @sproutsocial/seeds-react-token-input
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b04649d: Bump token version to 1.1.1
8
+
9
+ ### Patch Changes
10
+
11
+ - b04649d: Updates type parameter syntax for onClick events
12
+ - Updated dependencies [b04649d]
13
+ - @sproutsocial/seeds-react-token@1.1.2
14
+
15
+ ## 1.2.0
16
+
17
+ ### Minor Changes
18
+
19
+ - d61745a: Adds boolean `hasWarning` prop to `Token` component, which is set to `false` by default. Instances of `Token` with `hasWarning` set to `true` will appear in a yellow warning state.
20
+
21
+ Adds support for new `hasWarning` state for `Tokens` within the `TokenInput` component.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [d61745a]
26
+ - @sproutsocial/seeds-react-token@1.1.0
27
+
3
28
  ## 1.1.0
4
29
 
5
30
  ### Minor Changes
package/dist/esm/index.js CHANGED
@@ -314,6 +314,7 @@ var TokenInput = class extends React2.Component {
314
314
  iconProps = { "aria-hidden": true },
315
315
  value,
316
316
  valid,
317
+ hasWarning,
317
318
  tokenProps: { onClick, ...restTokenProps } = {}
318
319
  } = token;
319
320
  const iconName = tokenIconName || defaultIconName;
@@ -327,6 +328,7 @@ var TokenInput = class extends React2.Component {
327
328
  onClick?.(e);
328
329
  },
329
330
  valid,
331
+ hasWarning,
330
332
  active: isActive,
331
333
  disabled,
332
334
  ...restTokenProps,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TokenInput.tsx","../../src/styles.ts","../../src/util.ts","../../src/TokenScreenReaderStatus.tsx","../../../seeds-react-visually-hidden/src/VisuallyHidden.tsx","../../src/TokenInputTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Accessory } from \"@sproutsocial/seeds-react-input\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Token from \"@sproutsocial/seeds-react-token\";\nimport Container from \"./styles\";\nimport { asTokenSpec, delimitersAsRegExp } from \"./util\";\nimport type { TypeTokenInputProps, TypeTokenSpec } from \"./TokenInputTypes\";\nimport { TokenScreenReaderStatus } from \"./TokenScreenReaderStatus\";\n\ntype TypeState = {\n prevProps: TypeTokenInputProps;\n hasFocus: boolean;\n activeToken: string | null | undefined;\n value: string;\n};\n\nconst DefaultDelimiters = [\",\", \"Enter\"];\nconst ControlledPropNames: (keyof TypeState)[] = [\n \"value\",\n \"hasFocus\",\n \"activeToken\",\n];\n\nexport default class TokenInput extends React.Component<\n TypeTokenInputProps,\n TypeState\n> {\n delimiterMatcher: RegExp;\n\n constructor(props: TypeTokenInputProps) {\n super(props);\n const { hasFocus, activeToken, value, delimiters } = props;\n this.delimiterMatcher = delimitersAsRegExp(delimiters || DefaultDelimiters);\n this.state = {\n prevProps: props,\n hasFocus: hasFocus || false,\n activeToken: activeToken,\n value: value || \"\",\n };\n }\n\n static getDerivedStateFromProps(\n props: Readonly<TypeTokenInputProps>,\n state: TypeState\n ) {\n const { prevProps } = state;\n const modifiedState: Partial<TypeState> = { prevProps: props };\n ControlledPropNames.forEach((propName) => {\n const currentProp = props[propName as keyof TypeTokenInputProps];\n\n // @ts-ignore: TODO - fix state types for prevProps\n if (currentProp !== prevProps[propName]) {\n modifiedState[propName] = currentProp;\n }\n });\n modifiedState.prevProps = props;\n return modifiedState;\n }\n\n isDelimiter(keyName: string) {\n const { delimiters = DefaultDelimiters } = this.props;\n return delimiters.includes(keyName);\n }\n\n spawnNewTokens(texts: string[]) {\n const {\n onAddToken,\n onChangeTokens,\n tokenMaxLength: max = Infinity,\n tokens = [],\n } = this.props;\n const tokenSpecs = texts.map((text) => asTokenSpec(text.slice(0, max)));\n\n if (onAddToken) {\n tokenSpecs.forEach(onAddToken);\n } else if (onChangeTokens) {\n onChangeTokens(tokens.concat(tokenSpecs));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n deleteToken(tokenId?: string) {\n const { onRemoveToken, onChangeTokens, tokens = [] } = this.props;\n const count = tokens.length;\n if (count === 0) return;\n const id = tokenId ?? tokens[count - 1]?.id;\n\n if (onRemoveToken) {\n onRemoveToken(id ? id : \"\");\n } else if (onChangeTokens) {\n onChangeTokens(tokens.filter((tokenSpec) => tokenSpec.id !== id));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n handleChangeText = (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { value } = e.currentTarget;\n const { onChange } = this.props;\n this.setState({\n value,\n });\n onChange?.(e, value);\n };\n\n handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onFocus } = this.props;\n this.setState({\n hasFocus: true,\n });\n onFocus?.(e);\n };\n\n handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onBlur } = this.props;\n if (onBlur) onBlur(e);\n this.setState({\n hasFocus: false,\n });\n };\n\n handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n this.props.onKeyUp?.(e, e.currentTarget.value);\n };\n\n handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyDown } = this.props;\n const { key, currentTarget } = e;\n const text = currentTarget.value;\n if (onKeyDown) onKeyDown(e, text);\n\n // keyPress event runs before change\n // Prevent event from bubbling up and calling change, which can lead to comma in value\n if (this.isDelimiter(key)) {\n if (text) {\n this.spawnNewTokens([text]);\n e.preventDefault();\n }\n } else if (key === \"Backspace\") {\n if (text === \"\") {\n this.deleteToken();\n }\n }\n };\n\n handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n const text = e.clipboardData.getData(\"text\");\n const { onPaste } = this.props;\n if (onPaste) onPaste(e, text);\n const subtexts = text.split(this.delimiterMatcher);\n const texts = subtexts.filter((subtext) => subtext.length);\n\n if (texts.length > 1) {\n this.spawnNewTokens(texts);\n e.preventDefault();\n }\n };\n\n handleClickToken = (\n e: React.MouseEvent<Element, MouseEvent>,\n token: TypeTokenSpec\n ) => {\n const { onClickToken, disabled } = this.props;\n if (onClickToken) onClickToken(e, token.id);\n\n if (!disabled) {\n this.deleteToken(token.id);\n }\n };\n\n renderToken(token: TypeTokenSpec): React.ReactNode {\n const { iconName: defaultIconName, disabled } = this.props;\n const activeId = this.state.activeToken;\n const {\n id,\n iconName: tokenIconName,\n iconProps = { \"aria-hidden\": true },\n value,\n valid,\n tokenProps: { onClick, ...restTokenProps } = {},\n } = token;\n const iconName = tokenIconName || defaultIconName;\n const isActive = activeId === id;\n return (\n <Token\n id={id}\n onClick={(e) => {\n this.handleClickToken(e, token);\n onClick?.(e);\n }}\n valid={valid}\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n active={isActive}\n disabled={disabled}\n {...restTokenProps}\n >\n <Box display=\"flex\" alignItems=\"center\">\n {iconName && (\n <Icon name={iconName} size=\"mini\" pr={300} {...iconProps} />\n )}\n {value}\n </Box>\n </Token>\n );\n }\n\n renderTokens(tokens: TypeTokenSpec[]): React.ReactNode {\n return tokens.map<React.ReactNode>((token) => (\n <div key={token.id} className=\"TokenInput-token\">\n {this.renderToken(token)}\n </div>\n ));\n }\n\n override render() {\n const {\n autoFocus,\n autocomplete,\n disabled,\n isInvalid,\n hasWarning,\n id,\n name,\n placeholder,\n required,\n elemBefore,\n elemAfter,\n maxLength,\n ariaDescribedby,\n ariaLabel,\n innerRef,\n // These functions are used in the class functions above, but need to be extracted in order for `rest` to be correct\n /* eslint-disable @typescript-eslint/no-unused-vars */\n value,\n onAddToken,\n onRemoveToken,\n onChangeTokens,\n onClickToken,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onPaste,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n inputProps = {},\n qa = {},\n tokens,\n ...rest\n } = this.props;\n const { state } = this;\n return (\n <Container\n hasBeforeElement={!!elemBefore}\n hasAfterElement={!!elemAfter}\n disabled={disabled}\n invalid={!!isInvalid}\n warning={hasWarning}\n focused={state.hasFocus}\n {...rest}\n >\n {elemBefore && <Accessory before>{elemBefore}</Accessory>}\n\n {tokens && this.renderTokens(tokens)}\n\n <TokenScreenReaderStatus tokens={tokens} />\n\n <input\n aria-describedby={ariaDescribedby}\n aria-invalid={!!isInvalid}\n aria-label={ariaLabel}\n autoFocus={autoFocus}\n autoComplete={autocomplete}\n disabled={disabled}\n id={id}\n name={name}\n placeholder={placeholder}\n type=\"text\"\n required={required}\n value={state.value}\n maxLength={maxLength}\n onBlur={this.handleBlur}\n onChange={this.handleChangeText}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n onKeyUp={this.handleKeyUp}\n onPaste={this.handlePaste}\n ref={innerRef}\n data-qa-input={name || \"\"}\n data-qa-input-isdisabled={!!disabled}\n data-qa-input-isrequired={!!required}\n {...qa}\n {...inputProps}\n />\n\n {elemAfter && <Accessory after>{elemAfter}</Accessory>}\n </Container>\n );\n }\n}\n","import styled, { css } from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport type { TypeInputContainerProps } from \"@sproutsocial/seeds-react-input\";\n\ninterface TypeTokenInputContainerProps\n extends Pick<\n TypeInputContainerProps,\n \"hasBeforeElement\" | \"hasAfterElement\" | \"disabled\" | \"invalid\" | \"warning\"\n > {\n focused?: boolean;\n}\n\nconst Container = styled.div<TypeTokenInputContainerProps>`\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n align-content: center;\n cursor: text;\n width: 100%;\n border: 1px solid ${(props) => props.theme.colors.form.border.base};\n border-radius: ${(props) => props.theme.radii[500]};\n margin: 0;\n padding: ${(props) => props.theme.space[300]};\n padding-top: ${(props) => props.theme.space[200]};\n background-color: ${(props) => props.theme.colors.form.background.base};\n color: ${(props) => props.theme.colors.text.body};\n transition: border-color ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in},\n box-shadow ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in};\n ${(props) => props.theme.typography[200]};\n font-family: ${(props) => props.theme.fontFamily};\n font-weight: ${(props) => props.theme.fontWeights.normal};\n appearance: none;\n\n button {\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[200]} 0 0;\n }\n\n input {\n ${(props) => props.theme.typography[200]};\n outline: none;\n border: none;\n flex: 1;\n padding: 0;\n padding-top: ${(props) => props.theme.space[100]};\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[300]} ${(props) => props.theme.space[100]}\n 0;\n color: ${(props) => props.theme.colors.text.body};\n background-color: ${(props) => props.theme.colors.form.background.base};\n /** This matches the height of the token so size does not change as tokens are added */\n min-height: 20px;\n\n &::-webkit-search-cancel-button {\n appearance: none;\n }\n\n /* Explicitly removes double focus ring in environments where box-shadow focus styles have been specified (Seeds). Focus is passed up from the input to the parent container. */\n &:focus {\n box-shadow: none;\n }\n\n /* https://stackoverflow.com/questions/14007655/remove-ie10s-clear-field-x-button-on-certain-inputs */\n &::-ms-clear {\n display: none;\n }\n\n /* Fix for red ring when input is marked required in Firefox */\n &:not(output):not(:focus):-moz-ui-invalid {\n box-shadow: none;\n }\n\n &::placeholder {\n color: ${(props) => props.theme.colors.form.placeholder.base};\n font-style: italic;\n }\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n }\n\n ${(props) =>\n props.hasBeforeElement &&\n css`\n padding-left: 40px;\n `}\n\n ${(props) =>\n props.hasAfterElement &&\n css`\n padding-right: 40px;\n `}\n\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n\n ${(props) =>\n props.focused &&\n css`\n ${focusRing}\n `}\n\n ${(props) =>\n props.invalid &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.error};\n `}\n\n\t${(props) =>\n props.warning &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.warning};\n `}\n\n ${COMMON}\n`;\n\nContainer.displayName = \"TokenInputContainer\";\n\nexport default Container;\n","import uniqueId from \"lodash.uniqueid\";\nimport type { TypeTokenSpec } from \"./\";\n\nexport const asTokenSpec = (text: string): TypeTokenSpec => ({\n id: uniqueId(`${text}-`),\n value: text.trim(),\n});\n\nconst KeyNameToRegExpChar: { [key: string]: string } = {\n Enter: \"\\\\n\",\n};\n\nexport const delimitersAsRegExp = (delimiters: string[] | null | undefined) => {\n if (!delimiters) return /[,\\n]/;\n const chars = delimiters\n .map(\n (key) =>\n KeyNameToRegExpChar[key as keyof typeof KeyNameToRegExpChar] || key\n )\n .join(\"\");\n return RegExp(`[${chars}]`);\n};\n","import React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport type { TypeTokenInputProps } from \"./\";\n\nfunction usePrevious(value: TypeTokenInputProps[\"tokens\"]) {\n const ref = useRef<TypeTokenInputProps[\"tokens\"]>();\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n}\n\nexport const TokenScreenReaderStatus = ({\n tokens,\n}: {\n tokens: TypeTokenInputProps[\"tokens\"];\n}) => {\n const prevTokens = usePrevious(tokens);\n const [tokenStatus, setTokenStatus] = useState(\"\");\n\n // TODO: Use callbacks so consumers can pass localized messaging to the screen reader\n useEffect(() => {\n if (prevTokens && tokens) {\n if (prevTokens.length > tokens.length) {\n setTokenStatus(\n `${\n prevTokens.filter((item) => tokens.indexOf(item) === -1)[0]?.value\n } has been removed`\n );\n }\n\n if (prevTokens.length < tokens.length) {\n setTokenStatus(`${tokens[tokens.length - 1]?.value} has been added.`);\n }\n }\n }, [prevTokens, tokens, tokenStatus]);\n\n return (\n <VisuallyHidden as=\"div\" role=\"status\">\n {tokenStatus}\n </VisuallyHidden>\n );\n};\n","import styled from \"styled-components\";\nimport { visuallyHidden } from \"@sproutsocial/seeds-react-mixins\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nconst StyledVisuallyHidden = styled.span`\n ${visuallyHidden}\n`;\n\nexport type VisuallyHiddenProps = ComponentPropsWithRef<\n typeof StyledVisuallyHidden\n>;\n\n// This wrapper component is needed for react-docgen to work.\n// It has issues with generating docs for the styled component directly.\nexport const VisuallyHidden = (props: VisuallyHiddenProps) => {\n return <StyledVisuallyHidden {...props} />;\n};\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type {\n TypeIconProps,\n TypeIconName,\n} from \"@sproutsocial/seeds-react-icon\";\nimport type { TypeTokenProps } from \"@sproutsocial/seeds-react-token\";\n\nexport interface TypeTokenSpec {\n id: string;\n iconName?: TypeIconName;\n iconProps?: Omit<TypeIconProps, \"name\">;\n value: string;\n valid?: boolean;\n tokenProps?: Partial<TypeTokenProps>;\n}\n\nexport interface TypeBaseTokenInputProps {\n /** ID of the form element, should match the \"for\" value of the associated label */\n id: string;\n name: string;\n iconName?: TypeIconName;\n\n /** Array of delimiter key names */\n delimiters?: string[];\n\n /** Current input text. Required when controlling the input text */\n value?: string;\n\n /** Current focus state. Required when controlling the focus via onFocus and onBlur */\n hasFocus?: boolean;\n\n /** Id of the currently selected token */\n activeToken?: string;\n\n /** Array of current tokens */\n tokens?: TypeTokenSpec[];\n\n /** Standard control of changing tokens. For fine-grain control use onAddToken and onRemoveToken, instead */\n onChangeTokens?: (tokens: TypeTokenSpec[]) => void;\n\n /** Fine-grained control of adding tokens. Use with onRemoveToken instead of onChangeTokens */\n onAddToken?: (tokenSpec: TypeTokenSpec) => void;\n\n /** Fine-grained control of removing tokens. Use with onAddToken instead of onChangeTokens */\n onRemoveToken?: (tokenId: string) => void;\n\n /** Controls clicking on a token. When absent, clicking a token removes itself */\n onClickToken?: (\n e: React.MouseEvent<Element, MouseEvent>,\n tokenId: string\n ) => void;\n\n /** Fine-grained control of the input text used to create tokens */\n onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;\n\n /** Fine-grained control of pasted text */\n onPaste?: (e: React.ClipboardEvent<HTMLInputElement>, value: string) => void;\n onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n\n /** Attribute used to associate other elements that describe the Input, like an error */\n ariaDescribedby?: string;\n\n /** Label used to describe the input if not used with an accompanying visual label */\n ariaLabel?: string;\n\n /** Placeholder text for when value is undefined or empty */\n placeholder?: string;\n\n /** Will autofocus the element when mounted to the DOM */\n autoFocus?: boolean;\n\n /** HTML disabled attribute */\n disabled?: boolean;\n\n /** Whether or not the current contents of the input are invalid */\n isInvalid?: boolean;\n\n /** Whether or not the current contents of the input has any warnings */\n hasWarning?: boolean;\n\n /** HTML required attribute */\n required?: boolean;\n\n /** 16x16 element, such as an icon */\n elemBefore?: React.ReactNode;\n\n /** 16x16 element, such as an icon */\n elemAfter?: React.ReactNode;\n\n /** Max input text length */\n maxLength?: number;\n\n /** Max length of the token */\n tokenMaxLength?: number;\n\n /** Props to spread onto the underlying input element */\n inputProps?: React.ComponentPropsWithoutRef<\"input\">;\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLInputElement>;\n qa?: object;\n\n /** Browser autocomplete support */\n autocomplete?: string;\n}\n\nexport interface TypeTokenInputProps\n extends TypeBaseTokenInputProps,\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<\n React.ComponentPropsWithoutRef<\"div\">,\n keyof TypeBaseTokenInputProps | \"color\"\n > {}\n","import TokenInput from \"./TokenInput\";\n\nexport default TokenInput;\nexport { TokenInput };\nexport * from \"./TokenInputTypes\";\n"],"mappings":";AAAA,YAAYA,YAAW;AACvB,SAAS,iBAAiB;AAC1B,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,WAAW;;;ACJlB,OAAO,UAAU,WAAW;AAC5B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAW1B,IAAM,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBASH,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,OAAO,IAAI;AAAA,mBACjD,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA,aAEvC,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,iBAC7B,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,sBAC5B,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,WAAW,IAAI;AAAA,WAC7D,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,IAAI;AAAA,6BACrB,CAAC,UAAU,MAAM,MAAM,SAAS,IAAI;AAAA,QACzD,CAAC,UAAU,MAAM,MAAM,OAAO,OAAO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AAA;AAAA,MAEA,aAAa,CAAC;AAAA,MACd,KAAK,CAAC;AAAA,MACN;AAAA,MACA,GAAG;AAAA,IACL,IAAI,KAAK;AACT,UAAM,EAAE,MAAM,IAAI;AAClB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,kBAAkB,CAAC,CAAC;AAAA,QACpB,iBAAiB,CAAC,CAAC;AAAA,QACnB;AAAA,QACA,SAAS,CAAC,CAAC;AAAA,QACX,SAAS;AAAA,QACT,SAAS,MAAM;AAAA,QACd,GAAG;AAAA,QAEH;AAAA,wBAAc,gBAAAA,KAAC,aAAU,QAAM,MAAE,sBAAW;AAAA,UAE5C,UAAU,KAAK,aAAa,MAAM;AAAA,UAEnC,gBAAAA,KAAC,2BAAwB,QAAgB;AAAA,UAEzC,gBAAAA;AAAA,YAAC;AAAA;AAAA,cACC,oBAAkB;AAAA,cAClB,gBAAc,CAAC,CAAC;AAAA,cAChB,cAAY;AAAA,cACZ;AAAA,cACA,cAAc;AAAA,cACd;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,MAAK;AAAA,cACL;AAAA,cACA,OAAO,MAAM;AAAA,cACb;AAAA,cACA,QAAQ,KAAK;AAAA,cACb,UAAU,KAAK;AAAA,cACf,SAAS,KAAK;AAAA,cACd,WAAW,KAAK;AAAA,cAChB,SAAS,KAAK;AAAA,cACd,SAAS,KAAK;AAAA,cACd,KAAK;AAAA,cACL,iBAAe,QAAQ;AAAA,cACvB,4BAA0B,CAAC,CAAC;AAAA,cAC5B,4BAA0B,CAAC,CAAC;AAAA,cAC3B,GAAG;AAAA,cACH,GAAG;AAAA;AAAA,UACN;AAAA,UAEC,aAAa,gBAAAA,KAAC,aAAU,OAAK,MAAE,qBAAU;AAAA;AAAA;AAAA,IAC5C;AAAA,EAEJ;AACF;;;AKlTA,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":["React","props","styled","jsx","jsx"]}
1
+ {"version":3,"sources":["../../src/TokenInput.tsx","../../src/styles.ts","../../src/util.ts","../../src/TokenScreenReaderStatus.tsx","../../../seeds-react-visually-hidden/src/VisuallyHidden.tsx","../../src/TokenInputTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Accessory } from \"@sproutsocial/seeds-react-input\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Token from \"@sproutsocial/seeds-react-token\";\nimport Container from \"./styles\";\nimport { asTokenSpec, delimitersAsRegExp } from \"./util\";\nimport type { TypeTokenInputProps, TypeTokenSpec } from \"./TokenInputTypes\";\nimport { TokenScreenReaderStatus } from \"./TokenScreenReaderStatus\";\n\ntype TypeState = {\n prevProps: TypeTokenInputProps;\n hasFocus: boolean;\n activeToken: string | null | undefined;\n value: string;\n};\n\nconst DefaultDelimiters = [\",\", \"Enter\"];\nconst ControlledPropNames: (keyof TypeState)[] = [\n \"value\",\n \"hasFocus\",\n \"activeToken\",\n];\n\nexport default class TokenInput extends React.Component<\n TypeTokenInputProps,\n TypeState\n> {\n delimiterMatcher: RegExp;\n\n constructor(props: TypeTokenInputProps) {\n super(props);\n const { hasFocus, activeToken, value, delimiters } = props;\n this.delimiterMatcher = delimitersAsRegExp(delimiters || DefaultDelimiters);\n this.state = {\n prevProps: props,\n hasFocus: hasFocus || false,\n activeToken: activeToken,\n value: value || \"\",\n };\n }\n\n static getDerivedStateFromProps(\n props: Readonly<TypeTokenInputProps>,\n state: TypeState\n ) {\n const { prevProps } = state;\n const modifiedState: Partial<TypeState> = { prevProps: props };\n ControlledPropNames.forEach((propName) => {\n const currentProp = props[propName as keyof TypeTokenInputProps];\n\n // @ts-ignore: TODO - fix state types for prevProps\n if (currentProp !== prevProps[propName]) {\n modifiedState[propName] = currentProp;\n }\n });\n modifiedState.prevProps = props;\n return modifiedState;\n }\n\n isDelimiter(keyName: string) {\n const { delimiters = DefaultDelimiters } = this.props;\n return delimiters.includes(keyName);\n }\n\n spawnNewTokens(texts: string[]) {\n const {\n onAddToken,\n onChangeTokens,\n tokenMaxLength: max = Infinity,\n tokens = [],\n } = this.props;\n const tokenSpecs = texts.map((text) => asTokenSpec(text.slice(0, max)));\n\n if (onAddToken) {\n tokenSpecs.forEach(onAddToken);\n } else if (onChangeTokens) {\n onChangeTokens(tokens.concat(tokenSpecs));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n deleteToken(tokenId?: string) {\n const { onRemoveToken, onChangeTokens, tokens = [] } = this.props;\n const count = tokens.length;\n if (count === 0) return;\n const id = tokenId ?? tokens[count - 1]?.id;\n\n if (onRemoveToken) {\n onRemoveToken(id ? id : \"\");\n } else if (onChangeTokens) {\n onChangeTokens(tokens.filter((tokenSpec) => tokenSpec.id !== id));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n handleChangeText = (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { value } = e.currentTarget;\n const { onChange } = this.props;\n this.setState({\n value,\n });\n onChange?.(e, value);\n };\n\n handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onFocus } = this.props;\n this.setState({\n hasFocus: true,\n });\n onFocus?.(e);\n };\n\n handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onBlur } = this.props;\n if (onBlur) onBlur(e);\n this.setState({\n hasFocus: false,\n });\n };\n\n handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n this.props.onKeyUp?.(e, e.currentTarget.value);\n };\n\n handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyDown } = this.props;\n const { key, currentTarget } = e;\n const text = currentTarget.value;\n if (onKeyDown) onKeyDown(e, text);\n\n // keyPress event runs before change\n // Prevent event from bubbling up and calling change, which can lead to comma in value\n if (this.isDelimiter(key)) {\n if (text) {\n this.spawnNewTokens([text]);\n e.preventDefault();\n }\n } else if (key === \"Backspace\") {\n if (text === \"\") {\n this.deleteToken();\n }\n }\n };\n\n handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n const text = e.clipboardData.getData(\"text\");\n const { onPaste } = this.props;\n if (onPaste) onPaste(e, text);\n const subtexts = text.split(this.delimiterMatcher);\n const texts = subtexts.filter((subtext) => subtext.length);\n\n if (texts.length > 1) {\n this.spawnNewTokens(texts);\n e.preventDefault();\n }\n };\n\n handleClickToken = (\n e: React.MouseEvent<Element, MouseEvent>,\n token: TypeTokenSpec\n ) => {\n const { onClickToken, disabled } = this.props;\n if (onClickToken) onClickToken(e, token.id);\n\n if (!disabled) {\n this.deleteToken(token.id);\n }\n };\n\n renderToken(token: TypeTokenSpec): React.ReactNode {\n const { iconName: defaultIconName, disabled } = this.props;\n const activeId = this.state.activeToken;\n const {\n id,\n iconName: tokenIconName,\n iconProps = { \"aria-hidden\": true },\n value,\n valid,\n hasWarning,\n tokenProps: { onClick, ...restTokenProps } = {},\n } = token;\n const iconName = tokenIconName || defaultIconName;\n const isActive = activeId === id;\n return (\n <Token\n id={id}\n onClick={(e) => {\n this.handleClickToken(e, token);\n onClick?.(e);\n }}\n valid={valid}\n hasWarning={hasWarning}\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n active={isActive}\n disabled={disabled}\n {...restTokenProps}\n >\n <Box display=\"flex\" alignItems=\"center\">\n {iconName && (\n <Icon name={iconName} size=\"mini\" pr={300} {...iconProps} />\n )}\n {value}\n </Box>\n </Token>\n );\n }\n\n renderTokens(tokens: TypeTokenSpec[]): React.ReactNode {\n return tokens.map<React.ReactNode>((token) => (\n <div key={token.id} className=\"TokenInput-token\">\n {this.renderToken(token)}\n </div>\n ));\n }\n\n override render() {\n const {\n autoFocus,\n autocomplete,\n disabled,\n isInvalid,\n hasWarning,\n id,\n name,\n placeholder,\n required,\n elemBefore,\n elemAfter,\n maxLength,\n ariaDescribedby,\n ariaLabel,\n innerRef,\n // These functions are used in the class functions above, but need to be extracted in order for `rest` to be correct\n /* eslint-disable @typescript-eslint/no-unused-vars */\n value,\n onAddToken,\n onRemoveToken,\n onChangeTokens,\n onClickToken,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onPaste,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n inputProps = {},\n qa = {},\n tokens,\n ...rest\n } = this.props;\n const { state } = this;\n return (\n <Container\n hasBeforeElement={!!elemBefore}\n hasAfterElement={!!elemAfter}\n disabled={disabled}\n invalid={!!isInvalid}\n warning={hasWarning}\n focused={state.hasFocus}\n {...rest}\n >\n {elemBefore && <Accessory before>{elemBefore}</Accessory>}\n\n {tokens && this.renderTokens(tokens)}\n\n <TokenScreenReaderStatus tokens={tokens} />\n\n <input\n aria-describedby={ariaDescribedby}\n aria-invalid={!!isInvalid}\n aria-label={ariaLabel}\n autoFocus={autoFocus}\n autoComplete={autocomplete}\n disabled={disabled}\n id={id}\n name={name}\n placeholder={placeholder}\n type=\"text\"\n required={required}\n value={state.value}\n maxLength={maxLength}\n onBlur={this.handleBlur}\n onChange={this.handleChangeText}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n onKeyUp={this.handleKeyUp}\n onPaste={this.handlePaste}\n ref={innerRef}\n data-qa-input={name || \"\"}\n data-qa-input-isdisabled={!!disabled}\n data-qa-input-isrequired={!!required}\n {...qa}\n {...inputProps}\n />\n\n {elemAfter && <Accessory after>{elemAfter}</Accessory>}\n </Container>\n );\n }\n}\n","import styled, { css } from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport type { TypeInputContainerProps } from \"@sproutsocial/seeds-react-input\";\n\ninterface TypeTokenInputContainerProps\n extends Pick<\n TypeInputContainerProps,\n \"hasBeforeElement\" | \"hasAfterElement\" | \"disabled\" | \"invalid\" | \"warning\"\n > {\n focused?: boolean;\n}\n\nconst Container = styled.div<TypeTokenInputContainerProps>`\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n align-content: center;\n cursor: text;\n width: 100%;\n border: 1px solid ${(props) => props.theme.colors.form.border.base};\n border-radius: ${(props) => props.theme.radii[500]};\n margin: 0;\n padding: ${(props) => props.theme.space[300]};\n padding-top: ${(props) => props.theme.space[200]};\n background-color: ${(props) => props.theme.colors.form.background.base};\n color: ${(props) => props.theme.colors.text.body};\n transition: border-color ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in},\n box-shadow ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in};\n ${(props) => props.theme.typography[200]};\n font-family: ${(props) => props.theme.fontFamily};\n font-weight: ${(props) => props.theme.fontWeights.normal};\n appearance: none;\n\n button {\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[200]} 0 0;\n }\n\n input {\n ${(props) => props.theme.typography[200]};\n outline: none;\n border: none;\n flex: 1;\n padding: 0;\n padding-top: ${(props) => props.theme.space[100]};\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[300]} ${(props) => props.theme.space[100]}\n 0;\n color: ${(props) => props.theme.colors.text.body};\n background-color: ${(props) => props.theme.colors.form.background.base};\n /** This matches the height of the token so size does not change as tokens are added */\n min-height: 20px;\n\n &::-webkit-search-cancel-button {\n appearance: none;\n }\n\n /* Explicitly removes double focus ring in environments where box-shadow focus styles have been specified (Seeds). Focus is passed up from the input to the parent container. */\n &:focus {\n box-shadow: none;\n }\n\n /* https://stackoverflow.com/questions/14007655/remove-ie10s-clear-field-x-button-on-certain-inputs */\n &::-ms-clear {\n display: none;\n }\n\n /* Fix for red ring when input is marked required in Firefox */\n &:not(output):not(:focus):-moz-ui-invalid {\n box-shadow: none;\n }\n\n &::placeholder {\n color: ${(props) => props.theme.colors.form.placeholder.base};\n font-style: italic;\n }\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n }\n\n ${(props) =>\n props.hasBeforeElement &&\n css`\n padding-left: 40px;\n `}\n\n ${(props) =>\n props.hasAfterElement &&\n css`\n padding-right: 40px;\n `}\n\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n\n ${(props) =>\n props.focused &&\n css`\n ${focusRing}\n `}\n\n ${(props) =>\n props.invalid &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.error};\n `}\n\n\t${(props) =>\n props.warning &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.warning};\n `}\n\n ${COMMON}\n`;\n\nContainer.displayName = \"TokenInputContainer\";\n\nexport default Container;\n","import uniqueId from \"lodash.uniqueid\";\nimport type { TypeTokenSpec } from \"./\";\n\nexport const asTokenSpec = (text: string): TypeTokenSpec => ({\n id: uniqueId(`${text}-`),\n value: text.trim(),\n});\n\nconst KeyNameToRegExpChar: { [key: string]: string } = {\n Enter: \"\\\\n\",\n};\n\nexport const delimitersAsRegExp = (delimiters: string[] | null | undefined) => {\n if (!delimiters) return /[,\\n]/;\n const chars = delimiters\n .map(\n (key) =>\n KeyNameToRegExpChar[key as keyof typeof KeyNameToRegExpChar] || key\n )\n .join(\"\");\n return RegExp(`[${chars}]`);\n};\n","import React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport type { TypeTokenInputProps } from \"./\";\n\nfunction usePrevious(value: TypeTokenInputProps[\"tokens\"]) {\n const ref = useRef<TypeTokenInputProps[\"tokens\"]>();\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n}\n\nexport const TokenScreenReaderStatus = ({\n tokens,\n}: {\n tokens: TypeTokenInputProps[\"tokens\"];\n}) => {\n const prevTokens = usePrevious(tokens);\n const [tokenStatus, setTokenStatus] = useState(\"\");\n\n // TODO: Use callbacks so consumers can pass localized messaging to the screen reader\n useEffect(() => {\n if (prevTokens && tokens) {\n if (prevTokens.length > tokens.length) {\n setTokenStatus(\n `${\n prevTokens.filter((item) => tokens.indexOf(item) === -1)[0]?.value\n } has been removed`\n );\n }\n\n if (prevTokens.length < tokens.length) {\n setTokenStatus(`${tokens[tokens.length - 1]?.value} has been added.`);\n }\n }\n }, [prevTokens, tokens, tokenStatus]);\n\n return (\n <VisuallyHidden as=\"div\" role=\"status\">\n {tokenStatus}\n </VisuallyHidden>\n );\n};\n","import styled from \"styled-components\";\nimport { visuallyHidden } from \"@sproutsocial/seeds-react-mixins\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nconst StyledVisuallyHidden = styled.span`\n ${visuallyHidden}\n`;\n\nexport type VisuallyHiddenProps = ComponentPropsWithRef<\n typeof StyledVisuallyHidden\n>;\n\n// This wrapper component is needed for react-docgen to work.\n// It has issues with generating docs for the styled component directly.\nexport const VisuallyHidden = (props: VisuallyHiddenProps) => {\n return <StyledVisuallyHidden {...props} />;\n};\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type {\n TypeIconProps,\n TypeIconName,\n} from \"@sproutsocial/seeds-react-icon\";\nimport type { TypeTokenProps } from \"@sproutsocial/seeds-react-token\";\n\nexport interface TypeTokenSpec {\n id: string;\n iconName?: TypeIconName;\n iconProps?: Omit<TypeIconProps, \"name\">;\n value: string;\n valid?: boolean;\n hasWarning?: boolean;\n tokenProps?: Partial<TypeTokenProps>;\n}\n\nexport interface TypeBaseTokenInputProps {\n /** ID of the form element, should match the \"for\" value of the associated label */\n id: string;\n name: string;\n iconName?: TypeIconName;\n\n /** Array of delimiter key names */\n delimiters?: string[];\n\n /** Current input text. Required when controlling the input text */\n value?: string;\n\n /** Current focus state. Required when controlling the focus via onFocus and onBlur */\n hasFocus?: boolean;\n\n /** Id of the currently selected token */\n activeToken?: string;\n\n /** Array of current tokens */\n tokens?: TypeTokenSpec[];\n\n /** Standard control of changing tokens. For fine-grain control use onAddToken and onRemoveToken, instead */\n onChangeTokens?: (tokens: TypeTokenSpec[]) => void;\n\n /** Fine-grained control of adding tokens. Use with onRemoveToken instead of onChangeTokens */\n onAddToken?: (tokenSpec: TypeTokenSpec) => void;\n\n /** Fine-grained control of removing tokens. Use with onAddToken instead of onChangeTokens */\n onRemoveToken?: (tokenId: string) => void;\n\n /** Controls clicking on a token. When absent, clicking a token removes itself */\n onClickToken?(\n e: React.MouseEvent<Element, MouseEvent>,\n tokenId: string\n ): void;\n\n /** Fine-grained control of the input text used to create tokens */\n onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;\n\n /** Fine-grained control of pasted text */\n onPaste?: (e: React.ClipboardEvent<HTMLInputElement>, value: string) => void;\n onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n\n /** Attribute used to associate other elements that describe the Input, like an error */\n ariaDescribedby?: string;\n\n /** Label used to describe the input if not used with an accompanying visual label */\n ariaLabel?: string;\n\n /** Placeholder text for when value is undefined or empty */\n placeholder?: string;\n\n /** Will autofocus the element when mounted to the DOM */\n autoFocus?: boolean;\n\n /** HTML disabled attribute */\n disabled?: boolean;\n\n /** Whether or not the current contents of the input are invalid */\n isInvalid?: boolean;\n\n /** Whether or not the current contents of the input has any warnings */\n hasWarning?: boolean;\n\n /** HTML required attribute */\n required?: boolean;\n\n /** 16x16 element, such as an icon */\n elemBefore?: React.ReactNode;\n\n /** 16x16 element, such as an icon */\n elemAfter?: React.ReactNode;\n\n /** Max input text length */\n maxLength?: number;\n\n /** Max length of the token */\n tokenMaxLength?: number;\n\n /** Props to spread onto the underlying input element */\n inputProps?: React.ComponentPropsWithoutRef<\"input\">;\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLInputElement>;\n qa?: object;\n\n /** Browser autocomplete support */\n autocomplete?: string;\n}\n\nexport interface TypeTokenInputProps\n extends TypeBaseTokenInputProps,\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<\n React.ComponentPropsWithoutRef<\"div\">,\n keyof TypeBaseTokenInputProps | \"color\"\n > {}\n","import TokenInput from \"./TokenInput\";\n\nexport default TokenInput;\nexport { TokenInput };\nexport * from \"./TokenInputTypes\";\n"],"mappings":";AAAA,YAAYA,YAAW;AACvB,SAAS,iBAAiB;AAC1B,OAAO,SAAS;AAChB,OAAO,UAAU;AACjB,OAAO,WAAW;;;ACJlB,OAAO,UAAU,WAAW;AAC5B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAW1B,IAAM,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBASH,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,OAAO,IAAI;AAAA,mBACjD,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA,aAEvC,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,iBAC7B,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,sBAC5B,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,WAAW,IAAI;AAAA,WAC7D,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,IAAI;AAAA,6BACrB,CAAC,UAAU,MAAM,MAAM,SAAS,IAAI;AAAA,QACzD,CAAC,UAAU,MAAM,MAAM,OAAO,OAAO;AAAA,iBAC5B,CAAC,UAAU,MAAM,MAAM,SAAS,IAAI;AAAA,QAC7C,CAAC,UAAU,MAAM,MAAM,OAAO,OAAO;AAAA,IACzC,CAAC,UAAU,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,iBACzB,CAAC,UAAU,MAAM,MAAM,UAAU;AAAA,iBACjC,CAAC,UAAU,MAAM,MAAM,YAAY,MAAM;AAAA;AAAA;AAAA;AAAA,cAI5C,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,QACvC,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA,MAInC,CAAC,UAAU,MAAM,MAAM,WAAW,G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a,MAAM;AAAA,UAEnC,gBAAAA,KAAC,2BAAwB,QAAgB;AAAA,UAEzC,gBAAAA;AAAA,YAAC;AAAA;AAAA,cACC,oBAAkB;AAAA,cAClB,gBAAc,CAAC,CAAC;AAAA,cAChB,cAAY;AAAA,cACZ;AAAA,cACA,cAAc;AAAA,cACd;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,MAAK;AAAA,cACL;AAAA,cACA,OAAO,MAAM;AAAA,cACb;AAAA,cACA,QAAQ,KAAK;AAAA,cACb,UAAU,KAAK;AAAA,cACf,SAAS,KAAK;AAAA,cACd,WAAW,KAAK;AAAA,cAChB,SAAS,KAAK;AAAA,cACd,SAAS,KAAK;AAAA,cACd,KAAK;AAAA,cACL,iBAAe,QAAQ;AAAA,cACvB,4BAA0B,CAAC,CAAC;AAAA,cAC5B,4BAA0B,CAAC,CAAC;AAAA,cAC3B,GAAG;AAAA,cACH,GAAG;AAAA;AAAA,UACN;AAAA,UAEC,aAAa,gBAAAA,KAAC,aAAU,OAAK,MAAE,qBAAU;AAAA;AAAA;AAAA,IAC5C;AAAA,EAEJ;AACF;;;AKpTA,OAAuB;;;ACEvB,IAAO,gBAAQ;","names":["React","props","styled","jsx","jsx"]}
package/dist/index.d.mts CHANGED
@@ -10,6 +10,7 @@ interface TypeTokenSpec {
10
10
  iconProps?: Omit<TypeIconProps, "name">;
11
11
  value: string;
12
12
  valid?: boolean;
13
+ hasWarning?: boolean;
13
14
  tokenProps?: Partial<TypeTokenProps>;
14
15
  }
15
16
  interface TypeBaseTokenInputProps {
@@ -34,7 +35,7 @@ interface TypeBaseTokenInputProps {
34
35
  /** Fine-grained control of removing tokens. Use with onAddToken instead of onChangeTokens */
35
36
  onRemoveToken?: (tokenId: string) => void;
36
37
  /** Controls clicking on a token. When absent, clicking a token removes itself */
37
- onClickToken?: (e: React.MouseEvent<Element, MouseEvent>, tokenId: string) => void;
38
+ onClickToken?(e: React.MouseEvent<Element, MouseEvent>, tokenId: string): void;
38
39
  /** Fine-grained control of the input text used to create tokens */
39
40
  onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;
40
41
  /** Fine-grained control of pasted text */
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ interface TypeTokenSpec {
10
10
  iconProps?: Omit<TypeIconProps, "name">;
11
11
  value: string;
12
12
  valid?: boolean;
13
+ hasWarning?: boolean;
13
14
  tokenProps?: Partial<TypeTokenProps>;
14
15
  }
15
16
  interface TypeBaseTokenInputProps {
@@ -34,7 +35,7 @@ interface TypeBaseTokenInputProps {
34
35
  /** Fine-grained control of removing tokens. Use with onAddToken instead of onChangeTokens */
35
36
  onRemoveToken?: (tokenId: string) => void;
36
37
  /** Controls clicking on a token. When absent, clicking a token removes itself */
37
- onClickToken?: (e: React.MouseEvent<Element, MouseEvent>, tokenId: string) => void;
38
+ onClickToken?(e: React.MouseEvent<Element, MouseEvent>, tokenId: string): void;
38
39
  /** Fine-grained control of the input text used to create tokens */
39
40
  onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;
40
41
  /** Fine-grained control of pasted text */
package/dist/index.js CHANGED
@@ -351,6 +351,7 @@ var TokenInput = class extends React2.Component {
351
351
  iconProps = { "aria-hidden": true },
352
352
  value,
353
353
  valid,
354
+ hasWarning,
354
355
  tokenProps: { onClick, ...restTokenProps } = {}
355
356
  } = token;
356
357
  const iconName = tokenIconName || defaultIconName;
@@ -364,6 +365,7 @@ var TokenInput = class extends React2.Component {
364
365
  onClick?.(e);
365
366
  },
366
367
  valid,
368
+ hasWarning,
367
369
  active: isActive,
368
370
  disabled,
369
371
  ...restTokenProps,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/TokenInput.tsx","../src/styles.ts","../src/util.ts","../src/TokenScreenReaderStatus.tsx","../../seeds-react-visually-hidden/src/VisuallyHidden.tsx","../src/TokenInputTypes.ts"],"sourcesContent":["import TokenInput from \"./TokenInput\";\n\nexport default TokenInput;\nexport { TokenInput };\nexport * from \"./TokenInputTypes\";\n","import * as React from \"react\";\nimport { Accessory } from \"@sproutsocial/seeds-react-input\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Token from \"@sproutsocial/seeds-react-token\";\nimport Container from \"./styles\";\nimport { asTokenSpec, delimitersAsRegExp } from \"./util\";\nimport type { TypeTokenInputProps, TypeTokenSpec } from \"./TokenInputTypes\";\nimport { TokenScreenReaderStatus } from \"./TokenScreenReaderStatus\";\n\ntype TypeState = {\n prevProps: TypeTokenInputProps;\n hasFocus: boolean;\n activeToken: string | null | undefined;\n value: string;\n};\n\nconst DefaultDelimiters = [\",\", \"Enter\"];\nconst ControlledPropNames: (keyof TypeState)[] = [\n \"value\",\n \"hasFocus\",\n \"activeToken\",\n];\n\nexport default class TokenInput extends React.Component<\n TypeTokenInputProps,\n TypeState\n> {\n delimiterMatcher: RegExp;\n\n constructor(props: TypeTokenInputProps) {\n super(props);\n const { hasFocus, activeToken, value, delimiters } = props;\n this.delimiterMatcher = delimitersAsRegExp(delimiters || DefaultDelimiters);\n this.state = {\n prevProps: props,\n hasFocus: hasFocus || false,\n activeToken: activeToken,\n value: value || \"\",\n };\n }\n\n static getDerivedStateFromProps(\n props: Readonly<TypeTokenInputProps>,\n state: TypeState\n ) {\n const { prevProps } = state;\n const modifiedState: Partial<TypeState> = { prevProps: props };\n ControlledPropNames.forEach((propName) => {\n const currentProp = props[propName as keyof TypeTokenInputProps];\n\n // @ts-ignore: TODO - fix state types for prevProps\n if (currentProp !== prevProps[propName]) {\n modifiedState[propName] = currentProp;\n }\n });\n modifiedState.prevProps = props;\n return modifiedState;\n }\n\n isDelimiter(keyName: string) {\n const { delimiters = DefaultDelimiters } = this.props;\n return delimiters.includes(keyName);\n }\n\n spawnNewTokens(texts: string[]) {\n const {\n onAddToken,\n onChangeTokens,\n tokenMaxLength: max = Infinity,\n tokens = [],\n } = this.props;\n const tokenSpecs = texts.map((text) => asTokenSpec(text.slice(0, max)));\n\n if (onAddToken) {\n tokenSpecs.forEach(onAddToken);\n } else if (onChangeTokens) {\n onChangeTokens(tokens.concat(tokenSpecs));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n deleteToken(tokenId?: string) {\n const { onRemoveToken, onChangeTokens, tokens = [] } = this.props;\n const count = tokens.length;\n if (count === 0) return;\n const id = tokenId ?? tokens[count - 1]?.id;\n\n if (onRemoveToken) {\n onRemoveToken(id ? id : \"\");\n } else if (onChangeTokens) {\n onChangeTokens(tokens.filter((tokenSpec) => tokenSpec.id !== id));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n handleChangeText = (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { value } = e.currentTarget;\n const { onChange } = this.props;\n this.setState({\n value,\n });\n onChange?.(e, value);\n };\n\n handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onFocus } = this.props;\n this.setState({\n hasFocus: true,\n });\n onFocus?.(e);\n };\n\n handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onBlur } = this.props;\n if (onBlur) onBlur(e);\n this.setState({\n hasFocus: false,\n });\n };\n\n handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n this.props.onKeyUp?.(e, e.currentTarget.value);\n };\n\n handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyDown } = this.props;\n const { key, currentTarget } = e;\n const text = currentTarget.value;\n if (onKeyDown) onKeyDown(e, text);\n\n // keyPress event runs before change\n // Prevent event from bubbling up and calling change, which can lead to comma in value\n if (this.isDelimiter(key)) {\n if (text) {\n this.spawnNewTokens([text]);\n e.preventDefault();\n }\n } else if (key === \"Backspace\") {\n if (text === \"\") {\n this.deleteToken();\n }\n }\n };\n\n handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n const text = e.clipboardData.getData(\"text\");\n const { onPaste } = this.props;\n if (onPaste) onPaste(e, text);\n const subtexts = text.split(this.delimiterMatcher);\n const texts = subtexts.filter((subtext) => subtext.length);\n\n if (texts.length > 1) {\n this.spawnNewTokens(texts);\n e.preventDefault();\n }\n };\n\n handleClickToken = (\n e: React.MouseEvent<Element, MouseEvent>,\n token: TypeTokenSpec\n ) => {\n const { onClickToken, disabled } = this.props;\n if (onClickToken) onClickToken(e, token.id);\n\n if (!disabled) {\n this.deleteToken(token.id);\n }\n };\n\n renderToken(token: TypeTokenSpec): React.ReactNode {\n const { iconName: defaultIconName, disabled } = this.props;\n const activeId = this.state.activeToken;\n const {\n id,\n iconName: tokenIconName,\n iconProps = { \"aria-hidden\": true },\n value,\n valid,\n tokenProps: { onClick, ...restTokenProps } = {},\n } = token;\n const iconName = tokenIconName || defaultIconName;\n const isActive = activeId === id;\n return (\n <Token\n id={id}\n onClick={(e) => {\n this.handleClickToken(e, token);\n onClick?.(e);\n }}\n valid={valid}\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n active={isActive}\n disabled={disabled}\n {...restTokenProps}\n >\n <Box display=\"flex\" alignItems=\"center\">\n {iconName && (\n <Icon name={iconName} size=\"mini\" pr={300} {...iconProps} />\n )}\n {value}\n </Box>\n </Token>\n );\n }\n\n renderTokens(tokens: TypeTokenSpec[]): React.ReactNode {\n return tokens.map<React.ReactNode>((token) => (\n <div key={token.id} className=\"TokenInput-token\">\n {this.renderToken(token)}\n </div>\n ));\n }\n\n override render() {\n const {\n autoFocus,\n autocomplete,\n disabled,\n isInvalid,\n hasWarning,\n id,\n name,\n placeholder,\n required,\n elemBefore,\n elemAfter,\n maxLength,\n ariaDescribedby,\n ariaLabel,\n innerRef,\n // These functions are used in the class functions above, but need to be extracted in order for `rest` to be correct\n /* eslint-disable @typescript-eslint/no-unused-vars */\n value,\n onAddToken,\n onRemoveToken,\n onChangeTokens,\n onClickToken,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onPaste,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n inputProps = {},\n qa = {},\n tokens,\n ...rest\n } = this.props;\n const { state } = this;\n return (\n <Container\n hasBeforeElement={!!elemBefore}\n hasAfterElement={!!elemAfter}\n disabled={disabled}\n invalid={!!isInvalid}\n warning={hasWarning}\n focused={state.hasFocus}\n {...rest}\n >\n {elemBefore && <Accessory before>{elemBefore}</Accessory>}\n\n {tokens && this.renderTokens(tokens)}\n\n <TokenScreenReaderStatus tokens={tokens} />\n\n <input\n aria-describedby={ariaDescribedby}\n aria-invalid={!!isInvalid}\n aria-label={ariaLabel}\n autoFocus={autoFocus}\n autoComplete={autocomplete}\n disabled={disabled}\n id={id}\n name={name}\n placeholder={placeholder}\n type=\"text\"\n required={required}\n value={state.value}\n maxLength={maxLength}\n onBlur={this.handleBlur}\n onChange={this.handleChangeText}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n onKeyUp={this.handleKeyUp}\n onPaste={this.handlePaste}\n ref={innerRef}\n data-qa-input={name || \"\"}\n data-qa-input-isdisabled={!!disabled}\n data-qa-input-isrequired={!!required}\n {...qa}\n {...inputProps}\n />\n\n {elemAfter && <Accessory after>{elemAfter}</Accessory>}\n </Container>\n );\n }\n}\n","import styled, { css } from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport type { TypeInputContainerProps } from \"@sproutsocial/seeds-react-input\";\n\ninterface TypeTokenInputContainerProps\n extends Pick<\n TypeInputContainerProps,\n \"hasBeforeElement\" | \"hasAfterElement\" | \"disabled\" | \"invalid\" | \"warning\"\n > {\n focused?: boolean;\n}\n\nconst Container = styled.div<TypeTokenInputContainerProps>`\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n align-content: center;\n cursor: text;\n width: 100%;\n border: 1px solid ${(props) => props.theme.colors.form.border.base};\n border-radius: ${(props) => props.theme.radii[500]};\n margin: 0;\n padding: ${(props) => props.theme.space[300]};\n padding-top: ${(props) => props.theme.space[200]};\n background-color: ${(props) => props.theme.colors.form.background.base};\n color: ${(props) => props.theme.colors.text.body};\n transition: border-color ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in},\n box-shadow ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in};\n ${(props) => props.theme.typography[200]};\n font-family: ${(props) => props.theme.fontFamily};\n font-weight: ${(props) => props.theme.fontWeights.normal};\n appearance: none;\n\n button {\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[200]} 0 0;\n }\n\n input {\n ${(props) => props.theme.typography[200]};\n outline: none;\n border: none;\n flex: 1;\n padding: 0;\n padding-top: ${(props) => props.theme.space[100]};\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[300]} ${(props) => props.theme.space[100]}\n 0;\n color: ${(props) => props.theme.colors.text.body};\n background-color: ${(props) => props.theme.colors.form.background.base};\n /** This matches the height of the token so size does not change as tokens are added */\n min-height: 20px;\n\n &::-webkit-search-cancel-button {\n appearance: none;\n }\n\n /* Explicitly removes double focus ring in environments where box-shadow focus styles have been specified (Seeds). Focus is passed up from the input to the parent container. */\n &:focus {\n box-shadow: none;\n }\n\n /* https://stackoverflow.com/questions/14007655/remove-ie10s-clear-field-x-button-on-certain-inputs */\n &::-ms-clear {\n display: none;\n }\n\n /* Fix for red ring when input is marked required in Firefox */\n &:not(output):not(:focus):-moz-ui-invalid {\n box-shadow: none;\n }\n\n &::placeholder {\n color: ${(props) => props.theme.colors.form.placeholder.base};\n font-style: italic;\n }\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n }\n\n ${(props) =>\n props.hasBeforeElement &&\n css`\n padding-left: 40px;\n `}\n\n ${(props) =>\n props.hasAfterElement &&\n css`\n padding-right: 40px;\n `}\n\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n\n ${(props) =>\n props.focused &&\n css`\n ${focusRing}\n `}\n\n ${(props) =>\n props.invalid &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.error};\n `}\n\n\t${(props) =>\n props.warning &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.warning};\n `}\n\n ${COMMON}\n`;\n\nContainer.displayName = \"TokenInputContainer\";\n\nexport default Container;\n","import uniqueId from \"lodash.uniqueid\";\nimport type { TypeTokenSpec } from \"./\";\n\nexport const asTokenSpec = (text: string): TypeTokenSpec => ({\n id: uniqueId(`${text}-`),\n value: text.trim(),\n});\n\nconst KeyNameToRegExpChar: { [key: string]: string } = {\n Enter: \"\\\\n\",\n};\n\nexport const delimitersAsRegExp = (delimiters: string[] | null | undefined) => {\n if (!delimiters) return /[,\\n]/;\n const chars = delimiters\n .map(\n (key) =>\n KeyNameToRegExpChar[key as keyof typeof KeyNameToRegExpChar] || key\n )\n .join(\"\");\n return RegExp(`[${chars}]`);\n};\n","import React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport type { TypeTokenInputProps } from \"./\";\n\nfunction usePrevious(value: TypeTokenInputProps[\"tokens\"]) {\n const ref = useRef<TypeTokenInputProps[\"tokens\"]>();\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n}\n\nexport const TokenScreenReaderStatus = ({\n tokens,\n}: {\n tokens: TypeTokenInputProps[\"tokens\"];\n}) => {\n const prevTokens = usePrevious(tokens);\n const [tokenStatus, setTokenStatus] = useState(\"\");\n\n // TODO: Use callbacks so consumers can pass localized messaging to the screen reader\n useEffect(() => {\n if (prevTokens && tokens) {\n if (prevTokens.length > tokens.length) {\n setTokenStatus(\n `${\n prevTokens.filter((item) => tokens.indexOf(item) === -1)[0]?.value\n } has been removed`\n );\n }\n\n if (prevTokens.length < tokens.length) {\n setTokenStatus(`${tokens[tokens.length - 1]?.value} has been added.`);\n }\n }\n }, [prevTokens, tokens, tokenStatus]);\n\n return (\n <VisuallyHidden as=\"div\" role=\"status\">\n {tokenStatus}\n </VisuallyHidden>\n );\n};\n","import styled from \"styled-components\";\nimport { visuallyHidden } from \"@sproutsocial/seeds-react-mixins\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nconst StyledVisuallyHidden = styled.span`\n ${visuallyHidden}\n`;\n\nexport type VisuallyHiddenProps = ComponentPropsWithRef<\n typeof StyledVisuallyHidden\n>;\n\n// This wrapper component is needed for react-docgen to work.\n// It has issues with generating docs for the styled component directly.\nexport const VisuallyHidden = (props: VisuallyHiddenProps) => {\n return <StyledVisuallyHidden {...props} />;\n};\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type {\n TypeIconProps,\n TypeIconName,\n} from \"@sproutsocial/seeds-react-icon\";\nimport type { TypeTokenProps } from \"@sproutsocial/seeds-react-token\";\n\nexport interface TypeTokenSpec {\n id: string;\n iconName?: TypeIconName;\n iconProps?: Omit<TypeIconProps, \"name\">;\n value: string;\n valid?: boolean;\n tokenProps?: Partial<TypeTokenProps>;\n}\n\nexport interface TypeBaseTokenInputProps {\n /** ID of the form element, should match the \"for\" value of the associated label */\n id: string;\n name: string;\n iconName?: TypeIconName;\n\n /** Array of delimiter key names */\n delimiters?: string[];\n\n /** Current input text. Required when controlling the input text */\n value?: string;\n\n /** Current focus state. Required when controlling the focus via onFocus and onBlur */\n hasFocus?: boolean;\n\n /** Id of the currently selected token */\n activeToken?: string;\n\n /** Array of current tokens */\n tokens?: TypeTokenSpec[];\n\n /** Standard control of changing tokens. For fine-grain control use onAddToken and onRemoveToken, instead */\n onChangeTokens?: (tokens: TypeTokenSpec[]) => void;\n\n /** Fine-grained control of adding tokens. Use with onRemoveToken instead of onChangeTokens */\n onAddToken?: (tokenSpec: TypeTokenSpec) => void;\n\n /** Fine-grained control of removing tokens. Use with onAddToken instead of onChangeTokens */\n onRemoveToken?: (tokenId: string) => void;\n\n /** Controls clicking on a token. When absent, clicking a token removes itself */\n onClickToken?: (\n e: React.MouseEvent<Element, MouseEvent>,\n tokenId: string\n ) => void;\n\n /** Fine-grained control of the input text used to create tokens */\n onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;\n\n /** Fine-grained control of pasted text */\n onPaste?: (e: React.ClipboardEvent<HTMLInputElement>, value: string) => void;\n onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n\n /** Attribute used to associate other elements that describe the Input, like an error */\n ariaDescribedby?: string;\n\n /** Label used to describe the input if not used with an accompanying visual label */\n ariaLabel?: string;\n\n /** Placeholder text for when value is undefined or empty */\n placeholder?: string;\n\n /** Will autofocus the element when mounted to the DOM */\n autoFocus?: boolean;\n\n /** HTML disabled attribute */\n disabled?: boolean;\n\n /** Whether or not the current contents of the input are invalid */\n isInvalid?: boolean;\n\n /** Whether or not the current contents of the input has any warnings */\n hasWarning?: boolean;\n\n /** HTML required attribute */\n required?: boolean;\n\n /** 16x16 element, such as an icon */\n elemBefore?: React.ReactNode;\n\n /** 16x16 element, such as an icon */\n elemAfter?: React.ReactNode;\n\n /** Max input text length */\n maxLength?: number;\n\n /** Max length of the token */\n tokenMaxLength?: number;\n\n /** Props to spread onto the underlying input element */\n inputProps?: React.ComponentPropsWithoutRef<\"input\">;\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLInputElement>;\n qa?: object;\n\n /** Browser autocomplete support */\n autocomplete?: string;\n}\n\nexport interface TypeTokenInputProps\n extends TypeBaseTokenInputProps,\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<\n React.ComponentPropsWithoutRef<\"div\">,\n keyof TypeBaseTokenInputProps | \"color\"\n > {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;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ACZ;AAAA,cACA,cAAc;AAAA,cACd;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,MAAK;AAAA,cACL;AAAA,cACA,OAAO,MAAM;AAAA,cACb;AAAA,cACA,QAAQ,KAAK;AAAA,cACb,UAAU,KAAK;AAAA,cACf,SAAS,KAAK;AAAA,cACd,WAAW,KAAK;AAAA,cAChB,SAAS,KAAK;AAAA,cACd,SAAS,KAAK;AAAA,cACd,KAAK;AAAA,cACL,iBAAe,QAAQ;AAAA,cACvB,4BAA0B,CAAC,CAAC;AAAA,cAC5B,4BAA0B,CAAC,CAAC;AAAA,cAC3B,GAAG;AAAA,cACH,GAAG;AAAA;AAAA,UACN;AAAA,UAEC,aAAa,6CAAC,sCAAU,OAAK,MAAE,qBAAU;AAAA;AAAA;AAAA,IAC5C;AAAA,EAEJ;AACF;;;AKlTA,IAAAC,SAAuB;;;ANEvB,IAAO,gBAAQ;","names":["React","styled","props","uniqueId","import_react","import_styled_components","import_seeds_react_mixins","styled","import_jsx_runtime","import_jsx_runtime","Token","Box","Icon","React"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/TokenInput.tsx","../src/styles.ts","../src/util.ts","../src/TokenScreenReaderStatus.tsx","../../seeds-react-visually-hidden/src/VisuallyHidden.tsx","../src/TokenInputTypes.ts"],"sourcesContent":["import TokenInput from \"./TokenInput\";\n\nexport default TokenInput;\nexport { TokenInput };\nexport * from \"./TokenInputTypes\";\n","import * as React from \"react\";\nimport { Accessory } from \"@sproutsocial/seeds-react-input\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Token from \"@sproutsocial/seeds-react-token\";\nimport Container from \"./styles\";\nimport { asTokenSpec, delimitersAsRegExp } from \"./util\";\nimport type { TypeTokenInputProps, TypeTokenSpec } from \"./TokenInputTypes\";\nimport { TokenScreenReaderStatus } from \"./TokenScreenReaderStatus\";\n\ntype TypeState = {\n prevProps: TypeTokenInputProps;\n hasFocus: boolean;\n activeToken: string | null | undefined;\n value: string;\n};\n\nconst DefaultDelimiters = [\",\", \"Enter\"];\nconst ControlledPropNames: (keyof TypeState)[] = [\n \"value\",\n \"hasFocus\",\n \"activeToken\",\n];\n\nexport default class TokenInput extends React.Component<\n TypeTokenInputProps,\n TypeState\n> {\n delimiterMatcher: RegExp;\n\n constructor(props: TypeTokenInputProps) {\n super(props);\n const { hasFocus, activeToken, value, delimiters } = props;\n this.delimiterMatcher = delimitersAsRegExp(delimiters || DefaultDelimiters);\n this.state = {\n prevProps: props,\n hasFocus: hasFocus || false,\n activeToken: activeToken,\n value: value || \"\",\n };\n }\n\n static getDerivedStateFromProps(\n props: Readonly<TypeTokenInputProps>,\n state: TypeState\n ) {\n const { prevProps } = state;\n const modifiedState: Partial<TypeState> = { prevProps: props };\n ControlledPropNames.forEach((propName) => {\n const currentProp = props[propName as keyof TypeTokenInputProps];\n\n // @ts-ignore: TODO - fix state types for prevProps\n if (currentProp !== prevProps[propName]) {\n modifiedState[propName] = currentProp;\n }\n });\n modifiedState.prevProps = props;\n return modifiedState;\n }\n\n isDelimiter(keyName: string) {\n const { delimiters = DefaultDelimiters } = this.props;\n return delimiters.includes(keyName);\n }\n\n spawnNewTokens(texts: string[]) {\n const {\n onAddToken,\n onChangeTokens,\n tokenMaxLength: max = Infinity,\n tokens = [],\n } = this.props;\n const tokenSpecs = texts.map((text) => asTokenSpec(text.slice(0, max)));\n\n if (onAddToken) {\n tokenSpecs.forEach(onAddToken);\n } else if (onChangeTokens) {\n onChangeTokens(tokens.concat(tokenSpecs));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n deleteToken(tokenId?: string) {\n const { onRemoveToken, onChangeTokens, tokens = [] } = this.props;\n const count = tokens.length;\n if (count === 0) return;\n const id = tokenId ?? tokens[count - 1]?.id;\n\n if (onRemoveToken) {\n onRemoveToken(id ? id : \"\");\n } else if (onChangeTokens) {\n onChangeTokens(tokens.filter((tokenSpec) => tokenSpec.id !== id));\n }\n\n this.setState({\n value: \"\",\n });\n }\n\n handleChangeText = (e: React.SyntheticEvent<HTMLInputElement>) => {\n const { value } = e.currentTarget;\n const { onChange } = this.props;\n this.setState({\n value,\n });\n onChange?.(e, value);\n };\n\n handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onFocus } = this.props;\n this.setState({\n hasFocus: true,\n });\n onFocus?.(e);\n };\n\n handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n const { onBlur } = this.props;\n if (onBlur) onBlur(e);\n this.setState({\n hasFocus: false,\n });\n };\n\n handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {\n this.props.onKeyUp?.(e, e.currentTarget.value);\n };\n\n handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n const { onKeyDown } = this.props;\n const { key, currentTarget } = e;\n const text = currentTarget.value;\n if (onKeyDown) onKeyDown(e, text);\n\n // keyPress event runs before change\n // Prevent event from bubbling up and calling change, which can lead to comma in value\n if (this.isDelimiter(key)) {\n if (text) {\n this.spawnNewTokens([text]);\n e.preventDefault();\n }\n } else if (key === \"Backspace\") {\n if (text === \"\") {\n this.deleteToken();\n }\n }\n };\n\n handlePaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n const text = e.clipboardData.getData(\"text\");\n const { onPaste } = this.props;\n if (onPaste) onPaste(e, text);\n const subtexts = text.split(this.delimiterMatcher);\n const texts = subtexts.filter((subtext) => subtext.length);\n\n if (texts.length > 1) {\n this.spawnNewTokens(texts);\n e.preventDefault();\n }\n };\n\n handleClickToken = (\n e: React.MouseEvent<Element, MouseEvent>,\n token: TypeTokenSpec\n ) => {\n const { onClickToken, disabled } = this.props;\n if (onClickToken) onClickToken(e, token.id);\n\n if (!disabled) {\n this.deleteToken(token.id);\n }\n };\n\n renderToken(token: TypeTokenSpec): React.ReactNode {\n const { iconName: defaultIconName, disabled } = this.props;\n const activeId = this.state.activeToken;\n const {\n id,\n iconName: tokenIconName,\n iconProps = { \"aria-hidden\": true },\n value,\n valid,\n hasWarning,\n tokenProps: { onClick, ...restTokenProps } = {},\n } = token;\n const iconName = tokenIconName || defaultIconName;\n const isActive = activeId === id;\n return (\n <Token\n id={id}\n onClick={(e) => {\n this.handleClickToken(e, token);\n onClick?.(e);\n }}\n valid={valid}\n hasWarning={hasWarning}\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n active={isActive}\n disabled={disabled}\n {...restTokenProps}\n >\n <Box display=\"flex\" alignItems=\"center\">\n {iconName && (\n <Icon name={iconName} size=\"mini\" pr={300} {...iconProps} />\n )}\n {value}\n </Box>\n </Token>\n );\n }\n\n renderTokens(tokens: TypeTokenSpec[]): React.ReactNode {\n return tokens.map<React.ReactNode>((token) => (\n <div key={token.id} className=\"TokenInput-token\">\n {this.renderToken(token)}\n </div>\n ));\n }\n\n override render() {\n const {\n autoFocus,\n autocomplete,\n disabled,\n isInvalid,\n hasWarning,\n id,\n name,\n placeholder,\n required,\n elemBefore,\n elemAfter,\n maxLength,\n ariaDescribedby,\n ariaLabel,\n innerRef,\n // These functions are used in the class functions above, but need to be extracted in order for `rest` to be correct\n /* eslint-disable @typescript-eslint/no-unused-vars */\n value,\n onAddToken,\n onRemoveToken,\n onChangeTokens,\n onClickToken,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n onPaste,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n inputProps = {},\n qa = {},\n tokens,\n ...rest\n } = this.props;\n const { state } = this;\n return (\n <Container\n hasBeforeElement={!!elemBefore}\n hasAfterElement={!!elemAfter}\n disabled={disabled}\n invalid={!!isInvalid}\n warning={hasWarning}\n focused={state.hasFocus}\n {...rest}\n >\n {elemBefore && <Accessory before>{elemBefore}</Accessory>}\n\n {tokens && this.renderTokens(tokens)}\n\n <TokenScreenReaderStatus tokens={tokens} />\n\n <input\n aria-describedby={ariaDescribedby}\n aria-invalid={!!isInvalid}\n aria-label={ariaLabel}\n autoFocus={autoFocus}\n autoComplete={autocomplete}\n disabled={disabled}\n id={id}\n name={name}\n placeholder={placeholder}\n type=\"text\"\n required={required}\n value={state.value}\n maxLength={maxLength}\n onBlur={this.handleBlur}\n onChange={this.handleChangeText}\n onFocus={this.handleFocus}\n onKeyDown={this.handleKeyDown}\n onKeyUp={this.handleKeyUp}\n onPaste={this.handlePaste}\n ref={innerRef}\n data-qa-input={name || \"\"}\n data-qa-input-isdisabled={!!disabled}\n data-qa-input-isrequired={!!required}\n {...qa}\n {...inputProps}\n />\n\n {elemAfter && <Accessory after>{elemAfter}</Accessory>}\n </Container>\n );\n }\n}\n","import styled, { css } from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport type { TypeInputContainerProps } from \"@sproutsocial/seeds-react-input\";\n\ninterface TypeTokenInputContainerProps\n extends Pick<\n TypeInputContainerProps,\n \"hasBeforeElement\" | \"hasAfterElement\" | \"disabled\" | \"invalid\" | \"warning\"\n > {\n focused?: boolean;\n}\n\nconst Container = styled.div<TypeTokenInputContainerProps>`\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n align-content: center;\n cursor: text;\n width: 100%;\n border: 1px solid ${(props) => props.theme.colors.form.border.base};\n border-radius: ${(props) => props.theme.radii[500]};\n margin: 0;\n padding: ${(props) => props.theme.space[300]};\n padding-top: ${(props) => props.theme.space[200]};\n background-color: ${(props) => props.theme.colors.form.background.base};\n color: ${(props) => props.theme.colors.text.body};\n transition: border-color ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in},\n box-shadow ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in};\n ${(props) => props.theme.typography[200]};\n font-family: ${(props) => props.theme.fontFamily};\n font-weight: ${(props) => props.theme.fontWeights.normal};\n appearance: none;\n\n button {\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[200]} 0 0;\n }\n\n input {\n ${(props) => props.theme.typography[200]};\n outline: none;\n border: none;\n flex: 1;\n padding: 0;\n padding-top: ${(props) => props.theme.space[100]};\n margin: ${(props) => props.theme.space[200]}\n ${(props) => props.theme.space[300]} ${(props) => props.theme.space[100]}\n 0;\n color: ${(props) => props.theme.colors.text.body};\n background-color: ${(props) => props.theme.colors.form.background.base};\n /** This matches the height of the token so size does not change as tokens are added */\n min-height: 20px;\n\n &::-webkit-search-cancel-button {\n appearance: none;\n }\n\n /* Explicitly removes double focus ring in environments where box-shadow focus styles have been specified (Seeds). Focus is passed up from the input to the parent container. */\n &:focus {\n box-shadow: none;\n }\n\n /* https://stackoverflow.com/questions/14007655/remove-ie10s-clear-field-x-button-on-certain-inputs */\n &::-ms-clear {\n display: none;\n }\n\n /* Fix for red ring when input is marked required in Firefox */\n &:not(output):not(:focus):-moz-ui-invalid {\n box-shadow: none;\n }\n\n &::placeholder {\n color: ${(props) => props.theme.colors.form.placeholder.base};\n font-style: italic;\n }\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n }\n\n ${(props) =>\n props.hasBeforeElement &&\n css`\n padding-left: 40px;\n `}\n\n ${(props) =>\n props.hasAfterElement &&\n css`\n padding-right: 40px;\n `}\n\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n cursor: not-allowed;\n `}\n\n ${(props) =>\n props.focused &&\n css`\n ${focusRing}\n `}\n\n ${(props) =>\n props.invalid &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.error};\n `}\n\n\t${(props) =>\n props.warning &&\n css`\n border-color: ${(props) => props.theme.colors.form.border.warning};\n `}\n\n ${COMMON}\n`;\n\nContainer.displayName = \"TokenInputContainer\";\n\nexport default Container;\n","import uniqueId from \"lodash.uniqueid\";\nimport type { TypeTokenSpec } from \"./\";\n\nexport const asTokenSpec = (text: string): TypeTokenSpec => ({\n id: uniqueId(`${text}-`),\n value: text.trim(),\n});\n\nconst KeyNameToRegExpChar: { [key: string]: string } = {\n Enter: \"\\\\n\",\n};\n\nexport const delimitersAsRegExp = (delimiters: string[] | null | undefined) => {\n if (!delimiters) return /[,\\n]/;\n const chars = delimiters\n .map(\n (key) =>\n KeyNameToRegExpChar[key as keyof typeof KeyNameToRegExpChar] || key\n )\n .join(\"\");\n return RegExp(`[${chars}]`);\n};\n","import React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { VisuallyHidden } from \"@sproutsocial/seeds-react-visually-hidden\";\nimport type { TypeTokenInputProps } from \"./\";\n\nfunction usePrevious(value: TypeTokenInputProps[\"tokens\"]) {\n const ref = useRef<TypeTokenInputProps[\"tokens\"]>();\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n}\n\nexport const TokenScreenReaderStatus = ({\n tokens,\n}: {\n tokens: TypeTokenInputProps[\"tokens\"];\n}) => {\n const prevTokens = usePrevious(tokens);\n const [tokenStatus, setTokenStatus] = useState(\"\");\n\n // TODO: Use callbacks so consumers can pass localized messaging to the screen reader\n useEffect(() => {\n if (prevTokens && tokens) {\n if (prevTokens.length > tokens.length) {\n setTokenStatus(\n `${\n prevTokens.filter((item) => tokens.indexOf(item) === -1)[0]?.value\n } has been removed`\n );\n }\n\n if (prevTokens.length < tokens.length) {\n setTokenStatus(`${tokens[tokens.length - 1]?.value} has been added.`);\n }\n }\n }, [prevTokens, tokens, tokenStatus]);\n\n return (\n <VisuallyHidden as=\"div\" role=\"status\">\n {tokenStatus}\n </VisuallyHidden>\n );\n};\n","import styled from \"styled-components\";\nimport { visuallyHidden } from \"@sproutsocial/seeds-react-mixins\";\nimport type { ComponentPropsWithRef } from \"react\";\n\nconst StyledVisuallyHidden = styled.span`\n ${visuallyHidden}\n`;\n\nexport type VisuallyHiddenProps = ComponentPropsWithRef<\n typeof StyledVisuallyHidden\n>;\n\n// This wrapper component is needed for react-docgen to work.\n// It has issues with generating docs for the styled component directly.\nexport const VisuallyHidden = (props: VisuallyHiddenProps) => {\n return <StyledVisuallyHidden {...props} />;\n};\n","import * as React from \"react\";\nimport type {\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\nimport type {\n TypeIconProps,\n TypeIconName,\n} from \"@sproutsocial/seeds-react-icon\";\nimport type { TypeTokenProps } from \"@sproutsocial/seeds-react-token\";\n\nexport interface TypeTokenSpec {\n id: string;\n iconName?: TypeIconName;\n iconProps?: Omit<TypeIconProps, \"name\">;\n value: string;\n valid?: boolean;\n hasWarning?: boolean;\n tokenProps?: Partial<TypeTokenProps>;\n}\n\nexport interface TypeBaseTokenInputProps {\n /** ID of the form element, should match the \"for\" value of the associated label */\n id: string;\n name: string;\n iconName?: TypeIconName;\n\n /** Array of delimiter key names */\n delimiters?: string[];\n\n /** Current input text. Required when controlling the input text */\n value?: string;\n\n /** Current focus state. Required when controlling the focus via onFocus and onBlur */\n hasFocus?: boolean;\n\n /** Id of the currently selected token */\n activeToken?: string;\n\n /** Array of current tokens */\n tokens?: TypeTokenSpec[];\n\n /** Standard control of changing tokens. For fine-grain control use onAddToken and onRemoveToken, instead */\n onChangeTokens?: (tokens: TypeTokenSpec[]) => void;\n\n /** Fine-grained control of adding tokens. Use with onRemoveToken instead of onChangeTokens */\n onAddToken?: (tokenSpec: TypeTokenSpec) => void;\n\n /** Fine-grained control of removing tokens. Use with onAddToken instead of onChangeTokens */\n onRemoveToken?: (tokenId: string) => void;\n\n /** Controls clicking on a token. When absent, clicking a token removes itself */\n onClickToken?(\n e: React.MouseEvent<Element, MouseEvent>,\n tokenId: string\n ): void;\n\n /** Fine-grained control of the input text used to create tokens */\n onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;\n\n /** Fine-grained control of pasted text */\n onPaste?: (e: React.ClipboardEvent<HTMLInputElement>, value: string) => void;\n onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;\n\n /** Attribute used to associate other elements that describe the Input, like an error */\n ariaDescribedby?: string;\n\n /** Label used to describe the input if not used with an accompanying visual label */\n ariaLabel?: string;\n\n /** Placeholder text for when value is undefined or empty */\n placeholder?: string;\n\n /** Will autofocus the element when mounted to the DOM */\n autoFocus?: boolean;\n\n /** HTML disabled attribute */\n disabled?: boolean;\n\n /** Whether or not the current contents of the input are invalid */\n isInvalid?: boolean;\n\n /** Whether or not the current contents of the input has any warnings */\n hasWarning?: boolean;\n\n /** HTML required attribute */\n required?: boolean;\n\n /** 16x16 element, such as an icon */\n elemBefore?: React.ReactNode;\n\n /** 16x16 element, such as an icon */\n elemAfter?: React.ReactNode;\n\n /** Max input text length */\n maxLength?: number;\n\n /** Max length of the token */\n tokenMaxLength?: number;\n\n /** Props to spread onto the underlying input element */\n inputProps?: React.ComponentPropsWithoutRef<\"input\">;\n\n /** Used to get a reference to the underlying element */\n innerRef?: React.Ref<HTMLInputElement>;\n qa?: object;\n\n /** Browser autocomplete support */\n autocomplete?: string;\n}\n\nexport interface TypeTokenInputProps\n extends TypeBaseTokenInputProps,\n TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<\n React.ComponentPropsWithoutRef<\"div\">,\n keyof TypeBaseTokenInputProps | \"color\"\n > {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;AACvB,+BAA0B;AAC1B,6BAAgB;AAChB,8BAAiB;AACjB,+BAAkB;;;ACJlB,+BAA4B;AAC5B,sCAAuB;AACvB,gCAA0B;AAW1B,IAAM,YAAY,yBAAAC,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBASH,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,OAAO,IAAI;AAAA,mBACjD,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA;AAAA,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ACvB,4BAA0B,CAAC,CAAC;AAAA,cAC5B,4BAA0B,CAAC,CAAC;AAAA,cAC3B,GAAG;AAAA,cACH,GAAG;AAAA;AAAA,UACN;AAAA,UAEC,aAAa,6CAAC,sCAAU,OAAK,MAAE,qBAAU;AAAA;AAAA;AAAA,IAC5C;AAAA,EAEJ;AACF;;;AKpTA,IAAAC,SAAuB;;;ANEvB,IAAO,gBAAQ;","names":["React","styled","props","uniqueId","import_react","import_styled_components","import_seeds_react_mixins","styled","import_jsx_runtime","import_jsx_runtime","Token","Box","Icon","React"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sproutsocial/seeds-react-token-input",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "Seeds React TokenInput",
5
5
  "author": "Sprout Social, Inc.",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "@sproutsocial/seeds-react-input": "^1.3.1",
25
25
  "@sproutsocial/seeds-react-box": "^1.1.1",
26
26
  "@sproutsocial/seeds-react-icon": "^1.1.1",
27
- "@sproutsocial/seeds-react-token": "^1.0.2",
27
+ "@sproutsocial/seeds-react-token": "^1.1.1",
28
28
  "lodash.uniqueid": "^4.0.1"
29
29
  },
30
30
  "devDependencies": {
@@ -183,6 +183,7 @@ export default class TokenInput extends React.Component<
183
183
  iconProps = { "aria-hidden": true },
184
184
  value,
185
185
  valid,
186
+ hasWarning,
186
187
  tokenProps: { onClick, ...restTokenProps } = {},
187
188
  } = token;
188
189
  const iconName = tokenIconName || defaultIconName;
@@ -195,6 +196,7 @@ export default class TokenInput extends React.Component<
195
196
  onClick?.(e);
196
197
  }}
197
198
  valid={valid}
199
+ hasWarning={hasWarning}
198
200
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
199
201
  // @ts-ignore
200
202
  active={isActive}
@@ -15,6 +15,7 @@ export interface TypeTokenSpec {
15
15
  iconProps?: Omit<TypeIconProps, "name">;
16
16
  value: string;
17
17
  valid?: boolean;
18
+ hasWarning?: boolean;
18
19
  tokenProps?: Partial<TypeTokenProps>;
19
20
  }
20
21
 
@@ -49,10 +50,10 @@ export interface TypeBaseTokenInputProps {
49
50
  onRemoveToken?: (tokenId: string) => void;
50
51
 
51
52
  /** Controls clicking on a token. When absent, clicking a token removes itself */
52
- onClickToken?: (
53
+ onClickToken?(
53
54
  e: React.MouseEvent<Element, MouseEvent>,
54
55
  tokenId: string
55
- ) => void;
56
+ ): void;
56
57
 
57
58
  /** Fine-grained control of the input text used to create tokens */
58
59
  onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;