@gtkx/react 1.2.2 → 1.4.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.
Files changed (82) hide show
  1. package/README.md +6 -4
  2. package/dist/adw/dialog.js +2 -2
  3. package/dist/adw/dialog.js.map +1 -1
  4. package/dist/components/application.d.ts.map +1 -1
  5. package/dist/components/application.js +3 -3
  6. package/dist/components/application.js.map +1 -1
  7. package/dist/components/window.js +3 -3
  8. package/dist/components/window.js.map +1 -1
  9. package/dist/element-behaviors.js +130 -1
  10. package/dist/element-behaviors.js.map +1 -1
  11. package/dist/element-config.js +1 -1
  12. package/dist/element-config.js.map +1 -1
  13. package/dist/hooks/use-bind-setting.d.ts.map +1 -1
  14. package/dist/hooks/use-bind-setting.js +3 -2
  15. package/dist/hooks/use-bind-setting.js.map +1 -1
  16. package/dist/hooks/use-property.d.ts +1 -1
  17. package/dist/hooks/use-property.d.ts.map +1 -1
  18. package/dist/hooks/use-property.js +5 -1
  19. package/dist/hooks/use-property.js.map +1 -1
  20. package/dist/internal.d.ts +2 -0
  21. package/dist/internal.d.ts.map +1 -1
  22. package/dist/internal.js +2 -0
  23. package/dist/internal.js.map +1 -1
  24. package/dist/prop-types.d.ts +20 -2
  25. package/dist/prop-types.d.ts.map +1 -1
  26. package/dist/prop-types.js.map +1 -1
  27. package/dist/reconciler/apply-props.d.ts +2 -1
  28. package/dist/reconciler/apply-props.d.ts.map +1 -1
  29. package/dist/reconciler/apply-props.js +60 -24
  30. package/dist/reconciler/apply-props.js.map +1 -1
  31. package/dist/reconciler/behaviors.d.ts.map +1 -1
  32. package/dist/reconciler/behaviors.js +40 -9
  33. package/dist/reconciler/behaviors.js.map +1 -1
  34. package/dist/reconciler/host-config.d.ts.map +1 -1
  35. package/dist/reconciler/host-config.js +10 -2
  36. package/dist/reconciler/host-config.js.map +1 -1
  37. package/dist/reconciler/metadata.d.ts +6 -1
  38. package/dist/reconciler/metadata.d.ts.map +1 -1
  39. package/dist/reconciler/metadata.js +39 -6
  40. package/dist/reconciler/metadata.js.map +1 -1
  41. package/dist/reconciler/placement.js +4 -4
  42. package/dist/reconciler/placement.js.map +1 -1
  43. package/dist/reconciler/registry.d.ts +2 -0
  44. package/dist/reconciler/registry.d.ts.map +1 -1
  45. package/dist/reconciler/registry.js.map +1 -1
  46. package/dist/reconciler/root.d.ts.map +1 -1
  47. package/dist/reconciler/root.js.map +1 -1
  48. package/dist/reconciler/signals.d.ts +3 -2
  49. package/dist/reconciler/signals.d.ts.map +1 -1
  50. package/dist/reconciler/signals.js +49 -16
  51. package/dist/reconciler/signals.js.map +1 -1
  52. package/dist/reconciler/style.d.ts +7 -0
  53. package/dist/reconciler/style.d.ts.map +1 -0
  54. package/dist/reconciler/style.js +61 -0
  55. package/dist/reconciler/style.js.map +1 -0
  56. package/dist/reconciler/text.js +3 -3
  57. package/dist/reconciler/text.js.map +1 -1
  58. package/dist/utils/accessible-props.d.ts.map +1 -1
  59. package/dist/utils/accessible-props.js +13 -7
  60. package/dist/utils/accessible-props.js.map +1 -1
  61. package/env.d.ts +10 -7
  62. package/package.json +6 -5
  63. package/src/adw/dialog.tsx +2 -2
  64. package/src/components/application.tsx +18 -3
  65. package/src/components/window.tsx +3 -3
  66. package/src/element-behaviors.ts +180 -1
  67. package/src/element-config.ts +1 -1
  68. package/src/hooks/use-bind-setting.ts +3 -2
  69. package/src/hooks/use-property.ts +6 -2
  70. package/src/internal.ts +2 -0
  71. package/src/prop-types.ts +96 -1
  72. package/src/reconciler/apply-props.ts +74 -26
  73. package/src/reconciler/behaviors.ts +60 -12
  74. package/src/reconciler/host-config.ts +13 -2
  75. package/src/reconciler/metadata.ts +62 -6
  76. package/src/reconciler/placement.ts +4 -4
  77. package/src/reconciler/registry.ts +2 -0
  78. package/src/reconciler/root.ts +1 -1
  79. package/src/reconciler/signals.ts +62 -17
  80. package/src/reconciler/style.ts +84 -0
  81. package/src/reconciler/text.ts +3 -3
  82. package/src/utils/accessible-props.ts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AAmB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,MAAsB,EAAE,QAAsB,EAAE,QAAe,EAAQ,EAAE;IACnG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpC,IAAI,QAAQ,EAAE,CAAC;QACX,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAwB,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport type { Props } from \"../reconciler/registry.js\";\n\n/**\n * Accessibility props available on every widget. Each member maps to a GTK4 accessible attribute\n * (a `Gtk.AccessibleProperty`, `Gtk.AccessibleState`, or `Gtk.AccessibleRelation`) and is applied\n * to the widget's accessible interface. Setting a member to `null` or `undefined`, or dropping it from the\n * props, resets that attribute to its default.\n */\ntype AccessibleProps = {\n /** How the widget completes the text being typed into it. */\n accessibleAutocomplete?: Gtk.AccessibleAutocomplete | null | undefined;\n /** Longer description announced after the label. */\n accessibleDescription?: string | null | undefined;\n /** Whether activating the widget opens a popup. */\n accessibleHasPopup?: boolean | null | undefined;\n /** Keyboard shortcuts that activate the widget. */\n accessibleKeyShortcuts?: string | null | undefined;\n /** Short name announced for the widget. */\n accessibleLabel?: string | null | undefined;\n /** Depth of the widget within a hierarchy of headings, list items, or tree rows. */\n accessibleLevel?: number | null | undefined;\n /** Whether the widget blocks interaction with everything behind it. */\n accessibleModal?: boolean | null | undefined;\n /** Whether the text input accepts more than one line. */\n accessibleMultiLine?: boolean | null | undefined;\n /** Whether more than one of the widget's items can be selected at a time. */\n accessibleMultiSelectable?: boolean | null | undefined;\n /** Whether the widget arranges its items horizontally or vertically. */\n accessibleOrientation?: Gtk.Orientation | null | undefined;\n /** Hint announced while the input is empty. */\n accessiblePlaceholder?: string | null | undefined;\n /** Whether the value can be read but not changed. */\n accessibleReadOnly?: boolean | null | undefined;\n /** Whether a value has to be supplied before the form can be submitted. */\n accessibleRequired?: boolean | null | undefined;\n /** Wording that replaces the default announcement of the widget's role. */\n accessibleRoleDescription?: string | null | undefined;\n /** Direction the widget's items are sorted in. */\n accessibleSort?: Gtk.AccessibleSort | null | undefined;\n /** Upper bound of the widget's value range. */\n accessibleValueMax?: number | null | undefined;\n /** Lower bound of the widget's value range. */\n accessibleValueMin?: number | null | undefined;\n /** Current value within the widget's range. */\n accessibleValueNow?: number | null | undefined;\n /** Wording announced in place of the numeric value. */\n accessibleValueText?: string | null | undefined;\n /** Help text describing how to use the widget. */\n accessibleHelpText?: string | null | undefined;\n /** Whether the widget is still loading and its content may yet change. */\n accessibleBusy?: boolean | null | undefined;\n /** Checked state of a check button or menu item, which may be mixed. */\n accessibleChecked?: Gtk.AccessibleTristate | null | undefined;\n /** Whether the widget is visible but cannot be edited or operated. */\n accessibleDisabled?: boolean | null | undefined;\n /** Whether the content the widget discloses is showing. */\n accessibleExpanded?: boolean | null | undefined;\n /** Whether the widget is kept out of the accessibility tree. */\n accessibleHidden?: boolean | null | undefined;\n /** Whether the entered value fails validation, and in what way. */\n accessibleInvalid?: Gtk.AccessibleInvalidState | null | undefined;\n /** Pressed state of a toggle button, which may be mixed. */\n accessiblePressed?: Gtk.AccessibleTristate | null | undefined;\n /** Whether the widget is selected within its container. */\n accessibleSelected?: boolean | null | undefined;\n /** Whether the link has already been followed. */\n accessibleVisited?: boolean | null | undefined;\n /** Descendant that holds the focus while the widget itself keeps it. */\n accessibleActiveDescendant?: Gtk.Accessible | null | undefined;\n /** Total number of columns in the table, including any that are not rendered. */\n accessibleColCount?: number | null | undefined;\n /** One-based column position of the cell within its table. */\n accessibleColIndex?: number | null | undefined;\n /** Wording announced in place of the numeric column position. */\n accessibleColIndexText?: string | null | undefined;\n /** Number of columns the cell spans. */\n accessibleColSpan?: number | null | undefined;\n /** Widgets whose content or presence this widget controls. */\n accessibleControls?: Gtk.Accessible[] | null | undefined;\n /** Widgets that describe this one. */\n accessibleDescribedBy?: Gtk.Accessible[] | null | undefined;\n /** Widgets holding extended detail about this one. */\n accessibleDetails?: Gtk.Accessible[] | null | undefined;\n /** Widgets holding the message that explains why the value is invalid. */\n accessibleErrorMessage?: Gtk.Accessible[] | null | undefined;\n /** Widgets to read next, overriding the default reading order. */\n accessibleFlowTo?: Gtk.Accessible[] | null | undefined;\n /** Widgets that label this one. */\n accessibleLabelledBy?: Gtk.Accessible[] | null | undefined;\n /** Widgets this one owns that the widget hierarchy does not already imply. */\n accessibleOwns?: Gtk.Accessible[] | null | undefined;\n /** One-based position of the widget within its set. */\n accessiblePosInSet?: number | null | undefined;\n /** Total number of rows in the table, including any that are not rendered. */\n accessibleRowCount?: number | null | undefined;\n /** One-based row position of the cell within its table. */\n accessibleRowIndex?: number | null | undefined;\n /** Wording announced in place of the numeric row position. */\n accessibleRowIndexText?: string | null | undefined;\n /** Number of rows the cell spans. */\n accessibleRowSpan?: number | null | undefined;\n /** Total number of items in the set the widget belongs to. */\n accessibleSetSize?: number | null | undefined;\n};\n\ntype AccessibleValueType = \"string\" | \"boolean\" | \"optionalBoolean\" | \"int\" | \"double\" | \"object\" | \"list\";\n\ntype AccessiblePropertyDescriptor = {\n kind: \"property\";\n property: Gtk.AccessibleProperty;\n type: AccessibleValueType;\n};\n\ntype AccessibleStateDescriptor = {\n kind: \"state\";\n state: Gtk.AccessibleState;\n type: AccessibleValueType;\n};\n\ntype AccessibleRelationDescriptor = {\n kind: \"relation\";\n relation: Gtk.AccessibleRelation;\n type: AccessibleValueType;\n};\n\ntype AccessibleDescriptor = AccessiblePropertyDescriptor | AccessibleStateDescriptor | AccessibleRelationDescriptor;\n\nconst ACCESSIBLE_PROP_MAP: Record<keyof AccessibleProps, AccessibleDescriptor> = {\n accessibleAutocomplete: buildProperty(Gtk.AccessibleProperty.AUTOCOMPLETE, \"int\"),\n accessibleDescription: buildProperty(Gtk.AccessibleProperty.DESCRIPTION, \"string\"),\n accessibleHasPopup: buildProperty(Gtk.AccessibleProperty.HAS_POPUP, \"boolean\"),\n accessibleKeyShortcuts: buildProperty(Gtk.AccessibleProperty.KEY_SHORTCUTS, \"string\"),\n accessibleLabel: buildProperty(Gtk.AccessibleProperty.LABEL, \"string\"),\n accessibleLevel: buildProperty(Gtk.AccessibleProperty.LEVEL, \"int\"),\n accessibleModal: buildProperty(Gtk.AccessibleProperty.MODAL, \"boolean\"),\n accessibleMultiLine: buildProperty(Gtk.AccessibleProperty.MULTI_LINE, \"boolean\"),\n accessibleMultiSelectable: buildProperty(Gtk.AccessibleProperty.MULTI_SELECTABLE, \"boolean\"),\n accessibleOrientation: buildProperty(Gtk.AccessibleProperty.ORIENTATION, \"int\"),\n accessiblePlaceholder: buildProperty(Gtk.AccessibleProperty.PLACEHOLDER, \"string\"),\n accessibleReadOnly: buildProperty(Gtk.AccessibleProperty.READ_ONLY, \"boolean\"),\n accessibleRequired: buildProperty(Gtk.AccessibleProperty.REQUIRED, \"boolean\"),\n accessibleRoleDescription: buildProperty(Gtk.AccessibleProperty.ROLE_DESCRIPTION, \"string\"),\n accessibleSort: buildProperty(Gtk.AccessibleProperty.SORT, \"int\"),\n accessibleValueMax: buildProperty(Gtk.AccessibleProperty.VALUE_MAX, \"double\"),\n accessibleValueMin: buildProperty(Gtk.AccessibleProperty.VALUE_MIN, \"double\"),\n accessibleValueNow: buildProperty(Gtk.AccessibleProperty.VALUE_NOW, \"double\"),\n accessibleValueText: buildProperty(Gtk.AccessibleProperty.VALUE_TEXT, \"string\"),\n accessibleHelpText: buildProperty(Gtk.AccessibleProperty.HELP_TEXT, \"string\"),\n accessibleBusy: buildState(Gtk.AccessibleState.BUSY, \"boolean\"),\n accessibleChecked: buildState(Gtk.AccessibleState.CHECKED, \"int\"),\n accessibleDisabled: buildState(Gtk.AccessibleState.DISABLED, \"boolean\"),\n accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, \"optionalBoolean\"),\n accessibleHidden: buildState(Gtk.AccessibleState.HIDDEN, \"boolean\"),\n accessibleInvalid: buildState(Gtk.AccessibleState.INVALID, \"int\"),\n accessiblePressed: buildState(Gtk.AccessibleState.PRESSED, \"int\"),\n accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, \"optionalBoolean\"),\n accessibleVisited: buildState(Gtk.AccessibleState.VISITED, \"optionalBoolean\"),\n accessibleActiveDescendant: buildRelation(Gtk.AccessibleRelation.ACTIVE_DESCENDANT, \"object\"),\n accessibleColCount: buildRelation(Gtk.AccessibleRelation.COL_COUNT, \"int\"),\n accessibleColIndex: buildRelation(Gtk.AccessibleRelation.COL_INDEX, \"int\"),\n accessibleColIndexText: buildRelation(Gtk.AccessibleRelation.COL_INDEX_TEXT, \"string\"),\n accessibleColSpan: buildRelation(Gtk.AccessibleRelation.COL_SPAN, \"int\"),\n accessibleControls: buildRelation(Gtk.AccessibleRelation.CONTROLS, \"list\"),\n accessibleDescribedBy: buildRelation(Gtk.AccessibleRelation.DESCRIBED_BY, \"list\"),\n accessibleDetails: buildRelation(Gtk.AccessibleRelation.DETAILS, \"list\"),\n accessibleErrorMessage: buildRelation(Gtk.AccessibleRelation.ERROR_MESSAGE, \"list\"),\n accessibleFlowTo: buildRelation(Gtk.AccessibleRelation.FLOW_TO, \"list\"),\n accessibleLabelledBy: buildRelation(Gtk.AccessibleRelation.LABELLED_BY, \"list\"),\n accessibleOwns: buildRelation(Gtk.AccessibleRelation.OWNS, \"list\"),\n accessiblePosInSet: buildRelation(Gtk.AccessibleRelation.POS_IN_SET, \"int\"),\n accessibleRowCount: buildRelation(Gtk.AccessibleRelation.ROW_COUNT, \"int\"),\n accessibleRowIndex: buildRelation(Gtk.AccessibleRelation.ROW_INDEX, \"int\"),\n accessibleRowIndexText: buildRelation(Gtk.AccessibleRelation.ROW_INDEX_TEXT, \"string\"),\n accessibleRowSpan: buildRelation(Gtk.AccessibleRelation.ROW_SPAN, \"int\"),\n accessibleSetSize: buildRelation(Gtk.AccessibleRelation.SET_SIZE, \"int\"),\n};\n\nfunction buildProperty(property: Gtk.AccessibleProperty, type: AccessibleValueType): AccessiblePropertyDescriptor {\n return {\n kind: \"property\",\n property,\n type,\n };\n}\n\nfunction buildState(state: Gtk.AccessibleState, type: AccessibleValueType): AccessibleStateDescriptor {\n return {\n kind: \"state\",\n state,\n type,\n };\n}\n\nfunction buildRelation(relation: Gtk.AccessibleRelation, type: AccessibleValueType): AccessibleRelationDescriptor {\n return {\n kind: \"relation\",\n relation,\n type,\n };\n}\n\nconst buildValue = (descriptor: AccessibleDescriptor, jsValue: unknown): GObject.Value => {\n switch (descriptor.type) {\n case \"string\": {\n return GObject.buildValue(GObject.TYPE_STRING, (v) => {\n v.setString(jsValue as string);\n });\n }\n case \"boolean\": {\n return GObject.buildValue(GObject.TYPE_BOOLEAN, (v) => {\n v.setBoolean(jsValue as boolean);\n });\n }\n case \"optionalBoolean\": {\n return GObject.buildValue(GObject.TYPE_INT, (v) => {\n v.setInt(jsValue === true ? 1 : 0);\n });\n }\n case \"int\": {\n return GObject.buildValue(GObject.TYPE_INT, (v) => {\n v.setInt(jsValue as number);\n });\n }\n case \"double\": {\n return GObject.buildValue(GObject.TYPE_DOUBLE, (v) => {\n v.setDouble(jsValue as number);\n });\n }\n case \"object\": {\n return GObject.buildValue(GObject.TYPE_OBJECT, (v) => {\n v.setObject(jsValue as GObject.Object | null);\n });\n }\n case \"list\": {\n const list = Gtk.AccessibleList.newFromList(jsValue as Gtk.Accessible[]);\n\n return GObject.buildValue(Gtk.AccessibleList.prototype.__type__, (v) => {\n v.setBoxed(list);\n });\n }\n }\n};\n\nconst isAccessibleProp = (name: string): name is keyof AccessibleProps =>\n Object.hasOwn(ACCESSIBLE_PROP_MAP, name);\n\nfunction applyDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescriptor, newValue: unknown): void {\n const value = buildValue(descriptor, newValue);\n\n switch (descriptor.kind) {\n case \"property\": {\n widget.updateProperty([descriptor.property], [value]);\n break;\n }\n case \"state\": {\n widget.updateState([descriptor.state], [value]);\n break;\n }\n case \"relation\": {\n widget.updateRelation([descriptor.relation], [value]);\n break;\n }\n }\n}\n\nfunction resetDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescriptor): void {\n switch (descriptor.kind) {\n case \"property\": {\n widget.resetProperty(descriptor.property);\n break;\n }\n case \"state\": {\n widget.resetState(descriptor.state);\n break;\n }\n case \"relation\": {\n widget.resetRelation(descriptor.relation);\n break;\n }\n }\n}\n\nconst applyChangedProp = (widget: Gtk.Accessible, name: keyof AccessibleProps, newValue: unknown): void => {\n if (newValue == null) {\n resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);\n } else {\n applyDescriptor(widget, ACCESSIBLE_PROP_MAP[name], newValue);\n }\n};\n\nconst applyChangedProps = (widget: Gtk.Accessible, newProps: Props): void => {\n for (const name in newProps) {\n if (!isAccessibleProp(name)) {\n continue;\n }\n\n applyChangedProp(widget, name, newProps[name]);\n }\n};\n\nconst isRemovedAccessibleProp = (name: string, oldProps: Props, newProps: Props): name is keyof AccessibleProps =>\n !Object.hasOwn(newProps, name) && isAccessibleProp(name) && oldProps[name] !== undefined;\n\nconst resetRemovedProps = (widget: Gtk.Accessible, oldProps: Props, newProps: Props): void => {\n for (const name in oldProps) {\n if (!isRemovedAccessibleProp(name, oldProps, newProps)) {\n continue;\n }\n\n resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);\n }\n};\n\nconst applyAccessibleProps = (widget: Gtk.Accessible, oldProps: Props | null, newProps: Props): void => {\n applyChangedProps(widget, newProps);\n\n if (oldProps) {\n resetRemovedProps(widget, oldProps, newProps);\n }\n};\n\nexport { isAccessibleProp, applyAccessibleProps, type AccessibleProps };\n"]}
