@ni/spright-components 5.1.1 → 5.2.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.
@@ -29876,7 +29876,7 @@ so this becomes the fallback color for the slot */ ''}
29876
29876
  value = value.replace(/\r\n?/g, "\n");
29877
29877
  }
29878
29878
  if (value)
29879
- this.insertNode(this.parser.schema.text(value), marks);
29879
+ this.insertNode(this.parser.schema.text(value), marks, !/\S/.test(value));
29880
29880
  this.findInText(dom);
29881
29881
  }
29882
29882
  else {
@@ -29940,7 +29940,7 @@ so this becomes the fallback color for the slot */ ''}
29940
29940
  ignoreFallback(dom, marks) {
29941
29941
  // Ignored BR nodes should at least create an inline context
29942
29942
  if (dom.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent))
29943
- this.findPlace(this.parser.schema.text("-"), marks);
29943
+ this.findPlace(this.parser.schema.text("-"), marks, true);
29944
29944
  }
29945
29945
  // Run any style parser associated with the node's styles. Either
29946
29946
  // return an updated array of marks, or null to indicate some of the
@@ -29988,7 +29988,7 @@ so this becomes the fallback color for the slot */ ''}
29988
29988
  marks = inner;
29989
29989
  }
29990
29990
  }
29991
- else if (!this.insertNode(nodeType.create(rule.attrs), marks)) {
29991
+ else if (!this.insertNode(nodeType.create(rule.attrs), marks, dom.nodeName == "BR")) {
29992
29992
  this.leafFallback(dom, marks);
29993
29993
  }
29994
29994
  }
@@ -30005,7 +30005,7 @@ so this becomes the fallback color for the slot */ ''}
30005
30005
  }
30006
30006
  else if (rule.getContent) {
30007
30007
  this.findInside(dom);
30008
- rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node, marks));
30008
+ rule.getContent(dom, this.parser.schema).forEach(node => this.insertNode(node, marks, false));
30009
30009
  }
30010
30010
  else {
30011
30011
  let contentDOM = dom;
@@ -30036,19 +30036,22 @@ so this becomes the fallback color for the slot */ ''}
30036
30036
  // Try to find a way to fit the given node type into the current
30037
30037
  // context. May add intermediate wrappers and/or leave non-solid
30038
30038
  // nodes that we're in.
