@ni/nimble-components 32.8.0 → 32.8.1
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/README.md +7 -7
- package/dist/all-components-bundle.js +277 -126
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +2188 -2170
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/rich-text/editor/models/create-tiptap-editor.js +1 -1
- package/dist/esm/rich-text/editor/models/create-tiptap-editor.js.map +1 -1
- package/dist/esm/switch/styles.js +2 -1
- package/dist/esm/switch/styles.js.map +1 -1
- package/dist/esm/table/components/row/styles.js +4 -2
- package/dist/esm/table/components/row/styles.js.map +1 -1
- package/dist/esm/table/styles.js +5 -2
- package/dist/esm/table/styles.js.map +1 -1
- package/package.json +17 -17
|
@@ -125,7 +125,7 @@ function createCustomLinkExtension() {
|
|
|
125
125
|
// linkOnPaste can be enabled when hyperlink support added
|
|
126
126
|
// See: https://github.com/ni/nimble/issues/1527
|
|
127
127
|
linkOnPaste: false,
|
|
128
|
-
|
|
128
|
+
shouldAutoLink: href => validAbsoluteLinkRegex.test(href)
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
function createCustomMentionExtension(config, activeMentionCharacterEmitter, activeMentionCommandEmitter, mentionListbox) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-tiptap-editor.js","sourceRoot":"","sources":["../../../../../src/rich-text/editor/models/create-tiptap-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,MAAM,MAAM,0BAA0B,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ACF,IAAI,QAAQ,EAAE,CAAC;gBACX,0CAA0C;gBAC1C,sFAAsF;gBACtF,gDAAgD;gBAChD,IACI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAc,CAAC,EAC5D,CAAC;oBACC,gIAAgI;oBAChI,iEAAiE;oBACjE,gDAAgD;oBAChD,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CACpB,QAAQ,CAAC,KAAK,CAAC,IAAc,EAC7B,IAAI,CAAC,KAAK,CACb,CACJ,CAAC;gBACN,CAAC;qBAAM,CAAC;oBACJ,uGAAuG;oBACvG,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CACpB,IAAI,CAAC,WAAW,EAChB,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CACrC,CACJ,CAAC;gBACN,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACxD,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CACvD,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,MAAM,cAAc,GAAG,yBAAyB,CAC5C,YAAY,EACZ,IAAI,CAAC,OAAO,CACf,CAAC;YACF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACjD,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { Editor, Mark, Node, mergeAttributes } from '@tiptap/core';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport History from '@tiptap/extension-history';\nimport Italic from '@tiptap/extension-italic';\nimport Link from '@tiptap/extension-link';\nimport ListItem from '@tiptap/extension-list-item';\nimport Mention from '@tiptap/extension-mention';\nimport OrderedList from '@tiptap/extension-ordered-list';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Text from '@tiptap/extension-text';\nimport { Slice, Fragment, Node as FragmentNode } from 'prosemirror-model';\nimport { PluginKey } from 'prosemirror-state';\n\nimport { keyEscape } from '@microsoft/fast-web-utilities';\nimport {\n ActiveMentionCommandEmitter,\n ActiveMentionCharacterEmitter,\n mentionPluginPrefix\n} from '../types';\n\nimport { anchorTag } from '../../../anchor';\nimport type { MentionExtensionConfiguration } from '../../models/mention-extension-configuration';\nimport type { RichTextMentionListbox } from '../../mention-listbox';\n\nconst validAbsoluteLinkRegex = /^https?:\\/\\//i;\n\nexport function createTiptapEditor(\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n editor: HTMLDivElement,\n mentionExtensionConfig: MentionExtensionConfiguration[],\n mentionListbox?: RichTextMentionListbox,\n placeholder?: string\n): Editor {\n const customLink = createCustomLinkExtension();\n const mentionExtensions = mentionExtensionConfig.map(config => createCustomMentionExtension(\n config,\n activeMentionCharacterEmitter,\n activeMentionCommandEmitter,\n mentionListbox\n ));\n\n /**\n * For more information on the extensions for the supported formatting options, refer to the links below.\n * Tiptap marks: https://tiptap.dev/api/marks\n * Tiptap nodes: https://tiptap.dev/api/nodes\n */\n const tipTapEditor = new Editor({\n element: editor,\n // The editor will detect markdown syntax for an input only for these items\n // https://tiptap.dev/api/editor#enable-input-rules\n enableInputRules: [BulletList, OrderedList],\n // The editor will not detect markdown syntax when pasting content in any supported items\n // Lists do not have any default paste rules, they have only input rules, so disabled paste rules\n // https://tiptap.dev/api/editor#enable-paste-rules\n enablePasteRules: false,\n editorProps: {\n // Validating whether the links in the pasted content belongs to the supported scheme (HTTPS/HTTP),\n // and rendering it as a link in the editor. If not, rendering it as a plain text.\n // Also, updating the link text content with its href as we support only the absolute link.\n\n // `transformPasted` can be updated/removed when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n transformPasted\n },\n extensions: [\n Document,\n Paragraph,\n Text,\n BulletList,\n OrderedList,\n ListItem,\n Bold,\n Italic,\n History,\n Placeholder.configure({\n placeholder,\n showOnlyWhenEditable: false\n }),\n HardBreak,\n customLink,\n ...mentionExtensions\n ]\n });\n\n /**\n * @param slice contains the Fragment of the copied content. If the content is a link, the slice contains Text node with Link mark.\n * ProseMirror reference for `transformPasted`: https://prosemirror.net/docs/ref/#view.EditorProps.transformPasted\n */\n function transformPasted(slice: Slice): Slice {\n const modifiedFragment = updateLinkAndMentionNodes(\n tipTapEditor,\n slice.content\n );\n return new Slice(modifiedFragment, slice.openStart, slice.openEnd);\n }\n\n return tipTapEditor;\n}\n\n/**\n * Extending the default link mark schema defined in the TipTap.\n *\n * \"excludes\": https://prosemirror.net/docs/ref/#model.MarkSpec.excludes\n * \"inclusive\": https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive\n * \"parseHTML\": https://tiptap.dev/guide/custom-extensions#parse-html\n * \"renderHTML\": https://tiptap.dev/guide/custom-extensions/#render-html\n */\nfunction createCustomLinkExtension(): Mark {\n return Link.extend({\n // Excludes can be removed/enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n excludes: '_',\n // Inclusive can be updated when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n inclusive: false,\n parseHTML() {\n return [\n // To load the `nimble-anchor` from the HTML parsed content by markdown-parser as links in the Tiptap editor, the `parseHTML`\n // of Link extension should return nimble `anchorTag`.\n // This is because the link mark schema in `markdown-parser.ts` file uses `<nimble-anchor>` as anchor tag and not `<a>`.\n {\n tag: anchorTag\n },\n // `<a>` tag is added here to support when pasting a link from external source.\n {\n tag: 'a'\n }\n ];\n },\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n // eslint-disable-next-line @typescript-eslint/naming-convention\n renderHTML({ HTMLAttributes }) {\n // The below 'a' tag should be replaced with 'nimble-anchor' once the below issue is fixed.\n // https://github.com/ni/nimble/issues/1516\n return ['a', HTMLAttributes];\n }\n }).configure({\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: {\n rel: 'noopener noreferrer',\n target: null,\n // Adding `class` here is a workaround to render two mentions without a whitespace as display names\n // This attribute can be removed when the below issue is resolved\n // https://github.com/ni/nimble/issues/1707\n class: ''\n },\n autolink: true,\n openOnClick: false,\n // linkOnPaste can be enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n linkOnPaste: false,\n validate: href => validAbsoluteLinkRegex.test(href)\n });\n}\n\nfunction createCustomMentionExtension(\n config: MentionExtensionConfiguration,\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n mentionListbox?: RichTextMentionListbox\n): Node {\n return Mention.extend({\n name: config.name,\n parseHTML() {\n return [\n {\n tag: config.viewElement\n }\n ];\n },\n addAttributes() {\n return {\n href: {\n default: null,\n parseHTML: element => element.getAttribute('mention-href'),\n renderHTML: attributes => {\n return {\n 'mention-href': attributes.href as string\n };\n }\n },\n label: {\n default: null,\n parseHTML: element => element.getAttribute('mention-label'),\n renderHTML: attributes => {\n return {\n 'mention-label': attributes.label as string\n };\n }\n },\n disabled: {\n default: null,\n parseHTML: element => element.getAttribute('disabled'),\n renderHTML: attributes => {\n return {\n disabled: attributes.disabled as string\n };\n }\n }\n };\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n renderHTML({ node, HTMLAttributes }) {\n return [\n config.viewElement,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n this.options.renderText({\n options: this.options,\n node\n })\n ];\n }\n }).configure({\n suggestion: {\n char: config.character,\n decorationClass: 'nimble-mention-view-edit',\n pluginKey: new PluginKey(config.key),\n allowSpaces: true,\n render: () => {\n let inSuggestionMode = false;\n return {\n onStart: (props): void => {\n /**\n * If the cursor position moves to outside of the mention and configuration element changes,\n * the setMarkdown() will trigger this `onStart` without a decoration node because the cursor\n * position is temporarily moved out of the suggestion decoration. Ignore `onStart` in that case\n * and don't show the mention list box since it doesn't have anything to anchor to.\n */\n if (props.decorationNode === null) {\n return;\n }\n inSuggestionMode = true;\n config.mentionUpdateEmitter(props.query);\n activeMentionCharacterEmitter(props.text.slice(0, 1));\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onUpdate: (props): void => {\n if (!inSuggestionMode) {\n return;\n }\n config.mentionUpdateEmitter(props.query);\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onKeyDown: (props): boolean => {\n if (!inSuggestionMode) {\n return false;\n }\n if (props.event.key === keyEscape) {\n inSuggestionMode = false;\n }\n return (\n mentionListbox?.keydownHandler(props.event) ?? false\n );\n },\n onExit: (): void => {\n activeMentionCharacterEmitter('');\n activeMentionCommandEmitter(undefined);\n mentionListbox?.close();\n }\n };\n }\n }\n });\n}\n\n/**\n * This method finds the Link mark in the pasted content and update its Text node.\n * If there is no text node, pass the node's fragment recursively and updates only node containing Link mark.\n * If the Text node does not contains Link mark, push the same node to `updatedNodes`.\n *\n * @param fragment Fragment containing the pasted content. [Fragment](https://prosemirror.net/docs/ref/#model.Fragment)\n * @returns modified fragment from the `updatedNode` after updating the valid link text with its href value.\n */\nfunction updateLinkAndMentionNodes(\n tiptapEditor: Editor,\n fragment: Fragment\n): Fragment {\n const updatedNodes: FragmentNode[] = [];\n\n fragment.forEach(node => {\n if (node.isText && node.marks.length > 0) {\n const linkMark = node.marks.find(\n mark => mark.type.name === 'link' && mark.attrs\n );\n if (linkMark) {\n // Checks if the link is valid link or not\n // Needing to separately validate the link on paste is a workaround for a tiptap issue\n // See: https://github.com/ni/nimble/issues/1527\n if (\n validAbsoluteLinkRegex.test(linkMark.attrs.href as string)\n ) {\n // The below lines of code is responsible for updating the text content with its href value and creates a new updated text node.\n // This code needs an update when the hyperlink support is added.\n // See: https://github.com/ni/nimble/issues/1527\n updatedNodes.push(\n tiptapEditor.schema.text(\n linkMark.attrs.href as string,\n node.marks\n )\n );\n } else {\n // If it is a invalid link, creates a new Text node with the same text content and without a Link mark.\n updatedNodes.push(\n tiptapEditor.schema.text(\n node.textContent,\n linkMark.removeFromSet(node.marks)\n )\n );\n }\n } else {\n updatedNodes.push(node);\n }\n } else if (node.type.name.startsWith(mentionPluginPrefix)) {\n updatedNodes.push(\n tiptapEditor.schema.text(node.attrs.label as string)\n );\n } else {\n const updatedContent = updateLinkAndMentionNodes(\n tiptapEditor,\n node.content\n );\n updatedNodes.push(node.copy(updatedContent));\n }\n });\n\n return Fragment.fromArray(updatedNodes);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-tiptap-editor.js","sourceRoot":"","sources":["../../../../../src/rich-text/editor/models/create-tiptap-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAO,QAAQ,MAAM,4BAA4B,CAAC;AAClD,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAC9C,OAAO,IAAI,MAAM,wBAAwB,CAAC;AAC1C,OAAO,QAAQ,MAAM,6BAA6B,CAAC;AACnD,OAAO,OAAO,MAAM,2BAA2B,CAAC;AAChD,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO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AgI;oBAChI,iEAAiE;oBACjE,gDAAgD;oBAChD,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CACpB,QAAQ,CAAC,KAAK,CAAC,IAAc,EAC7B,IAAI,CAAC,KAAK,CACb,CACJ,CAAC;gBACN,CAAC;qBAAM,CAAC;oBACJ,uGAAuG;oBACvG,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CACpB,IAAI,CAAC,WAAW,EAChB,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CACrC,CACJ,CAAC;gBACN,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACxD,YAAY,CAAC,IAAI,CACb,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CACvD,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,MAAM,cAAc,GAAG,yBAAyB,CAC5C,YAAY,EACZ,IAAI,CAAC,OAAO,CACf,CAAC;YACF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;QACjD,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { Editor, Mark, Node, mergeAttributes } from '@tiptap/core';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport History from '@tiptap/extension-history';\nimport Italic from '@tiptap/extension-italic';\nimport Link from '@tiptap/extension-link';\nimport ListItem from '@tiptap/extension-list-item';\nimport Mention from '@tiptap/extension-mention';\nimport OrderedList from '@tiptap/extension-ordered-list';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Text from '@tiptap/extension-text';\nimport { Slice, Fragment, Node as FragmentNode } from 'prosemirror-model';\nimport { PluginKey } from 'prosemirror-state';\n\nimport { keyEscape } from '@microsoft/fast-web-utilities';\nimport {\n ActiveMentionCommandEmitter,\n ActiveMentionCharacterEmitter,\n mentionPluginPrefix\n} from '../types';\n\nimport { anchorTag } from '../../../anchor';\nimport type { MentionExtensionConfiguration } from '../../models/mention-extension-configuration';\nimport type { RichTextMentionListbox } from '../../mention-listbox';\n\nconst validAbsoluteLinkRegex = /^https?:\\/\\//i;\n\nexport function createTiptapEditor(\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n editor: HTMLDivElement,\n mentionExtensionConfig: MentionExtensionConfiguration[],\n mentionListbox?: RichTextMentionListbox,\n placeholder?: string\n): Editor {\n const customLink = createCustomLinkExtension();\n const mentionExtensions = mentionExtensionConfig.map(config => createCustomMentionExtension(\n config,\n activeMentionCharacterEmitter,\n activeMentionCommandEmitter,\n mentionListbox\n ));\n\n /**\n * For more information on the extensions for the supported formatting options, refer to the links below.\n * Tiptap marks: https://tiptap.dev/api/marks\n * Tiptap nodes: https://tiptap.dev/api/nodes\n */\n const tipTapEditor = new Editor({\n element: editor,\n // The editor will detect markdown syntax for an input only for these items\n // https://tiptap.dev/api/editor#enable-input-rules\n enableInputRules: [BulletList, OrderedList],\n // The editor will not detect markdown syntax when pasting content in any supported items\n // Lists do not have any default paste rules, they have only input rules, so disabled paste rules\n // https://tiptap.dev/api/editor#enable-paste-rules\n enablePasteRules: false,\n editorProps: {\n // Validating whether the links in the pasted content belongs to the supported scheme (HTTPS/HTTP),\n // and rendering it as a link in the editor. If not, rendering it as a plain text.\n // Also, updating the link text content with its href as we support only the absolute link.\n\n // `transformPasted` can be updated/removed when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n transformPasted\n },\n extensions: [\n Document,\n Paragraph,\n Text,\n BulletList,\n OrderedList,\n ListItem,\n Bold,\n Italic,\n History,\n Placeholder.configure({\n placeholder,\n showOnlyWhenEditable: false\n }),\n HardBreak,\n customLink,\n ...mentionExtensions\n ]\n });\n\n /**\n * @param slice contains the Fragment of the copied content. If the content is a link, the slice contains Text node with Link mark.\n * ProseMirror reference for `transformPasted`: https://prosemirror.net/docs/ref/#view.EditorProps.transformPasted\n */\n function transformPasted(slice: Slice): Slice {\n const modifiedFragment = updateLinkAndMentionNodes(\n tipTapEditor,\n slice.content\n );\n return new Slice(modifiedFragment, slice.openStart, slice.openEnd);\n }\n\n return tipTapEditor;\n}\n\n/**\n * Extending the default link mark schema defined in the TipTap.\n *\n * \"excludes\": https://prosemirror.net/docs/ref/#model.MarkSpec.excludes\n * \"inclusive\": https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive\n * \"parseHTML\": https://tiptap.dev/guide/custom-extensions#parse-html\n * \"renderHTML\": https://tiptap.dev/guide/custom-extensions/#render-html\n */\nfunction createCustomLinkExtension(): Mark {\n return Link.extend({\n // Excludes can be removed/enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n excludes: '_',\n // Inclusive can be updated when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n inclusive: false,\n parseHTML() {\n return [\n // To load the `nimble-anchor` from the HTML parsed content by markdown-parser as links in the Tiptap editor, the `parseHTML`\n // of Link extension should return nimble `anchorTag`.\n // This is because the link mark schema in `markdown-parser.ts` file uses `<nimble-anchor>` as anchor tag and not `<a>`.\n {\n tag: anchorTag\n },\n // `<a>` tag is added here to support when pasting a link from external source.\n {\n tag: 'a'\n }\n ];\n },\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n // eslint-disable-next-line @typescript-eslint/naming-convention\n renderHTML({ HTMLAttributes }) {\n // The below 'a' tag should be replaced with 'nimble-anchor' once the below issue is fixed.\n // https://github.com/ni/nimble/issues/1516\n return ['a', HTMLAttributes];\n }\n }).configure({\n // HTMLAttribute cannot be in camelCase as we want to match it with the name in Tiptap\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HTMLAttributes: {\n rel: 'noopener noreferrer',\n target: null,\n // Adding `class` here is a workaround to render two mentions without a whitespace as display names\n // This attribute can be removed when the below issue is resolved\n // https://github.com/ni/nimble/issues/1707\n class: ''\n },\n autolink: true,\n openOnClick: false,\n // linkOnPaste can be enabled when hyperlink support added\n // See: https://github.com/ni/nimble/issues/1527\n linkOnPaste: false,\n shouldAutoLink: href => validAbsoluteLinkRegex.test(href)\n });\n}\n\nfunction createCustomMentionExtension(\n config: MentionExtensionConfiguration,\n activeMentionCharacterEmitter: ActiveMentionCharacterEmitter,\n activeMentionCommandEmitter: ActiveMentionCommandEmitter,\n mentionListbox?: RichTextMentionListbox\n): Node {\n return Mention.extend({\n name: config.name,\n parseHTML() {\n return [\n {\n tag: config.viewElement\n }\n ];\n },\n addAttributes() {\n return {\n href: {\n default: null,\n parseHTML: element => element.getAttribute('mention-href'),\n renderHTML: attributes => {\n return {\n 'mention-href': attributes.href as string\n };\n }\n },\n label: {\n default: null,\n parseHTML: element => element.getAttribute('mention-label'),\n renderHTML: attributes => {\n return {\n 'mention-label': attributes.label as string\n };\n }\n },\n disabled: {\n default: null,\n parseHTML: element => element.getAttribute('disabled'),\n renderHTML: attributes => {\n return {\n disabled: attributes.disabled as string\n };\n }\n }\n };\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n renderHTML({ node, HTMLAttributes }) {\n return [\n config.viewElement,\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n this.options.renderText({\n options: this.options,\n node\n })\n ];\n }\n }).configure({\n suggestion: {\n char: config.character,\n decorationClass: 'nimble-mention-view-edit',\n pluginKey: new PluginKey(config.key),\n allowSpaces: true,\n render: () => {\n let inSuggestionMode = false;\n return {\n onStart: (props): void => {\n /**\n * If the cursor position moves to outside of the mention and configuration element changes,\n * the setMarkdown() will trigger this `onStart` without a decoration node because the cursor\n * position is temporarily moved out of the suggestion decoration. Ignore `onStart` in that case\n * and don't show the mention list box since it doesn't have anything to anchor to.\n */\n if (props.decorationNode === null) {\n return;\n }\n inSuggestionMode = true;\n config.mentionUpdateEmitter(props.query);\n activeMentionCharacterEmitter(props.text.slice(0, 1));\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onUpdate: (props): void => {\n if (!inSuggestionMode) {\n return;\n }\n config.mentionUpdateEmitter(props.query);\n activeMentionCommandEmitter(props.command);\n mentionListbox?.show({\n filter: props.query,\n anchorNode: props.decorationNode as HTMLElement\n });\n },\n onKeyDown: (props): boolean => {\n if (!inSuggestionMode) {\n return false;\n }\n if (props.event.key === keyEscape) {\n inSuggestionMode = false;\n }\n return (\n mentionListbox?.keydownHandler(props.event) ?? false\n );\n },\n onExit: (): void => {\n activeMentionCharacterEmitter('');\n activeMentionCommandEmitter(undefined);\n mentionListbox?.close();\n }\n };\n }\n }\n });\n}\n\n/**\n * This method finds the Link mark in the pasted content and update its Text node.\n * If there is no text node, pass the node's fragment recursively and updates only node containing Link mark.\n * If the Text node does not contains Link mark, push the same node to `updatedNodes`.\n *\n * @param fragment Fragment containing the pasted content. [Fragment](https://prosemirror.net/docs/ref/#model.Fragment)\n * @returns modified fragment from the `updatedNode` after updating the valid link text with its href value.\n */\nfunction updateLinkAndMentionNodes(\n tiptapEditor: Editor,\n fragment: Fragment\n): Fragment {\n const updatedNodes: FragmentNode[] = [];\n\n fragment.forEach(node => {\n if (node.isText && node.marks.length > 0) {\n const linkMark = node.marks.find(\n mark => mark.type.name === 'link' && mark.attrs\n );\n if (linkMark) {\n // Checks if the link is valid link or not\n // Needing to separately validate the link on paste is a workaround for a tiptap issue\n // See: https://github.com/ni/nimble/issues/1527\n if (\n validAbsoluteLinkRegex.test(linkMark.attrs.href as string)\n ) {\n // The below lines of code is responsible for updating the text content with its href value and creates a new updated text node.\n // This code needs an update when the hyperlink support is added.\n // See: https://github.com/ni/nimble/issues/1527\n updatedNodes.push(\n tiptapEditor.schema.text(\n linkMark.attrs.href as string,\n node.marks\n )\n );\n } else {\n // If it is a invalid link, creates a new Text node with the same text content and without a Link mark.\n updatedNodes.push(\n tiptapEditor.schema.text(\n node.textContent,\n linkMark.removeFromSet(node.marks)\n )\n );\n }\n } else {\n updatedNodes.push(node);\n }\n } else if (node.type.name.startsWith(mentionPluginPrefix)) {\n updatedNodes.push(\n tiptapEditor.schema.text(node.attrs.label as string)\n );\n } else {\n const updatedContent = updateLinkAndMentionNodes(\n tiptapEditor,\n node.content\n );\n updatedNodes.push(node.copy(updatedContent));\n }\n });\n\n return Fragment.fromArray(updatedNodes);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/switch/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EACH,OAAO,EACP,MAAM,EACN,OAAO,EACP,KAAK,EACR,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,4BAA4B,EAC5B,oBAAoB,EACpB,aAAa,EACb,6BAA6B,EAC7B,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,UAAU,EACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CA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;;;;;;;;;;;;;;kBAuBxB,WAAW;;;;;uBAKN,WAAW,eAAe,gBAAgB;;;;;;;kBAO/C,WAAW;;;;YAIjB,YAAY;kBACN,WAAW,UAAU,gBAAgB;;;;;;;;;8BASzB,UAAU;;;;;;;;;;;;;;;;;;;;;;;CAuBvC,CAAC,aAAa,CACX,aAAa,CACT,KAAK,CAAC,KAAK,EACX,GAAG,CAAA;;iEAEsD,iBAAiB,CAC9D,OAAO,EACP,IAAI,CACP;kEACiD,KAAK;2EACI,iBAAiB,CACxE,KAAK,EACL,GAAG,CACN;8DAC6C,OAAO;uEACE,iBAAiB,CACpE,OAAO,EACP,GAAG,CACN;;SAER,CACJ,EACD,aAAa,CACT,KAAK,CAAC,IAAI,EACV,GAAG,CAAA;;iEAEsD,iBAAiB,CAC9D,OAAO,EACP,IAAI,CACP;kEACiD,iBAAiB,CAC/D,OAAO,EACP,GAAG,CACN;2EAC0D,iBAAiB,CACxE,OAAO,EACP,GAAG,CACN;8DAC6C,MAAM;uEACG,iBAAiB,CACpE,MAAM,EACN,GAAG,CACN;;SAER,CACJ,EACD,aAAa,CACT,KAAK,CAAC,KAAK,EACX,GAAG,CAAA;;iEAEsD,iBAAiB,CAC9D,KAAK,EACL,IAAI,CACP;kEACiD,iBAAiB,CAC/D,KAAK,EACL,GAAG,CACN;2EAC0D,iBAAiB,CACxE,KAAK,EACL,GAAG,CACN;8DAC6C,KAAK;uEACI,iBAAiB,CACpE,KAAK,EACL,GAAG,CACN;;SAER,CACJ,CACJ,CAAC","sourcesContent":["import { css } from '@microsoft/fast-element';\nimport {\n Black15,\n Black7,\n Black91,\n White\n} from '@ni/nimble-tokens/dist/styledictionary/js/tokens';\nimport { display } from '../utilities/style/display';\nimport {\n bodyFont,\n borderHoverColor,\n borderWidth,\n buttonLabelDisabledFontColor,\n buttonLabelFontColor,\n controlHeight,\n controlLabelDisabledFontColor,\n controlLabelFont,\n controlLabelFontColor,\n fillHoverColor,\n smallDelay\n} from '../theme-provider/design-tokens';\nimport { Theme } from '../theme-provider/types';\nimport { hexToRgbaCssColor } from '../utilities/style/colors';\nimport { focusVisible } from '../utilities/style/focus';\nimport { themeBehavior } from '../utilities/style/theme';\n\nexport const styles = css`\n ${display('inline-flex')}\n\n :host {\n outline: none;\n font: ${bodyFont};\n color: ${buttonLabelFontColor};\n flex-direction: column;\n cursor: pointer;\n --ni-private-switch-height: 24px;\n --ni-private-switch-indicator-size: 16px;\n padding-bottom: calc(\n ${controlHeight} - var(--ni-private-switch-height)\n );\n }\n\n :host([disabled]) {\n cursor: default;\n color: ${buttonLabelDisabledFontColor};\n }\n\n .label {\n color: ${controlLabelFontColor};\n font: ${controlLabelFont};\n }\n\n :host([disabled]) .label {\n color: ${controlLabelDisabledFontColor};\n }\n\n .label__hidden {\n display: none;\n visibility: hidden;\n }\n\n .switch-container {\n display: flex;\n align-items: center;\n }\n\n slot[name='unchecked-message']::slotted(*) {\n margin-inline-end: 8px;\n }\n\n .switch {\n display: flex;\n height: var(--ni-private-switch-height);\n width: calc(var(--ni-private-switch-height) * 2);\n background-color: ${fillHoverColor};\n border-radius: calc(var(--ni-private-switch-height) / 2);\n align-items: center;\n border: calc(${borderWidth} * 2) solid transparent;\n }\n\n :host([disabled]) .switch {\n background-color: var(--ni-private-switch-background-disabled-color);\n }\n\n :host(${focusVisible}) .switch {\n border-color: ${borderHoverColor};\n }\n\n .checked-indicator-spacer {\n flex-grow: 0;\n transition: flex-grow ${smallDelay} ease-in-out;\n }\n\n :host([aria-checked='true']) .checked-indicator-spacer {\n flex-grow: 1;\n }\n\n .checked-indicator {\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: var(--ni-private-switch-indicator-background-color);\n width: var(--ni-private-switch-indicator-size);\n height: var(--ni-private-switch-indicator-size);\n border-radius: calc(var(--ni-private-switch-indicator-size) / 2);\n margin: calc(\n calc(\n var(--ni-private-switch-height) - var(\n --ni-private-switch-indicator-size\n )\n ) /\n 2\n );\n border: ${borderWidth} solid\n var(--ni-private-switch-indicator-border-color);\n }\n\n :host(:hover) .checked-indicator {\n border: calc(${borderWidth} * 2) solid ${borderHoverColor};\n }\n\n :host([disabled]) .checked-indicator {\n background-color: var(\n --ni-private-switch-indicator-background-disabled-color\n );\n border: ${borderWidth} solid\n var(--ni-private-switch-indicator-border-disabled-color);\n }\n\n :host(${focusVisible}) .checked-indicator {\n border: ${borderWidth} solid ${borderHoverColor};\n }\n\n .checked-indicator-inner {\n width: calc(var(--ni-private-switch-indicator-size) / 2);\n height: calc(var(--ni-private-switch-indicator-size) / 2);\n border-radius: calc(var(--ni-private-switch-indicator-size) / 4);\n background-color: var(--ni-private-switch-indicator-border-color);\n opacity: 0;\n transition: opacity ${smallDelay} ease-in-out;\n }\n\n :host([disabled]) .checked-indicator-inner {\n background-color: var(\n --ni-private-switch-indicator-border-disabled-color\n );\n }\n\n :host([aria-checked='true']) .checked-indicator-inner {\n opacity: 1;\n }\n\n slot[name='checked-message']::slotted(*) {\n margin-inline-start: 8px;\n }\n\n @media (prefers-reduced-motion) {\n .checked-indicator-inner,\n .checked-indicator-spacer {\n transition-duration: 0s;\n }\n }\n`.withBehaviors(\n themeBehavior(\n Theme.light,\n css`\n :host {\n --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(\n Black91,\n 0.07\n )};\n --ni-private-switch-indicator-background-color: ${White};\n --ni-private-switch-indicator-background-disabled-color: ${hexToRgbaCssColor(\n White,\n 0.1\n )};\n --ni-private-switch-indicator-border-color: ${Black91};\n --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(\n Black91,\n 0.3\n )};\n }\n `\n ),\n themeBehavior(\n Theme.dark,\n css`\n :host {\n --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(\n Black15,\n 0.07\n )};\n --ni-private-switch-indicator-background-color: ${hexToRgbaCssColor(\n Black91,\n 0.3\n )};\n --ni-private-switch-indicator-background-disabled-color: ${hexToRgbaCssColor(\n Black91,\n 0.1\n )};\n --ni-private-switch-indicator-border-color: ${Black7};\n --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(\n Black7,\n 0.3\n )};\n }\n `\n ),\n themeBehavior(\n Theme.color,\n css`\n :host {\n --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(\n White,\n 0.07\n )};\n --ni-private-switch-indicator-background-color: ${hexToRgbaCssColor(\n White,\n 0.1\n )};\n --ni-private-switch-indicator-background-disabled-color: ${hexToRgbaCssColor(\n White,\n 0.1\n )};\n --ni-private-switch-indicator-border-color: ${White};\n --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(\n White,\n 0.3\n )};\n }\n `\n )\n);\n"]}
|
|
@@ -130,7 +130,8 @@ export const styles = css `
|
|
|
130
130
|
|
|
131
131
|
nimble-table-cell:first-of-type${focusVisible} {
|
|
132
132
|
margin-left: calc(
|
|
133
|
-
-1 * (${controlHeight} - ${smallPadding}) *
|
|
133
|
+
-1 * (${controlHeight} - ${smallPadding}) *
|
|
134
|
+
var(--ni-private-table-cell-focus-offset-multiplier)
|
|
134
135
|
);
|
|
135
136
|
padding-left: calc(
|
|
136
137
|
(${controlHeight} - ${mediumPadding}) *
|
|
@@ -147,7 +148,8 @@ export const styles = css `
|
|
|
147
148
|
${controlHeight} *
|
|
148
149
|
var(--ni-private-table-cell-nesting-level) +
|
|
149
150
|
${smallPadding}
|
|
150
|
-
) *
|
|
151
|
+
) *
|
|
152
|
+
var(--ni-private-table-cell-focus-offset-multiplier)
|
|
151
153
|
);
|
|
152
154
|
height: ${controlHeight};
|
|
153
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../src/table/components/row/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EACH,0BAA0B,EA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nB,YAAY;;;CAGvB,CAAC,aAAa,CACX,aAAa,CACT,KAAK,CAAC,KAAK,EACX,GAAG,CAAA;;oCAEyB,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC;;;;oCAI9B,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC;;;;oCAI9B,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC;;SAExD,CACJ,CACJ,CAAC","sourcesContent":["import { css } from '@microsoft/fast-element';\nimport { White } from '@ni/nimble-tokens/dist/styledictionary/js/tokens';\nimport { display } from '../../../utilities/style/display';\nimport {\n applicationBackgroundColor,\n borderHoverColor,\n borderWidth,\n controlHeight,\n controlSlimHeight,\n fillHoverColor,\n fillHoverSelectedColor,\n fillSelectedColor,\n mediumPadding,\n smallPadding,\n standardPadding\n} from '../../../theme-provider/design-tokens';\nimport { Theme } from '../../../theme-provider/types';\nimport { hexToRgbaCssColor } from '../../../utilities/style/colors';\nimport { themeBehavior } from '../../../utilities/style/theme';\nimport { styles as expandCollapseStyles } from '../../../patterns/expand-collapse/styles';\nimport { focusVisible } from '../../../utilities/style/focus';\n\nexport const styles = css`\n ${display('flex')}\n ${expandCollapseStyles}\n\n :host {\n width: fit-content;\n min-width: 100%;\n background-color: ${applicationBackgroundColor};\n height: calc(${controlHeight} + 2 * ${borderWidth});\n border-top: calc(2 * ${borderWidth}) solid transparent;\n background-clip: padding-box;\n }\n\n :host::before {\n content: '';\n width: 100%;\n height: ${controlHeight};\n pointer-events: none;\n bottom: 0px;\n position: absolute;\n }\n\n :host([selectable]:not([selected])[allow-hover]:hover)::before {\n background-color: ${fillHoverColor};\n }\n\n :host([selected])::before {\n background-color: ${fillSelectedColor};\n }\n\n :host([selected][allow-hover]:hover)::before {\n background-color: ${fillHoverSelectedColor};\n }\n\n :host(${focusVisible}) {\n outline: none;\n box-shadow:\n inset calc(2 * ${borderWidth}) calc(2 * ${borderWidth})\n ${borderHoverColor},\n inset calc(-2 * ${borderWidth}) calc(-2 * ${borderWidth})\n ${borderHoverColor};\n }\n\n .expand-collapse-button {\n flex: 0 0 auto;\n margin-left: max(\n calc(\n ${mediumPadding} +\n (var(--ni-private-table-row-indent-level) - 1) *\n ${controlHeight}\n ),\n 0px\n );\n }\n\n .spinner-container {\n flex: 0 0 auto;\n width: ${controlSlimHeight};\n height: ${controlSlimHeight};\n align-self: center;\n display: flex;\n align-items: center;\n justify-content: center;\n margin-left: max(\n calc(\n ${mediumPadding} +\n (var(--ni-private-table-row-indent-level) - 1) *\n ${controlHeight}\n ),\n 0px\n );\n }\n\n .row-operations-container {\n flex: 0 0 auto;\n display: flex;\n }\n\n .selection-checkbox {\n margin-left: ${standardPadding};\n }\n\n .selection-checkbox::part(label) {\n padding-left: 0px;\n }\n\n .row-front-spacer {\n width: ${controlHeight};\n flex: 0 0 auto;\n }\n\n .row-front-spacer.reduced-size-spacer {\n width: ${mediumPadding};\n }\n\n .cell-container {\n display: grid;\n width: 100%;\n grid-auto-flow: column;\n grid-auto-columns: 1fr;\n grid-template-columns: var(--ni-private-table-row-grid-columns) auto;\n }\n\n .cell-container.nested-parent {\n margin-left: calc(\n (${controlHeight} * var(--ni-private-table-row-indent-level)) * -1\n );\n }\n\n nimble-table-cell {\n --ni-private-table-cell-action-menu-display: none;\n }\n\n nimble-table-cell[menu-open] {\n --ni-private-table-cell-action-menu-display: block;\n }\n\n nimble-table-cell${focusVisible} {\n --ni-private-table-cell-action-menu-display: block;\n }\n\n nimble-table-cell:first-of-type${focusVisible} {\n margin-left: calc(\n -1 * (${controlHeight} - ${smallPadding}) *\n var(--ni-private-table-cell-focus-offset-multiplier)\n );\n padding-left: calc(\n (${controlHeight} - ${mediumPadding}) *\n var(--ni-private-table-cell-focus-offset-multiplier) +\n ${mediumPadding}\n );\n }\n\n nimble-table-cell:first-of-type${focusVisible}::before {\n content: '';\n display: block;\n width: calc(\n (\n ${controlHeight} *\n var(--ni-private-table-cell-nesting-level) +\n ${smallPadding}\n ) *\n var(--ni-private-table-cell-focus-offset-multiplier)\n );\n height: ${controlHeight};\n }\n\n :host([allow-hover]:hover) nimble-table-cell {\n --ni-private-table-cell-action-menu-display: block;\n }\n\n :host([selected]) nimble-table-cell {\n --ni-private-table-cell-action-menu-display: block;\n }\n\n :host(${focusVisible}) nimble-table-cell {\n --ni-private-table-cell-action-menu-display: block;\n }\n`.withBehaviors(\n themeBehavior(\n Theme.color,\n css`\n :host([selectable]:not([selected])[allow-hover]:hover)::before {\n background-color: ${hexToRgbaCssColor(White, 0.05)};\n }\n\n :host([selected])::before {\n background-color: ${hexToRgbaCssColor(White, 0.25)};\n }\n\n :host([selected][allow-hover]:hover)::before {\n background-color: ${hexToRgbaCssColor(White, 0.2)};\n }\n `\n )\n);\n"]}
|
package/dist/esm/table/styles.js
CHANGED
|
@@ -150,8 +150,11 @@ focus outline in that case.
|
|
|
150
150
|
);
|
|
151
151
|
height: 100%;
|
|
152
152
|
left: calc(
|
|
153
|
-
-1 *
|
|
154
|
-
|
|
153
|
+
-1 *
|
|
154
|
+
(
|
|
155
|
+
var(--ni-private-column-divider-width) +
|
|
156
|
+
var(--ni-private-column-divider-padding)
|
|
157
|
+
)
|
|
155
158
|
);
|
|
156
159
|
}
|
|
157
160
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/table/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,0BAA0B,EAC1B,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,WAAW,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB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ourcesContent":["import { css } from '@microsoft/fast-element';\nimport { White } from '@ni/nimble-tokens/dist/styledictionary/js/tokens';\nimport { display } from '../utilities/style/display';\nimport {\n applicationBackgroundColor,\n bodyFont,\n bodyFontColor,\n popupBorderColor,\n controlSlimHeight,\n mediumPadding,\n standardPadding,\n tableRowBorderColor,\n borderHoverColor,\n controlHeight,\n tableFitRowsHeight,\n borderWidth\n} from '../theme-provider/design-tokens';\nimport { Theme } from '../theme-provider/types';\nimport { hexToRgbaCssColor } from '../utilities/style/colors';\nimport { themeBehavior } from '../utilities/style/theme';\nimport { userSelectNone } from '../utilities/style/user-select';\nimport { accessiblyHidden } from '../utilities/style/accessibly-hidden';\nimport { ZIndexLevels } from '../utilities/style/types';\nimport { focusVisible } from '../utilities/style/focus';\n\nexport const styles = css`\n ${display('flex')}\n\n :host {\n height: 480px;\n ${tableFitRowsHeight.cssCustomProperty}: calc(var(--ni-private-table-scroll-height) + ${controlHeight});\n ${\n /**\n * Set a default maximum height for the table of 40.5 rows plus the header row so\n * that clients don't accidentally create a table that tries to render too many rows at once.\n * If needed, the max-height can be overridden by the client, but setting a default ensures\n * that the max-height is considered if a larger one is needed rather than being overlooked.\n */ ''\n }\n max-height: calc(${controlHeight} + (40.5 * (2 * ${borderWidth} + ${controlHeight})));\n --ni-private-column-divider-width: 2px;\n --ni-private-column-divider-padding: 3px;\n }\n\n :host(${focusVisible}) {\n ${\n /* The table can briefly be focused in some keyboard nav cases (e.g. regaining focus and we\n need to scroll to the previously focused row first). Ensure that we don't get the browser-default\n focus outline in that case.\n ) */ ''\n }\n outline: none;\n }\n\n .disable-select {\n ${userSelectNone}\n }\n\n .table-container {\n overflow: hidden;\n display: flex;\n flex-direction: column;\n width: 100%;\n font: ${bodyFont};\n color: ${bodyFontColor};\n cursor: var(--ni-private-table-cursor-override);\n }\n\n .header-row-container {\n position: sticky;\n top: 0;\n }\n\n .header-row {\n display: flex;\n background: ${applicationBackgroundColor};\n position: relative;\n width: fit-content;\n min-width: max(\n 100%,\n calc(\n var(--ni-private-table-scrollable-min-width) +\n var(--ni-private-table-header-container-margin-right)\n )\n );\n left: var(--ni-private-table-scroll-x);\n align-items: center;\n }\n\n .header-row-action-container {\n display: flex;\n align-items: center;\n }\n\n .checkbox-container {\n display: flex;\n }\n\n .column-headers-container {\n display: grid;\n width: 100%;\n grid-template-columns: var(--ni-private-table-row-grid-columns) auto;\n }\n\n .collapse-all-button-container {\n display: flex;\n min-width: ${mediumPadding};\n }\n\n .collapse-all-button {\n height: ${controlSlimHeight};\n margin-left: ${mediumPadding};\n visibility: hidden;\n }\n\n .collapse-all-button.hidden-size-reduced {\n display: none;\n }\n\n .collapse-all-button.visible {\n visibility: visible;\n }\n\n .header-container {\n display: flex;\n align-items: center;\n position: relative;\n }\n\n .header-scrollbar-spacer {\n width: var(--ni-private-table-header-container-margin-right);\n }\n\n .header {\n flex: 1;\n overflow: hidden;\n }\n\n .column-divider {\n border-left: var(--ni-private-column-divider-width) solid\n ${popupBorderColor};\n display: none;\n height: ${controlSlimHeight};\n cursor: col-resize;\n position: absolute;\n z-index: ${ZIndexLevels.zIndex1};\n touch-action: pan-y;\n }\n\n .column-divider:hover,\n .column-divider.divider-active {\n border-color: ${borderHoverColor};\n }\n\n .column-divider.column-active.draggable,\n .header-container:hover .column-divider.draggable {\n display: block;\n }\n\n .column-divider::before {\n content: '';\n position: absolute;\n width: calc(\n var(--ni-private-column-divider-width) +\n (2 * var(--ni-private-column-divider-padding))\n );\n height: 100%;\n left: calc(\n -1 *\n (\n var(--ni-private-column-divider-width) +\n var(--ni-private-column-divider-padding)\n )\n );\n }\n\n .column-divider.left {\n left: -1px;\n }\n\n .column-divider.right {\n left: calc(100% - 1px);\n }\n\n .table-viewport {\n overflow: auto;\n display: block;\n height: 100%;\n position: relative;\n }\n\n .table-viewport${focusVisible} {\n outline: none;\n }\n\n .table-scroll {\n pointer-events: none;\n position: absolute;\n top: 0px;\n width: 100%;\n height: var(--ni-private-table-scroll-height);\n }\n\n .table-row-container {\n width: fit-content;\n min-width: max(100%, var(--ni-private-table-scrollable-min-width));\n position: relative;\n top: var(--ni-private-table-row-container-top);\n background-color: ${tableRowBorderColor};\n }\n\n .selection-checkbox {\n margin-left: ${standardPadding};\n }\n\n .selection-checkbox::part(label) {\n padding-left: 0px;\n }\n\n .group-row {\n position: relative;\n --ni-private-table-cell-focus-offset-multiplier: 0;\n }\n\n .row {\n position: relative;\n --ni-private-table-cell-focus-offset-multiplier: 0;\n }\n\n .collapse-all-visible .row,\n .collapse-all-visible .group-row {\n --ni-private-table-cell-focus-offset-multiplier: 1;\n }\n\n .accessibly-hidden {\n ${accessiblyHidden}\n }\n`.withBehaviors(\n themeBehavior(\n Theme.color,\n css`\n .table-row-container::before {\n content: '';\n width: 100%;\n height: 100%;\n background-color: ${hexToRgbaCssColor(White, 0.1)};\n position: absolute;\n }\n `\n )\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ni/nimble-components",
|
|
3
|
-
"version": "32.8.
|
|
3
|
+
"version": "32.8.1",
|
|
4
4
|
"description": "Styled web components for the NI Nimble Design System",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run generate-icons && npm run generate-workers && npm run build-components && npm run bundle-components && npm run generate-scss",
|
|
@@ -66,20 +66,20 @@
|
|
|
66
66
|
"@ni/nimble-tokens": "^8.5.0",
|
|
67
67
|
"@tanstack/table-core": "^8.19.3",
|
|
68
68
|
"@tanstack/virtual-core": "^3.10.6",
|
|
69
|
-
"@tiptap/core": "^2.
|
|
70
|
-
"@tiptap/extension-bold": "^2.
|
|
71
|
-
"@tiptap/extension-bullet-list": "^2.
|
|
72
|
-
"@tiptap/extension-document": "^2.
|
|
73
|
-
"@tiptap/extension-hard-break": "^2.
|
|
74
|
-
"@tiptap/extension-history": "^2.
|
|
75
|
-
"@tiptap/extension-italic": "^2.
|
|
76
|
-
"@tiptap/extension-link": "^2.
|
|
77
|
-
"@tiptap/extension-list-item": "^2.
|
|
78
|
-
"@tiptap/extension-mention": "^2.
|
|
79
|
-
"@tiptap/extension-ordered-list": "^2.
|
|
80
|
-
"@tiptap/extension-paragraph": "^2.
|
|
81
|
-
"@tiptap/extension-placeholder": "^2.
|
|
82
|
-
"@tiptap/extension-text": "^2.
|
|
69
|
+
"@tiptap/core": "^2.10.3",
|
|
70
|
+
"@tiptap/extension-bold": "^2.10.3",
|
|
71
|
+
"@tiptap/extension-bullet-list": "^2.10.3",
|
|
72
|
+
"@tiptap/extension-document": "^2.10.3",
|
|
73
|
+
"@tiptap/extension-hard-break": "^2.10.3",
|
|
74
|
+
"@tiptap/extension-history": "^2.10.3",
|
|
75
|
+
"@tiptap/extension-italic": "^2.10.3",
|
|
76
|
+
"@tiptap/extension-link": "^2.10.3",
|
|
77
|
+
"@tiptap/extension-list-item": "^2.10.3",
|
|
78
|
+
"@tiptap/extension-mention": "^2.10.3",
|
|
79
|
+
"@tiptap/extension-ordered-list": "^2.10.3",
|
|
80
|
+
"@tiptap/extension-paragraph": "^2.10.3",
|
|
81
|
+
"@tiptap/extension-placeholder": "^2.10.3",
|
|
82
|
+
"@tiptap/extension-text": "^2.10.3",
|
|
83
83
|
"@types/d3-array": "^3.0.4",
|
|
84
84
|
"@types/d3-random": "^3.0.1",
|
|
85
85
|
"@types/d3-scale": "^4.0.2",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"d3-scale": "^4.0.2",
|
|
93
93
|
"d3-selection": "^3.0.0",
|
|
94
94
|
"d3-zoom": "^3.0.0",
|
|
95
|
-
"prosemirror-markdown": "^1.
|
|
96
|
-
"prosemirror-model": "^1.
|
|
95
|
+
"prosemirror-markdown": "^1.13.1",
|
|
96
|
+
"prosemirror-model": "^1.24.0",
|
|
97
97
|
"prosemirror-state": "^1.4.3",
|
|
98
98
|
"tslib": "^2.2.0"
|
|
99
99
|
},
|