@homebound/beam 3.0.0-alpha.10 → 3.0.0-alpha.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.
package/dist/index.d.cts CHANGED
@@ -10,6 +10,7 @@ export { DateRange } from 'react-day-picker';
10
10
  import { MenuTriggerState } from 'react-stately';
11
11
  import { FieldState, ListFieldState, ObjectState } from '@homebound/form-state';
12
12
  import { NumberFieldAria } from '@react-aria/numberfield';
13
+ export { RuntimeStyle } from '@homebound/truss/runtime';
13
14
 
14
15
  /** Given a type X, and the user's proposed type T, only allow keys in X and nothing else. */
15
16
  type Only<X, T> = X & Record<Exclude<keyof T, keyof X>, never>;
@@ -35,6 +36,7 @@ type Opts<T> = {
35
36
  enabled: boolean;
36
37
  selector: string | undefined;
37
38
  elseApplied: boolean;
39
+ runtimeError: string | undefined;
38
40
  };
39
41
  declare class CssBuilder<T extends Properties> {
40
42
  private opts;
@@ -4085,7 +4087,7 @@ declare class CssBuilder<T extends Properties> {
4085
4087
  name?: string;
4086
4088
  lt?: number;
4087
4089
  gt?: number;
4088
- }): this;
4090
+ }): CssBuilder<T>;
4089
4091
  /** Apply styles within a pseudo-element (e.g. `"::placeholder"`, `"::selection"`). */
4090
4092
  element(_pseudoElement: string): CssBuilder<T>;
4091
4093
  get ifPrint(): CssBuilder<T>;
@@ -4111,9 +4113,12 @@ declare class CssBuilder<T extends Properties> {
4111
4113
  className(className: string): CssBuilder<T>;
4112
4114
  /** Convert a style hash into `{ className, style }` props for manual spreading into non-`css=` contexts. */
4113
4115
  props(styles: Properties): Record<string, unknown>;
4116
+ /** Tagged template literal for raw CSS in .css.ts files; passes through the string as-is. */
4117
+ raw(strings: TemplateStringsArray, ...values: unknown[]): string;
4114
4118
  private get rules();
4115
4119
  private get enabled();
4116
4120
  private get selector();
4121
+ private unsupportedRuntime;
4117
4122
  private newCss;
4118
4123
  }
4119
4124
  /** Converts `inc` into pixels value with a `px` suffix. */
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { DateRange } from 'react-day-picker';
10
10
  import { MenuTriggerState } from 'react-stately';
11
11
  import { FieldState, ListFieldState, ObjectState } from '@homebound/form-state';
12
12
  import { NumberFieldAria } from '@react-aria/numberfield';
13
+ export { RuntimeStyle } from '@homebound/truss/runtime';
13
14
 
14
15
  /** Given a type X, and the user's proposed type T, only allow keys in X and nothing else. */
15
16
  type Only<X, T> = X & Record<Exclude<keyof T, keyof X>, never>;
@@ -35,6 +36,7 @@ type Opts<T> = {
35
36
  enabled: boolean;
36
37
  selector: string | undefined;
37
38
  elseApplied: boolean;
39
+ runtimeError: string | undefined;
38
40
  };
39
41
  declare class CssBuilder<T extends Properties> {
40
42
  private opts;
@@ -4085,7 +4087,7 @@ declare class CssBuilder<T extends Properties> {
4085
4087
  name?: string;
4086
4088
  lt?: number;
4087
4089
  gt?: number;
4088
- }): this;
4090
+ }): CssBuilder<T>;
4089
4091
  /** Apply styles within a pseudo-element (e.g. `"::placeholder"`, `"::selection"`). */
4090
4092
  element(_pseudoElement: string): CssBuilder<T>;
4091
4093
  get ifPrint(): CssBuilder<T>;
@@ -4111,9 +4113,12 @@ declare class CssBuilder<T extends Properties> {
4111
4113
  className(className: string): CssBuilder<T>;
4112
4114
  /** Convert a style hash into `{ className, style }` props for manual spreading into non-`css=` contexts. */
4113
4115
  props(styles: Properties): Record<string, unknown>;
4116
+ /** Tagged template literal for raw CSS in .css.ts files; passes through the string as-is. */
4117
+ raw(strings: TemplateStringsArray, ...values: unknown[]): string;
4114
4118
  private get rules();
4115
4119
  private get enabled();
4116
4120
  private get selector();
4121
+ private unsupportedRuntime;
4117
4122
  private newCss;
4118
4123
  }