30039
- findPlace(node, marks) {
30039
+ findPlace(node, marks, cautious) {
30040
30040
  let route, sync;
30041
- for (let depth = this.open; depth >= 0; depth--) {
30041
+ for (let depth = this.open, penalty = 0; depth >= 0; depth--) {
30042
30042
  let cx = this.nodes[depth];
30043
30043
  let found = cx.findWrapping(node);
30044
- if (found && (!route || route.length > found.length)) {
30044
+ if (found && (!route || route.length > found.length + penalty)) {
30045
30045
  route = found;
30046
30046
  sync = cx;
30047
30047
  if (!found.length)
30048
30048
  break;
30049
30049
  }
30050
- if (cx.solid)
30051
- break;
30050
+ if (cx.solid) {
30051
+ if (cautious)
30052
+ break;
30053
+ penalty += 2;
30054
+ }
30052
30055
  }
30053
30056
  if (!route)
30054
30057
  return null;
@@ -30058,13 +30061,13 @@ so this becomes the fallback color for the slot */ ''}
30058
30061
  return marks;
30059
30062
  }
30060
30063
  // Try to insert the given node, adjusting the context when needed.
30061
- insertNode(node, marks) {
30064
+ insertNode(node, marks, cautious) {
30062
30065
  if (node.isInline && this.needsBlock && !this.top.type) {
30063
30066
  let block = this.textblockFromContext();
30064
30067
  if (block)
30065
30068
  marks = this.enterInner(block, null, marks);
30066
30069
  }
30067
- let innerMarks = this.findPlace(node, marks);
30070
+ let innerMarks = this.findPlace(node, marks, cautious);
30068
30071
  if (innerMarks) {
30069
30072
  this.closeExtra();
30070
30073
  let top = this.top;
@@ -30082,7 +30085,7 @@ so this becomes the fallback color for the slot */ ''}
30082
30085
  // Try to start a node of the given type, adjusting the context when
30083
30086
  // necessary.
30084
30087
  enter(type, attrs, marks, preserveWS) {
30085
- let innerMarks = this.findPlace(type.create(attrs), marks);
30088
+ let innerMarks = this.findPlace(type.create(attrs), marks, false);
30086
30089
  if (innerMarks)
30087
30090
  innerMarks = this.enterInner(type, attrs, marks, true, preserveWS);
30088
30091
  return innerMarks;
@@ -31216,7 +31219,7 @@ so this becomes the fallback color for the slot */ ''}
31216
31219
  let from = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
31217
31220
  if (from.deletedAcross && to.deletedAcross)
31218
31221
  return null;
31219
- return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
31222
+ return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);
31220
31223
  }
31221
31224
  merge(other) {
31222
31225
  if (!(other instanceof ReplaceStep) || other.structure || this.structure)
@@ -32593,19 +32596,26 @@ so this becomes the fallback color for the slot */ ''}
32593
32596
  return this;
32594
32597
  }
32595
32598
  /**
32596
- Remove a mark (or a mark of the given type) from the node at
32599
+ Remove a mark (or all marks of the given type) from the node at
32597
32600
  position `pos`.
32598
32601
  */
32599
32602
  removeNodeMark(pos, mark) {
32600
- if (!(mark instanceof Mark$1)) {
32601
- let node = this.doc.nodeAt(pos);
32602
- if (!node)
32603
- throw new RangeError("No node at position " + pos);
32604
- mark = mark.isInSet(node.marks);
32605
- if (!mark)
32606
- return this;
32603
+ let node = this.doc.nodeAt(pos);
32604
+ if (!node)
32605
+ throw new RangeError("No node at position " + pos);
32606
+ if (mark instanceof Mark$1) {
32607
+ if (mark.isInSet(node.marks))
32608
+ this.step(new RemoveNodeMarkStep(pos, mark));
32609
+ }
32610
+ else {
32611
+ let set = node.marks, found, steps = [];
32612
+ while (found = mark.isInSet(set)) {
32613
+ steps.push(new RemoveNodeMarkStep(pos, found));
32614
+ set = found.removeFromSet(set);
32615
+ }
32616
+ for (let i = steps.length - 1; i >= 0; i--)
32617
+ this.step(steps[i]);
32607
32618
  }
32608
- this.step(new RemoveNodeMarkStep(pos, mark));
32609
32619
  return this;
32610
32620
  }
32611
32621
  /**
@@ -36629,7 +36639,7 @@ so this becomes the fallback color for the slot */ ''}
36629
36639
  // innerHTML, even on a detached document. This wraps the string in
36630
36640
  // a way that makes the browser allow us to use its parser again.
36631
36641
  if (!_policy)
36632
- _policy = trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
36642
+ _policy = trustedTypes.defaultPolicy || trustedTypes.createPolicy("ProseMirrorClipboard", { createHTML: (s) => s });
36633
36643
  return _policy.createHTML(html);
36634
36644
  }
36635
36645
  function readHTML(html) {
@@ -37320,6 +37330,10 @@ so this becomes the fallback color for the slot */ ''}
37320
37330
  }
37321
37331
  }
37322
37332
  const dragCopyModifier = mac$2 ? "altKey" : "ctrlKey";
37333
+ function dragMoves(view, event) {
37334
+ let moves = view.someProp("dragCopies", test => !test(event));
37335
+ return moves != null ? moves : !event[dragCopyModifier];
37336
+ }
37323
37337
  handlers.dragstart = (view, _event) => {
37324
37338
  let event = _event;
37325
37339
  let mouseDown = view.input.mouseDown;
@@ -37349,7 +37363,7 @@ so this becomes the fallback color for the slot */ ''}
37349
37363
  event.dataTransfer.effectAllowed = "copyMove";
37350
37364
  if (!brokenClipboardAPI)
37351
37365
  event.dataTransfer.setData("text/plain", text);
37352
- view.dragging = new Dragging(slice, !event[dragCopyModifier], node);
37366
+ view.dragging = new Dragging(slice, dragMoves(view, event), node);
37353
37367
  };
37354
37368
  handlers.dragend = view => {
37355
37369
  let dragging = view.dragging;
@@ -37376,7 +37390,7 @@ so this becomes the fallback color for the slot */ ''}
37376
37390
  else {
37377
37391
  slice = parseFromClipboard(view, getText$1(event.dataTransfer), brokenClipboardAPI ? null : event.dataTransfer.getData("text/html"), false, $mouse);
37378
37392
  }
