@ni/ok-components 0.1.12 → 0.1.15

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 CHANGED
@@ -6,6 +6,14 @@
6
6
 
7
7
  [![NPM Version](https://img.shields.io/npm/v/@ni/ok-components.svg)](https://www.npmjs.com/package/@ni/ok-components)
8
8
 
9
- Experimental components built using the same technologies (FAST, native web components, etc.) as other nimble packages, but not part of the core design system.
9
+ Components built using the same technologies (FAST, native web components, etc.) as other nimble packages, but not part of the core design system.
10
10
 
11
- The `ok-components` package is intended for components that do not belong in [`nimble-components`](/packages/nimble-components) due to being prototypes or experimental.
11
+ Compared to the general purpose components in the `nimble-components` library, `ok-components` are components that are leveraging Nimble infrastructure but have varied ownership. See individual component documentation for details.
12
+
13
+ ## Getting Started
14
+
15
+ Follow the [Nimble Components: Getting Started](/packages/nimble-components/README.md#getting-started) topic.
16
+
17
+ ## Contributing
18
+
19
+ Follow the instructions in [CONTRIBUTING.md](/packages/ok-components/CONTRIBUTING.md) to modify this library.
@@ -14992,7 +14992,7 @@
14992
14992
  new Intl.Locale(value);
14993
14993
  return true;
14994
14994
  }
14995
- catch (e) {
14995
+ catch (_e) {
14996
14996
  return false;
14997
14997
  }
14998
14998
  }
@@ -22273,7 +22273,6 @@ so this becomes the fallback color for the slot */ ''}
22273
22273
  /**
22274
22274
  * A nimble-styled dialog.
22275
22275
  */
22276
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
22277
22276
  class Dialog extends FoundationElement {
22278
22277
  constructor() {
22279
22278
  super(...arguments);
@@ -22558,7 +22557,6 @@ so this becomes the fallback color for the slot */ ''}
22558
22557
  * Drawer control. Shows content in a panel on the left / right side of the screen,
22559
22558
  * which animates to be visible with a slide-in / slide-out animation.
22560
22559
  */
22561
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
22562
22560
  class Drawer extends FoundationElement {
22563
22561
  constructor() {
22564
22562
  super(...arguments);
@@ -26146,7 +26144,7 @@ so this becomes the fallback color for the slot */ ''}
26146
26144
  this.resolvedIcon = undefined;
26147
26145
  await customElements.whenDefined(icon);
26148
26146
  }
26149
- catch (ex) {
26147
+ catch (_ex) {
26150
26148
  // If any error (i.e. invalid custom element name) don't continue
26151
26149
  // Don't update the resolvedIcon as it was already set to undefined before async resolution
26152
26150
  // (in case other async resolutions were started)
@@ -35564,17 +35562,20 @@ so this becomes the fallback color for the slot */ ''}
35564
35562
  }
35565
35563
  function findOffsetInText(node, coords) {
35566
35564
  let len = node.nodeValue.length;
35567
- let range = document.createRange();
35565
+ let range = document.createRange(), result;
35568
35566
  for (let i = 0; i < len; i++) {
35569
35567
  range.setEnd(node, i + 1);
35570
35568
  range.setStart(node, i);
35571
35569
  let rect = singleRect(range, 1);
35572
35570
  if (rect.top == rect.bottom)
35573
35571
  continue;
35574
- if (inRect(coords, rect))
35575
- return { node, offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0) };
35572
+ if (inRect(coords, rect)) {
35573
+ result = { node, offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0) };
35574
+ break;
35575
+ }
35576
35576
  }
35577
- return { node, offset: 0 };
35577
+ range.detach();
35578
+ return result || { node, offset: 0 };
35578
35579
  }
35579
35580
  function inRect(coords, rect) {
35580
35581
  return coords.left >= rect.left - 1 && coords.left <= rect.right + 1 &&
@@ -38667,7 +38668,8 @@ so this becomes the fallback color for the slot */ ''}
38667
38668
  let { state } = view, $pos = state.selection.$to;
