@oprt/tailwind 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +185 -2
- package/dist/index.cjs +551 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +517 -0
- package/package.json +49 -3
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => index_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_plugin = __toESM(require("tailwindcss/plugin"), 1);
|
|
37
|
+
|
|
38
|
+
// src/cut.ts
|
|
39
|
+
var CUT_RATIO = 0.4;
|
|
40
|
+
var ROUNDS = "@supports (width: round(1px, 1px))";
|
|
41
|
+
var size = (name) => {
|
|
42
|
+
const share = `calc(var(--oprt-height-${name}) * ${CUT_RATIO})`;
|
|
43
|
+
return {
|
|
44
|
+
"--oprt-cut-size": share,
|
|
45
|
+
[ROUNDS]: { "--oprt-cut-size": `round(${share}, 1px)` }
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
var ENABLED = ":not(:disabled):not([aria-disabled=true])";
|
|
49
|
+
var BOTH = {
|
|
50
|
+
"--oprt-cut-tr": "var(--oprt-cut-depth)",
|
|
51
|
+
"--oprt-cut-bl": "var(--oprt-cut-depth)"
|
|
52
|
+
};
|
|
53
|
+
var TR = "var(--oprt-cut-tr, 0px)";
|
|
54
|
+
var BL = "var(--oprt-cut-bl, 0px)";
|
|
55
|
+
var LENGTH = { syntax: '"<length>"', inherits: "false", "initial-value": "0px" };
|
|
56
|
+
var cutProperties = {
|
|
57
|
+
"@property --oprt-cut-tr": LENGTH,
|
|
58
|
+
"@property --oprt-cut-bl": LENGTH
|
|
59
|
+
};
|
|
60
|
+
var EDGE = "var(--oprt-cut-edge, transparent)";
|
|
61
|
+
var STROKE_TOP_RIGHT = `linear-gradient(to top right, transparent calc(50% - 1.5px), ${EDGE} calc(50% - 1px), ${EDGE} 50%, transparent 50%)`;
|
|
62
|
+
var STROKE_BOTTOM_LEFT = `linear-gradient(to top right, transparent 50%, ${EDGE} 50%, ${EDGE} calc(50% + 1px), transparent calc(50% + 1.5px))`;
|
|
63
|
+
var stripes = (width) => `repeating-linear-gradient(45deg, color-mix(in srgb, var(--oprt-error) 10%, transparent) 0 ${width}, transparent ${width} var(--oprt-space-1))`;
|
|
64
|
+
var STRIPES = { "--oprt-cut-hatch": stripes("var(--oprt-space-0-5)") };
|
|
65
|
+
var STRIPES_PRESSED = { "--oprt-cut-hatch": stripes("calc(var(--oprt-space-0-5) * 1.5)") };
|
|
66
|
+
var cutDefaults = {
|
|
67
|
+
":where(.oprt-cut)": { "--oprt-cut-fill": "transparent", "--oprt-cut-edge": "transparent" }
|
|
68
|
+
};
|
|
69
|
+
var cutUtilities = {
|
|
70
|
+
".oprt-cut": {
|
|
71
|
+
position: "relative",
|
|
72
|
+
isolation: "isolate",
|
|
73
|
+
"--oprt-cut-depth": "var(--oprt-cut, var(--oprt-cut-size, 0px))",
|
|
74
|
+
"&::before": {
|
|
75
|
+
content: '""',
|
|
76
|
+
position: "absolute",
|
|
77
|
+
inset: "-1px",
|
|
78
|
+
"z-index": "-1",
|
|
79
|
+
"pointer-events": "none",
|
|
80
|
+
"--oprt-cut-tr": "inherit",
|
|
81
|
+
"--oprt-cut-bl": "inherit",
|
|
82
|
+
border: `1px solid ${EDGE}`,
|
|
83
|
+
"background-color": "var(--oprt-cut-fill, transparent)",
|
|
84
|
+
"background-image": `${STROKE_TOP_RIGHT}, ${STROKE_BOTTOM_LEFT}, var(--oprt-cut-hatch, none)`,
|
|
85
|
+
"background-position": "top right, bottom left, 0 0",
|
|
86
|
+
"background-size": `${TR} ${TR}, ${BL} ${BL}, auto`,
|
|
87
|
+
"background-repeat": "no-repeat, no-repeat, repeat",
|
|
88
|
+
"background-origin": "border-box",
|
|
89
|
+
"clip-path": `polygon(0 0, calc(100% - ${TR}) 0, 100% ${TR}, 100% 100%, ${BL} 100%, 0 calc(100% - ${BL}))`,
|
|
90
|
+
// The layer animates the two depths itself, on the element's timing. Animated on the element
|
|
91
|
+
// and inherited here, they left Safari's clip behind: the value moved, but the clip and the
|
|
92
|
+
// strokes were not worked out again, so a cut never appeared until something else changed.
|
|
93
|
+
"transition-property": "background-color, border-color, --oprt-cut-tr, --oprt-cut-bl",
|
|
94
|
+
"transition-duration": "inherit",
|
|
95
|
+
"transition-timing-function": "inherit"
|
|
96
|
+
},
|
|
97
|
+
// Contact cuts both corners. Hover counts only where a pointer can hover: on a touch screen a
|
|
98
|
+
// tap would otherwise leave the button cut until the next tap elsewhere.
|
|
99
|
+
[`&:active${ENABLED}, &:focus-visible${ENABLED}`]: BOTH,
|
|
100
|
+
"@media (hover: hover)": { [`&:hover${ENABLED}`]: BOTH },
|
|
101
|
+
// Forced colors replace every color the layer draws with, so it steps aside and the
|
|
102
|
+
// element's own border, which that mode makes visible, is the boundary.
|
|
103
|
+
"@media (forced-colors: active)": { "&::before": { display: "none" } }
|
|
104
|
+
},
|
|
105
|
+
".oprt-cut-sm": size("sm"),
|
|
106
|
+
".oprt-cut-md": size("md"),
|
|
107
|
+
".oprt-cut-lg": size("lg"),
|
|
108
|
+
/** No cut, for this control or for every control inside this element. */
|
|
109
|
+
".oprt-cut-none": { "--oprt-cut": "0px" },
|
|
110
|
+
/** The top-right corner is cut at rest. */
|
|
111
|
+
".oprt-cut-standing": { "--oprt-cut-tr": "var(--oprt-cut-depth)" },
|
|
112
|
+
/** Hazard stripes fill the control while it is armed: hovered, focused from the keyboard, pressed. */
|
|
113
|
+
".oprt-cut-hazard": {
|
|
114
|
+
[`&:focus-visible${ENABLED}`]: STRIPES,
|
|
115
|
+
"@media (hover: hover)": { [`&:hover${ENABLED}`]: STRIPES },
|
|
116
|
+
[`&:active${ENABLED}`]: STRIPES_PRESSED
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/motion.ts
|
|
121
|
+
var duration = (role) => `calc(var(--oprt-motion-${role}) * var(--oprt-motion-factor, 1))`;
|
|
122
|
+
var response = "var(--oprt-motion-ease-response)";
|
|
123
|
+
var move = "var(--oprt-motion-ease-move)";
|
|
124
|
+
var motionUtilities = {
|
|
125
|
+
".oprt-motion": {
|
|
126
|
+
"&[data-oprt-motion=none]": { "--oprt-motion-factor": "0" },
|
|
127
|
+
"&[data-oprt-motion=none], &[data-oprt-motion=none] *": { "transition-property": "none" },
|
|
128
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
129
|
+
"--oprt-motion-factor": "0",
|
|
130
|
+
"&.oprt-motion, &.oprt-motion *": { "transition-property": "none" }
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
".oprt-motion-press": {
|
|
134
|
+
position: "relative",
|
|
135
|
+
scale: "1",
|
|
136
|
+
// A control that carries the cut animates its two depths in the cut's own layer, on this
|
|
137
|
+
// timing, which the layer inherits (see ./cut).
|
|
138
|
+
"transition-property": "scale, background-color, border-color, color",
|
|
139
|
+
"transition-duration": duration("release"),
|
|
140
|
+
"transition-timing-function": response,
|
|
141
|
+
"&::after": {
|
|
142
|
+
content: '""',
|
|
143
|
+
position: "absolute",
|
|
144
|
+
inset: "0",
|
|
145
|
+
scale: "1",
|
|
146
|
+
"transition-property": "scale",
|
|
147
|
+
"transition-duration": "inherit",
|
|
148
|
+
"transition-timing-function": "inherit"
|
|
149
|
+
},
|
|
150
|
+
"&:active:not(:disabled):not([aria-disabled=true])": {
|
|
151
|
+
"--oprt-press-target-scale": "calc(1 + (var(--oprt-motion-press-scale) - 1) * var(--oprt-motion-factor, 1))",
|
|
152
|
+
scale: "var(--oprt-press-target-scale)",
|
|
153
|
+
"transition-duration": duration("press"),
|
|
154
|
+
// The transparent hit surface exactly compensates for visual compression.
|
|
155
|
+
"&::after": { scale: "calc(1 / var(--oprt-press-target-scale))" }
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
".oprt-motion-track": {
|
|
159
|
+
"transition-property": "background-color, border-color",
|
|
160
|
+
"transition-duration": duration("state"),
|
|
161
|
+
"transition-timing-function": response
|
|
162
|
+
},
|
|
163
|
+
// Tailwind 4's `translate-x-*` moves the thumb with `translate`; `transform` stays for a thumb
|
|
164
|
+
// moved by a style of its own.
|
|
165
|
+
".oprt-motion-thumb": {
|
|
166
|
+
"transition-property": "translate, transform, background-color",
|
|
167
|
+
"transition-duration": duration("state"),
|
|
168
|
+
"transition-timing-function": `${move}, ${move}, ${response}`
|
|
169
|
+
},
|
|
170
|
+
".oprt-motion-check": {
|
|
171
|
+
display: "block",
|
|
172
|
+
position: "absolute",
|
|
173
|
+
inset: "0",
|
|
174
|
+
margin: "auto",
|
|
175
|
+
opacity: "0",
|
|
176
|
+
scale: "var(--oprt-motion-mark-scale)",
|
|
177
|
+
"transition-property": "opacity, scale",
|
|
178
|
+
"transition-duration": duration("state"),
|
|
179
|
+
"transition-timing-function": response,
|
|
180
|
+
"[data-selected]:not([data-indeterminate]) &.oprt-cb-check, [data-indeterminate] &.oprt-cb-bar": {
|
|
181
|
+
opacity: "1",
|
|
182
|
+
scale: "1"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
".oprt-motion-tabs": {
|
|
186
|
+
position: "relative",
|
|
187
|
+
"&[data-indicator-ready] [role=tab][data-selected]": { "border-bottom-color": "transparent" },
|
|
188
|
+
"&[data-orientation=vertical]": {
|
|
189
|
+
"border-bottom-width": "0",
|
|
190
|
+
"border-inline-end-width": "1px",
|
|
191
|
+
"flex-direction": "column",
|
|
192
|
+
"& [role=tab]": {
|
|
193
|
+
"margin-bottom": "0",
|
|
194
|
+
"border-bottom-width": "1px",
|
|
195
|
+
"border-inline-end-width": "2px"
|
|
196
|
+
},
|
|
197
|
+
"&:not([data-indicator-ready]) [role=tab][data-selected]": {
|
|
198
|
+
"border-inline-end-color": "var(--oprt-accent)",
|
|
199
|
+
"border-bottom-color": "transparent"
|
|
200
|
+
},
|
|
201
|
+
"&[data-indicator-ready] [role=tab][data-selected]": {
|
|
202
|
+
"border-inline-end-color": "transparent"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
// A horizontal tab list scrolls (design call DC-14) and lays its last pixel row over the rail
|
|
207
|
+
// line its row draws, so the indicator sits on the list's own bottom edge, inside what scrolls,
|
|
208
|
+
// and still straddles the line.
|
|
209
|
+
".oprt-motion-indicator": {
|
|
210
|
+
position: "absolute",
|
|
211
|
+
bottom: "0",
|
|
212
|
+
left: "0",
|
|
213
|
+
width: "1px",
|
|
214
|
+
height: "2px",
|
|
215
|
+
"pointer-events": "none",
|
|
216
|
+
"transform-origin": "left center",
|
|
217
|
+
"background-color": "var(--oprt-accent)",
|
|
218
|
+
"transition-property": "transform",
|
|
219
|
+
"transition-duration": duration("state"),
|
|
220
|
+
"transition-timing-function": move,
|
|
221
|
+
"&[data-immediate=true]": { "transition-duration": "0s", "transition-property": "none" },
|
|
222
|
+
// Forced colors replace a background with the page color, which would hide the selected
|
|
223
|
+
// tab's underline: draw it in Highlight instead (Tabs-R3).
|
|
224
|
+
"@media (forced-colors: active)": {
|
|
225
|
+
"forced-color-adjust": "none",
|
|
226
|
+
"background-color": "Highlight"
|
|
227
|
+
},
|
|
228
|
+
"[data-orientation=vertical] > &": {
|
|
229
|
+
bottom: "auto",
|
|
230
|
+
top: "0",
|
|
231
|
+
left: "auto",
|
|
232
|
+
right: "auto",
|
|
233
|
+
"inset-inline-end": "-1px",
|
|
234
|
+
width: "2px",
|
|
235
|
+
height: "1px",
|
|
236
|
+
"transform-origin": "center top"
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
".oprt-motion-panel": {
|
|
240
|
+
height: "var(--disclosure-panel-height)",
|
|
241
|
+
overflow: "clip",
|
|
242
|
+
"transition-property": "height",
|
|
243
|
+
"transition-duration": duration("expand"),
|
|
244
|
+
"transition-timing-function": move,
|
|
245
|
+
"&[aria-hidden=true]": { "transition-duration": duration("collapse") }
|
|
246
|
+
},
|
|
247
|
+
// `rotate-180` turns the chevron with `rotate` in Tailwind 4.
|
|
248
|
+
".oprt-motion-chevron": {
|
|
249
|
+
"transition-property": "rotate, transform",
|
|
250
|
+
"transition-duration": duration("expand"),
|
|
251
|
+
"transition-timing-function": move,
|
|
252
|
+
".oprt-motion-disclosure:not([data-expanded]) &": {
|
|
253
|
+
"transition-duration": duration("collapse")
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
".oprt-motion-popover-chevron": {
|
|
257
|
+
transform: "rotate(0deg)",
|
|
258
|
+
"transition-property": "transform",
|
|
259
|
+
"transition-duration": duration("exit"),
|
|
260
|
+
"transition-timing-function": response,
|
|
261
|
+
"[aria-expanded=true] > &": {
|
|
262
|
+
transform: "rotate(180deg)",
|
|
263
|
+
"transition-duration": duration("enter")
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
".oprt-motion-overlay": {
|
|
267
|
+
opacity: "1",
|
|
268
|
+
"transition-property": "opacity",
|
|
269
|
+
"transition-duration": duration("enter"),
|
|
270
|
+
"transition-timing-function": response,
|
|
271
|
+
"&[data-entering], &[data-exiting]": { opacity: "calc(1 - var(--oprt-motion-factor, 1))" },
|
|
272
|
+
"&[data-exiting]": { "transition-duration": duration("exit") }
|
|
273
|
+
},
|
|
274
|
+
".oprt-motion-surface": {
|
|
275
|
+
scale: "1",
|
|
276
|
+
opacity: "1",
|
|
277
|
+
"transition-property": "scale, opacity",
|
|
278
|
+
"transition-duration": duration("enter"),
|
|
279
|
+
"transition-timing-function": response,
|
|
280
|
+
"&[data-entering], &[data-exiting]": {
|
|
281
|
+
scale: "calc(1 + (var(--oprt-motion-surface-scale) - 1) * var(--oprt-motion-factor, 1))",
|
|
282
|
+
opacity: "calc(1 - var(--oprt-motion-factor, 1))"
|
|
283
|
+
},
|
|
284
|
+
"&[data-exiting]": { "transition-duration": duration("exit") }
|
|
285
|
+
},
|
|
286
|
+
".oprt-motion-popover": {
|
|
287
|
+
"transform-origin": "var(--trigger-anchor-point, center)",
|
|
288
|
+
translate: "0 0",
|
|
289
|
+
scale: "1",
|
|
290
|
+
opacity: "1",
|
|
291
|
+
"transition-property": "translate, scale, opacity",
|
|
292
|
+
"transition-duration": duration("enter"),
|
|
293
|
+
"transition-timing-function": response,
|
|
294
|
+
"&[data-entering], &[data-exiting]": {
|
|
295
|
+
translate: "var(--oprt-popover-x, 0px) var(--oprt-popover-y, 0px)",
|
|
296
|
+
scale: "calc(1 + (var(--oprt-motion-surface-scale) - 1) * var(--oprt-motion-factor, 1))",
|
|
297
|
+
opacity: "calc(1 - var(--oprt-motion-factor, 1))"
|
|
298
|
+
},
|
|
299
|
+
"&[data-placement=bottom]": {
|
|
300
|
+
"--oprt-popover-y": "calc(-1 * var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
301
|
+
},
|
|
302
|
+
"&[data-placement=top]": {
|
|
303
|
+
"--oprt-popover-y": "calc(var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
304
|
+
},
|
|
305
|
+
"&[data-placement=right]": {
|
|
306
|
+
"--oprt-popover-x": "calc(-1 * var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
307
|
+
},
|
|
308
|
+
"&[data-placement=left]": {
|
|
309
|
+
"--oprt-popover-x": "calc(var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
310
|
+
},
|
|
311
|
+
"&[data-exiting]": {
|
|
312
|
+
"transition-duration": duration("exit"),
|
|
313
|
+
"pointer-events": "none"
|
|
314
|
+
},
|
|
315
|
+
// Collision flips settle travel immediately; the surface still arrives.
|
|
316
|
+
"&:where([data-oprt-repositioned]:not([data-exiting]))": {
|
|
317
|
+
"transition-property": "scale, opacity"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var HATCH_REPEAT = "calc(var(--oprt-space-1) * 1.41421)";
|
|
322
|
+
var slideKeyframes = {
|
|
323
|
+
"oprt-slide": {
|
|
324
|
+
from: { translate: "0 0" },
|
|
325
|
+
to: { translate: "var(--oprt-slide-distance) 0" }
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
var slideMotion = (distance) => ({
|
|
329
|
+
"--oprt-slide-distance": distance,
|
|
330
|
+
animation: "oprt-slide 1.5s linear infinite",
|
|
331
|
+
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
|
|
332
|
+
"@media (forced-colors: active)": { animation: "none" },
|
|
333
|
+
"[data-oprt-motion=none] &": { animation: "none" }
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// src/index.ts
|
|
337
|
+
var SPACING = {
|
|
338
|
+
// No 7u — char-grid skips to 8u. Mirrors --oprt-space-* CSS tokens.
|
|
339
|
+
"0.5u": "var(--oprt-space-0-5)",
|
|
340
|
+
"1u": "var(--oprt-space-1)",
|
|
341
|
+
"1.5u": "calc(var(--oprt-space-1) * 1.5)",
|
|
342
|
+
"2u": "var(--oprt-space-2)",
|
|
343
|
+
"2.5u": "calc(var(--oprt-space-1) * 2.5)",
|
|
344
|
+
"3u": "var(--oprt-space-3)",
|
|
345
|
+
"4u": "var(--oprt-space-4)",
|
|
346
|
+
"5u": "var(--oprt-space-5)",
|
|
347
|
+
"6u": "var(--oprt-space-6)",
|
|
348
|
+
"8u": "var(--oprt-space-8)",
|
|
349
|
+
// 12u for Select popover max-height (~96px).
|
|
350
|
+
"12u": "calc(var(--oprt-space-6) * 2)",
|
|
351
|
+
// Compact plots span two of the foundation's 8u blocks.
|
|
352
|
+
"16u": "calc(var(--oprt-space-8) * 2)",
|
|
353
|
+
// CommandPalette list height: ten 4u rows before it scrolls.
|
|
354
|
+
"40u": "calc(var(--oprt-space-8) * 5)",
|
|
355
|
+
"oprt-cell-inline": "var(--oprt-table-cell-inline)",
|
|
356
|
+
"oprt-cell-block": "var(--oprt-table-cell-block)",
|
|
357
|
+
"oprt-cell-block-dense": "var(--oprt-table-cell-block-dense)"
|
|
358
|
+
};
|
|
359
|
+
var HEIGHT = {
|
|
360
|
+
"oprt-sm": "var(--oprt-height-sm)",
|
|
361
|
+
"oprt-md": "var(--oprt-height-md)",
|
|
362
|
+
"oprt-lg": "var(--oprt-height-lg)",
|
|
363
|
+
"oprt-badge-sm": "var(--oprt-badge-height-sm)",
|
|
364
|
+
"oprt-badge-md": "var(--oprt-badge-height-md)",
|
|
365
|
+
"oprt-row": "var(--oprt-table-row)",
|
|
366
|
+
"oprt-row-dense": "var(--oprt-table-row-dense)",
|
|
367
|
+
// Rail thicknesses for track-and-thumb controls. Deliberately off the 8px
|
|
368
|
+
// char grid: 1u (8px) is half the md thumb and reads as a bar, not a rail.
|
|
369
|
+
// Held at ~1/4 of the thumb at every size.
|
|
370
|
+
"oprt-track-sm": "var(--oprt-track-sm)",
|
|
371
|
+
"oprt-track-md": "var(--oprt-track-md)",
|
|
372
|
+
"oprt-track-lg": "var(--oprt-track-lg)"
|
|
373
|
+
};
|
|
374
|
+
var typeStep = (step) => [
|
|
375
|
+
`var(--oprt-type-${step})`,
|
|
376
|
+
{
|
|
377
|
+
lineHeight: `var(--oprt-line-${step})`,
|
|
378
|
+
letterSpacing: `var(--oprt-tracking-${step})`,
|
|
379
|
+
fontWeight: `var(--oprt-weight-${step})`
|
|
380
|
+
}
|
|
381
|
+
];
|
|
382
|
+
var FONT_SIZE = {
|
|
383
|
+
"oprt-xs": typeStep("xs"),
|
|
384
|
+
"oprt-sm": typeStep("sm"),
|
|
385
|
+
"oprt-base": typeStep("base"),
|
|
386
|
+
"oprt-md": typeStep("md"),
|
|
387
|
+
"oprt-lg": typeStep("lg"),
|
|
388
|
+
"oprt-xl": typeStep("xl"),
|
|
389
|
+
"oprt-2xl": typeStep("2xl")
|
|
390
|
+
};
|
|
391
|
+
var BORDER_RADIUS = {
|
|
392
|
+
none: "0px",
|
|
393
|
+
sm: "0px",
|
|
394
|
+
DEFAULT: "0px",
|
|
395
|
+
md: "0px",
|
|
396
|
+
lg: "0px",
|
|
397
|
+
xl: "0px",
|
|
398
|
+
"2xl": "0px",
|
|
399
|
+
"3xl": "0px",
|
|
400
|
+
full: "0px"
|
|
401
|
+
};
|
|
402
|
+
var COLORS = {
|
|
403
|
+
bg: "var(--oprt-bg)",
|
|
404
|
+
"surface-1": "var(--oprt-surface-1)",
|
|
405
|
+
"surface-2": "var(--oprt-surface-2)",
|
|
406
|
+
"surface-3": "var(--oprt-surface-3)",
|
|
407
|
+
border: "var(--oprt-border)",
|
|
408
|
+
"border-strong": "var(--oprt-border-strong)",
|
|
409
|
+
"border-focus": "var(--oprt-border-focus)",
|
|
410
|
+
// The boundary of a control: `border-oprt-border-control`. `border-oprt-border` is for layout lines.
|
|
411
|
+
"border-control": "var(--oprt-border-control)",
|
|
412
|
+
text: "var(--oprt-text)",
|
|
413
|
+
"text-dim": "var(--oprt-text-dim)",
|
|
414
|
+
// An empty field's placeholder: brighter than text-dim, which is also the disabled text.
|
|
415
|
+
"text-placeholder": "var(--oprt-text-placeholder)",
|
|
416
|
+
"text-muted": "var(--oprt-text-muted)",
|
|
417
|
+
accent: "var(--oprt-accent)",
|
|
418
|
+
"accent-light": "var(--oprt-accent-light)",
|
|
419
|
+
"accent-hover": "var(--oprt-accent-hover)",
|
|
420
|
+
"accent-active": "var(--oprt-accent-active)",
|
|
421
|
+
"accent-ghost": "var(--oprt-accent-ghost)",
|
|
422
|
+
"accent-bg": "var(--oprt-accent-bg)",
|
|
423
|
+
"accent-border": "var(--oprt-accent-border)",
|
|
424
|
+
success: "var(--oprt-success)",
|
|
425
|
+
warning: "var(--oprt-warning)",
|
|
426
|
+
error: "var(--oprt-error)",
|
|
427
|
+
info: "var(--oprt-info)",
|
|
428
|
+
"success-subtle": "var(--oprt-success-subtle)",
|
|
429
|
+
"success-strong": "var(--oprt-success-strong)",
|
|
430
|
+
"warning-subtle": "var(--oprt-warning-subtle)",
|
|
431
|
+
"warning-strong": "var(--oprt-warning-strong)",
|
|
432
|
+
"error-subtle": "var(--oprt-error-subtle)",
|
|
433
|
+
"error-strong": "var(--oprt-error-strong)",
|
|
434
|
+
"info-subtle": "var(--oprt-info-subtle)",
|
|
435
|
+
"info-strong": "var(--oprt-info-strong)",
|
|
436
|
+
"cat-1": "var(--oprt-cat-1)",
|
|
437
|
+
"cat-2": "var(--oprt-cat-2)",
|
|
438
|
+
"cat-3": "var(--oprt-cat-3)",
|
|
439
|
+
"cat-4": "var(--oprt-cat-4)",
|
|
440
|
+
"cat-5": "var(--oprt-cat-5)",
|
|
441
|
+
"cat-6": "var(--oprt-cat-6)",
|
|
442
|
+
"cat-7": "var(--oprt-cat-7)",
|
|
443
|
+
"cat-8": "var(--oprt-cat-8)",
|
|
444
|
+
"data-seq-1": "var(--oprt-data-seq-1)",
|
|
445
|
+
"data-seq-2": "var(--oprt-data-seq-2)",
|
|
446
|
+
"data-seq-3": "var(--oprt-data-seq-3)",
|
|
447
|
+
"data-seq-4": "var(--oprt-data-seq-4)",
|
|
448
|
+
"data-seq-5": "var(--oprt-data-seq-5)",
|
|
449
|
+
"chart-grid": "var(--oprt-chart-grid)",
|
|
450
|
+
"chart-axis": "var(--oprt-chart-axis)",
|
|
451
|
+
"chart-threshold": "var(--oprt-chart-threshold)",
|
|
452
|
+
"surface-4": "var(--oprt-surface-4)",
|
|
453
|
+
"surface-5": "var(--oprt-surface-5)",
|
|
454
|
+
"surface-6": "var(--oprt-surface-6)",
|
|
455
|
+
"border-subtle": "var(--oprt-border-subtle)",
|
|
456
|
+
"surface-hover": "var(--oprt-surface-hover)",
|
|
457
|
+
"surface-active": "var(--oprt-surface-active)",
|
|
458
|
+
"surface-selected": "var(--oprt-surface-selected)",
|
|
459
|
+
"overlay-scrim": "var(--oprt-overlay-scrim)"
|
|
460
|
+
};
|
|
461
|
+
var TRANSITION_DURATION = {
|
|
462
|
+
"oprt-instant": "var(--oprt-duration-instant)",
|
|
463
|
+
"oprt-fast": "var(--oprt-duration-fast)",
|
|
464
|
+
"oprt-normal": "var(--oprt-duration-normal)",
|
|
465
|
+
"oprt-slow": "var(--oprt-duration-slow)"
|
|
466
|
+
};
|
|
467
|
+
var TRANSITION_TIMING = {
|
|
468
|
+
oprt: "var(--oprt-easing)"
|
|
469
|
+
};
|
|
470
|
+
var LETTER_SPACING = {
|
|
471
|
+
"oprt-xs": "var(--oprt-tracking-xs)",
|
|
472
|
+
"oprt-sm": "var(--oprt-tracking-sm)",
|
|
473
|
+
// Uppercase control labels. The type-scale trackings above are tuned for
|
|
474
|
+
// their own size; `oprt-sm` (0.12em) is right for 9px overlines and far too
|
|
475
|
+
// wide once the same class lands on an 11px/13px control at weight 500-600.
|
|
476
|
+
// Tracking must fall as size and weight rise, so these are bound to a
|
|
477
|
+
// component's SIZE variant, never to its base class.
|
|
478
|
+
"oprt-caps": "var(--oprt-tracking-caps)",
|
|
479
|
+
// 11px uppercase controls
|
|
480
|
+
"oprt-caps-lg": "var(--oprt-tracking-caps-lg)",
|
|
481
|
+
// 13px uppercase controls
|
|
482
|
+
"oprt-base": "var(--oprt-tracking-base)",
|
|
483
|
+
"oprt-md": "var(--oprt-tracking-md)",
|
|
484
|
+
"oprt-lg": "var(--oprt-tracking-lg)",
|
|
485
|
+
"oprt-xl": "var(--oprt-tracking-xl)",
|
|
486
|
+
"oprt-2xl": "var(--oprt-tracking-2xl)"
|
|
487
|
+
};
|
|
488
|
+
var BOX_SHADOW = {
|
|
489
|
+
// Focus indicator: a 1px ring in the focus border color (WCAG 2.4.7). The exact geometry and
|
|
490
|
+
// its relation to 2.4.11 and 2.4.13 are on the Focus foundations page.
|
|
491
|
+
"oprt-focus": "0 0 0 1px var(--oprt-border-focus)"
|
|
492
|
+
};
|
|
493
|
+
var CONTAINER_WIDTHS = { "oprt-sm": "320px", "oprt-md": "480px", "oprt-lg": "640px" };
|
|
494
|
+
var operatorPlugin = (0, import_plugin.default)(
|
|
495
|
+
({ addBase, addVariant, addUtilities, matchUtilities }) => {
|
|
496
|
+
addBase({
|
|
497
|
+
"*, ::after, ::before, ::backdrop, ::file-selector-button": {
|
|
498
|
+
"border-color": "var(--oprt-border)"
|
|
499
|
+
},
|
|
500
|
+
'button:not(:disabled), [role="button"]:not(:disabled)': { cursor: "pointer" }
|
|
501
|
+
});
|
|
502
|
+
addVariant("theme-bone", '[data-theme="bone"] &');
|
|
503
|
+
addUtilities(motionUtilities);
|
|
504
|
+
addBase(cutProperties);
|
|
505
|
+
addBase(cutDefaults);
|
|
506
|
+
addUtilities(cutUtilities);
|
|
507
|
+
matchUtilities({ "oprt-motion-slide": slideMotion }, { values: { DEFAULT: HATCH_REPEAT } });
|
|
508
|
+
addUtilities({ ".oprt-wrap-anywhere": { "overflow-wrap": "anywhere" } });
|
|
509
|
+
for (const [name, width] of Object.entries(CONTAINER_WIDTHS))
|
|
510
|
+
addVariant(`@${name}`, `@container (min-width: ${width})`);
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
theme: {
|
|
514
|
+
borderRadius: BORDER_RADIUS,
|
|
515
|
+
extend: {
|
|
516
|
+
keyframes: slideKeyframes,
|
|
517
|
+
spacing: SPACING,
|
|
518
|
+
height: HEIGHT,
|
|
519
|
+
// Same control-size scale exposed on width, so square controls
|
|
520
|
+
// (Avatar, icon-only Button) can pin both axes to one token. Without
|
|
521
|
+
// this, `w-oprt-*` silently resolves to nothing: Tailwind derives
|
|
522
|
+
// `width` from `spacing`, which carries only the `Nu` char-grid keys.
|
|
523
|
+
width: HEIGHT,
|
|
524
|
+
// The same holds for the four min/max properties: they derive from `spacing` plus
|
|
525
|
+
// keywords, so `min-h-oprt-md` compiled to nothing until it was registered here.
|
|
526
|
+
minHeight: HEIGHT,
|
|
527
|
+
minWidth: HEIGHT,
|
|
528
|
+
maxHeight: HEIGHT,
|
|
529
|
+
maxWidth: HEIGHT,
|
|
530
|
+
fontSize: FONT_SIZE,
|
|
531
|
+
fontFamily: {
|
|
532
|
+
mono: ["var(--oprt-font-mono)"],
|
|
533
|
+
sans: ["var(--oprt-font-sans)"]
|
|
534
|
+
},
|
|
535
|
+
// Plain values: Tailwind 4 mixes an opacity modifier such as `/40` into any color
|
|
536
|
+
// itself, toward transparent, so the token keeps its hue and only its alpha falls.
|
|
537
|
+
colors: {
|
|
538
|
+
oprt: COLORS
|
|
539
|
+
},
|
|
540
|
+
transitionDuration: TRANSITION_DURATION,
|
|
541
|
+
transitionTimingFunction: TRANSITION_TIMING,
|
|
542
|
+
letterSpacing: LETTER_SPACING,
|
|
543
|
+
boxShadow: BOX_SHADOW
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
var index_default = operatorPlugin;
|
|
549
|
+
// operator: CommonJS entry is the plugin
|
|
550
|
+
module.exports = module.exports.default ?? module.exports;
|
|
551
|
+
Object.defineProperty(module.exports, "default", { value: module.exports });
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin, as Tailwind loads it from `@plugin "@oprt/tailwind"` or from a config's
|
|
3
|
+
* `plugins`. The type is written out here rather than borrowed from Tailwind: Tailwind 4 does not
|
|
4
|
+
* export the name of its plugin type, and some TypeScript module settings cannot read Tailwind's
|
|
5
|
+
* declarations at all, so declarations that referred to them would fail in a strict consumer.
|
|
6
|
+
*/
|
|
7
|
+
interface OperatorPlugin {
|
|
8
|
+
handler(api: unknown): void;
|
|
9
|
+
}
|
|
10
|
+
declare const operatorPlugin: OperatorPlugin;
|
|
11
|
+
|
|
12
|
+
declare const cjsPlugin: typeof operatorPlugin & { readonly default: typeof operatorPlugin };
|
|
13
|
+
|
|
14
|
+
export = cjsPlugin;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin, as Tailwind loads it from `@plugin "@oprt/tailwind"` or from a config's
|
|
3
|
+
* `plugins`. The type is written out here rather than borrowed from Tailwind: Tailwind 4 does not
|
|
4
|
+
* export the name of its plugin type, and some TypeScript module settings cannot read Tailwind's
|
|
5
|
+
* declarations at all, so declarations that referred to them would fail in a strict consumer.
|
|
6
|
+
*/
|
|
7
|
+
interface OperatorPlugin {
|
|
8
|
+
handler(api: unknown): void;
|
|
9
|
+
}
|
|
10
|
+
declare const operatorPlugin: OperatorPlugin;
|
|
11
|
+
|
|
12
|
+
export { type OperatorPlugin, operatorPlugin as default };
|