37379
- let move = !!(dragging && !event[dragCopyModifier]);
37393
+ let move = !!(dragging && dragMoves(view, event));
37380
37394
  if (view.someProp("handleDrop", f => f(view, event, slice || Slice.empty, move))) {
37381
37395
  event.preventDefault();
37382
37396
  return;
@@ -38661,9 +38675,11 @@ so this becomes the fallback color for the slot */ ''}
38661
38675
  // as being an iOS enter press), just dispatch an Enter key instead.
38662
38676
  if (((ios && view.input.lastIOSEnter > Date.now() - 225 &&
38663
38677
  (!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
38664
- (!inlineChange && $from.pos < parse.doc.content.size && !$from.sameParent($to) &&
38678
+ (!inlineChange && $from.pos < parse.doc.content.size &&
38679
+ (!$from.sameParent($to) || !$from.parent.inlineContent) &&
38680
+ !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")) &&
38665
38681
  (nextSel = Selection$2.findFrom(parse.doc.resolve($from.pos + 1), 1, true)) &&
38666
- nextSel.head == $to.pos)) &&
38682
+ nextSel.head > $from.pos)) &&
38667
38683
  view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
38668
38684
  view.input.lastIOSEnter = 0;
38669
38685
  return;
@@ -40116,6 +40132,8 @@ so this becomes the fallback color for the slot */ ''}
40116
40132
  types[0] = deflt ? { type: deflt } : null;
40117
40133
  can = canSplit(tr.doc, splitPos, types.length, types);
40118
40134
  }
40135
+ if (!can)
40136
+ return false;
40119
40137
  tr.split(splitPos, types.length, types);
40120
40138
  if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {
40121
40139
  let first = tr.mapping.map($from.before(splitDepth)), $first = tr.doc.resolve(first);
@@ -44730,7 +44748,7 @@ img.ProseMirror-separator {
44730
44748
  // @ts-ignore
44731
44749
  const name = typeof nameOrPluginKey === 'string' ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
44732
44750
  // @ts-ignore
44733
- plugins = prevPlugins.filter(plugin => !plugin.key.startsWith(name));
44751
+ plugins = plugins.filter(plugin => !plugin.key.startsWith(name));
44734
44752
  });
44735
44753
  if (prevPlugins.length === plugins.length) {
44736
44754
  // No plugin was removed, so we don’t need to update the state
@@ -63767,6 +63785,10 @@ img.ProseMirror-separator {
63767
63785
  }
63768
63786
  };
63769
63787
 
63788
+ function safelyAccessDocument(_document) {
63789
+ return _document || (typeof document !== 'undefined' ? document : null);
63790
+ }
63791
+
63770
63792
  //
63771
63793
 
63772
63794
  //
@@ -63906,7 +63928,7 @@ img.ProseMirror-separator {
63906
63928
  columnSizingStart: []
63907
63929
  }));
63908
63930
  };
