@bikdotai/bik-component-library 0.0.836 → 0.0.837-beta.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.
- package/dist/cjs/components/agent-builder/AgentBuilder.js +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js +41 -23
- package/dist/cjs/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js +1 -1
- package/dist/cjs/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +1 -1
- package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/DiscardModal.js +1 -1
- package/dist/cjs/components/agent-builder/components/DiscardModal.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/GoLiveModal.js +1 -1
- package/dist/cjs/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/MentionPicker.js +2 -2
- package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js +1 -1
- package/dist/cjs/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js +6 -6
- package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/StepSectionHeader.js +1 -1
- package/dist/cjs/components/agent-builder/components/StepSectionHeader.js.map +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js +1 -1
- package/dist/cjs/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js +3 -1
- package/dist/cjs/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js +1 -1
- package/dist/cjs/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js +5 -3
- package/dist/cjs/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentListing.js +1 -1
- package/dist/cjs/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentTable.js +1 -1
- package/dist/cjs/components/agent-listing/AgentTable.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentTableRow.js +1 -1
- package/dist/cjs/components/agent-listing/AgentTableRow.js.map +1 -1
- package/dist/cjs/components/agent-listing/AgentTableShimmer.js +2 -0
- package/dist/cjs/components/agent-listing/AgentTableShimmer.js.map +1 -0
- package/dist/cjs/components/button/Button.styled.js +1 -0
- package/dist/cjs/components/button/Button.styled.js.map +1 -1
- package/dist/cjs/components/dropdown/Dropdown.js +1 -1
- package/dist/cjs/components/dropdown/Dropdown.js.map +1 -1
- package/dist/cjs/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.js.map +1 -1
- package/dist/cjs/editor/BikEditor.styles.js +74 -42
- package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.js +80 -77
- package/dist/esm/components/agent-builder/AgentBuilder.js.map +1 -1
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +3 -0
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js +106 -84
- package/dist/esm/components/agent-builder/AgentBuilder.styled.js.map +1 -1
- package/dist/esm/components/agent-builder/__fixtures__/agentValue.d.ts +11 -0
- package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js +29 -21
- package/dist/esm/components/agent-builder/components/AgentBuilderFooter.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js +21 -21
- package/dist/esm/components/agent-builder/components/AgentBuilderTopBar.js.map +1 -1
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +24 -23
- package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/DiscardModal.js +15 -8
- package/dist/esm/components/agent-builder/components/DiscardModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/GoLiveModal.js +11 -11
- package/dist/esm/components/agent-builder/components/GoLiveModal.js.map +1 -1
- package/dist/esm/components/agent-builder/components/MentionPicker.js +41 -40
- package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js +22 -21
- package/dist/esm/components/agent-builder/components/RestApiToolPanel.js.map +1 -1
- package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +13 -4
- package/dist/esm/components/agent-builder/components/SelectableListSection.js +167 -144
- package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
- package/dist/esm/components/agent-builder/components/StepSectionHeader.js +7 -7
- package/dist/esm/components/agent-builder/components/StepSectionHeader.js.map +1 -1
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js +104 -103
- package/dist/esm/components/agent-builder/context/AgentBuilderContext.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js +84 -82
- package/dist/esm/components/agent-builder/steps/Step2WhenItStepsIn.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +20 -19
- package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js +23 -79
- package/dist/esm/components/agent-builder/steps/Step4HandoverRules.js.map +1 -1
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js +37 -25
- package/dist/esm/components/agent-builder/utils/mentionSerialization.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentListing.js +70 -65
- package/dist/esm/components/agent-listing/AgentListing.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTable.d.ts +2 -0
- package/dist/esm/components/agent-listing/AgentTable.js +16 -15
- package/dist/esm/components/agent-listing/AgentTable.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTableRow.js +7 -7
- package/dist/esm/components/agent-listing/AgentTableRow.js.map +1 -1
- package/dist/esm/components/agent-listing/AgentTableShimmer.d.ts +12 -0
- package/dist/esm/components/agent-listing/AgentTableShimmer.js +20 -0
- package/dist/esm/components/agent-listing/AgentTableShimmer.js.map +1 -0
- package/dist/esm/components/agent-listing/__fixtures__/agents.d.ts +3 -0
- package/dist/esm/components/button/Button.styled.js +25 -19
- package/dist/esm/components/button/Button.styled.js.map +1 -1
- package/dist/esm/components/dropdown/Dropdown.js +18 -13
- package/dist/esm/components/dropdown/Dropdown.js.map +1 -1
- package/dist/esm/editor/BikEditor.js +173 -160
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.styles.d.ts +20 -3
- package/dist/esm/editor/BikEditor.styles.js +78 -44
- package/dist/esm/editor/BikEditor.styles.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import React, { Ref, useEffect, useRef, useState } from 'react';\nimport { BASE_COLORS, COLORS } from '@src/constants/Theme';\nimport DownIcon from '../../assets/icons/chevronDown.svg';\nimport { Input } from '../input';\nimport { InputStyleContext } from '../input/context/InputStyleProvider';\nimport ChipInput from './ChipInput';\nimport { DropdownPopover } from './DropdownPopover';\nimport { getSelectedOptionsAsText } from './OpenedDropdown/utils/iterationOnOptions';\nimport {\n\tDropdownOption,\n\tGroupedOption,\n\tOpenDropdownProps,\n\tSingleOption,\n} from './type';\n\nexport type DropdownProps = OpenDropdownProps & {\n\tplaceHolder?: string;\n\tsize?: 'default' | 'small' | 'x-small';\n\tdisabled?: boolean;\n\tnoErrorHint?: boolean;\n\tbuttonWidth?: string;\n\tplaceHolderHeight?: string;\n\tshowPlaceholderWhenSelected?: boolean;\n\tinputStyle?: React.CSSProperties;\n\tinputType?: 'chip' | 'default';\n\tonDeleteChip?: (chip: SingleOption) => void;\n\ttruncatedText?: boolean;\n\t'data-test'?: string;\n\tshowLeadingIconInPlaceholder?: boolean;\n\tshowTrailingIconPlaceholder?: boolean;\n\tshowLabelsOnMoreHover?: boolean;\n\tbackgroundColor?: string;\n\tvalue?: string;\n\tshowSelected?: boolean;\n\t/** Fired when the dropdown opens/closes. Runs alongside internal open state. */\n\tonDropdownVisbilityChange?: (isOpen: boolean) => void;\n};\n\nfunction noop() {\n\t/** empty */\n}\n\nexport const Dropdown: React.FC<DropdownProps> = ({\n\tplaceHolder,\n\tsize,\n\tonSelect,\n\tdefaultOptions,\n\tdisabled,\n\tnoErrorHint,\n\tplaceHolderHeight,\n\tshowPlaceholderWhenSelected = false,\n\tinputStyle = {},\n\tinputType = 'default',\n\tonDeleteChip,\n\ttruncatedText,\n\tshowLeadingIconInPlaceholder = false,\n\tshowTrailingIconPlaceholder = false,\n\tshowLabelsOnMoreHover = false,\n\tvalue,\n\tshowSelected = false,\n\tonDropdownVisbilityChange,\n\t...openDropdownProps\n}) => {\n\tconst [isDropdownOpened, setDropdownOpenFlag] = useState(false);\n\tconst [isHovering, setIsHovering] = useState(false);\n\tconst sizeToUse = size ?? 'default';\n\tconst dropdownVisibilityRef = useRef<{\n\t\topenDropdown: boolean;\n\t}>();\n\tconst [selectedOption, setSelectedOption] = useState<DropdownOption[]>(\n\t\tdefaultOptions ?? [],\n\t);\n\tfunction handleSelection(option: DropdownOption | DropdownOption[]) {\n\t\tif (Array.isArray(option)) {\n\t\t\tsetSelectedOption([...option]);\n\t\t} else {\n\t\t\tsetSelectedOption([...[option]]);\n\t\t}\n\t\tonSelect?.(option);\n\t}\n\n\tuseEffect(() => {\n\t\tconst flatSelectedOption: SingleOption[] = [];\n\t\topenDropdownProps?.options?.forEach((option) => {\n\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t(option as GroupedOption).options.forEach((op) => {\n\t\t\t\t\tif (op.selected) {\n\t\t\t\t\t\tflatSelectedOption.push({\n\t\t\t\t\t\t\t...op,\n\t\t\t\t\t\t\tlabel: op.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tif ((option as SingleOption).selected) {\n\t\t\t\t\tflatSelectedOption.push(option as SingleOption);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tsetSelectedOption([...flatSelectedOption]);\n\t}, [openDropdownProps.options]);\n\n\tuseEffect(() => {\n\t\tif (defaultOptions) {\n\t\t\tsetSelectedOption([...defaultOptions]);\n\t\t}\n\t}, [defaultOptions]);\n\n\tconst textVal = getSelectedOptionsAsText(selectedOption);\n\tconst displayText = showPlaceholderWhenSelected\n\t\t? placeHolder\n\t\t: textVal ?? placeHolder ?? 'Select an option';\n\n\tconst configuredMaxWidth = openDropdownProps.buttonWidth;\n\n\t// Shared width for the input wrapper and dropdown popover\n\tconst inputWidth = configuredMaxWidth ?? openDropdownProps.width ?? '100%';\n\n\t// Width passed to dropdown popover — matches input box width\n\tconst dropdownWidth = openDropdownProps.dropdownWidth ?? inputWidth;\n\n\treturn (\n\t\t<>\n\t\t\t<InputStyleContext.Provider\n\t\t\t\tvalue={{\n\t\t\t\t\tInputWrapper: {\n\t\t\t\t\t\theight: placeHolderHeight\n\t\t\t\t\t\t\t? placeHolderHeight\n\t\t\t\t\t\t\t: sizeToUse === 'x-small'\n\t\t\t\t\t\t\t? 24\n\t\t\t\t\t\t\t: sizeToUse === 'small'\n\t\t\t\t\t\t\t? 32\n\t\t\t\t\t\t\t: 48,\n\t\t\t\t\t\twidth: inputWidth,\n\t\t\t\t\t\t...(configuredMaxWidth ? { maxWidth: configuredMaxWidth } : {}),\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\tpadding: sizeToUse === 'x-small' ? '4px 8px' : '6px 8px',\n\t\t\t\t\t\tbackgroundColor:\n\t\t\t\t\t\t\topenDropdownProps.version === '3.0'\n\t\t\t\t\t\t\t\t? isDropdownOpened || isHovering\n\t\t\t\t\t\t\t\t\t? COLORS.surface.hovered\n\t\t\t\t\t\t\t\t\t: COLORS.surface.standard\n\t\t\t\t\t\t\t\t: showSelected && value !== undefined\n\t\t\t\t\t\t\t\t? BASE_COLORS.positive['100']\n\t\t\t\t\t\t\t\t: isHovering\n\t\t\t\t\t\t\t\t? COLORS.background.inactive\n\t\t\t\t\t\t\t\t: COLORS.surface.standard,\n\t\t\t\t\t\ttransition: 'background-color 0.3s ease',\n\t\t\t\t\t\t...inputStyle,\n\t\t\t\t\t},\n\t\t\t\t\tinput: {\n\t\t\t\t\t\tminHeight: '100%',\n\t\t\t\t\t\tmaxWidth: '100%',\n\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\tshowSelected && value !== undefined\n\t\t\t\t\t\t\t\t? COLORS.content.positive\n\t\t\t\t\t\t\t\t: 'inherit',\n\t\t\t\t\t},\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tonMouseEnter={() => setIsHovering(true)}\n\t\t\t\t\tonMouseLeave={() => setIsHovering(false)}\n\t\t\t\t\tstyle={\n\t\t\t\t\t\topenDropdownProps.width\n\t\t\t\t\t\t\t? { width: openDropdownProps.width }\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<DropdownPopover\n\t\t\t\t\t\tdata-test={openDropdownProps['data-test']}\n\t\t\t\t\t\tref={\n\t\t\t\t\t\t\tdropdownVisibilityRef as Ref<{\n\t\t\t\t\t\t\t\topenDropdown: boolean;\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={handleSelection}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t{...openDropdownProps}\n\t\t\t\t\t\tonDropdownVisbilityChange={(isOpen) => {\n\t\t\t\t\t\t\t// Keep the internal open flag (carat/open styling) AND forward\n\t\t\t\t\t\t\t// to a consumer-provided handler so callers can react to open state.\n\t\t\t\t\t\t\tsetDropdownOpenFlag(isOpen);\n\t\t\t\t\t\t\tonDropdownVisbilityChange?.(isOpen);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\twidth={dropdownWidth}\n\t\t\t\t\t>\n\t\t\t\t\t\t{inputType == 'default' && (\n\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\tversion={openDropdownProps.version}\n\t\t\t\t\t\t\t\tnoErrorHint={noErrorHint}\n\t\t\t\t\t\t\t\tstate={disabled ? 'disabled' : 'none'}\n\t\t\t\t\t\t\t\tvalue={value === undefined ? displayText : value}\n\t\t\t\t\t\t\t\terrorMessage={openDropdownProps.error}\n\t\t\t\t\t\t\t\tvariant={sizeToUse}\n\t\t\t\t\t\t\t\tplaceholder={placeHolder ?? 'Select an option'}\n\t\t\t\t\t\t\t\tonChangeText={noop}\n\t\t\t\t\t\t\t\tleftIcon={\n\t\t\t\t\t\t\t\t\tshowLeadingIconInPlaceholder && selectedOption[0]?.leadingIcon\n\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\ticon: () => <>{selectedOption[0]?.leadingIcon}</>,\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trightIcon={{\n\t\t\t\t\t\t\t\t\ticon: () => (\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{showTrailingIconPlaceholder &&\n\t\t\t\t\t\t\t\t\t\t\t\t(selectedOption[0] as SingleOption)?.trailingIcon}\n\t\t\t\t\t\t\t\t\t\t\t<DownIcon\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransform: isDropdownOpened\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'rotate(180deg)'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 'rotate(0deg)',\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={noop}\n\t\t\t\t\t\t\t\t\t\t\t\twidth={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsizeToUse === 'x-small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 16\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: sizeToUse === 'small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 20\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 24\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\theight={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsizeToUse === 'x-small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 16\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: sizeToUse === 'small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 20\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 24\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tcolor={\n\t\t\t\t\t\t\t\t\t\t\t\t\tshowSelected\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? COLORS.content.positive\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: COLORS.content.primary\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\ttruncateText={truncatedText ?? true}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{inputType == 'chip' && (\n\t\t\t\t\t\t\t<ChipInput\n\t\t\t\t\t\t\t\tplaceholder={placeHolder ?? 'Select options'}\n\t\t\t\t\t\t\t\tchips={selectedOption as SingleOption[]}\n\t\t\t\t\t\t\t\tonDeleteChip={(chip) => {\n\t\t\t\t\t\t\t\t\tonDeleteChip?.(chip);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\terrorMessage={openDropdownProps.error}\n\t\t\t\t\t\t\t\tisDropdownOpened={isDropdownOpened}\n\t\t\t\t\t\t\t\tsizeToUse={sizeToUse}\n\t\t\t\t\t\t\t\tcontainerStyle={{\n\t\t\t\t\t\t\t\t\twidth: openDropdownProps.width ?? '100%',\n\t\t\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tshowLabelsOnMoreHover={showLabelsOnMoreHover}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</DropdownPopover>\n\t\t\t\t</div>\n\t\t\t</InputStyleContext.Provider>\n\t\t</>\n\t);\n};\n\nDropdown.displayName = 'Dropdown';\n"],"names":["noop","Dropdown","placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover","value","showSelected","onDropdownVisbilityChange","openDropdownProps","isDropdownOpened","setDropdownOpenFlag","useState","isHovering","setIsHovering","sizeToUse","dropdownVisibilityRef","useRef","selectedOption","setSelectedOption","handleSelection","option","useEffect","flatSelectedOption","op","textVal","getSelectedOptionsAsText","displayText","configuredMaxWidth","inputWidth","dropdownWidth","jsx","Fragment","InputStyleContext","CO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ACCA,MAAc,YACX,KACAA,MAAc,UACd,KACA;AAAA,gCAEJ,OACCR,IACG2B,EAAO,QAAQ,WACfA,EAAO,QAAQ;AAAA,8BAAA;AAAA,4BAAA;AAAA,0BAEpB;AAAA,wBAAA;AAAA,sBAAA;AAAA,oBACD;AAAA,oBAGF,cAAchC,KAAiB;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAGhCF,KAAa,UACb,gBAAA+B;AAAA,kBAACU;AAAA,kBAAA;AAAA,oBACA,aAAalD,KAAe;AAAA,oBAC5B,OAAO2B;AAAA,oBACP,cAAc,CAACwB,MAAS;AACvB,sBAAAzC,IAAeyC,CAAI;AAAA,oBACpB;AAAA,oBACA,cAAcjC,EAAkB;AAAA,oBAChC,kBAAAC;AAAA,oBACA,WAAAK;AAAA,oBACA,gBAAgB;AAAA,sBACf,OAAON,EAAkB,SAAS;AAAA,sBAClC,QAAQ;AAAA,oBAAA;AAAA,oBAET,uBAAAJ;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACD;AAAA,YAAA;AAAA,UAAA;AAAA,QAEF;AAAA,MAAA;AAAA,IACD;AAAA,EAAA,GAEF;AAEF;AAEAf,EAAS,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import React, { Ref, useEffect, useRef, useState } from 'react';\nimport { BASE_COLORS, COLORS } from '@src/constants/Theme';\nimport DownIcon from '../../assets/icons/chevronDown.svg';\nimport { Input } from '../input';\nimport { InputStyleContext } from '../input/context/InputStyleProvider';\nimport ChipInput from './ChipInput';\nimport { DropdownPopover } from './DropdownPopover';\nimport { getSelectedOptionsAsText } from './OpenedDropdown/utils/iterationOnOptions';\nimport {\n\tDropdownOption,\n\tGroupedOption,\n\tOpenDropdownProps,\n\tSingleOption,\n} from './type';\n\nexport type DropdownProps = OpenDropdownProps & {\n\tplaceHolder?: string;\n\tsize?: 'default' | 'small' | 'x-small';\n\tdisabled?: boolean;\n\tnoErrorHint?: boolean;\n\tbuttonWidth?: string;\n\tplaceHolderHeight?: string;\n\tshowPlaceholderWhenSelected?: boolean;\n\tinputStyle?: React.CSSProperties;\n\tinputType?: 'chip' | 'default';\n\tonDeleteChip?: (chip: SingleOption) => void;\n\ttruncatedText?: boolean;\n\t'data-test'?: string;\n\tshowLeadingIconInPlaceholder?: boolean;\n\tshowTrailingIconPlaceholder?: boolean;\n\tshowLabelsOnMoreHover?: boolean;\n\tbackgroundColor?: string;\n\tvalue?: string;\n\tshowSelected?: boolean;\n\t/** Fired when the dropdown opens/closes. Runs alongside internal open state. */\n\tonDropdownVisbilityChange?: (isOpen: boolean) => void;\n};\n\nfunction noop() {\n\t/** empty */\n}\n\nexport const Dropdown: React.FC<DropdownProps> = ({\n\tplaceHolder,\n\tsize,\n\tonSelect,\n\tdefaultOptions,\n\tdisabled,\n\tnoErrorHint,\n\tplaceHolderHeight,\n\tshowPlaceholderWhenSelected = false,\n\tinputStyle = {},\n\tinputType = 'default',\n\tonDeleteChip,\n\ttruncatedText,\n\tshowLeadingIconInPlaceholder = false,\n\tshowTrailingIconPlaceholder = false,\n\tshowLabelsOnMoreHover = false,\n\tvalue,\n\tshowSelected = false,\n\tonDropdownVisbilityChange,\n\t...openDropdownProps\n}) => {\n\tconst [isDropdownOpened, setDropdownOpenFlag] = useState(false);\n\tconst [isHovering, setIsHovering] = useState(false);\n\tconst sizeToUse = size ?? 'default';\n\tconst dropdownVisibilityRef = useRef<{\n\t\topenDropdown: boolean;\n\t}>();\n\tconst [selectedOption, setSelectedOption] = useState<DropdownOption[]>(\n\t\tdefaultOptions ?? [],\n\t);\n\tfunction handleSelection(option: DropdownOption | DropdownOption[]) {\n\t\tif (Array.isArray(option)) {\n\t\t\tsetSelectedOption([...option]);\n\t\t} else {\n\t\t\tsetSelectedOption([...[option]]);\n\t\t}\n\t\tonSelect?.(option);\n\t}\n\n\tuseEffect(() => {\n\t\tconst flatSelectedOption: SingleOption[] = [];\n\t\topenDropdownProps?.options?.forEach((option) => {\n\t\t\tif ((option as GroupedOption).options) {\n\t\t\t\t(option as GroupedOption).options.forEach((op) => {\n\t\t\t\t\tif (op.selected) {\n\t\t\t\t\t\tflatSelectedOption.push({\n\t\t\t\t\t\t\t...op,\n\t\t\t\t\t\t\tlabel: op.label,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tif ((option as SingleOption).selected) {\n\t\t\t\t\tflatSelectedOption.push(option as SingleOption);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tsetSelectedOption([...flatSelectedOption]);\n\t}, [openDropdownProps.options]);\n\n\tuseEffect(() => {\n\t\tif (defaultOptions) {\n\t\t\tsetSelectedOption([...defaultOptions]);\n\t\t}\n\t}, [defaultOptions]);\n\n\tconst textVal = getSelectedOptionsAsText(selectedOption);\n\tconst displayText = showPlaceholderWhenSelected\n\t\t? placeHolder\n\t\t: textVal ?? placeHolder ?? 'Select an option';\n\n\tconst configuredMaxWidth = openDropdownProps.buttonWidth;\n\n\t// Shared width for the input wrapper and dropdown popover\n\tconst inputWidth = configuredMaxWidth ?? openDropdownProps.width ?? '100%';\n\n\t// Width passed to dropdown popover — matches input box width\n\tconst dropdownWidth = openDropdownProps.dropdownWidth ?? inputWidth;\n\n\treturn (\n\t\t<>\n\t\t\t<InputStyleContext.Provider\n\t\t\t\tvalue={{\n\t\t\t\t\tInputWrapper: {\n\t\t\t\t\t\theight: placeHolderHeight\n\t\t\t\t\t\t\t? placeHolderHeight\n\t\t\t\t\t\t\t: sizeToUse === 'x-small'\n\t\t\t\t\t\t\t? 24\n\t\t\t\t\t\t\t: sizeToUse === 'small'\n\t\t\t\t\t\t\t? 32\n\t\t\t\t\t\t\t: 48,\n\t\t\t\t\t\twidth: inputWidth,\n\t\t\t\t\t\t...(configuredMaxWidth ? { maxWidth: configuredMaxWidth } : {}),\n\t\t\t\t\t\tzIndex: 1,\n\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\tpadding: sizeToUse === 'x-small' ? '4px 8px' : '6px 8px',\n\t\t\t\t\t\tbackgroundColor:\n\t\t\t\t\t\t\topenDropdownProps.version === '3.0'\n\t\t\t\t\t\t\t\t? isDropdownOpened || isHovering\n\t\t\t\t\t\t\t\t\t? COLORS.surface.hovered\n\t\t\t\t\t\t\t\t\t: COLORS.surface.standard\n\t\t\t\t\t\t\t\t: showSelected && value !== undefined\n\t\t\t\t\t\t\t\t? BASE_COLORS.positive['100']\n\t\t\t\t\t\t\t\t: // The hover wrapper also contains the popover, so while the\n\t\t\t\t\t\t\t\t// dropdown is open, hovering an option would grey the input\n\t\t\t\t\t\t\t\t// — only show hover feedback while closed.\n\t\t\t\t\t\t\t\tisHovering && !isDropdownOpened\n\t\t\t\t\t\t\t\t? COLORS.background.inactive\n\t\t\t\t\t\t\t\t: COLORS.surface.standard,\n\t\t\t\t\t\ttransition: 'background-color 0.3s ease',\n\t\t\t\t\t\t...inputStyle,\n\t\t\t\t\t},\n\t\t\t\t\tinput: {\n\t\t\t\t\t\tminHeight: '100%',\n\t\t\t\t\t\tmaxWidth: '100%',\n\t\t\t\t\t\tcolor:\n\t\t\t\t\t\t\tshowSelected && value !== undefined\n\t\t\t\t\t\t\t\t? COLORS.content.positive\n\t\t\t\t\t\t\t\t: 'inherit',\n\t\t\t\t\t},\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tonMouseEnter={() => setIsHovering(true)}\n\t\t\t\t\tonMouseLeave={() => setIsHovering(false)}\n\t\t\t\t\tstyle={\n\t\t\t\t\t\topenDropdownProps.width\n\t\t\t\t\t\t\t? { width: openDropdownProps.width }\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<DropdownPopover\n\t\t\t\t\t\tdata-test={openDropdownProps['data-test']}\n\t\t\t\t\t\tref={\n\t\t\t\t\t\t\tdropdownVisibilityRef as Ref<{\n\t\t\t\t\t\t\t\topenDropdown: boolean;\n\t\t\t\t\t\t\t}>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonSelect={handleSelection}\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t{...openDropdownProps}\n\t\t\t\t\t\tonDropdownVisbilityChange={(isOpen) => {\n\t\t\t\t\t\t\t// Keep the internal open flag (carat/open styling) AND forward\n\t\t\t\t\t\t\t// to a consumer-provided handler so callers can react to open state.\n\t\t\t\t\t\t\tsetDropdownOpenFlag(isOpen);\n\t\t\t\t\t\t\tonDropdownVisbilityChange?.(isOpen);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\twidth={dropdownWidth}\n\t\t\t\t\t>\n\t\t\t\t\t\t{inputType == 'default' && (\n\t\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\t\tversion={openDropdownProps.version}\n\t\t\t\t\t\t\t\tnoErrorHint={noErrorHint}\n\t\t\t\t\t\t\t\tstate={disabled ? 'disabled' : 'none'}\n\t\t\t\t\t\t\t\tvalue={value === undefined ? displayText : value}\n\t\t\t\t\t\t\t\terrorMessage={openDropdownProps.error}\n\t\t\t\t\t\t\t\tvariant={sizeToUse}\n\t\t\t\t\t\t\t\tplaceholder={placeHolder ?? 'Select an option'}\n\t\t\t\t\t\t\t\tonChangeText={noop}\n\t\t\t\t\t\t\t\tleftIcon={\n\t\t\t\t\t\t\t\t\tshowLeadingIconInPlaceholder && selectedOption[0]?.leadingIcon\n\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\ticon: () => <>{selectedOption[0]?.leadingIcon}</>,\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trightIcon={{\n\t\t\t\t\t\t\t\t\ticon: () => (\n\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{showTrailingIconPlaceholder &&\n\t\t\t\t\t\t\t\t\t\t\t\t(selectedOption[0] as SingleOption)?.trailingIcon}\n\t\t\t\t\t\t\t\t\t\t\t<DownIcon\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\t\t\ttransform: isDropdownOpened\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 'rotate(180deg)'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 'rotate(0deg)',\n\t\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={noop}\n\t\t\t\t\t\t\t\t\t\t\t\twidth={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsizeToUse === 'x-small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 16\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: sizeToUse === 'small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 20\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 24\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\theight={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsizeToUse === 'x-small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 16\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: sizeToUse === 'small'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? 20\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: 24\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tcolor={\n\t\t\t\t\t\t\t\t\t\t\t\t\tshowSelected\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? COLORS.content.positive\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: COLORS.content.primary\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\ttruncateText={truncatedText ?? true}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{inputType == 'chip' && (\n\t\t\t\t\t\t\t<ChipInput\n\t\t\t\t\t\t\t\tplaceholder={placeHolder ?? 'Select options'}\n\t\t\t\t\t\t\t\tchips={selectedOption as SingleOption[]}\n\t\t\t\t\t\t\t\tonDeleteChip={(chip) => {\n\t\t\t\t\t\t\t\t\tonDeleteChip?.(chip);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\terrorMessage={openDropdownProps.error}\n\t\t\t\t\t\t\t\tisDropdownOpened={isDropdownOpened}\n\t\t\t\t\t\t\t\tsizeToUse={sizeToUse}\n\t\t\t\t\t\t\t\tcontainerStyle={{\n\t\t\t\t\t\t\t\t\twidth: openDropdownProps.width ?? '100%',\n\t\t\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tshowLabelsOnMoreHover={showLabelsOnMoreHover}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</DropdownPopover>\n\t\t\t\t</div>\n\t\t\t</InputStyleContext.Provider>\n\t\t</>\n\t);\n};\n\nDropdown.displayName = 'Dropdown';\n"],"names":["noop","Dropdown","placeHolder","size","onSelect","defaultOptions","disabled","noErrorHint","placeHolderHeight","showPlaceholderWhenSelected","inputStyle","inputType","onDeleteChip","truncatedText","showLeadingIconInPlaceholder","showTrailingIconPlaceholder","showLabelsOnMoreHover","value","showSelected","onDropdownVisbilityChange","openDropdownProps","isDropdownOpened","setDropdownOpenFlag","useState","isHovering","setIsHovering","sizeToUse","dropdownVisibilityRef","useRef","selectedOption","setSelectedOption","handleSelection","option","useEffect","flatSelectedOption","op","textVal","getSelectedOptionsAsText","displayText","configuredMaxWidth","inputWidth","dropdownWidth","jsx","Fragment","InputStyleContext","COLORS","BASE_COLORS","jsxs","DropdownPopover","isOpen","Input","DownIcon","ChipInput","chip"],"mappings":";;;;;;;;;AAsCA,SAASA,IAAO;AAEhB;AAEO,MAAMC,IAAoC,CAAC;AAAA,EACjD,aAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,6BAAAC,IAA8B;AAAA,EAC9B,YAAAC,IAAa,CAAA;AAAA,EACb,WAAAC,IAAY;AAAA,EACZ,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,8BAAAC,IAA+B;AAAA,EAC/B,6BAAAC,IAA8B;AAAA,EAC9B,uBAAAC,IAAwB;AAAA,EACxB,OAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,2BAAAC;AAAA,EACA,GAAGC;AACJ,MAAM;AACL,QAAM,CAACC,GAAkBC,CAAmB,IAAIC,EAAS,EAAK,GACxD,CAACC,GAAYC,CAAa,IAAIF,EAAS,EAAK,GAC5CG,IAAYvB,KAAQ,WACpBwB,IAAwBC,EAAA,GAGxB,CAACC,GAAgBC,CAAiB,IAAIP;AAAA,IAC3ClB,KAAkB,CAAA;AAAA,EAAC;AAEpB,WAAS0B,EAAgBC,GAA2C;AACnE,IAAI,MAAM,QAAQA,CAAM,IACvBF,EAAkB,CAAC,GAAGE,CAAM,CAAC,IAE7BF,EAAkB,CAAKE,CAAO,CAAC,GAEhC5B,IAAW4B,CAAM;AAAA,EAClB;AAEA,EAAAC,EAAU,MAAM;AACf,UAAMC,IAAqC,CAAA;AAC3C,IAAAd,GAAmB,SAAS,QAAQ,CAACY,MAAW;AAC/C,MAAKA,EAAyB,UAC5BA,EAAyB,QAAQ,QAAQ,CAACG,MAAO;AACjD,QAAIA,EAAG,YACND,EAAmB,KAAK;AAAA,UACvB,GAAGC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BACA;AAAA,gCAAA;AAAA,gCAEJ,SAASrB;AAAA,gCACT,OACC0B,MAAc,YACX,KACAA,MAAc,UACd,KACA;AAAA,gCAEJ,QACCA,MAAc,YACX,KACAA,MAAc,UACd,KACA;AAAA,gCAEJ,OACCR,IACG2B,EAAO,QAAQ,WACfA,EAAO,QAAQ;AAAA,8BAAA;AAAA,4BAAA;AAAA,0BAEpB;AAAA,wBAAA;AAAA,sBAAA;AAAA,oBACD;AAAA,oBAGF,cAAchC,KAAiB;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAGhCF,KAAa,UACb,gBAAA+B;AAAA,kBAACU;AAAA,kBAAA;AAAA,oBACA,aAAalD,KAAe;AAAA,oBAC5B,OAAO2B;AAAA,oBACP,cAAc,CAACwB,MAAS;AACvB,sBAAAzC,IAAeyC,CAAI;AAAA,oBACpB;AAAA,oBACA,cAAcjC,EAAkB;AAAA,oBAChC,kBAAAC;AAAA,oBACA,WAAAK;AAAA,oBACA,gBAAgB;AAAA,sBACf,OAAON,EAAkB,SAAS;AAAA,sBAClC,QAAQ;AAAA,oBAAA;AAAA,oBAET,uBAAAJ;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACD;AAAA,YAAA;AAAA,UAAA;AAAA,QAEF;AAAA,MAAA;AAAA,IACD;AAAA,EAAA,GAEF;AAEF;AAEAf,EAAS,cAAc;"}
|
|
@@ -1,125 +1,129 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { getMarkRange as
|
|
3
|
-
import { useEditor as
|
|
4
|
-
import { forwardRef as bt, useState as
|
|
5
|
-
import { BodyCaption as
|
|
6
|
-
import { BikEditorShell as
|
|
7
|
-
import { DEFAULT_FORMAT_STATE as
|
|
8
|
-
import { buildJsonCodeBlockHtml as
|
|
9
|
-
import { buildExtensions as
|
|
10
|
-
import { LinkBubbleMenu as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsxs as u, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { getMarkRange as xt } from "../node_modules/@tiptap/core/dist/index.js";
|
|
3
|
+
import { useEditor as vt, EditorContent as X } from "@tiptap/react";
|
|
4
|
+
import { forwardRef as bt, useState as A, useRef as a, useEffect as Et, useImperativeHandle as At } from "react";
|
|
5
|
+
import { BodyCaption as Y } from "../components/TypographyStyle.js";
|
|
6
|
+
import { BikEditorShell as Tt, BikJsonHeader as Rt, BikJsonBody as It, BikJsonEmptyState as Jt, BikJsonError as Lt } from "./BikEditor.styles.js";
|
|
7
|
+
import { DEFAULT_FORMAT_STATE as tt } from "./BikEditor.types.js";
|
|
8
|
+
import { buildJsonCodeBlockHtml as Mt, buildSectionedContent as et, normalizeHtml as i, extractActiveFormats as nt, extractContent as ot, getCodeBlockText as g, parseJson as p, extractBodyContent as Ot, extractSectionContent as Ft, setCodeBlockText as x, findSectionEndPos as rt, findSectionStartPos as zt, setSectionContentInEditor as T, insertInlineHtml as Nt } from "./BikEditor.utils.js";
|
|
9
|
+
import { buildExtensions as jt } from "./extensions/buildExtensions.js";
|
|
10
|
+
import { LinkBubbleMenu as Ht } from "./floating/LinkBubbleMenu.js";
|
|
11
|
+
import wt from "../icons/BIK AI specific/WandSparkles.js";
|
|
12
|
+
import Pt from "../icons/Actions/Formatting/Copy.js";
|
|
13
|
+
import Dt from "../icons/Actions/Common actions/Code.js";
|
|
14
|
+
import qt from "../icons/Informational/General/Info.js";
|
|
15
|
+
function Ut(k) {
|
|
16
|
+
return Object.entries(k).map(
|
|
17
|
+
([v, C]) => `${v.replace(/([A-Z])/g, (y) => `-${y.toLowerCase()}`)}:${C}`
|
|
16
18
|
).join(";");
|
|
17
19
|
}
|
|
18
|
-
const
|
|
20
|
+
const $t = (k, v) => {
|
|
19
21
|
const {
|
|
20
|
-
initialContent:
|
|
21
|
-
sections:
|
|
22
|
+
initialContent: C,
|
|
23
|
+
sections: y,
|
|
22
24
|
features: B,
|
|
23
|
-
disabled:
|
|
24
|
-
maxCharacters:
|
|
25
|
-
characterLimit:
|
|
26
|
-
shortcuts:
|
|
27
|
-
sendShortcut:
|
|
28
|
-
mentions:
|
|
29
|
-
slashCommands:
|
|
30
|
-
link:
|
|
31
|
-
onPaste:
|
|
32
|
-
onReady:
|
|
33
|
-
onChange:
|
|
34
|
-
onSend:
|
|
25
|
+
disabled: st,
|
|
26
|
+
maxCharacters: R,
|
|
27
|
+
characterLimit: it,
|
|
28
|
+
shortcuts: ct,
|
|
29
|
+
sendShortcut: at,
|
|
30
|
+
mentions: d,
|
|
31
|
+
slashCommands: S,
|
|
32
|
+
link: lt,
|
|
33
|
+
onPaste: dt,
|
|
34
|
+
onReady: I,
|
|
35
|
+
onChange: J,
|
|
36
|
+
onSend: b,
|
|
35
37
|
onFocus: L,
|
|
36
38
|
onBlur: M,
|
|
37
39
|
onSelectionChange: O,
|
|
38
|
-
minHeight:
|
|
39
|
-
maxHeight:
|
|
40
|
-
style:
|
|
41
|
-
className:
|
|
42
|
-
editorClassName:
|
|
43
|
-
editorStyle:
|
|
40
|
+
minHeight: ut,
|
|
41
|
+
maxHeight: mt,
|
|
42
|
+
style: ft,
|
|
43
|
+
className: gt,
|
|
44
|
+
editorClassName: F,
|
|
45
|
+
editorStyle: z,
|
|
44
46
|
renderJsonError: N
|
|
45
|
-
} =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
U.current =
|
|
56
|
-
const W = a(
|
|
57
|
-
W.current =
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
47
|
+
} = k, m = !!B?.jsonMode, [f, j] = A(null), [ht, H] = A(!1), [pt, w] = A(
|
|
48
|
+
m && !(C ?? "").trim()
|
|
49
|
+
), Ct = m ? Mt(C ?? "") : y?.length ? et(
|
|
50
|
+
i(C ?? ""),
|
|
51
|
+
y.map((t) => ({ ...t, content: i(t.content) }))
|
|
52
|
+
) : i(C ?? ""), E = a([]), P = a(!1), D = a(I);
|
|
53
|
+
D.current = I;
|
|
54
|
+
const q = a(J);
|
|
55
|
+
q.current = J;
|
|
56
|
+
const U = a(O);
|
|
57
|
+
U.current = O;
|
|
58
|
+
const $ = a(tt), W = a(L);
|
|
59
|
+
W.current = L;
|
|
60
|
+
const V = a(M);
|
|
61
|
+
V.current = M;
|
|
62
|
+
const _ = a(b);
|
|
63
|
+
_.current = b;
|
|
64
|
+
const Q = a(d?.agents ?? []);
|
|
65
|
+
Q.current = d?.agents ?? [];
|
|
66
|
+
const Z = a(d?.teams ?? []);
|
|
67
|
+
Z.current = d?.teams ?? [];
|
|
68
|
+
const G = a(S?.items ?? []);
|
|
69
|
+
G.current = S?.items ?? [];
|
|
70
|
+
const n = vt({
|
|
71
|
+
extensions: jt({
|
|
68
72
|
features: B,
|
|
69
|
-
placeholder:
|
|
70
|
-
maxCharacters:
|
|
71
|
-
characterLimit:
|
|
72
|
-
hasSections: (
|
|
73
|
+
placeholder: k.placeholder,
|
|
74
|
+
maxCharacters: R,
|
|
75
|
+
characterLimit: it,
|
|
76
|
+
hasSections: (y?.length ?? 0) > 0,
|
|
73
77
|
mentions: {
|
|
74
|
-
agents:
|
|
75
|
-
teams:
|
|
78
|
+
agents: d ? Q : void 0,
|
|
79
|
+
teams: d ? Z : void 0
|
|
76
80
|
},
|
|
77
|
-
slashCommands:
|
|
78
|
-
onPaste:
|
|
79
|
-
onSend:
|
|
80
|
-
sendShortcut:
|
|
81
|
-
shortcuts:
|
|
82
|
-
onMentionSelected:
|
|
83
|
-
onSlashCommandSelected:
|
|
84
|
-
renderMentionItem:
|
|
85
|
-
renderMentionDropdown:
|
|
86
|
-
removeMentionTriggerOnDismiss:
|
|
87
|
-
renderSlashCommandItem:
|
|
88
|
-
renderSlashCommandDropdown:
|
|
81
|
+
slashCommands: S ? G : void 0,
|
|
82
|
+
onPaste: dt,
|
|
83
|
+
onSend: b ? (t) => _.current?.(t) : void 0,
|
|
84
|
+
sendShortcut: at,
|
|
85
|
+
shortcuts: ct,
|
|
86
|
+
onMentionSelected: d?.onSelect,
|
|
87
|
+
onSlashCommandSelected: S?.onSelect,
|
|
88
|
+
renderMentionItem: d?.renderItem,
|
|
89
|
+
renderMentionDropdown: d?.renderDropdown,
|
|
90
|
+
removeMentionTriggerOnDismiss: d?.removeTriggerOnDismiss,
|
|
91
|
+
renderSlashCommandItem: S?.renderItem,
|
|
92
|
+
renderSlashCommandDropdown: S?.renderDropdown
|
|
89
93
|
}),
|
|
90
|
-
content:
|
|
91
|
-
editable: !
|
|
94
|
+
content: Ct,
|
|
95
|
+
editable: !st,
|
|
92
96
|
immediatelyRender: !1,
|
|
93
97
|
// SSR-safe — NEVER remove this
|
|
94
98
|
editorProps: {
|
|
95
99
|
attributes: {
|
|
96
|
-
...
|
|
97
|
-
...
|
|
100
|
+
...F ? { class: F } : {},
|
|
101
|
+
...z ? { style: Ut(z) } : {}
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
onUpdate: ({ editor: t }) => {
|
|
101
|
-
if (
|
|
102
|
-
const e =
|
|
103
|
-
j(
|
|
105
|
+
if (q.current?.(ot(t)), m) {
|
|
106
|
+
const e = g(t), o = p(e);
|
|
107
|
+
j(o.valid ? null : o), w(!e.trim());
|
|
104
108
|
}
|
|
105
109
|
},
|
|
106
110
|
onTransaction: ({ editor: t }) => {
|
|
107
|
-
const e =
|
|
108
|
-
(o.bold !== e.bold || o.italic !== e.italic || o.underline !== e.underline || o.strike !== e.strike || o.bulletList !== e.bulletList || o.orderedList !== e.orderedList || o.blockquote !== e.blockquote || o.codeBlock !== e.codeBlock || o.superscript !== e.superscript || o.subscript !== e.subscript || o.textAlign !== e.textAlign || o.fontFamily !== e.fontFamily || o.fontSize !== e.fontSize || o.color !== e.color || o.highlight !== e.highlight || o.link?.href !== e.link?.href) && (
|
|
111
|
+
const e = nt(t), o = $.current;
|
|
112
|
+
(o.bold !== e.bold || o.italic !== e.italic || o.underline !== e.underline || o.strike !== e.strike || o.bulletList !== e.bulletList || o.orderedList !== e.orderedList || o.blockquote !== e.blockquote || o.codeBlock !== e.codeBlock || o.superscript !== e.superscript || o.subscript !== e.subscript || o.textAlign !== e.textAlign || o.fontFamily !== e.fontFamily || o.fontSize !== e.fontSize || o.color !== e.color || o.highlight !== e.highlight || o.link?.href !== e.link?.href) && ($.current = e, U.current?.(e));
|
|
109
113
|
},
|
|
110
|
-
onFocus: () =>
|
|
111
|
-
onBlur: () =>
|
|
114
|
+
onFocus: () => W.current?.(),
|
|
115
|
+
onBlur: () => V.current?.()
|
|
112
116
|
});
|
|
113
117
|
function s(t) {
|
|
114
|
-
n ? t(n) :
|
|
118
|
+
n ? t(n) : E.current.push(t);
|
|
115
119
|
}
|
|
116
|
-
|
|
117
|
-
if (n && (
|
|
118
|
-
const t =
|
|
119
|
-
j(
|
|
120
|
+
Et(() => {
|
|
121
|
+
if (n && (E.current.length > 0 && E.current.splice(0).forEach((e) => e(n)), P.current || (P.current = !0, D.current?.()), m)) {
|
|
122
|
+
const t = g(n), e = p(t);
|
|
123
|
+
j(e.valid ? null : e), w(!t.trim());
|
|
120
124
|
}
|
|
121
|
-
}, [n, m]),
|
|
122
|
-
|
|
125
|
+
}, [n, m]), At(
|
|
126
|
+
v,
|
|
123
127
|
() => ({
|
|
124
128
|
// ── Focus ────────────────────────────────────────────────────────
|
|
125
129
|
focus: (t) => s((e) => e.commands.focus(t)),
|
|
@@ -135,7 +139,7 @@ const Ht = (y, x) => {
|
|
|
135
139
|
s((o) => o.commands.insertContent(e));
|
|
136
140
|
},
|
|
137
141
|
insertInlineContent: (t) => {
|
|
138
|
-
s((e) =>
|
|
142
|
+
s((e) => Nt(e, t));
|
|
139
143
|
},
|
|
140
144
|
insertAtStart: (t) => {
|
|
141
145
|
const e = i(t);
|
|
@@ -160,7 +164,7 @@ const Ht = (y, x) => {
|
|
|
160
164
|
appendContent(t) {
|
|
161
165
|
this.appendInline(t);
|
|
162
166
|
},
|
|
163
|
-
getContent: () => n ?
|
|
167
|
+
getContent: () => n ? ot(n) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
|
|
164
168
|
getJSON: () => n?.getJSON() ?? null,
|
|
165
169
|
getMentions: () => {
|
|
166
170
|
const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Set();
|
|
@@ -185,19 +189,19 @@ const Ht = (y, x) => {
|
|
|
185
189
|
return t.doc.textBetween(e, o, " ");
|
|
186
190
|
const c = t.schema.marks.link;
|
|
187
191
|
if (c) {
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
return t.doc.textBetween(
|
|
192
|
+
const h = xt(t.doc.resolve(e), c);
|
|
193
|
+
if (h)
|
|
194
|
+
return t.doc.textBetween(h.from, h.to, " ");
|
|
191
195
|
}
|
|
192
196
|
return "";
|
|
193
197
|
},
|
|
194
198
|
// ── Character count ───────────────────────────────────────────────
|
|
195
199
|
getCharacterCount: () => ({
|
|
196
200
|
count: n?.storage.characterCount?.characters?.() ?? n?.getText().length ?? 0,
|
|
197
|
-
limit:
|
|
201
|
+
limit: R ?? null
|
|
198
202
|
}),
|
|
199
203
|
// ── Sections ─────────────────────────────────────────────────────
|
|
200
|
-
getSectionContent: (t) => n ?
|
|
204
|
+
getSectionContent: (t) => n ? Ft(n, t) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
|
|
201
205
|
setSectionContent: (t, e) => {
|
|
202
206
|
const o = i(e);
|
|
203
207
|
s((r) => T(r, t, o));
|
|
@@ -206,7 +210,7 @@ const Ht = (y, x) => {
|
|
|
206
210
|
s((e) => {
|
|
207
211
|
if (t === "body") {
|
|
208
212
|
let r = e.state.doc.content.size - 1;
|
|
209
|
-
e.state.doc.descendants((c,
|
|
213
|
+
e.state.doc.descendants((c, h) => (c.type.name === "sectionDivider" && r === e.state.doc.content.size - 1 && (r = h - 1), r === e.state.doc.content.size - 1)), r < 1 && (r = 1), e.chain().focus().setTextSelection(r).run();
|
|
210
214
|
return;
|
|
211
215
|
}
|
|
212
216
|
let o = -1;
|
|
@@ -220,13 +224,13 @@ const Ht = (y, x) => {
|
|
|
220
224
|
s((e) => T(e, t, "<p></p>"));
|
|
221
225
|
},
|
|
222
226
|
// ── Convenience body shorthands ───────────────────────────────────
|
|
223
|
-
getBodyContent: () => n ?
|
|
227
|
+
getBodyContent: () => n ? Ot(n) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
|
|
224
228
|
setBodyContent: (t) => {
|
|
225
229
|
const e = i(t);
|
|
226
230
|
s((o) => T(o, "body", e));
|
|
227
231
|
},
|
|
228
232
|
setBodyAndSections: (t, e) => {
|
|
229
|
-
const o =
|
|
233
|
+
const o = et(
|
|
230
234
|
i(t),
|
|
231
235
|
e.map((r) => ({
|
|
232
236
|
id: r.id,
|
|
@@ -238,7 +242,7 @@ const Ht = (y, x) => {
|
|
|
238
242
|
appendBodyContent: (t) => {
|
|
239
243
|
const e = i(t);
|
|
240
244
|
s((o) => {
|
|
241
|
-
const r =
|
|
245
|
+
const r = rt(o, "body");
|
|
242
246
|
o.commands.insertContentAt(r - 1, e, {
|
|
243
247
|
parseOptions: { preserveWhitespace: !0 }
|
|
244
248
|
});
|
|
@@ -247,7 +251,7 @@ const Ht = (y, x) => {
|
|
|
247
251
|
insertAtSectionStart: (t, e) => {
|
|
248
252
|
const o = i(e);
|
|
249
253
|
s((r) => {
|
|
250
|
-
const c =
|
|
254
|
+
const c = zt(r, t);
|
|
251
255
|
c !== -1 && r.commands.insertContentAt(c, o, {
|
|
252
256
|
parseOptions: { preserveWhitespace: !0 }
|
|
253
257
|
});
|
|
@@ -256,14 +260,14 @@ const Ht = (y, x) => {
|
|
|
256
260
|
insertAtSectionEnd: (t, e) => {
|
|
257
261
|
const o = i(e);
|
|
258
262
|
s((r) => {
|
|
259
|
-
const c =
|
|
263
|
+
const c = rt(r, t);
|
|
260
264
|
r.commands.insertContentAt(c, o, {
|
|
261
265
|
parseOptions: { preserveWhitespace: !0 }
|
|
262
266
|
});
|
|
263
267
|
});
|
|
264
268
|
},
|
|
265
269
|
// ── Formats & actions ─────────────────────────────────────────────
|
|
266
|
-
getActiveFormats: () => n ?
|
|
270
|
+
getActiveFormats: () => n ? nt(n) : tt,
|
|
267
271
|
actions: {
|
|
268
272
|
toggleBold: () => n?.chain().focus().toggleBold().run(),
|
|
269
273
|
toggleItalic: () => n?.chain().focus().toggleItalic().run(),
|
|
@@ -282,12 +286,12 @@ const Ht = (y, x) => {
|
|
|
282
286
|
unsetHighlight: () => n?.chain().focus().unsetHighlight().run(),
|
|
283
287
|
setLink: (t, e) => {
|
|
284
288
|
n && (e !== void 0 ? n.chain().focus().extendMarkRange("link").command(({ tr: o, state: r }) => {
|
|
285
|
-
const { from: c, to:
|
|
286
|
-
if (!
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
]),
|
|
290
|
-
return o.replaceWith(c,
|
|
289
|
+
const { from: c, to: h } = o.selection, K = r.schema.marks.link;
|
|
290
|
+
if (!K) return !1;
|
|
291
|
+
const yt = r.schema.text(e, [
|
|
292
|
+
K.create({ href: t })
|
|
293
|
+
]), Bt = r.schema.text(" ");
|
|
294
|
+
return o.replaceWith(c, h, [yt, Bt]), !0;
|
|
291
295
|
}).run() : n.chain().focus().extendMarkRange("link").setLink({ href: t }).insertContent(" ").run());
|
|
292
296
|
},
|
|
293
297
|
updateLink: (t) => n?.chain().focus().extendMarkRange("link").setLink({ href: t }).run(),
|
|
@@ -305,82 +309,91 @@ const Ht = (y, x) => {
|
|
|
305
309
|
},
|
|
306
310
|
// ── JSON body ─────────────────────────────────────────────────────
|
|
307
311
|
json: B?.jsonMode ? {
|
|
308
|
-
getText: () => n ?
|
|
309
|
-
setText: (t) => s((e) =>
|
|
310
|
-
parse: () => p(n ?
|
|
311
|
-
isValid: () => p(n ?
|
|
312
|
+
getText: () => n ? g(n) : "",
|
|
313
|
+
setText: (t) => s((e) => x(e, t)),
|
|
314
|
+
parse: () => p(n ? g(n) : ""),
|
|
315
|
+
isValid: () => p(n ? g(n) : "").valid,
|
|
312
316
|
format: (t = 2) => s((e) => {
|
|
313
|
-
const { valid: o, value: r } = p(
|
|
314
|
-
!o || r === null ||
|
|
317
|
+
const { valid: o, value: r } = p(g(e));
|
|
318
|
+
!o || r === null || x(e, JSON.stringify(r, null, t));
|
|
315
319
|
}),
|
|
316
320
|
minify: () => s((t) => {
|
|
317
|
-
const { valid: e, value: o } = p(
|
|
318
|
-
!e || o === null ||
|
|
321
|
+
const { valid: e, value: o } = p(g(t));
|
|
322
|
+
!e || o === null || x(t, JSON.stringify(o));
|
|
319
323
|
})
|
|
320
324
|
} : void 0
|
|
321
325
|
}),
|
|
322
326
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
323
327
|
[n]
|
|
324
328
|
);
|
|
325
|
-
const
|
|
329
|
+
const St = () => {
|
|
326
330
|
if (!n) return;
|
|
327
|
-
const { valid: t, value: e } = p(
|
|
328
|
-
!t || e === null ||
|
|
329
|
-
},
|
|
330
|
-
n && (navigator.clipboard?.writeText(
|
|
331
|
+
const { valid: t, value: e } = p(g(n));
|
|
332
|
+
!t || e === null || x(n, JSON.stringify(e, null, 2));
|
|
333
|
+
}, kt = () => {
|
|
334
|
+
n && (navigator.clipboard?.writeText(g(n)), H(!0), setTimeout(() => H(!1), 1500));
|
|
331
335
|
};
|
|
332
|
-
return n ? /* @__PURE__ */
|
|
333
|
-
|
|
336
|
+
return n ? /* @__PURE__ */ u(
|
|
337
|
+
Tt,
|
|
334
338
|
{
|
|
335
|
-
minHeight:
|
|
336
|
-
maxHeight:
|
|
339
|
+
minHeight: ut,
|
|
340
|
+
maxHeight: mt,
|
|
337
341
|
tightParagraphs: !B?.richPaste,
|
|
338
342
|
jsonMode: m,
|
|
339
|
-
style:
|
|
340
|
-
className:
|
|
343
|
+
style: ft,
|
|
344
|
+
className: gt,
|
|
341
345
|
children: [
|
|
342
|
-
m && /* @__PURE__ */
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
+
m && /* @__PURE__ */ u(Rt, { children: [
|
|
347
|
+
/* @__PURE__ */ l("span", { className: "bik-json-header-label", children: "JSON" }),
|
|
348
|
+
/* @__PURE__ */ u("div", { className: "bik-json-header-actions", children: [
|
|
349
|
+
/* @__PURE__ */ u(
|
|
346
350
|
"button",
|
|
347
351
|
{
|
|
348
352
|
type: "button",
|
|
349
|
-
onClick:
|
|
350
|
-
disabled: !!
|
|
353
|
+
onClick: St,
|
|
354
|
+
disabled: !!f,
|
|
351
355
|
title: "Format JSON",
|
|
352
356
|
children: [
|
|
353
|
-
/* @__PURE__ */
|
|
354
|
-
/* @__PURE__ */
|
|
357
|
+
/* @__PURE__ */ l(wt, { size: 16 }),
|
|
358
|
+
/* @__PURE__ */ l(Y, { children: "Beautify" })
|
|
355
359
|
]
|
|
356
360
|
}
|
|
357
361
|
),
|
|
358
|
-
/* @__PURE__ */
|
|
359
|
-
/* @__PURE__ */
|
|
360
|
-
|
|
362
|
+
/* @__PURE__ */ u("button", { type: "button", onClick: kt, title: "Copy JSON", children: [
|
|
363
|
+
/* @__PURE__ */ l(Pt, { size: 16 }),
|
|
364
|
+
ht && /* @__PURE__ */ l(Y, { children: "Copied" })
|
|
361
365
|
] })
|
|
362
366
|
] })
|
|
363
367
|
] }),
|
|
364
|
-
/* @__PURE__ */
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
"
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
u
|
|
368
|
+
m ? /* @__PURE__ */ u(It, { $error: !!f, children: [
|
|
369
|
+
/* @__PURE__ */ l(X, { editor: n }),
|
|
370
|
+
pt && /* @__PURE__ */ u(Jt, { "aria-hidden": !0, children: [
|
|
371
|
+
/* @__PURE__ */ l(Dt, { size: 20 }),
|
|
372
|
+
/* @__PURE__ */ l("span", { children: k.placeholder ?? "Type or paste JSON here" })
|
|
373
|
+
] })
|
|
374
|
+
] }) : /* @__PURE__ */ l(X, { editor: n }),
|
|
375
|
+
/* @__PURE__ */ l(Ht, { editor: n, renderLinkTooltip: lt?.renderTooltip }),
|
|
376
|
+
m && f ? N ? N(f) : /* @__PURE__ */ u(Lt, { children: [
|
|
377
|
+
/* @__PURE__ */ l(qt, { size: 16 }),
|
|
378
|
+
/* @__PURE__ */ u("span", { children: [
|
|
379
|
+
f.line != null && /* @__PURE__ */ u("strong", { children: [
|
|
380
|
+
"Line ",
|
|
381
|
+
f.line,
|
|
382
|
+
f.column != null ? `, column ${f.column}` : "",
|
|
383
|
+
":",
|
|
384
|
+
" "
|
|
385
|
+
] }),
|
|
386
|
+
f.error
|
|
387
|
+
] })
|
|
375
388
|
] }) : null
|
|
376
389
|
]
|
|
377
390
|
}
|
|
378
391
|
) : null;
|
|
379
|
-
},
|
|
380
|
-
|
|
392
|
+
}, Wt = bt(
|
|
393
|
+
$t
|
|
381
394
|
);
|
|
382
|
-
|
|
395
|
+
Wt.displayName = "BikEditor";
|
|
383
396
|
export {
|
|
384
|
-
|
|
397
|
+
Wt as BikEditor
|
|
385
398
|
};
|
|
386
399
|
//# sourceMappingURL=BikEditor.js.map
|