4119
4124
  /** Converts `inc` into pixels value with a `px` suffix. */
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ import {
21
21
 
22
22
  // src/Css.ts
23
23
  import { trussProps } from "@homebound/truss/runtime";
24
+ import { RuntimeStyle } from "@homebound/truss/runtime";
24
25
  var CssBuilder = class _CssBuilder {
25
26
  constructor(opts) {
26
27
  this.opts = opts;
@@ -3768,6 +3769,12 @@ var CssBuilder = class _CssBuilder {
3768
3769
  }
3769
3770
  // aliases
3770
3771
  get $() {
3772
+ if (this.opts.runtimeError) {
3773
+ throw new Error(this.opts.runtimeError);
3774
+ }
3775
+ if (this.selector !== void 0) {
3776
+ throw new Error("Selector-based Css helpers cannot be used in RuntimeStyle css expressions.");
3777
+ }
3771
3778
  return this.rules;
3772
3779
  }
3773
3780
  get onHover() {
@@ -3796,11 +3803,11 @@ var CssBuilder = class _CssBuilder {
3796
3803
  }
3797
3804
  /** Marks this element as a default hover marker (for ancestor pseudo selectors). */
3798
3805
  get marker() {
3799
- return this;
3806
+ return this.unsupportedRuntime("marker cannot be used in RuntimeStyle css expressions.");
3800
3807
  }
3801
3808
  /** Marks this element with a user-defined marker. */
3802
3809
  markerOf(_marker) {
3803
- return this;
3810
+ return this.unsupportedRuntime("markerOf() cannot be used in RuntimeStyle css expressions.");
3804
3811
  }
3805
3812
  /** Creates a marker token for use with markerOf() and when(). */
3806
3813
  newMarker() {
@@ -3810,14 +3817,14 @@ var CssBuilder = class _CssBuilder {
3810
3817
  return this[key];
3811
3818
  }
3812
3819
  when(_selectorOrMarker, _relationship, _pseudo) {
3813
- return this;
3820
+ return this.unsupportedRuntime("when() cannot be used in RuntimeStyle css expressions.");
3814
3821
  }
3815
3822
  ifContainer(_props) {
3816
- return this;
3823
+ return this.unsupportedRuntime("ifContainer() cannot be used in RuntimeStyle css expressions.");
3817
3824
  }
3818
3825
  /** Apply styles within a pseudo-element (e.g. `"::placeholder"`, `"::selection"`). */
3819
3826
  element(_pseudoElement) {
3820
- return this;
3827
+ return this.unsupportedRuntime("element() cannot be used in RuntimeStyle css expressions.");
3821
3828
  }
3822
3829
  get ifPrint() {
3823
3830
  return this.newCss({ selector: "@media print" });
@@ -3847,7 +3854,7 @@ var CssBuilder = class _CssBuilder {
3847
3854
  if (typeof condOrMediaQuery === "boolean") {
3848
3855
  return new _CssBuilder({ ...this.opts, enabled: condOrMediaQuery, elseApplied: false });
3849
3856
  }
3850
- return this.newCss({ selector: condOrMediaQuery, elseApplied: false });
3857
+ return this.unsupportedRuntime("if(mediaQuery) cannot be used in RuntimeStyle css expressions.");
3851
3858
  }
3852
3859
  get else() {
3853
3860
  if (this.selector !== void 0) {
@@ -3876,12 +3883,16 @@ var CssBuilder = class _CssBuilder {
3876
3883
  /** Marker for the build-time transform to append a raw className. */
3877
3884
  className(className) {
3878
3885
  void className;
3879
- return this;
3886
+ return this.unsupportedRuntime("className() cannot be used in RuntimeStyle css expressions.");
3880
3887
  }
3881
3888
  /** Convert a style hash into `{ className, style }` props for manual spreading into non-`css=` contexts. */
3882
3889
  props(styles) {
3883
3890
  return trussProps(styles);
3884
3891
  }
3892
+ /** Tagged template literal for raw CSS in .css.ts files; passes through the string as-is. */
3893
+ raw(strings, ...values) {
3894
+ return String.raw(strings, ...values);
3895
+ }
3885
3896
  get rules() {
3886
3897
  return this.opts.rules;
3887
3898
  }
@@ -3891,6 +3902,9 @@ var CssBuilder = class _CssBuilder {
3891
3902
  get selector() {
3892
3903
  return this.opts.selector;
3893
3904
  }
3905
+ unsupportedRuntime(message) {
3906
+ return this.newCss({ runtimeError: message });
3907
+ }
3894
3908
  newCss(opts) {
3895
3909
  return new _CssBuilder({ ...this.opts, ...opts });
3896
3910
  }
@@ -3986,7 +4000,13 @@ var Palette = /* @__PURE__ */ ((Palette4) => {
3986
4000
  return Palette4;
3987
4001
  })(Palette || {});
3988
4002
  var marker = /* @__PURE__ */ Symbol.for("truss-default-marker");
3989
- var Css = new CssBuilder({ rules: {}, enabled: true, selector: void 0, elseApplied: false });
4003
+ var Css = new CssBuilder({
4004
+ rules: {},
4005
+ enabled: true,
4006
+ selector: void 0,
4007
+ elseApplied: false,
4008
+ runtimeError: void 0
4009
+ });
3990
4010
  var Breakpoints = /* @__PURE__ */ ((Breakpoints2) => {
3991
4011
  Breakpoints2["print"] = "@media print";
3992
4012
  Breakpoints2["sm"] = "@media screen and (max-width: 599px)";
@@ -21469,6 +21489,7 @@ export {
21469
21489
  RightPaneProvider,
21470
21490
  RightSidebar,
21471
21491
  Row,
21492
+ RuntimeStyle,
21472
21493
  ScrollShadows,
21473
21494
  ScrollableContent,
21474
21495
  ScrollableParent,