63909
- const contextDocument = _contextDocument || typeof document !== 'undefined' ? document : null;
63931
+ const contextDocument = safelyAccessDocument(_contextDocument);
63910
63932
  const mouseEvents = {
63911
63933
  moveHandler: e => onMove(e.clientX),
63912
63934
  upHandler: e => {
@@ -74849,6 +74871,7 @@ focus outline in that case.
74849
74871
  frameless: 'frameless'
74850
74872
  };
74851
74873
 
74874
+ // prettier-ignore
74852
74875
  const styles$8 = css `
74853
74876
  ${display$1('inline-block')}
74854
74877
  ${styles$Q}
@@ -74863,12 +74886,17 @@ focus outline in that case.
74863
74886
  --ni-private-height-within-border: calc(
74864
74887
  ${controlHeight} - 2 * ${borderWidth}
74865
74888
  );
74889
+ --ni-private-default-start-slot-opacity: 0.6;
74866
74890
  }
74867
74891
 
74868
74892
  :host([disabled]) {
74869
74893
  color: ${bodyDisabledFontColor};
74870
74894
  }
74871
74895
 
74896
+ :host([disabled][appearance-readonly]) {
74897
+ color: ${bodyFontColor};
74898
+ }
74899
+
74872
74900
  .label {
74873
74901
  display: flex;
74874
74902
  color: ${controlLabelFontColor};
@@ -74879,6 +74907,10 @@ focus outline in that case.
74879
74907
  color: ${controlLabelDisabledFontColor};
74880
74908
  }
74881
74909
 
74910
+ :host([disabled][appearance-readonly]) .label {
74911
+ color: ${controlLabelFontColor};
74912
+ }
74913
+
74882
74914
  .root {
74883
74915
  position: relative;
74884
74916
  display: flex;
@@ -74944,7 +74976,7 @@ focus outline in that case.
74944
74976
 
74945
74977
  slot[name='start']::slotted(*) {
74946
74978
  flex: none;
74947
- opacity: 0.6;
74979
+ opacity: var(--ni-private-default-start-slot-opacity);
74948
74980
  margin-right: ${smallPadding};
74949
74981
  }
74950
74982
 
@@ -74952,6 +74984,10 @@ focus outline in that case.
74952
74984
  opacity: 0.3;
74953
74985
  }
74954
74986
 
74987
+ :host([disabled][appearance-readonly]) slot[name='start']::slotted(*) {
74988
+ opacity: var(--ni-private-default-start-slot-opacity);
74989
+ }
74990
+
74955
74991
  .control {
74956
74992
  -webkit-appearance: none;
74957
74993
  font: inherit;
@@ -74985,10 +75021,14 @@ focus outline in that case.
74985
75021
  color: ${controlLabelFontColor};
74986
75022
  }
74987
75023
 
74988
- .control[disabled]::placeholder {
75024
+ :host([disabled]) .control::placeholder {
74989
75025
  color: ${bodyDisabledFontColor};
74990
75026
  }
74991
75027
 
75028
+ :host([disabled][appearance-readonly]) .control::placeholder {
75029
+ color: ${controlLabelFontColor};
75030
+ }
75031
+
74992
75032
  [part='end'] {
74993
75033
  display: contents;
74994
75034
  }
@@ -75175,6 +75215,7 @@ focus outline in that case.
75175
75215
  */
75176
75216
  this.appearance = TextFieldAppearance.underline;
75177
75217
  this.fullBleed = false;
75218
+ this.appearanceReadOnly = false;
75178
75219
  }
75179
75220
  }
75180
75221
  __decorate([
@@ -75183,6 +75224,9 @@ focus outline in that case.
75183
75224
  __decorate([
75184
75225
  attr({ attribute: 'full-bleed', mode: 'boolean' })
75185
75226
  ], TextField.prototype, "fullBleed", void 0);
75227
+ __decorate([
75228
+ attr({ attribute: 'appearance-readonly', mode: 'boolean' })
75229
+ ], TextField.prototype, "appearanceReadOnly", void 0);
75186
75230
  const nimbleTextField = TextField.compose({
75187
75231
  baseName: 'text-field',
75188
75232
  baseClass: TextField$1,
@@ -93047,7 +93091,7 @@ focus outline in that case.
93047
93091
  :host {
93048
93092
  flex-direction: column;
93049
93093
  justify-content: flex-start;
93050
- row-gap: ${standardPadding};
93094
+ row-gap: 32px;
93051
93095
  padding: ${mediumPadding};
93052
93096
  background: ${applicationBackgroundColor};
93053
93097
  overflow-y: auto;
@@ -93073,6 +93117,16 @@ focus outline in that case.
93073
93117
  .withPrefix('spright')
93074
93118
  .register(sprightChatConversation());
93075
93119
 
93120
+ /**
93121
+ * A message type in a chat conversation.
93122
+ * @public
93123
+ */
93124
+ const ChatMessageType = {
93125
+ system: undefined,
93126
+ outbound: 'outbound',
93127
+ inbound: 'inbound'
93128
+ };
93129
+
93076
93130
  const styles$1 = css `
93077
93131
  ${display('flex')}
93078
93132
 
@@ -93087,45 +93141,85 @@ focus outline in that case.
93087
93141
  color: ${bodyFontColor};
93088
93142
  }
93089
93143
 
