@charcuterie/ui 4.3.0 → 4.5.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.
- package/dist/ActionTiles/ActionTiles.d.ts +2 -1
- package/dist/ActionTiles/ActionTiles.d.ts.map +1 -1
- package/dist/ActionTiles/ActionTiles.js +4 -2
- package/dist/ActionTiles/ActionTiles.js.map +1 -1
- package/dist/TimecodeInput/TimecodeInput.d.ts +17 -0
- package/dist/TimecodeInput/TimecodeInput.d.ts.map +1 -1
- package/dist/TimecodeInput/TimecodeInput.js +80 -6
- package/dist/TimecodeInput/TimecodeInput.js.map +1 -1
- package/dist/TimecodeInput/timecode.d.ts +21 -8
- package/dist/TimecodeInput/timecode.d.ts.map +1 -1
- package/dist/TimecodeInput/timecode.js +15 -7
- package/dist/TimecodeInput/timecode.js.map +1 -1
- package/package.json +2 -2
- package/src/ActionTiles/ActionTiles.mdx +6 -0
- package/src/ActionTiles/ActionTiles.tsx +4 -2
- package/src/TimecodeInput/TimecodeInput.mdx +46 -6
- package/src/TimecodeInput/TimecodeInput.stories.tsx +28 -6
- package/src/TimecodeInput/TimecodeInput.test.tsx +255 -32
- package/src/TimecodeInput/TimecodeInput.tsx +130 -19
- package/src/TimecodeInput/timecode.test.ts +43 -0
- package/src/TimecodeInput/timecode.ts +30 -12
- package/src/sourceRules.test.ts +7 -0
|
@@ -90,8 +90,17 @@ export type FormatTimecodeOptions = {
|
|
|
90
90
|
* unchanged because the largest field present is unbounded.
|
|
91
91
|
*/
|
|
92
92
|
isHoursShown?: boolean
|
|
93
|
-
/**
|
|
94
|
-
|
|
93
|
+
/**
|
|
94
|
+
* `0` through `3`. `0` drops the fraction and its separator.
|
|
95
|
+
*
|
|
96
|
+
* `"auto"` prints the fraction only when there is one to print: a
|
|
97
|
+
* whole number of seconds comes back as `01:01:00`, and half a
|
|
98
|
+
* second more comes back as `01:01:00.500`. It is how a decimal
|
|
99
|
+
* number is written everywhere else — you write `3`, not `3.000` —
|
|
100
|
+
* and the grammar reads both spellings back to the number that
|
|
101
|
+
* produced them, because its fraction is optional.
|
|
102
|
+
*/
|
|
103
|
+
millisecondDigits?: "auto" | number
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
const padTwo = (value: number) =>
|
|
@@ -105,12 +114,16 @@ const padTwo = (value: number) =>
|
|
|
105
114
|
* because it has not reached second 2 yet. Rounding would print a
|
|
106
115
|
* seek point the media has not played.
|
|
107
116
|
*
|
|
108
|
-
* The default is the canonical `hh:mm:ss.mmm
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
117
|
+
* The default is the canonical `hh:mm:ss.mmm`. `TimecodeInput` asks
|
|
118
|
+
* for `millisecondDigits: "auto"` instead, so a whole second is
|
|
119
|
+
* written back as `01:01:00` rather than as `01:01:00.000` — a
|
|
120
|
+
* person who typed no fraction did not ask for one, and both
|
|
121
|
+
* spellings re-read to the number that produced them.
|
|
122
|
+
*
|
|
123
|
+
* Either way it is ONE spelling per value, which is what the fleet's
|
|
124
|
+
* five printers never were: three of them hide the hour and two do
|
|
125
|
+
* not pad the minute, so the same position is a different picture in
|
|
126
|
+
* each app.
|
|
114
127
|
*/
|
|
115
128
|
export const formatTimecode = (
|
|
116
129
|
milliseconds: number,
|
|
@@ -123,10 +136,15 @@ export const formatTimecode = (
|
|
|
123
136
|
? Math.max(0, Math.floor(milliseconds))
|
|
124
137
|
: 0
|
|
125
138
|
|
|
126
|
-
const digits =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
139
|
+
const digits =
|
|
140
|
+
millisecondDigits === "auto"
|
|
141
|
+
? total % MILLISECONDS_PER_SECOND === 0
|
|
142
|
+
? 0
|
|
143
|
+
: 3
|
|
144
|
+
: Math.min(
|
|
145
|
+
3,
|
|
146
|
+
Math.max(0, Math.floor(millisecondDigits)),
|
|
147
|
+
)
|
|
130
148
|
|
|
131
149
|
const hours = isHoursShown
|
|
132
150
|
? Math.floor(total / MILLISECONDS_PER_HOUR)
|
package/src/sourceRules.test.ts
CHANGED
|
@@ -251,6 +251,13 @@ test("a container-query component is never storied in a shrink-to-fit cell", ()
|
|
|
251
251
|
// measured in Docket, before any of the steps contained
|
|
252
252
|
// anything.
|
|
253
253
|
"Stepper",
|
|
254
|
+
// `TimecodeInput` queries its own box to decide whether a section
|
|
255
|
+
// is `[start] to [end]` in a row or two captioned fields stacked.
|
|
256
|
+
// The width that decides it is a modal's, not a window's: the
|
|
257
|
+
// report came from a 390px dialog, and the same dialog on a
|
|
258
|
+
// 2560px monitor is the Wide View by every media query and the
|
|
259
|
+
// Narrow View by the only measurement that matters.
|
|
260
|
+
"TimecodeInput",
|
|
254
261
|
])
|
|
255
262
|
|
|
256
263
|
// `StoryCell`s are never nested, so the lazy match really does
|