38668
38669
  if (state.selection instanceof TextSelection &&
38669
38670
  (state.storedMarks ||
38670
- (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(m => m.type.spec.inclusive === false)))) {
38671
+ (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(m => m.type.spec.inclusive === false)) ||
38672
+ chrome && windows$1 && selectionBeforeUneditable(view))) { // Issue #1500
38671
38673
  // Need to wrap the cursor in mark nodes different from the ones in the DOM context
38672
38674
  view.markCursor = view.state.storedMarks || $pos.marks();
38673
38675
  endComposition(view, true);
@@ -38701,6 +38703,13 @@ so this becomes the fallback color for the slot */ ''}
38701
38703
  }
38702
38704
  scheduleComposeEnd(view, timeoutComposition);
38703
38705
  };
38706
+ function selectionBeforeUneditable(view) {
38707
+ let { focusNode, focusOffset } = view.domSelectionRange();
38708
+ if (!focusNode || focusNode.nodeType != 1 || focusOffset >= focusNode.childNodes.length)
38709
+ return false;
38710
+ let next = focusNode.childNodes[focusOffset];
38711
+ return next.nodeType == 1 && next.contentEditable == "false";
38712
+ }
38704
38713
  editHandlers.compositionend = (view, event) => {
38705
38714
  if (view.composing) {
38706
38715
  view.input.composing = false;
@@ -38928,10 +38937,15 @@ so this becomes the fallback color for the slot */ ''}
38928
38937
  }, 50);
38929
38938
  };
38930
38939
  editHandlers.dragover = editHandlers.dragenter = (_, e) => e.preventDefault();
38931
- editHandlers.drop = (view, _event) => {
38932
- let event = _event;
38933
- let dragging = view.dragging;
38934
- view.dragging = null;
38940
+ editHandlers.drop = (view, event) => {
38941
+ try {
38942
+ handleDrop(view, event, view.dragging);
38943
+ }
38944
+ finally {
38945
+ view.dragging = null;
38946
+ }
38947
+ };
38948
+ function handleDrop(view, event, dragging) {
38935
38949
  if (!event.dataTransfer)
38936
38950
  return;
38937
38951
  let eventPos = view.posAtCoords(eventCoords(event));
@@ -38985,7 +38999,7 @@ so this becomes the fallback color for the slot */ ''}
38985
38999
  }
38986
39000
  view.focus();
38987
39001
  view.dispatch(tr.setMeta("uiEvent", "drop"));
38988
- };
39002
+ }
38989
39003
  handlers.focus = view => {
38990
39004
  view.input.lastFocus = Date.now();
38991
39005
  if (!view.focused) {
@@ -39911,6 +39925,17 @@ so this becomes the fallback color for the slot */ ''}
39911
39925
  }
39912
39926
  }
39913
39927
  }
39928
+ else if ((chrome || safari) && added.some(n => n.nodeName == "BR") &&
39929
+ (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46)) {
39930
+ // Chrome/Safari sometimes insert a bogus break node if you
39931
+ // backspace out the last bit of text before an inline-flex node (#1552)
39932
+ for (let node of added)
39933
+ if (node.nodeName == "BR" && node.parentNode) {
39934
+ let after = node.nextSibling;
39935
+ if (after && after.nodeType == 1 && after.contentEditable == "false")
39936
+ node.parentNode.removeChild(node);
39937
+ }
39938
+ }
39914
39939
  let readSel = null;
39915
39940
  // If it looks like the browser has reset the selection to the
39916
39941
  // start of the document after focus, restore the selection from
@@ -43182,6 +43207,37 @@ so this becomes the fallback color for the slot */ ''}
43182
43207
  return value instanceof NodeSelection;
43183
43208
  }
43184
43209
 