93090
- :host([message-type='outbound']) {
93144
+ :host([message-type='${ChatMessageType.outbound}']) {
93091
93145
  justify-content: flex-end;
93092
93146
  }
93093
93147
 
93094
- :host([message-type='inbound']) {
93148
+ :host([message-type='${ChatMessageType.inbound}']) {
93095
93149
  justify-content: flex-start;
93096
93150
  }
93097
93151
 
93098
- div {
93099
- max-width: calc(100% - 200px);
93152
+ .container {
93153
+ display: flex;
93154
+ flex-direction: column;
93155
+ max-width: calc(90%);
93156
+ }
93157
+
93158
+ [part='start'] {
93159
+ display: none;
93160
+ }
93161
+
93162
+ .message-content {
93100
93163
  width: fit-content;
93101
93164
  height: fit-content;
93102
- padding: ${mediumPadding};
93103
93165
  overflow-x: auto;
93104
93166
  }
93105
93167
 
93106
- :host([message-type='outbound']) div {
93168
+ :host([message-type='${ChatMessageType.outbound}']) .message-content {
93107
93169
  background: ${fillSelectedColor};
93108
93170
  border: ${borderWidth} solid ${borderHoverColor};
93109
- border-radius: 8px 8px 0px 8px;
93171
+ border-radius: ${mediumPadding} ${mediumPadding} 0px ${mediumPadding};
93172
+ padding: ${mediumPadding};
93173
+ }
93174
+
93175
+ .footer-actions {
93176
+ display: none;
93177
+ }
93178
+
93179
+ :host([message-type='${ChatMessageType.inbound}'])
93180
+ .footer-actions.has-content {
93181
+ display: flex;
93182
+ column-gap: ${standardPadding};
93183
+ margin-top: ${mediumPadding};
93184
+ }
93185
+
93186
+ .footer-actions ::slotted(${buttonTag}),
93187
+ .footer-actions ::slotted(${toggleButtonTag}),
93188
+ .footer-actions ::slotted(${anchorButtonTag}),
93189
+ .footer-actions ::slotted(${menuButtonTag}) {
93190
+ height: ${controlSlimHeight};
93191
+ }
93192
+
93193
+ .end {
93194
+ display: none;
93110
93195
  }
93111
93196
 
93112
- :host([message-type='inbound']) div {
93113
- border-radius: 8px 8px 8px 0px;
93197
+ :host([message-type='${ChatMessageType.inbound}']) .end {
93198
+ display: flex;
93199
+ column-gap: ${standardPadding};
93200
+ margin-top: ${largePadding};
93114
93201
  }
93115
93202
  `;
93116
93203
 
93117
93204
  /* eslint-disable @typescript-eslint/indent */
93118
93205
  // prettier-ignore
93119
- const template$1 = html `<div><slot></slot></div>`;
93206
+ const template$1 = (context, definition) => html `
93207
+ <div class="container">
93208
+ ${startSlotTemplate(context, definition)}
93209
+ <section class="message-content">
93210
+ <slot></slot>
93211
+ </section>
93212
+ <section class="footer-actions ${x => (x.footerActionsIsEmpty ? '' : 'has-content')}">
93213
+ <slot
93214
+ name="footer-actions"
93215
+ ${slotted({ property: 'slottedFooterActionsElements' })}
93216
+ ></slot>
93217
+ </section>
93218
+ ${endSlotTemplate(context, definition)}
93219
+ </div>
93220
+ `;
93120
93221
  /* eslint-enable @typescript-eslint/indent */
93121
93222
 
93122
- /**
93123
- * A message type in a chat conversation.
93124
- * @public
93125
- */
93126
- const ChatMessageType = {
93127
- system: undefined};
93128
-
93129
93223
  /**
93130
93224
  * A Spright component for displaying a chat message
93131
93225
  */
@@ -93139,11 +93233,23 @@ focus outline in that case.
93139
93233
  * HTML Attribute: message-type
93140
93234
  */
93141
93235
  this.messageType = ChatMessageType.system;
93236
+ /** @internal */
93237
+ this.footerActionsIsEmpty = true;
93238
+ }
93239
+ slottedFooterActionsElementsChanged(_prev, next) {
93240
+ this.footerActionsIsEmpty = !next?.length;
93142
93241
  }
93143
93242
  }
93144
93243
  __decorate([
93145
93244
  attr({ attribute: 'message-type' })
93146
93245
  ], ChatMessage.prototype, "messageType", void 0);
93246
+ __decorate([
93247
+ observable
93248
+ ], ChatMessage.prototype, "footerActionsIsEmpty", void 0);
93249
+ __decorate([
93250
+ observable
93251
+ ], ChatMessage.prototype, "slottedFooterActionsElements", void 0);
93252
+ applyMixins(ChatMessage, StartEnd);
93147
93253
  const sprightChatMessage = ChatMessage.compose({
93148
93254
  baseName: 'chat-message',
93149
93255
  template: template$1,