@imposium-hub/components 1.60.9 → 1.60.11

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.
Files changed (42) hide show
  1. package/dist/cjs/Util.d.ts +1 -0
  2. package/dist/cjs/Util.js +41 -1
  3. package/dist/cjs/Util.js.map +1 -1
  4. package/dist/cjs/components/assets/AssetsTableTagsPivot.js +1 -1
  5. package/dist/cjs/components/assets/AssetsTableTagsPivot.js.map +1 -1
  6. package/dist/cjs/components/controlled-list/ControlledList.stories.js +1 -1
  7. package/dist/cjs/components/data-table/DataTable.js +2 -2
  8. package/dist/cjs/components/data-table/DataTable.js.map +1 -1
  9. package/dist/cjs/components/smpte-field/SMPTEField.d.ts +4 -3
  10. package/dist/cjs/components/smpte-field/SMPTEField.js +25 -57
  11. package/dist/cjs/components/smpte-field/SMPTEField.js.map +1 -1
  12. package/dist/cjs/components/story-previewer/StoryPreviewer.js +1 -1
  13. package/dist/cjs/index.d.ts +2 -2
  14. package/dist/cjs/index.js +2 -1
  15. package/dist/cjs/index.js.map +1 -1
  16. package/dist/esm/Util.d.ts +1 -0
  17. package/dist/esm/Util.js +39 -0
  18. package/dist/esm/Util.js.map +1 -1
  19. package/dist/esm/components/assets/AssetsTableTagsPivot.js +1 -1
  20. package/dist/esm/components/assets/AssetsTableTagsPivot.js.map +1 -1
  21. package/dist/esm/components/controlled-list/ControlledList.stories.js +1 -1
  22. package/dist/esm/components/data-table/DataTable.js +2 -2
  23. package/dist/esm/components/data-table/DataTable.js.map +1 -1
  24. package/dist/esm/components/smpte-field/SMPTEField.d.ts +4 -3
  25. package/dist/esm/components/smpte-field/SMPTEField.js +26 -58
  26. package/dist/esm/components/smpte-field/SMPTEField.js.map +1 -1
  27. package/dist/esm/components/story-previewer/StoryPreviewer.js +1 -1
  28. package/dist/esm/index.d.ts +2 -2
  29. package/dist/esm/index.js +2 -2
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/styles.css +2 -0
  32. package/dist/styles.less +2 -0
  33. package/less/components/determinate-loader.less +1 -0
  34. package/less/components/story-previewer.less +1 -0
  35. package/package.json +2 -2
  36. package/src/Util.ts +52 -0
  37. package/src/components/assets/AssetsTableTagsPivot.tsx +1 -1
  38. package/src/components/controlled-list/ControlledList.stories.tsx +1 -1
  39. package/src/components/data-table/DataTable.tsx +2 -2
  40. package/src/components/smpte-field/SMPTEField.tsx +30 -68
  41. package/src/components/story-previewer/StoryPreviewer.tsx +1 -1
  42. package/src/index.ts +3 -1
@@ -1,9 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import FieldWrapper from '../field-wrapper/FieldWrapper';
3
3
  import { IToolTipConfig } from '../Tooltip';
4
- import Timecode from 'smpte-timecode';
5
4
  import { TIMECODE } from '../../constants/timecode';
6
- import { toFixed } from '../../Util';
5
+ import { getSMPTE } from '../../Util';
7
6
 
8
7
  interface ISMPTEFieldProps {
9
8
  label?: string;
@@ -12,6 +11,7 @@ interface ISMPTEFieldProps {
12
11
  tooltip?: IToolTipConfig | string;
13
12
  width?: string | number;
14
13
  onChange?(e): void;
14
+ onBlur?(e): void;
15
15
  info?: string;
16
16
  labelPosition?: string;
17
17
  labelWidth?: string | number;
@@ -73,88 +73,49 @@ class SMPTEField extends React.PureComponent<ISMPTEFieldProps, ISMPTEFieldState>
73
73
  });
74
74
  }
75
75
 