1
+ {"version":3,"file":"accessible-props.js","sourceRoot":"","sources":["../../src/utils/accessible-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OA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AC,MAAM,EAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,MAAsB,EAAE,QAAsB,EAAE,QAAe,EAAQ,EAAE;IACnG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAEpC,IAAI,QAAQ,EAAE,CAAC;QACX,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAwB,CAAC","sourcesContent":["import * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport type { Props } from \"../reconciler/registry.js\";\n\n/**\n * Accessibility props available on every widget. Each member maps to a GTK4 accessible attribute\n * (a `Gtk.AccessibleProperty`, `Gtk.AccessibleState`, or `Gtk.AccessibleRelation`) and is applied\n * to the widget's accessible interface. Setting a member to `null` or `undefined`, or dropping it from the\n * props, resets that attribute to its default.\n */\ntype AccessibleProps = {\n /** How the widget completes the text being typed into it. */\n accessibleAutocomplete?: Gtk.AccessibleAutocomplete | null | undefined;\n /** Longer description announced after the label. */\n accessibleDescription?: string | null | undefined;\n /** Whether activating the widget opens a popup. */\n accessibleHasPopup?: boolean | null | undefined;\n /** Keyboard shortcuts that activate the widget. */\n accessibleKeyShortcuts?: string | null | undefined;\n /** Short name announced for the widget. */\n accessibleLabel?: string | null | undefined;\n /** Depth of the widget within a hierarchy of headings, list items, or tree rows. */\n accessibleLevel?: number | null | undefined;\n /** Whether the widget blocks interaction with everything behind it. */\n accessibleModal?: boolean | null | undefined;\n /** Whether the text input accepts more than one line. */\n accessibleMultiLine?: boolean | null | undefined;\n /** Whether more than one of the widget's items can be selected at a time. */\n accessibleMultiSelectable?: boolean | null | undefined;\n /** Whether the widget arranges its items horizontally or vertically. */\n accessibleOrientation?: Gtk.Orientation | null | undefined;\n /** Hint announced while the input is empty. */\n accessiblePlaceholder?: string | null | undefined;\n /** Whether the value can be read but not changed. */\n accessibleReadOnly?: boolean | null | undefined;\n /** Whether a value has to be supplied before the form can be submitted. */\n accessibleRequired?: boolean | null | undefined;\n /** Wording that replaces the default announcement of the widget's role. */\n accessibleRoleDescription?: string | null | undefined;\n /** Direction the widget's items are sorted in. */\n accessibleSort?: Gtk.AccessibleSort | null | undefined;\n /** Upper bound of the widget's value range. */\n accessibleValueMax?: number | null | undefined;\n /** Lower bound of the widget's value range. */\n accessibleValueMin?: number | null | undefined;\n /** Current value within the widget's range. */\n accessibleValueNow?: number | null | undefined;\n /** Wording announced in place of the numeric value. */\n accessibleValueText?: string | null | undefined;\n /** Help text describing how to use the widget. */\n accessibleHelpText?: string | null | undefined;\n /** Whether the widget is still loading and its content may yet change. */\n accessibleBusy?: boolean | null | undefined;\n /** Checked state of a check button or menu item, which may be mixed. */\n accessibleChecked?: Gtk.AccessibleTristate | null | undefined;\n /** Whether the widget is visible but cannot be edited or operated. */\n accessibleDisabled?: boolean | null | undefined;\n /** Whether the content the widget discloses is showing. */\n accessibleExpanded?: boolean | null | undefined;\n /** Whether the widget is kept out of the accessibility tree. */\n accessibleHidden?: boolean | null | undefined;\n /** Whether the entered value fails validation, and in what way. */\n accessibleInvalid?: Gtk.AccessibleInvalidState | null | undefined;\n /** Pressed state of a toggle button, which may be mixed. */\n accessiblePressed?: Gtk.AccessibleTristate | null | undefined;\n /** Whether the widget is selected within its container. */\n accessibleSelected?: boolean | null | undefined;\n /** Whether the link has already been followed. */\n accessibleVisited?: boolean | null | undefined;\n /** Descendant that holds the focus while the widget itself keeps it. */\n accessibleActiveDescendant?: Gtk.Accessible | null | undefined;\n /** Total number of columns in the table, including any that are not rendered. */\n accessibleColCount?: number | null | undefined;\n /** One-based column position of the cell within its table. */\n accessibleColIndex?: number | null | undefined;\n /** Wording announced in place of the numeric column position. */\n accessibleColIndexText?: string | null | undefined;\n /** Number of columns the cell spans. */\n accessibleColSpan?: number | null | undefined;\n /** Widgets whose content or presence this widget controls. */\n accessibleControls?: Gtk.Accessible[] | null | undefined;\n /** Widgets that describe this one. */\n accessibleDescribedBy?: Gtk.Accessible[] | null | undefined;\n /** Widgets holding extended detail about this one. */\n accessibleDetails?: Gtk.Accessible[] | null | undefined;\n /** Widgets holding the message that explains why the value is invalid. */\n accessibleErrorMessage?: Gtk.Accessible[] | null | undefined;\n /** Widgets to read next, overriding the default reading order. */\n accessibleFlowTo?: Gtk.Accessible[] | null | undefined;\n /** Widgets that label this one. */\n accessibleLabelledBy?: Gtk.Accessible[] | null | undefined;\n /** Widgets this one owns that the widget hierarchy does not already imply. */\n accessibleOwns?: Gtk.Accessible[] | null | undefined;\n /** One-based position of the widget within its set. */\n accessiblePosInSet?: number | null | undefined;\n /** Total number of rows in the table, including any that are not rendered. */\n accessibleRowCount?: number | null | undefined;\n /** One-based row position of the cell within its table. */\n accessibleRowIndex?: number | null | undefined;\n /** Wording announced in place of the numeric row position. */\n accessibleRowIndexText?: string | null | undefined;\n /** Number of rows the cell spans. */\n accessibleRowSpan?: number | null | undefined;\n /** Total number of items in the set the widget belongs to. */\n accessibleSetSize?: number | null | undefined;\n};\n\ntype AccessibleValueType = \"string\" | \"boolean\" | \"optionalBoolean\" | \"int\" | \"double\" | \"object\" | \"list\";\n\ntype AccessiblePropertyDescriptor = {\n kind: \"property\";\n property: Gtk.AccessibleProperty;\n type: AccessibleValueType;\n};\n\ntype AccessibleStateDescriptor = {\n kind: \"state\";\n state: Gtk.AccessibleState;\n type: AccessibleValueType;\n};\n\ntype AccessibleRelationDescriptor = {\n kind: \"relation\";\n relation: Gtk.AccessibleRelation;\n type: AccessibleValueType;\n};\n\ntype AccessibleDescriptor = AccessiblePropertyDescriptor | AccessibleStateDescriptor | AccessibleRelationDescriptor;\n\nconst ACCESSIBLE_PROP_MAP: Record<keyof AccessibleProps, AccessibleDescriptor> = {\n accessibleAutocomplete: buildProperty(Gtk.AccessibleProperty.AUTOCOMPLETE, \"int\"),\n accessibleDescription: buildProperty(Gtk.AccessibleProperty.DESCRIPTION, \"string\"),\n accessibleHasPopup: buildProperty(Gtk.AccessibleProperty.HAS_POPUP, \"boolean\"),\n accessibleKeyShortcuts: buildProperty(Gtk.AccessibleProperty.KEY_SHORTCUTS, \"string\"),\n accessibleLabel: buildProperty(Gtk.AccessibleProperty.LABEL, \"string\"),\n accessibleLevel: buildProperty(Gtk.AccessibleProperty.LEVEL, \"int\"),\n accessibleModal: buildProperty(Gtk.AccessibleProperty.MODAL, \"boolean\"),\n accessibleMultiLine: buildProperty(Gtk.AccessibleProperty.MULTI_LINE, \"boolean\"),\n accessibleMultiSelectable: buildProperty(Gtk.AccessibleProperty.MULTI_SELECTABLE, \"boolean\"),\n accessibleOrientation: buildProperty(Gtk.AccessibleProperty.ORIENTATION, \"int\"),\n accessiblePlaceholder: buildProperty(Gtk.AccessibleProperty.PLACEHOLDER, \"string\"),\n accessibleReadOnly: buildProperty(Gtk.AccessibleProperty.READ_ONLY, \"boolean\"),\n accessibleRequired: buildProperty(Gtk.AccessibleProperty.REQUIRED, \"boolean\"),\n accessibleRoleDescription: buildProperty(Gtk.AccessibleProperty.ROLE_DESCRIPTION, \"string\"),\n accessibleSort: buildProperty(Gtk.AccessibleProperty.SORT, \"int\"),\n accessibleValueMax: buildProperty(Gtk.AccessibleProperty.VALUE_MAX, \"double\"),\n accessibleValueMin: buildProperty(Gtk.AccessibleProperty.VALUE_MIN, \"double\"),\n accessibleValueNow: buildProperty(Gtk.AccessibleProperty.VALUE_NOW, \"double\"),\n accessibleValueText: buildProperty(Gtk.AccessibleProperty.VALUE_TEXT, \"string\"),\n accessibleHelpText: buildProperty(Gtk.AccessibleProperty.HELP_TEXT, \"string\"),\n accessibleBusy: buildState(Gtk.AccessibleState.BUSY, \"boolean\"),\n accessibleChecked: buildState(Gtk.AccessibleState.CHECKED, \"int\"),\n accessibleDisabled: buildState(Gtk.AccessibleState.DISABLED, \"boolean\"),\n accessibleExpanded: buildState(Gtk.AccessibleState.EXPANDED, \"optionalBoolean\"),\n accessibleHidden: buildState(Gtk.AccessibleState.HIDDEN, \"boolean\"),\n accessibleInvalid: buildState(Gtk.AccessibleState.INVALID, \"int\"),\n accessiblePressed: buildState(Gtk.AccessibleState.PRESSED, \"int\"),\n accessibleSelected: buildState(Gtk.AccessibleState.SELECTED, \"optionalBoolean\"),\n accessibleVisited: buildState(Gtk.AccessibleState.VISITED, \"optionalBoolean\"),\n accessibleActiveDescendant: buildRelation(Gtk.AccessibleRelation.ACTIVE_DESCENDANT, \"object\"),\n accessibleColCount: buildRelation(Gtk.AccessibleRelation.COL_COUNT, \"int\"),\n accessibleColIndex: buildRelation(Gtk.AccessibleRelation.COL_INDEX, \"int\"),\n accessibleColIndexText: buildRelation(Gtk.AccessibleRelation.COL_INDEX_TEXT, \"string\"),\n accessibleColSpan: buildRelation(Gtk.AccessibleRelation.COL_SPAN, \"int\"),\n accessibleControls: buildRelation(Gtk.AccessibleRelation.CONTROLS, \"list\"),\n accessibleDescribedBy: buildRelation(Gtk.AccessibleRelation.DESCRIBED_BY, \"list\"),\n accessibleDetails: buildRelation(Gtk.AccessibleRelation.DETAILS, \"list\"),\n accessibleErrorMessage: buildRelation(Gtk.AccessibleRelation.ERROR_MESSAGE, \"list\"),\n accessibleFlowTo: buildRelation(Gtk.AccessibleRelation.FLOW_TO, \"list\"),\n accessibleLabelledBy: buildRelation(Gtk.AccessibleRelation.LABELLED_BY, \"list\"),\n accessibleOwns: buildRelation(Gtk.AccessibleRelation.OWNS, \"list\"),\n accessiblePosInSet: buildRelation(Gtk.AccessibleRelation.POS_IN_SET, \"int\"),\n accessibleRowCount: buildRelation(Gtk.AccessibleRelation.ROW_COUNT, \"int\"),\n accessibleRowIndex: buildRelation(Gtk.AccessibleRelation.ROW_INDEX, \"int\"),\n accessibleRowIndexText: buildRelation(Gtk.AccessibleRelation.ROW_INDEX_TEXT, \"string\"),\n accessibleRowSpan: buildRelation(Gtk.AccessibleRelation.ROW_SPAN, \"int\"),\n accessibleSetSize: buildRelation(Gtk.AccessibleRelation.SET_SIZE, \"int\"),\n};\n\nfunction buildProperty(property: Gtk.AccessibleProperty, type: AccessibleValueType): AccessiblePropertyDescriptor {\n return {\n kind: \"property\",\n property,\n type,\n };\n}\n\nfunction buildState(state: Gtk.AccessibleState, type: AccessibleValueType): AccessibleStateDescriptor {\n return {\n kind: \"state\",\n state,\n type,\n };\n}\n\nfunction buildRelation(relation: Gtk.AccessibleRelation, type: AccessibleValueType): AccessibleRelationDescriptor {\n return {\n kind: \"relation\",\n relation,\n type,\n };\n}\n\nconst initValue = (gtype: GObject.Type, populate: (value: GObject.Value) => void): GObject.Value => {\n const value = new GObject.Value();\n value.init(gtype);\n populate(value);\n\n return value;\n};\n\nconst buildValue = (descriptor: AccessibleDescriptor, jsValue: unknown): GObject.Value => {\n switch (descriptor.type) {\n case \"string\": {\n return initValue(GObject.TYPE_STRING, (v) => {\n v.setString(jsValue as string);\n });\n }\n case \"boolean\": {\n return initValue(GObject.TYPE_BOOLEAN, (v) => {\n v.setBoolean(jsValue as boolean);\n });\n }\n case \"optionalBoolean\": {\n return initValue(GObject.TYPE_INT, (v) => {\n v.setInt(jsValue === true ? 1 : 0);\n });\n }\n case \"int\": {\n return initValue(GObject.TYPE_INT, (v) => {\n v.setInt(jsValue as number);\n });\n }\n case \"double\": {\n return initValue(GObject.TYPE_DOUBLE, (v) => {\n v.setDouble(jsValue as number);\n });\n }\n case \"object\": {\n return initValue(GObject.TYPE_OBJECT, (v) => {\n v.setObject(jsValue as GObject.Object | null);\n });\n }\n case \"list\": {\n const list = Gtk.AccessibleList.newFromList(jsValue as Gtk.Accessible[]);\n\n return initValue(Gtk.AccessibleList.prototype.__type__, (v) => {\n v.setBoxed(list);\n });\n }\n }\n};\n\nconst isAccessibleProp = (name: string): name is keyof AccessibleProps =>\n Object.hasOwn(ACCESSIBLE_PROP_MAP, name);\n\nfunction applyDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescriptor, newValue: unknown): void {\n const value = buildValue(descriptor, newValue);\n\n switch (descriptor.kind) {\n case \"property\": {\n widget.updateProperty([descriptor.property], [value]);\n break;\n }\n case \"state\": {\n widget.updateState([descriptor.state], [value]);\n break;\n }\n case \"relation\": {\n widget.updateRelation([descriptor.relation], [value]);\n break;\n }\n }\n}\n\nfunction resetDescriptor(widget: Gtk.Accessible, descriptor: AccessibleDescriptor): void {\n switch (descriptor.kind) {\n case \"property\": {\n widget.resetProperty(descriptor.property);\n break;\n }\n case \"state\": {\n widget.resetState(descriptor.state);\n break;\n }\n case \"relation\": {\n widget.resetRelation(descriptor.relation);\n break;\n }\n }\n}\n\nconst applyChangedProp = (widget: Gtk.Accessible, name: keyof AccessibleProps, newValue: unknown): void => {\n if (newValue == null) {\n resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);\n } else {\n applyDescriptor(widget, ACCESSIBLE_PROP_MAP[name], newValue);\n }\n};\n\nconst applyChangedProps = (widget: Gtk.Accessible, newProps: Props): void => {\n for (const name in newProps) {\n if (!isAccessibleProp(name)) {\n continue;\n }\n\n applyChangedProp(widget, name, newProps[name]);\n }\n};\n\nconst isRemovedAccessibleProp = (name: string, oldProps: Props, newProps: Props): name is keyof AccessibleProps =>\n !Object.hasOwn(newProps, name) && isAccessibleProp(name) && oldProps[name] !== undefined;\n\nconst resetRemovedProps = (widget: Gtk.Accessible, oldProps: Props, newProps: Props): void => {\n for (const name in oldProps) {\n if (!isRemovedAccessibleProp(name, oldProps, newProps)) {\n continue;\n }\n\n resetDescriptor(widget, ACCESSIBLE_PROP_MAP[name]);\n }\n};\n\nconst applyAccessibleProps = (widget: Gtk.Accessible, oldProps: Props | null, newProps: Props): void => {\n applyChangedProps(widget, newProps);\n\n if (oldProps) {\n resetRemovedProps(widget, oldProps, newProps);\n }\n};\n\nexport { isAccessibleProp, applyAccessibleProps, type AccessibleProps };\n"]}
package/env.d.ts CHANGED
@@ -1,15 +1,18 @@
1
1
  declare module "virtual:gtkx-config" {
2
2
  /** The GObject signal each `on…` handler prop connects to, keyed by GLib type name. */
3
3
  export const signals: Record<string, Record<string, string>>;
4
- /** Props GTK accepts only while an object is being built, keyed by GLib type name. */
5
- export const constructOnlyProps: Record<string, Set<string>>;
6
- /** Props that can be passed to the constructor, keyed by GLib type name. */
7
- export const constructProps: Record<string, Set<string>>;
8
- /** The value each property is reset to when its prop is removed, keyed by GLib type name. */
9
- export const defaultProps: Record<string, Record<string, unknown>>;
4
+ /** The GObject name of a property, what a write may do to it, and the value it resets to. */
5
+ export type PropertyEntry = [name: string, flags: number, defaultValue?: unknown];
6
+ /** Every property a GLib type declares itself, keyed by GLib type name and then by accessor. */
7
+ export const properties: Record<string, Record<string, PropertyEntry>>;
10
8
  /** The application id from `gtkx.config.ts`, used as the default for `<GtkApplication>`. */
11
9
  export const applicationId: import("@gtkx/config").ResolvedConfig["applicationId"];
12
- /** Signals a user can trigger, which stay blocked while props are written, keyed by GLib type name. */
10
+ /** The resource base derived from `gtkx.config.ts`, used by application elements. */
11
+ export const resourceBasePath: string;
12
+ /**
13
+ * Signals a user can trigger, which stay blocked while props are written, keyed by GLib type name.
14
+ * `notify` is blocked only for the property being written.
15
+ */
13
16
  export const userEventSignals: import("@gtkx/config").ResolvedConfig["userEventSignals"];
14
17
  /** The element configuration the project's `gtkx.config.ts` contributes, keyed by GLib type name. */
15
18
  export const elements: Record<string, import("@gtkx/react/config").ElementConfig>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gtkx/react",
3
- "version": "1.2.2",
4
- "description": "React reconciler that renders GTK4 object trees, with the portals, signal handling, and hooks GTKX apps use",
3
+ "version": "1.4.0",
4
+ "description": "React reconciler for GTK. Renders real GTK4 widget trees.",
5
5
  "keywords": [
6
6
  "gtkx",
7
7
  "gtk",
@@ -86,9 +86,10 @@
86
86
  },
87
87
  "dependencies": {
88
88
  "react-reconciler": "^0.33.0",
89
- "@gtkx/config": "1.2.2",
90
- "@gtkx/runtime": "1.2.2",
91
- "@gtkx/utils": "1.2.2"
89
+ "@gtkx/config": "1.4.0",
90
+ "@gtkx/runtime": "1.4.0",
91
+ "@gtkx/css": "1.4.0",
92
+ "@gtkx/utils": "1.4.0"
92
93
  },
93
94
  "devDependencies": {
94
95
  "@types/react": "^19.2.18",
@@ -3,12 +3,12 @@ import { type ElementType, type ReactNode, useCallback } from "react";
3
3
  import { createPortaledComponent } from "../components/portaled.js";
4
4
  import { useParentWindow } from "../hooks/use-parent-window.js";
5
5
  import { createPresentedComponent, type PresentedProps } from "../hooks/use-presented-instance.js";
6
- import { applyWrite } from "../reconciler/signals.js";
6
+ import { applyMutation } from "../reconciler/signals.js";
7
7
 
8
8
  type DialogComponentProps = PresentedProps<Adw.Dialog>;
9
9
 
10
10
  const closeDialog = (dialog: Adw.Dialog): void => {
11
- applyWrite(() => {
11
+ applyMutation(() => {
12
12
  dialog.forceClose();
13
13
  });
14
14
  };
@@ -3,7 +3,10 @@ import { quitApplication, runApplication } from "@gtkx/runtime";
3
3
  import { pickBy, warn } from "@gtkx/utils";
4
4
  import process from "node:process";
5
5
  import { type ElementType, type ReactNode, type Ref, useLayoutEffect, useState } from "react";
6
- import { applicationId as defaultApplicationId } from "virtual:gtkx-config";
6
+ import {
7
+ applicationId as defaultApplicationId,
8
+ resourceBasePath as defaultResourceBasePath,
9
+ } from "virtual:gtkx-config";
7
10
  import { ApplicationContext } from "../hooks/use-application.js";
8
11
  import { useMergedRef } from "../hooks/use-merged-refs.js";
9
12
  import { createPortaledComponent } from "./portaled.js";
@@ -12,6 +15,7 @@ type ApplicationComponentProps = {
12
15
  applicationId?: string | null | undefined;
13
16
  children?: ReactNode | undefined;
14
17
  ref?: Ref<Gtk.Application | null> | undefined;
18
+ resourceBasePath?: string | null | undefined;
15
19
  };
16
20
 
17
21
  const POST_ACTIVATE_PROPS = new Set(["menubar"]);
@@ -80,7 +84,13 @@ const applicationChildren = (application: Gtk.Application | null, children: Reac
80
84
  const createApplicationElement = (
81
85
  Component: ElementType,
82
86
  ): ((props: ApplicationComponentProps) => ReactNode) => {
83
- return ({ applicationId = defaultApplicationId, children, ref, ...rest }: ApplicationComponentProps): ReactNode => {
87
+ return ({
88
+ applicationId = defaultApplicationId,
89
+ children,
90
+ ref,
91
+ resourceBasePath = defaultResourceBasePath,
92
+ ...rest
93
+ }: ApplicationComponentProps): ReactNode => {
84
94
  const [application, setApplication] = useState<Gtk.Application | null>(null);
85
95
  const [activated, setActivated] = useState(false);
86
96
  useApplicationLifecycle(application, setActivated, applicationId);
@@ -88,7 +98,12 @@ const createApplicationElement = (
88
98
  const appliedProps = activated ? rest : pickBy(rest, (_value, key) => !POST_ACTIVATE_PROPS.has(key));
89
99
 
90
100
  return (
91
- <Component ref={mergedRef} applicationId={applicationId} {...appliedProps}>
101
+ <Component
102
+ ref={mergedRef}
103
+ applicationId={applicationId}
104
+ {...appliedProps}
105
+ resourceBasePath={resourceBasePath}
106
+ >
92
107
  {activated ? applicationChildren(application, children) : null}
93
108
  </Component>
94
109
  );
@@ -2,7 +2,7 @@ import type * as Gtk from "@gtkx/gi/gtk";
2
2
  import { type ElementType, type ReactElement, type ReactNode, use } from "react";
3
3
  import { ParentWindowContext } from "../hooks/use-parent-window.js";
4
4
  import { createPresentedComponent, type PresentedProps } from "../hooks/use-presented-instance.js";
5
- import { applyWrite } from "../reconciler/signals.js";
5
+ import { applyMutation } from "../reconciler/signals.js";
6
6
  import { createPortaledComponent } from "./portaled.js";
7
7
 
8
8
  type WindowComponentProps = PresentedProps<Gtk.Window> & {
@@ -11,13 +11,13 @@ type WindowComponentProps = PresentedProps<Gtk.Window> & {
11
11
  };
12
12
 
13
13
  const presentWindow = (window: Gtk.Window): void => {
14
- applyWrite(() => {
14
+ applyMutation(() => {
15
15
  window.present();
16
16
  });
17
17
  };
18
18
 
19
19
  const destroyWindow = (window: Gtk.Window): void => {
20
- applyWrite(() => {
20
+ applyMutation(() => {
21
21
  window.destroy();
22
22
  });
23
23
  };
@@ -26,7 +26,21 @@ import {
26
26
  value,
27
27
  wrappingIndexedSlot,
28
28
  } from "./reconciler/behaviors.js";
29
- import { type ElementConfig, forTypes, registerElements } from "./reconciler/registry.js";
29
+ import {
30
+ type ElementBehavior,
31
+ type ElementConfig,
32
+ forTypes,
33
+ type Props,
34
+ registerElements,
35
+ } from "./reconciler/registry.js";
36
+ import { applyWrite } from "./reconciler/signals.js";
37
+ import { applyStyle, CSS_CLASSES_PROP, styleClass } from "./reconciler/style.js";
38
+
39
+ type SelectedIndexState = { desired: number | undefined; isScheduled: boolean; disconnect: (() => void) | null };
40
+
41
+ const SELECTED_INDEX_PROP = "selectedIndex";
42
+ const SELECTION_SIGNAL = "selected-rows-changed";
43
+ const NO_SELECTION = -1;
30
44
 
31
45
  const BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {
32
46
  ...forTypes(SINGLE_CHILD_TYPES, {
@@ -95,6 +109,7 @@ const BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {
95
109
  widget.insertActionGroup((info.props.prefix as string | null) ?? "", null);
96
110
  },
97
111
  }),
112
+ styleBehavior(),
98
113
  ],
99
114
  },
100
115
  GtkBox: {
@@ -105,6 +120,7 @@ const BUILTIN_BEHAVIORS: Record<string, ElementConfig<never>> = {
105
120
  wrappingIndexedSlot(Gtk.ListBoxRow, (row, inner) => {
106
121
  row.setChild(inner);
107
122
  }),
123
+ selectedIndexBehavior(),
108
124
  ],
109
125
  },
110
126
  GtkFlowBox: {
@@ -400,6 +416,169 @@ function layoutChild(parent: Gtk.Widget, child: Gtk.Widget): GObject.Object | nu
400
416
  return parent.getLayoutManager()?.getLayoutChild(child) ?? null;
401
417
  }
402
418
 
419
+ const isNullish = (value: unknown): boolean => value === undefined || value === null;
420
+ const isInitialNull = (prevValue: unknown, value: unknown): boolean => value === null && prevValue === undefined;
421
+
422
+ const withStyleClass = (classes: unknown, className: string): string[] =>
423
+ Array.isArray(classes) ? [...(classes as string[]), className] : [className];
424
+
425
+ const hasCssClassesChange = (prev: Props, next: Props): boolean => {
426
+ const classes = next.cssClasses;
427
+
428
+ if (classes === undefined || Object.is(prev.cssClasses, classes)) {
429
+ return false;
430
+ }
431
+
432
+ return !isInitialNull(prev.cssClasses, classes);
433
+ };
434
+
435
+ const didWriteCssClasses = (widget: Gtk.Widget, prev: Props, next: Props, className: string | null): boolean => {
436
+ if (className === null || !hasCssClassesChange(prev, next)) {
437
+ return false;
438
+ }
439
+
440
+ applyWrite(CSS_CLASSES_PROP, () => {
441
+ Reflect.set(widget, CSS_CLASSES_PROP, withStyleClass(next.cssClasses, className));
442
+ });
443
+
444
+ return true;
445
+ };
446
+
447
+ const isRestyled = (prev: Props, next: Props): boolean => {
448
+ if (isNullish(prev.style) && isNullish(next.style)) {
449
+ return false;
450
+ }
451
+
452
+ return !Object.is(prev.style, next.style);
453
+ };
454
+
455
+ function updateStyle(widget: Gtk.Widget, prev: Props, next: Props): Iterable<string> | undefined {
456
+ const isChanged = isRestyled(prev, next);
457
+ const className = isChanged ? applyStyle(widget, next.style) : styleClass(widget);
458
+
459
+ if (!isChanged && className === null) {
460
+ return;
461
+ }
462
+
463
+ return didWriteCssClasses(widget, prev, next, className) ? ["style", "cssClasses"] : ["style"];
464
+ }
465
+
466
+ function styleBehavior(): ElementBehavior<Gtk.Widget> {
467
+ return { update: updateStyle };
468
+ }
469
+
470
+ function selectedRowIndex(box: Gtk.ListBox): number {
471
+ return box.getSelectedRow()?.getIndex() ?? NO_SELECTION;
472
+ }
473
+
474
+ function selectedIndexError(value: number): Error {
475
+ return new Error(
476
+ "The 'selectedIndex' of a <GtkListBox> must be a whole number, or -1 to select no row; " +
477
+ `received ${String(value)}.`,
478
+ );
479
+ }
480
+
481
+ function desiredIndex(value: unknown): number | undefined {
482
+ if (value === null) {
483
+ return NO_SELECTION;
484
+ }
485
+
486
+ if (typeof value !== "number") {
487
+ return undefined;
488
+ }
489
+
490
+ if (!Number.isSafeInteger(value)) {
491
+ throw selectedIndexError(value);
492
+ }
493
+
494
+ return value;
495
+ }
496
+
497
+ function selectRowAt(box: Gtk.ListBox, row: Gtk.ListBoxRow): void {
498
+ applyWrite(SELECTED_INDEX_PROP, () => {
499
+ box.selectRow(row);
500
+ });
501
+ }
502
+
503
+ function clearSelection(box: Gtk.ListBox): void {
504
+ applyWrite(SELECTED_INDEX_PROP, () => {
505
+ box.unselectAll();
506
+ });
507
+ }
508
+
509
+ function applySelectedIndex(box: Gtk.ListBox, state: SelectedIndexState): void {
510
+ const { desired } = state;
511
+
512
+ if (desired === undefined || selectedRowIndex(box) === desired) {
513
+ return;
514
+ }
515
+
516
+ if (desired < 0) {
517
+ clearSelection(box);
518
+
519
+ return;
520
+ }
521
+
522
+ const row = box.getRowAtIndex(desired);
523
+
524
+ if (row !== null) {
525
+ selectRowAt(box, row);
526
+ }
527
+ }
528
+
529
+ function scheduleSelectedIndex(box: Gtk.ListBox, state: SelectedIndexState): void {
530
+ if (state.isScheduled) {
531
+ return;
532
+ }
533
+
534
+ state.isScheduled = true;
535
+
536
+ queueMicrotask(() => {
537
+ state.isScheduled = false;
538
+
539
+ if (state.disconnect !== null) {
540
+ applySelectedIndex(box, state);
541
+ }
542
+ });
543
+ }
544
+
545
+ function watchSelectionDrift(box: Gtk.ListBox, state: SelectedIndexState): void {
546
+ if (state.disconnect !== null) {
547
+ return;
548
+ }
549
+
550
+ const handler = (): undefined => {
551
+ scheduleSelectedIndex(box, state);
552
+ };
553
+
554
+ box.on(SELECTION_SIGNAL, handler);
555
+
556
+ state.disconnect = (): void => {
557
+ box.off(SELECTION_SIGNAL, handler);
558
+ };
559
+ }
560
+
561
+ function selectedIndexBehavior(): ElementBehavior<Gtk.ListBox> {
562
+ return {
563
+ deferred: [SELECTED_INDEX_PROP],
564
+ initialize: (): SelectedIndexState => ({ desired: undefined, isScheduled: false, disconnect: null }),
565
+ update: (_box, _prev, next, context) => {
566
+ (context as SelectedIndexState).desired = desiredIndex(next[SELECTED_INDEX_PROP]);
567
+
568
+ return [SELECTED_INDEX_PROP];
569
+ },
570
+ flush: (box, context) => {
571
+ applySelectedIndex(box, context as SelectedIndexState);
572
+ watchSelectionDrift(box, context as SelectedIndexState);
573
+ },
574
+ teardown: (_box, context) => {
575
+ const state = context as SelectedIndexState;
576
+ state.disconnect?.();
577
+ state.disconnect = null;
578
+ },
579
+ };
580
+ }
581
+
403
582
  const addMainOption = (application: Gtk.Application, option: MainOption): void => {
404
583
  application.addMainOption(
405
584
  option.longName,
@@ -82,7 +82,7 @@ const BUILTIN_ELEMENTS: Record<string, ElementConfig> = {
82
82
  props: internal("ChildrenProps"),
83
83
  },
84
84
  GtkListBox: {
85
- props: internal("ChildrenProps"),
85
+ props: internal("GtkListBoxProps"),
86
86
  },
87
87
  GtkFlowBox: {
88
88
  props: internal("ChildrenProps"),
@@ -3,6 +3,7 @@ import * as Gio from "@gtkx/gi/gio";
3
3
  import { kebabCase } from "@gtkx/utils";
4
4
  import { useLayoutEffect } from "react";
5
5
  import type { SettingsSchema, SettingsSchemaKeys } from "../utils/settings.js";
6
+ import { getPropertyName } from "../reconciler/metadata.js";
6
7
  import { type RefProp, resolveRefProp } from "../utils/ref-prop.js";
7
8
  import { useSettings } from "./use-setting.js";
8
9
 
@@ -32,7 +33,6 @@ function useBindSetting<K extends SettingsSchemaKeys>({
32
33
  flags = Gio.SettingsBindFlags.DEFAULT,
33
34
  }: UseBindSettingOptions<K>): void {
34
35
  const settings = useSettings(schema);
35
- const propertyName = kebabCase(property);
36
36
 
37
37
  useLayoutEffect(() => {
38
38
  const resolved = resolveRefProp(object);
@@ -41,12 +41,13 @@ function useBindSetting<K extends SettingsSchemaKeys>({
41
41
  return;
42
42
  }
43
43
 
44
+ const propertyName = getPropertyName(resolved, property) ?? kebabCase(property);
44
45
  settings.bind(key, resolved, propertyName, flags);
45
46
 
46
47
  return () => {
47
48
  Gio.Settings.unbind(resolved, propertyName);
48
49
  };
49
- }, [settings, key, object, propertyName, flags]);
50
+ }, [settings, key, object, property, flags]);
50
51
  }
51
52
 
52
53
  export { useBindSetting };
@@ -1,6 +1,7 @@
1
1
  import type * as GObject from "@gtkx/gi/gobject";
2
2
  import { kebabCase } from "@gtkx/utils";
3
- import type { RefProp } from "../utils/ref-prop.js";
3
+ import { getPropertyName } from "../reconciler/metadata.js";
4
+ import { type RefProp, resolveRefProp } from "../utils/ref-prop.js";
4
5
  import { useObjectValue } from "./use-object-value.js";
5
6
 
6
7
  /** The property map `T` declares, from camelCase property name to value type. */
@@ -18,7 +19,10 @@ function useProperty<T extends GObject.Object, P extends PropertyName<T>>(
18
19
  object: RefProp<T>,
19
20
  propertyName: P & string,
20
21
  ): T[P] | undefined {
21
- return useObjectValue(object, `notify::${kebabCase(propertyName)}`, (obj) => obj?.[propertyName]);
22
+ const resolved = resolveRefProp(object);
23
+ const name = (resolved === null ? undefined : getPropertyName(resolved, propertyName)) ?? kebabCase(propertyName);
24
+
25
+ return useObjectValue(object, `notify::${name}`, (obj) => obj?.[propertyName]);
22
26
  }
23
27
 
24
28
  export { useProperty };
package/src/internal.ts CHANGED
@@ -15,4 +15,6 @@ export type * from "./prop-types.js";
15
15
  export { settleAccessible } from "./reconciler/apply-props.js";
16
16
  export { isRootElement } from "./reconciler/root-element.js";
17
17
  export { createReconcilerRoot, type ReconcilerRoot, setReconcilerErrorHandler } from "./reconciler/root.js";
18
+ export { applyWrite } from "./reconciler/signals.js";
19
+ export { applyStyle } from "./reconciler/style.js";
18
20
  export type { SettingsSchema, SettingsSchemaKeys, SettingValue } from "./utils/settings.js";