43210
+ // src/helpers/MappablePosition.ts
43211
+ var MappablePosition = class _MappablePosition {
43212
+ constructor(position) {
43213
+ this.position = position;
43214
+ }
43215
+ /**
43216
+ * Creates a MappablePosition from a JSON object.
43217
+ */
43218
+ static fromJSON(json) {
43219
+ return new _MappablePosition(json.position);
43220
+ }
43221
+ /**
43222
+ * Converts the MappablePosition to a JSON object.
43223
+ */
43224
+ toJSON() {
43225
+ return {
43226
+ position: this.position
43227
+ };
43228
+ }
43229
+ };
43230
+ function getUpdatedPosition(position, transaction) {
43231
+ const mapResult = transaction.mapping.mapResult(position.position);
43232
+ return {
43233
+ position: new MappablePosition(mapResult.pos),
43234
+ mapResult
43235
+ };
43236
+ }
43237
+ function createMappablePosition(position) {
43238
+ return new MappablePosition(position);
43239
+ }
43240
+
43185
43241
  // src/commands/setMark.ts
43186
43242
  function canSetMark(state, tr, newMarkType) {
43187
43243
  var _a;
@@ -45370,6 +45426,13 @@ img.ProseMirror-separator {
45370
45426
  };
45371
45427
  this.isCapturingTransaction = false;
45372
45428
  this.capturedTransaction = null;
45429
+ /**
45430
+ * Returns a set of utilities for working with positions and ranges.
45431
+ */
45432
+ this.utils = {
45433
+ getUpdatedPosition,
45434
+ createMappablePosition
45435
+ };
45373
45436
  this.setOptions(options);
45374
45437
  this.createExtensionManager();
45375
45438
  this.createCommandManager();
@@ -68778,7 +68841,7 @@ ${nextLine.slice(indentLevel + 2)}`;
68778
68841
  try {
68779
68842
  instance = document.createElement(groupHeaderViewTag);
68780
68843
  }
68781
- catch (ex) {
68844
+ catch (_ex) {
68782
68845
  // Swallow construction error to report a better one
68783
68846
  }
68784
68847
  if (!(instance instanceof TableGroupHeaderView)) {
@@ -68864,7 +68927,7 @@ ${nextLine.slice(indentLevel + 2)}`;
68864
68927
  try {
68865
68928
  instance = document.createElement(cellViewTag);
68866
68929
  }
68867
- catch (ex) {
68930
+ catch (_ex) {
68868
68931
  // Swallow construction error to report a better one
68869
68932
  }
68870
68933
  if (!(instance instanceof TableCellView)) {
@@ -74707,12 +74770,8 @@ focus outline in that case.
74707
74770
  this.columnInternals.minPixelWidth = this.minPixelWidth ?? defaultMinPixelWidth;
74708
74771
  }
74709
74772
  }
74710
- attr({ attribute: 'fractional-width', converter: nullableNumberConverter })(
74711
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
74712
- FractionalWidthColumn.prototype, 'fractionalWidth');
74713
- attr({ attribute: 'min-pixel-width', converter: nullableNumberConverter })(
74714
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
74715
- FractionalWidthColumn.prototype, 'minPixelWidth');
74773
+ attr({ attribute: 'fractional-width', converter: nullableNumberConverter })(FractionalWidthColumn.prototype, 'fractionalWidth');
74774
+ attr({ attribute: 'min-pixel-width', converter: nullableNumberConverter })(FractionalWidthColumn.prototype, 'minPixelWidth');
74716
74775
  return FractionalWidthColumn;
74717
74776
  }
74718
74777
 
@@ -74735,12 +74794,8 @@ focus outline in that case.
74735
74794
  this.columnInternals.groupIndex = this.groupIndex ?? undefined;
74736
74795
  }
74737
74796
  }