76
- private validate(e?) {
76
+ private onBlur(e?) {
77
77
  const val = e ? e.target.value : this.inputRef.current.value;
78
-
79
- const isValidSMPTETimeCode = new RegExp(this.regex);
80
- const error = isValidSMPTETimeCode.test(val);
78
+ const isValid = this.smptValidator(val);
81
79
 
82
80
  if (e && e.key === 'Enter') {
83
- this.setDuration(error, val);
81
+ this.setDuration(isValid, val);
84
82
  }
85
83
 
86
84
  if (e === undefined) {
87
- this.setDuration(error, val);
85
+ this.setDuration(isValid, val);
88
86
  }
89
87
  }
90
88
 
91
- private setDuration(error, val) {
92
- if (error) {
93
- this.setState({ error: !error, errorMsg: null });
94
- const smpte = this.getSMPTE(val);
95
- if (smpte) {
96
- this.props.onChange(smpte);
97
- }
98
- } else {
99
- this.setState({
100
- error: !error,
101
- errorMsg: TIMECODE.ERROR
102
- });
89
+ private onChange() {
90
+ const val = this.inputRef.current.value;
91
+ const isValid = this.smptValidator(val);
92
+
93
+ if (isValid) {
94
+ this.props.onChange(val);
103
95
  }
104
96
  }
105
97
 
106
- private getSMPTE(val) {
98
+ private setDuration(isValid, val) {
107
99
  const { frameRate } = this.props;
108
- const rates = Math.ceil(frameRate);
109
-
110
- const checkStr = val.includes(';');
111
- const valArray = checkStr
112
- ? val.replace(';', ':').split(':').map(Number)
113
- : val.split(':').map(Number);
114
-
115
- const toFrames = this.toFrames(valArray, rates);
116
-
117
- let duration: string = new Timecode(toFrames, rates).toString();
118
-
119
- if (parseFloat(toFixed(frameRate, 3)) === 29.97) {
120
- duration = duration.replace(/:(?=[^:]*$)/, ';');
100
+ if (isValid) {
101
+ const smpte = getSMPTE(frameRate, val);
102
+ if (smpte) {
103
+ this.props.onBlur(smpte);
104
+ }
121
105
  }
122
-
123
- this.inputRef.current.value = duration;
124
- return duration;
125
106
  }
126
107
 
127
- private toFrames(array, rates): number {
128
- const length = array.length;
129
-
130
- let hours = 0;
131
- let mins = 0;
132
- let secs = 0;
133
- let frames = 0;
134
-
135
- if (length === 1) {
136
- frames = array[0];
137
- }
138
-
139
- if (length === 2) {
140
- secs = array[0] * rates;
141
- frames = array[1];
142
- }
143
-
144
- if (length === 3) {
145
- mins = array[0] * 60 * rates;
146
- secs = array[1] * rates;
147
- frames = array[2];
148
- }
108
+ private smptValidator(val) {
109
+ const isValidSMPTETimeCode = new RegExp(this.regex);
110
+ const isValid = isValidSMPTETimeCode.test(val);
111
+ const errorMsg = isValid ? null : TIMECODE.ERROR;
149
112
 
150
- if (length === 4) {
151
- hours = array[0] * 3600 * rates;
152
- mins = array[1] * 60 * rates;
153
- secs = array[2] * rates;
154
- frames = array[3];
155
- }
113
+ this.setState({
114
+ error: !isValid,
115
+ errorMsg
116
+ });
156
117
 
157
- return hours + mins + secs + frames;
118
+ return isValid;
158
119
  }
159
120
 
160
121
  public render() {
@@ -175,8 +136,9 @@ class SMPTEField extends React.PureComponent<ISMPTEFieldProps, ISMPTEFieldState>
175
136
  pattern={this.regex}
176
137
  defaultValue={value}
177
138
  placeholder={placeholder}
178
- onBlur={() => this.validate()}
179
- onKeyDown={(e) => this.validate(e)}
139
+ onBlur={() => this.onBlur()}
140
+ onKeyDown={(e) => this.onBlur(e)}
141
+ onChange={(e) => this.onChange()}
180
142
  />
181
143
  </FieldWrapper>
182
144
  );
@@ -776,7 +776,7 @@ class StoryPreviewer extends React.PureComponent<IStoryPreviewerProps, IStoryPre
776
776
  <>
777
777
  <TextField
778
778
  readOnly={true}
779
- width='360px'
779
+ width='180px'
780
780
  label={copy.expIdField}
781
781
  showCopy={true}
782
782
  value={expId}
package/src/index.ts CHANGED
@@ -137,7 +137,8 @@ import {
137
137
  validateAssetMimetype,
138
138
  formatDateDefault,
139
139
  validateAccessLevel,
140
- formattedTime
140
+ formattedTime,
141
+ getSMPTE
141
142
  } from './Util';
142
143
  import PublishStatusIndicator from './components/publish-wizard/publish/PublishStatusIndicator';
143
144
  import { getMediaPreviewStyle } from './utils/assets';
@@ -264,6 +265,7 @@ export {
264
265
  mimetypeConformsToOverlay,
265
266
  validateAssetMimetype,
266
267
  toFixed,
268
+ getSMPTE,
267
269
  padStart,
268
270
  formatDateDefault,
269
271
  ASSET_TYPES,