@ni/ok-components 1.17.0 → 1.18.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.
@@ -116046,6 +116046,107 @@ focus outline in that case.
116046
116046
  });
116047
116047
  DesignSystem.getOrCreate().withPrefix('ok').register(okFvSearchInput());
116048
116048
 
116049
+ /**
116050
+ * A Nimble text field with optional Maskito input masking.
116051
+ */
116052
+ class FvTextField extends TextField {
116053
+ constructor() {
116054
+ super(...arguments);
116055
+ this.updatingValueFromControl = false;
116056
+ this.normalizingValue = false;
116057
+ }
116058
+ /** @internal */
116059
+ connectedCallback() {
116060
+ super.connectedCallback();
116061
+ this.initializeMask();
116062
+ }
116063
+ /** @internal */
116064
+ disconnectedCallback() {
116065
+ this.destroyMask();
116066
+ super.disconnectedCallback();
116067
+ }
116068
+ /** @internal */
116069
+ maskOptionsChanged() {
116070
+ if (this.$fastController.isConnected) {
116071
+ this.initializeMask();
116072
+ }
116073
+ }
116074
+ /** @internal */
116075
+ handleTextInput() {
116076
+ this.updatingValueFromControl = true;
116077
+ super.handleTextInput();
116078
+ this.updatingValueFromControl = false;
116079
+ }
116080
+ /** @internal */
116081
+ valueChanged(previous, next) {
116082
+ if (!this.maskOptions
116083
+ || this.updatingValueFromControl
116084
+ || this.normalizingValue) {
116085
+ super.valueChanged(previous, next);
116086
+ return;
116087
+ }
116088
+ const maskedValue = maskitoTransform(next, this.maskOptions);
116089
+ if (maskedValue !== next) {
116090
+ this.normalizingValue = true;
116091
+ this.value = maskedValue;
116092
+ this.normalizingValue = false;
116093
+ }
116094
+ else {
116095
+ super.valueChanged(previous, next);
116096
+ }
116097
+ if (this.$fastController.isConnected) {
116098
+ this.control.value = maskedValue;
116099
+ this.createMask();
116100
+ }
116101
+ }
116102
+ initializeMask() {
116103
+ this.destroyMask();
116104
+ if (!this.maskOptions) {
116105
+ return;
116106
+ }
116107
+ const maskedValue = maskitoTransform(this.value, this.maskOptions);
116108
+ if (maskedValue !== this.value) {
116109
+ this.value = maskedValue;
116110
+ return;
116111
+ }
116112
+ this.control.value = maskedValue;
116113
+ this.createMask();
116114
+ }
116115
+ createMask() {
116116
+ this.destroyMask();
116117
+ if (this.maskOptions) {
116118
+ this.maskito = new Maskito(this.control, this.maskOptions);
116119
+ }
116120
+ }
116121
+ destroyMask() {
116122
+ this.maskito?.destroy();
116123
+ this.maskito = undefined;
116124
+ }
116125
+ }
116126
+ __decorate([
116127
+ observable
116128
+ ], FvTextField.prototype, "maskOptions", void 0);
116129
+ const okFvTextField = FvTextField.compose({
116130
+ baseName: 'fv-text-field',
116131
+ baseClass: TextField,
116132
+ template: template$I,
116133
+ styles: styles$H,
116134
+ shadowOptions: {
116135
+ delegatesFocus: true
116136
+ },
116137
+ end: html `
116138
+ <${iconExclamationMarkTag}
116139
+ severity="error"
116140
+ class="error-icon"
116141
+ ></${iconExclamationMarkTag}>
116142
+ <span part="actions">
116143
+ <slot name="actions"></slot>
116144
+ </span>
116145
+ ${errorTextTemplate}
116146
+ `
116147
+ });
116148
+ DesignSystem.getOrCreate().withPrefix('ok').register(okFvTextField());
116149
+
116049
116150
  const styles$5 = css `
116050
116151
  @layer base, hover, focusVisible, active;
116051
116152