74738
- attr({ attribute: 'grouping-disabled', mode: 'boolean' })(
74739
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
74740
- GroupableColumn.prototype, 'groupingDisabled');
74741
- attr({ attribute: 'group-index', converter: nullableNumberConverter })(
74742
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
74743
- GroupableColumn.prototype, 'groupIndex');
74797
+ attr({ attribute: 'grouping-disabled', mode: 'boolean' })(GroupableColumn.prototype, 'groupingDisabled');
74798
+ attr({ attribute: 'group-index', converter: nullableNumberConverter })(GroupableColumn.prototype, 'groupIndex');
74744
74799
  return GroupableColumn;
74745
74800
  }
74746
74801
 
@@ -74753,9 +74808,7 @@ focus outline in that case.
74753
74808
  */
74754
74809
  class ColumnWithPlaceholder extends base {
74755
74810
  }
74756
- attr({ attribute: 'placeholder' })(
74757
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
74758
- ColumnWithPlaceholder.prototype, 'placeholder');
74811
+ attr({ attribute: 'placeholder' })(ColumnWithPlaceholder.prototype, 'placeholder');
74759
74812
  return ColumnWithPlaceholder;
74760
74813
  }
74761
74814
 
@@ -75039,15 +75092,9 @@ focus outline in that case.
75039
75092
  }
75040
75093
  }
75041
75094
  }
75042
- attr({ attribute: 'sorting-disabled', mode: 'boolean' })(
75043
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
75044
- SortableColumn.prototype, 'sortingDisabled');
75045
- attr({ attribute: 'sort-index', converter: nullableNumberConverter })(
75046
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
75047
- SortableColumn.prototype, 'sortIndex');
75048
- attr({ attribute: 'sort-direction' })(
75049
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
75050
- SortableColumn.prototype, 'sortDirection');
75095
+ attr({ attribute: 'sorting-disabled', mode: 'boolean' })(SortableColumn.prototype, 'sortingDisabled');
75096
+ attr({ attribute: 'sort-index', converter: nullableNumberConverter })(SortableColumn.prototype, 'sortIndex');
75097
+ attr({ attribute: 'sort-direction' })(SortableColumn.prototype, 'sortDirection');
75051
75098
  return SortableColumn;
75052
75099
  }
75053
75100
 
@@ -75109,9 +75156,7 @@ focus outline in that case.
75109
75156
  }
75110
75157
  }
75111
75158
  }
75112
- attr({ attribute: 'sort-by-field-name' })(
75113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
75114
- CustomSortOrderColumn.prototype, 'sortByFieldName');
75159
+ attr({ attribute: 'sort-by-field-name' })(CustomSortOrderColumn.prototype, 'sortByFieldName');
75115
75160
  return CustomSortOrderColumn;
75116
75161
  }
75117
75162
 
@@ -75265,7 +75310,7 @@ focus outline in that case.
75265
75310
  __decorate([
75266
75311
  attr({ attribute: 'field-name' })
75267
75312
  ], TableColumnTextBase.prototype, "fieldName", void 0);
75268
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any
75313
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
75269
75314
  function mixinTextBase(base) {
75270
75315
  return mixinGroupableColumnAPI(mixinFractionalWidthColumnAPI(mixinColumnWithPlaceholderAPI(mixinSortableColumnAPI(base))));
75271
75316
  }
@@ -75275,7 +75320,7 @@ focus outline in that case.
75275
75320
  try {
75276
75321
  return formatter.format(date);
75277
75322
  }
75278
- catch (e) {
75323
+ catch (_e) {
75279
75324
  return '';
75280
75325
  }
75281
75326
  }
@@ -75590,7 +75635,7 @@ focus outline in that case.
75590
75635
  try {
75591
75636
  return new Intl.DateTimeFormat(lang.getValueFor(this), options);
75592
75637
  }
75593
- catch (e) {
75638
+ catch (_e) {
75594
75639
  return undefined;
75595
75640
  }
75596
75641
  }