@react-spectrum/s2 1.0.0 → 1.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/dist/Accordion.cjs +3 -3
- package/dist/Accordion.cjs.map +1 -1
- package/dist/Accordion.css +2 -2
- package/dist/Accordion.css.map +1 -1
- package/dist/Accordion.mjs +3 -3
- package/dist/Accordion.mjs.map +1 -1
- package/dist/ActionBar.cjs +62 -61
- package/dist/ActionBar.cjs.map +1 -1
- package/dist/ActionBar.css +58 -58
- package/dist/ActionBar.css.map +1 -1
- package/dist/ActionBar.mjs +62 -61
- package/dist/ActionBar.mjs.map +1 -1
- package/dist/ActionButton.cjs +234 -234
- package/dist/ActionButton.cjs.map +1 -1
- package/dist/ActionButton.css +160 -160
- package/dist/ActionButton.css.map +1 -1
- package/dist/ActionButton.mjs +234 -234
- package/dist/ActionButton.mjs.map +1 -1
- package/dist/ActionButtonGroup.cjs +16 -16
- package/dist/ActionButtonGroup.css +9 -9
- package/dist/ActionButtonGroup.mjs +16 -16
- package/dist/Add.cjs +10 -10
- package/dist/Add.css +6 -6
- package/dist/Add.mjs +10 -10
- package/dist/AlertDialog.cjs +3 -3
- package/dist/AlertDialog.css +3 -3
- package/dist/AlertDialog.mjs +3 -3
- package/dist/Asterisk.cjs +6 -6
- package/dist/Asterisk.css +4 -4
- package/dist/Asterisk.mjs +6 -6
- package/dist/Avatar.cjs +17 -17
- package/dist/Avatar.css +16 -16
- package/dist/Avatar.mjs +17 -17
- package/dist/AvatarGroup.cjs +121 -121
- package/dist/AvatarGroup.css +31 -31
- package/dist/AvatarGroup.mjs +121 -121
- package/dist/Badge.cjs +197 -197
- package/dist/Badge.css +125 -125
- package/dist/Badge.mjs +197 -197
- package/dist/Breadcrumbs.cjs +235 -235
- package/dist/Breadcrumbs.cjs.map +1 -1
- package/dist/Breadcrumbs.css +100 -100
- package/dist/Breadcrumbs.css.map +1 -1
- package/dist/Breadcrumbs.mjs +235 -235
- package/dist/Breadcrumbs.mjs.map +1 -1
- package/dist/Button.cjs +333 -333
- package/dist/Button.cjs.map +1 -1
- package/dist/Button.css +174 -174
- package/dist/Button.css.map +1 -1
- package/dist/Button.mjs +333 -333
- package/dist/Button.mjs.map +1 -1
- package/dist/ButtonGroup.cjs +21 -21
- package/dist/ButtonGroup.css +15 -15
- package/dist/ButtonGroup.mjs +21 -21
- package/dist/Calendar.cjs +169 -169
- package/dist/Calendar.cjs.map +1 -1
- package/dist/Calendar.css +134 -134
- package/dist/Calendar.css.map +1 -1
- package/dist/Calendar.mjs +169 -169
- package/dist/Calendar.mjs.map +1 -1
- package/dist/Card.cjs +310 -310
- package/dist/Card.cjs.map +1 -1
- package/dist/Card.css +206 -206
- package/dist/Card.css.map +1 -1
- package/dist/Card.mjs +310 -310
- package/dist/Card.mjs.map +1 -1
- package/dist/CardView.cjs +19 -19
- package/dist/CardView.cjs.map +1 -1
- package/dist/CardView.css +17 -17
- package/dist/CardView.css.map +1 -1
- package/dist/CardView.mjs +19 -19
- package/dist/CardView.mjs.map +1 -1
- package/dist/CenterBaseline.cjs +1 -1
- package/dist/CenterBaseline.css +2 -2
- package/dist/CenterBaseline.mjs +1 -1
- package/dist/Checkbox.cjs +162 -162
- package/dist/Checkbox.cjs.map +1 -1
- package/dist/Checkbox.css +95 -91
- package/dist/Checkbox.css.map +1 -1
- package/dist/Checkbox.mjs +162 -162
- package/dist/Checkbox.mjs.map +1 -1
- package/dist/CheckboxGroup.cjs +44 -44
- package/dist/CheckboxGroup.cjs.map +1 -1
- package/dist/CheckboxGroup.css +37 -37
- package/dist/CheckboxGroup.css.map +1 -1
- package/dist/CheckboxGroup.mjs +44 -44
- package/dist/CheckboxGroup.mjs.map +1 -1
- package/dist/Checkmark.cjs +12 -12
- package/dist/Checkmark.css +8 -8
- package/dist/Checkmark.mjs +12 -12
- package/dist/Chevron.cjs +12 -12
- package/dist/Chevron.css +10 -10
- package/dist/Chevron.mjs +12 -12
- package/dist/ClearButton.cjs +30 -30
- package/dist/ClearButton.css +30 -30
- package/dist/ClearButton.mjs +30 -30
- package/dist/CloseButton.cjs +56 -56
- package/dist/CloseButton.css +47 -47
- package/dist/CloseButton.mjs +56 -56
- package/dist/ColorArea.cjs +17 -17
- package/dist/ColorArea.cjs.map +1 -1
- package/dist/ColorArea.css +16 -16
- package/dist/ColorArea.css.map +1 -1
- package/dist/ColorArea.mjs +17 -17
- package/dist/ColorArea.mjs.map +1 -1
- package/dist/ColorField.cjs +32 -32
- package/dist/ColorField.cjs.map +1 -1
- package/dist/ColorField.css +27 -27
- package/dist/ColorField.css.map +1 -1
- package/dist/ColorField.mjs +32 -32
- package/dist/ColorField.mjs.map +1 -1
- package/dist/ColorHandle.cjs +27 -27
- package/dist/ColorHandle.css +42 -42
- package/dist/ColorHandle.mjs +27 -27
- package/dist/ColorSlider.cjs +109 -109
- package/dist/ColorSlider.cjs.map +1 -1
- package/dist/ColorSlider.css +52 -52
- package/dist/ColorSlider.css.map +1 -1
- package/dist/ColorSlider.mjs +109 -109
- package/dist/ColorSlider.mjs.map +1 -1
- package/dist/ColorSwatch.cjs +30 -30
- package/dist/ColorSwatch.cjs.map +1 -1
- package/dist/ColorSwatch.css +29 -29
- package/dist/ColorSwatch.css.map +1 -1
- package/dist/ColorSwatch.mjs +30 -30
- package/dist/ColorSwatch.mjs.map +1 -1
- package/dist/ColorSwatchPicker.cjs +30 -30
- package/dist/ColorSwatchPicker.css +48 -48
- package/dist/ColorSwatchPicker.mjs +30 -30
- package/dist/ColorWheel.cjs +31 -27
- package/dist/ColorWheel.cjs.map +1 -1
- package/dist/ColorWheel.css +17 -17
- package/dist/ColorWheel.css.map +1 -1
- package/dist/ColorWheel.mjs +31 -27
- package/dist/ColorWheel.mjs.map +1 -1
- package/dist/ComboBox.cjs +383 -383
- package/dist/ComboBox.cjs.map +1 -1
- package/dist/ComboBox.css +187 -187
- package/dist/ComboBox.css.map +1 -1
- package/dist/ComboBox.mjs +383 -383
- package/dist/ComboBox.mjs.map +1 -1
- package/dist/ContextualHelp.cjs +5 -5
- package/dist/ContextualHelp.css +50 -50
- package/dist/ContextualHelp.mjs +5 -5
- package/dist/Cross.cjs +14 -14
- package/dist/Cross.css +10 -10
- package/dist/Cross.mjs +14 -14
- package/dist/CustomDialog.cjs +26 -26
- package/dist/CustomDialog.cjs.map +1 -1
- package/dist/CustomDialog.css +25 -25
- package/dist/CustomDialog.css.map +1 -1
- package/dist/CustomDialog.mjs +26 -26
- package/dist/CustomDialog.mjs.map +1 -1
- package/dist/Dash.cjs +10 -10
- package/dist/Dash.css +6 -6
- package/dist/Dash.mjs +10 -10
- package/dist/DateField.cjs +74 -74
- package/dist/DateField.cjs.map +1 -1
- package/dist/DateField.css +77 -77
- package/dist/DateField.css.map +1 -1
- package/dist/DateField.mjs +74 -74
- package/dist/DateField.mjs.map +1 -1
- package/dist/DatePicker.cjs +173 -173
- package/dist/DatePicker.cjs.map +1 -1
- package/dist/DatePicker.css +128 -128
- package/dist/DatePicker.css.map +1 -1
- package/dist/DatePicker.mjs +173 -173
- package/dist/DatePicker.mjs.map +1 -1
- package/dist/DateRangePicker.cjs +56 -56
- package/dist/DateRangePicker.cjs.map +1 -1
- package/dist/DateRangePicker.css +59 -59
- package/dist/DateRangePicker.css.map +1 -1
- package/dist/DateRangePicker.mjs +56 -56
- package/dist/DateRangePicker.mjs.map +1 -1
- package/dist/Dialog.cjs +17 -17
- package/dist/Dialog.cjs.map +1 -1
- package/dist/Dialog.css +70 -70
- package/dist/Dialog.css.map +1 -1
- package/dist/Dialog.mjs +17 -17
- package/dist/Dialog.mjs.map +1 -1
- package/dist/Disclosure.cjs +120 -120
- package/dist/Disclosure.cjs.map +1 -1
- package/dist/Disclosure.css +112 -112
- package/dist/Disclosure.css.map +1 -1
- package/dist/Disclosure.mjs +120 -120
- package/dist/Disclosure.mjs.map +1 -1
- package/dist/Divider.cjs +26 -26
- package/dist/Divider.cjs.map +1 -1
- package/dist/Divider.css +25 -25
- package/dist/Divider.css.map +1 -1
- package/dist/Divider.mjs +26 -26
- package/dist/Divider.mjs.map +1 -1
- package/dist/DropZone.cjs +62 -62
- package/dist/DropZone.cjs.map +1 -1
- package/dist/DropZone.css +57 -57
- package/dist/DropZone.css.map +1 -1
- package/dist/DropZone.mjs +62 -62
- package/dist/DropZone.mjs.map +1 -1
- package/dist/Field.cjs +348 -348
- package/dist/Field.cjs.map +1 -1
- package/dist/Field.css +147 -147
- package/dist/Field.css.map +1 -1
- package/dist/Field.mjs +348 -348
- package/dist/Field.mjs.map +1 -1
- package/dist/Form.cjs +10 -10
- package/dist/Form.cjs.map +1 -1
- package/dist/Form.css +9 -9
- package/dist/Form.css.map +1 -1
- package/dist/Form.mjs +10 -10
- package/dist/Form.mjs.map +1 -1
- package/dist/FullscreenDialog.cjs +5 -5
- package/dist/FullscreenDialog.cjs.map +1 -1
- package/dist/FullscreenDialog.css +78 -78
- package/dist/FullscreenDialog.css.map +1 -1
- package/dist/FullscreenDialog.mjs +5 -5
- package/dist/FullscreenDialog.mjs.map +1 -1
- package/dist/IllustratedMessage.cjs +229 -229
- package/dist/IllustratedMessage.css +72 -72
- package/dist/IllustratedMessage.mjs +229 -229
- package/dist/Image.cjs +14 -14
- package/dist/Image.css +14 -14
- package/dist/Image.mjs +14 -14
- package/dist/InlineAlert.cjs +101 -101
- package/dist/InlineAlert.css +76 -76
- package/dist/InlineAlert.mjs +101 -101
- package/dist/Link.cjs +50 -50
- package/dist/Link.cjs.map +1 -1
- package/dist/Link.css +41 -41
- package/dist/Link.css.map +1 -1
- package/dist/Link.mjs +50 -50
- package/dist/Link.mjs.map +1 -1
- package/dist/LinkOut.cjs +8 -8
- package/dist/LinkOut.css +8 -8
- package/dist/LinkOut.mjs +8 -8
- package/dist/Menu.cjs +446 -443
- package/dist/Menu.cjs.map +1 -1
- package/dist/Menu.css +184 -184
- package/dist/Menu.css.map +1 -1
- package/dist/Menu.mjs +446 -443
- package/dist/Menu.mjs.map +1 -1
- package/dist/Meter.cjs +154 -154
- package/dist/Meter.cjs.map +1 -1
- package/dist/Meter.css +91 -91
- package/dist/Meter.css.map +1 -1
- package/dist/Meter.mjs +154 -154
- package/dist/Meter.mjs.map +1 -1
- package/dist/Modal.cjs +66 -66
- package/dist/Modal.cjs.map +1 -1
- package/dist/Modal.css +54 -54
- package/dist/Modal.css.map +1 -1
- package/dist/Modal.mjs +66 -66
- package/dist/Modal.mjs.map +1 -1
- package/dist/NotificationBadge.cjs +57 -57
- package/dist/NotificationBadge.css +49 -49
- package/dist/NotificationBadge.mjs +57 -57
- package/dist/NumberField.cjs +115 -115
- package/dist/NumberField.cjs.map +1 -1
- package/dist/NumberField.css +99 -99
- package/dist/NumberField.css.map +1 -1
- package/dist/NumberField.mjs +115 -115
- package/dist/NumberField.mjs.map +1 -1
- package/dist/Picker.cjs +275 -275
- package/dist/Picker.cjs.map +1 -1
- package/dist/Picker.css +173 -173
- package/dist/Picker.css.map +1 -1
- package/dist/Picker.mjs +275 -275
- package/dist/Picker.mjs.map +1 -1
- package/dist/Popover.cjs +89 -89
- package/dist/Popover.cjs.map +1 -1
- package/dist/Popover.css +70 -70
- package/dist/Popover.css.map +1 -1
- package/dist/Popover.mjs +89 -89
- package/dist/Popover.mjs.map +1 -1
- package/dist/ProgressBar.cjs +164 -164
- package/dist/ProgressBar.cjs.map +1 -1
- package/dist/ProgressBar.css +99 -99
- package/dist/ProgressBar.css.map +1 -1
- package/dist/ProgressBar.mjs +164 -164
- package/dist/ProgressBar.mjs.map +1 -1
- package/dist/ProgressCircle.cjs +32 -32
- package/dist/ProgressCircle.cjs.map +1 -1
- package/dist/ProgressCircle.css +24 -24
- package/dist/ProgressCircle.css.map +1 -1
- package/dist/ProgressCircle.mjs +32 -32
- package/dist/ProgressCircle.mjs.map +1 -1
- package/dist/Provider.cjs +11 -11
- package/dist/Provider.css +10 -10
- package/dist/Provider.mjs +11 -11
- package/dist/Radio.cjs +146 -146
- package/dist/Radio.cjs.map +1 -1
- package/dist/Radio.css +78 -78
- package/dist/Radio.css.map +1 -1
- package/dist/Radio.mjs +146 -146
- package/dist/Radio.mjs.map +1 -1
- package/dist/RadioGroup.cjs +42 -42
- package/dist/RadioGroup.cjs.map +1 -1
- package/dist/RadioGroup.css +37 -37
- package/dist/RadioGroup.css.map +1 -1
- package/dist/RadioGroup.mjs +42 -42
- package/dist/RadioGroup.mjs.map +1 -1
- package/dist/RangeCalendar.cjs +8 -8
- package/dist/RangeCalendar.cjs.map +1 -1
- package/dist/RangeCalendar.css +10 -10
- package/dist/RangeCalendar.css.map +1 -1
- package/dist/RangeCalendar.mjs +8 -8
- package/dist/RangeCalendar.mjs.map +1 -1
- package/dist/SearchField.cjs +42 -42
- package/dist/SearchField.cjs.map +1 -1
- package/dist/SearchField.css +45 -45
- package/dist/SearchField.css.map +1 -1
- package/dist/SearchField.mjs +42 -42
- package/dist/SearchField.mjs.map +1 -1
- package/dist/SegmentedControl.cjs +180 -180
- package/dist/SegmentedControl.css +123 -123
- package/dist/SegmentedControl.mjs +180 -180
- package/dist/SelectBoxGroup.cjs +144 -144
- package/dist/SelectBoxGroup.cjs.map +1 -1
- package/dist/SelectBoxGroup.css +120 -120
- package/dist/SelectBoxGroup.css.map +1 -1
- package/dist/SelectBoxGroup.mjs +144 -144
- package/dist/SelectBoxGroup.mjs.map +1 -1
- package/dist/Slider.cjs +295 -295
- package/dist/Slider.cjs.map +1 -1
- package/dist/Slider.css +154 -154
- package/dist/Slider.css.map +1 -1
- package/dist/Slider.mjs +295 -295
- package/dist/Slider.mjs.map +1 -1
- package/dist/StatusLight.cjs +116 -116
- package/dist/StatusLight.css +59 -59
- package/dist/StatusLight.mjs +116 -116
- package/dist/Switch.cjs +155 -155
- package/dist/Switch.cjs.map +1 -1
- package/dist/Switch.css +74 -74
- package/dist/Switch.css.map +1 -1
- package/dist/Switch.mjs +155 -155
- package/dist/Switch.mjs.map +1 -1
- package/dist/TableView.cjs +415 -415
- package/dist/TableView.cjs.map +1 -1
- package/dist/TableView.css +199 -199
- package/dist/TableView.css.map +1 -1
- package/dist/TableView.mjs +416 -416
- package/dist/TableView.mjs.map +1 -1
- package/dist/Tabs.cjs +127 -127
- package/dist/Tabs.cjs.map +1 -1
- package/dist/Tabs.css +105 -105
- package/dist/Tabs.css.map +1 -1
- package/dist/Tabs.mjs +127 -127
- package/dist/Tabs.mjs.map +1 -1
- package/dist/TabsPicker.cjs +127 -127
- package/dist/TabsPicker.cjs.map +1 -1
- package/dist/TabsPicker.css +108 -108
- package/dist/TabsPicker.css.map +1 -1
- package/dist/TabsPicker.mjs +127 -127
- package/dist/TabsPicker.mjs.map +1 -1
- package/dist/TagGroup.cjs +204 -204
- package/dist/TagGroup.cjs.map +1 -1
- package/dist/TagGroup.css +146 -146
- package/dist/TagGroup.css.map +1 -1
- package/dist/TagGroup.mjs +204 -204
- package/dist/TagGroup.mjs.map +1 -1
- package/dist/TextField.cjs +59 -59
- package/dist/TextField.cjs.map +1 -1
- package/dist/TextField.css +54 -54
- package/dist/TextField.css.map +1 -1
- package/dist/TextField.mjs +59 -59
- package/dist/TextField.mjs.map +1 -1
- package/dist/TimeField.cjs +52 -52
- package/dist/TimeField.cjs.map +1 -1
- package/dist/TimeField.css +47 -47
- package/dist/TimeField.css.map +1 -1
- package/dist/TimeField.mjs +52 -52
- package/dist/TimeField.mjs.map +1 -1
- package/dist/Toast.cjs +120 -120
- package/dist/Toast.cjs.map +1 -1
- package/dist/Toast.css +110 -110
- package/dist/Toast.css.map +1 -1
- package/dist/Toast.mjs +120 -120
- package/dist/Toast.mjs.map +1 -1
- package/dist/ToggleButton.cjs +3 -3
- package/dist/ToggleButton.cjs.map +1 -1
- package/dist/ToggleButton.css +12 -12
- package/dist/ToggleButton.css.map +1 -1
- package/dist/ToggleButton.mjs +3 -3
- package/dist/ToggleButton.mjs.map +1 -1
- package/dist/ToggleButtonGroup.cjs.map +1 -1
- package/dist/ToggleButtonGroup.mjs.map +1 -1
- package/dist/Tooltip.cjs +78 -78
- package/dist/Tooltip.cjs.map +1 -1
- package/dist/Tooltip.css +65 -65
- package/dist/Tooltip.css.map +1 -1
- package/dist/Tooltip.mjs +78 -78
- package/dist/Tooltip.mjs.map +1 -1
- package/dist/TreeView.cjs +144 -128
- package/dist/TreeView.cjs.map +1 -1
- package/dist/TreeView.css +131 -127
- package/dist/TreeView.css.map +1 -1
- package/dist/TreeView.mjs +144 -128
- package/dist/TreeView.mjs.map +1 -1
- package/dist/types.d.ts +68 -72
- package/dist/types.d.ts.map +1 -1
- package/icons/Icon.cjs +12 -12
- package/icons/Icon.css +9 -9
- package/icons/Icon.mjs +12 -12
- package/icons/Skeleton.cjs +2 -2
- package/icons/Skeleton.cjs.map +1 -1
- package/icons/Skeleton.css +6 -6
- package/icons/Skeleton.mjs +2 -2
- package/icons/Skeleton.mjs.map +1 -1
- package/icons/runtime.cjs +16 -3
- package/icons/runtime.cjs.map +1 -1
- package/icons/runtime.mjs +16 -3
- package/icons/runtime.mjs.map +1 -1
- package/package.json +21 -21
- package/src/Accordion.tsx +1 -1
- package/src/ActionBar.tsx +2 -2
- package/src/ActionButton.tsx +1 -1
- package/src/Breadcrumbs.tsx +2 -2
- package/src/Button.tsx +2 -2
- package/src/Calendar.tsx +1 -1
- package/src/Card.tsx +1 -1
- package/src/CardView.tsx +1 -1
- package/src/Checkbox.tsx +2 -1
- package/src/CheckboxGroup.tsx +1 -1
- package/src/CoachMark.tsx +1 -1
- package/src/ColorArea.tsx +1 -1
- package/src/ColorField.tsx +1 -1
- package/src/ColorSlider.tsx +1 -1
- package/src/ColorSwatch.tsx +1 -1
- package/src/ColorWheel.tsx +2 -2
- package/src/ComboBox.tsx +2 -2
- package/src/CustomDialog.tsx +1 -1
- package/src/DateField.tsx +1 -1
- package/src/DatePicker.tsx +1 -1
- package/src/DateRangePicker.tsx +1 -1
- package/src/Dialog.tsx +1 -1
- package/src/Disclosure.tsx +2 -2
- package/src/Divider.tsx +1 -1
- package/src/DropZone.tsx +1 -1
- package/src/Field.tsx +3 -3
- package/src/Form.tsx +1 -1
- package/src/FullscreenDialog.tsx +1 -1
- package/src/Link.tsx +1 -1
- package/src/Menu.tsx +11 -13
- package/src/Meter.tsx +1 -1
- package/src/Modal.tsx +1 -1
- package/src/NumberField.tsx +1 -1
- package/src/Picker.tsx +3 -3
- package/src/Popover.tsx +2 -1
- package/src/ProgressBar.tsx +1 -1
- package/src/ProgressCircle.tsx +1 -1
- package/src/Radio.tsx +1 -1
- package/src/RadioGroup.tsx +1 -1
- package/src/RangeCalendar.tsx +1 -1
- package/src/SearchField.tsx +1 -1
- package/src/SelectBoxGroup.tsx +1 -1
- package/src/Slider.tsx +1 -1
- package/src/Switch.tsx +1 -1
- package/src/TableView.tsx +9 -9
- package/src/Tabs.tsx +4 -4
- package/src/TabsPicker.tsx +2 -2
- package/src/TagGroup.tsx +2 -2
- package/src/TextField.tsx +1 -1
- package/src/TimeField.tsx +1 -1
- package/src/Toast.tsx +1 -1
- package/src/ToggleButton.tsx +1 -1
- package/src/ToggleButtonGroup.tsx +1 -1
- package/src/Tooltip.tsx +1 -1
- package/src/TreeView.tsx +10 -6
- package/style/__tests__/mergeStyles.test.ts +68 -0
- package/style/__tests__/style-macro.test.js +79 -59
- package/style/dist/style-macro.cjs +65 -14
- package/style/dist/style-macro.cjs.map +1 -1
- package/style/dist/style-macro.mjs +65 -14
- package/style/dist/style-macro.mjs.map +1 -1
- package/style/runtime.ts +21 -5
- package/style/style-macro.ts +81 -16
- package/style/__tests__/mergeStyles.test.js +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAMD,gDAAgD;AAChD,MAAM,6BAAO,KAAK,KAAK,CAAC,CAAA,GAAA,SAAC,EAAE,YAAY,CAAC,0CAAY,oBAAoB;AACxE,MAAM,gCAAU,2BAAK,OAAO,CAAC,QAAQ,CAAC,aAAa,2BAAK,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,GAAG,2BAAK,OAAO,CAAC,OA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AK,QACpE,MAAM,IAAI,MAAM;IAElB,IAAI,OAAO,qDAA+B,KAAK;IAC/C,MAAM,CAAC,WAAW,EAAE,KAAK;EACzB,EAAE,IAAI;CACP,CAAC;IACA,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,YACnC,IAAI,CAAC,QAAQ,CAAC;QACZ,MAAM;QACN,SAAS;IACX;IAEF,OAAO;AACT","sources":["packages/@react-spectrum/s2/style/style-macro.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type {Condition, CSSProperties, CSSValue, CustomValue, Property, PropertyValueDefinition, PropertyValueMap, RenderProps, ShorthandProperty, StyleFunction, StyleValue, Theme, ThemeProperties, Value} from './types';\nimport fs from 'fs';\nimport * as propertyInfo from './properties.json';\n\n// Postfix all class names with version for now.\nconst json = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8'));\nconst POSTFIX = json.version.includes('nightly') ? json.version.match(/-nightly-(.*)/)[1] : json.version.replace(/[0.]/g, '');\n\nexport class ArbitraryProperty<T extends Value> implements Property<T> {\n property: string;\n toCSS: (value: T) => CSSValue;\n\n constructor(property: string, toCSS?: (value: T) => CSSValue) {\n this.property = property;\n this.toCSS = toCSS || ((value) => String(value));\n }\n\n get cssProperties(): string[] {\n return [this.property];\n }\n\n toCSSValue(value: T): PropertyValueDefinition<Value> {\n return this.toCSS(value);\n }\n\n toCSSProperties(customProperty: string | null, value: PropertyValueDefinition<Value>): PropertyValueDefinition<[CSSProperties]> {\n return mapConditionalValue(value, value => [{[customProperty || this.property]: String(value)}]);\n }\n}\n\nexport class MappedProperty<T extends CSSValue> extends ArbitraryProperty<T> implements Property<T> {\n mapping: PropertyValueMap<T> | string[];\n\n constructor(property: string, mapping: PropertyValueMap<T> | string[]) {\n super(property);\n this.mapping = mapping;\n }\n\n toCSSValue(value: T): PropertyValueDefinition<Value> {\n if (Array.isArray(this.mapping)) {\n if (!this.mapping.includes(String(value))) {\n throw new Error('Invalid style value: ' + value);\n }\n return value;\n } else {\n let res = this.mapping[String(value)];\n if (res == null) {\n throw new Error('Invalid style value: ' + value);\n }\n return res;\n }\n }\n}\n\nexport type Color<C extends string> = C | `${string}/${number}`;\nexport class ColorProperty<C extends string> extends MappedProperty<C> implements Property<Color<C>> {\n toCSSValue(value: Color<C>): PropertyValueDefinition<Value> {\n let [color, opacity] = value.split('/');\n return mapConditionalValue(this.mapping[color], value => {\n return opacity ? `rgb(from ${value} r g b / ${opacity}%)` : value;\n });\n }\n}\n\nexport type LengthPercentageUnit = '%' | 'vw' | 'svw' | 'dvw' | 'vh' | 'svh' | 'dvh' | 'vmin' | 'svmin' | 'dvmin' | 'vmax' | 'svmax' | 'dvmax' | 'cqw' | 'cqh' | 'cqmin' | 'cqmax';\nexport type LengthPercentage = `${number}${LengthPercentageUnit}`;\n\nexport class PercentageProperty<T extends CSSValue> extends MappedProperty<T> implements Property<T | LengthPercentage> {\n constructor(property: string, mapping: PropertyValueMap<T> | string[]) {\n super(property, mapping);\n }\n\n toCSSValue(value: T | LengthPercentage): PropertyValueDefinition<Value> {\n if (typeof value === 'string' && /^-?\\d+(?:\\.\\d+)?(%|vw|svw|dvw|vh|svh|dvh|vmin|svmin|dvmin|vmax|svmax|dvmax|cqw|cqh|cqmin|cqmax)$/.test(value)) {\n return value;\n }\n\n return super.toCSSValue(value as T);\n }\n}\n\nexport class SizingProperty<T extends CSSValue> extends PercentageProperty<T> implements Property<T | number | LengthPercentage> {\n numberToCSS: (value: number) => string;\n\n constructor(property: string, mapping: PropertyValueMap<T> | string[], numberToCSS: (value: number) => string) {\n super(property, mapping);\n this.numberToCSS = numberToCSS;\n }\n\n toCSSValue(value: T | LengthPercentage | number): PropertyValueDefinition<Value> {\n if (typeof value === 'number') {\n return value === 0 ? '0px' : this.numberToCSS(value);\n }\n\n return super.toCSSValue(value);\n }\n}\n\nexport class ExpandedProperty<T extends Value> implements Property<T> {\n cssProperties: string[];\n mapping: Property<T> | null;\n expand: (v: T | CSSValue) => CSSProperties;\n\n constructor(properties: string[], expand: (v: T | CSSValue) => CSSProperties, mapping?: Property<T> | PropertyValueMap<CSSValue>) {\n this.cssProperties = properties;\n this.expand = expand;\n if (mapping instanceof MappedProperty) {\n this.mapping = mapping;\n } else if (mapping) {\n this.mapping = new MappedProperty<any>(properties[0], mapping as any);\n } else {\n this.mapping = null;\n }\n }\n\n toCSSValue(value: T): PropertyValueDefinition<Value> {\n if (!this.mapping) {\n return value;\n }\n\n return this.mapping.toCSSValue(value);\n }\n\n toCSSProperties(customProperty: string | null, value: PropertyValueDefinition<T>): PropertyValueDefinition<[CSSProperties]> {\n if (customProperty) {\n throw new Error('Style properties that expand into multiple CSS properties cannot be set as CSS variables.');\n }\n return mapConditionalValue(value, value => [this.expand(value)]);\n }\n}\n\nfunction mapConditionalValue<T, U>(value: PropertyValueDefinition<T>, fn: (value: T) => U): PropertyValueDefinition<U> {\n if (typeof value === 'object' && !Array.isArray(value)) {\n let res: PropertyValueDefinition<U> = {};\n for (let condition in value) {\n res[condition] = mapConditionalValue((value as any)[condition], fn);\n }\n return res;\n } else {\n return fn(value);\n }\n}\n\nfunction mapConditionalShorthand<T, C extends string, R extends RenderProps<string>>(value: PropertyValueDefinition<T>, fn: ShorthandProperty<T>): {[property: string]: StyleValue<Value, C, R>} {\n if (typeof value === 'object') {\n let res = {};\n for (let condition in value) {\n let properties = mapConditionalShorthand(value[condition], fn);\n for (let property in properties) {\n res[property] ??= {};\n res[property][condition] = properties[property];\n }\n }\n return res;\n } else {\n return fn(value);\n }\n}\n\nexport function parseArbitraryValue(value: Value): string | undefined {\n if (typeof value === 'string' && value.startsWith('--')) {\n return `var(${value})`;\n } else if (typeof value === 'string' && value[0] === '[' && value[value.length - 1] === ']') {\n return value.slice(1, -1);\n } else if (\n typeof value === 'string' && (\n /^(var|calc|min|max|clamp|round|mod|rem|sin|cos|tan|asin|acos|atan|atan2|pow|sqrt|hypot|log|exp|abs|sign)\\(.+\\)$/.test(value) || \n /^(inherit|initial|unset)$/.test(value)\n )\n ) {\n return value;\n }\n}\n\nfunction shortCSSPropertyName(property: string) {\n return propertyInfo.properties[property] ?? generateArbitraryValueSelector(property, true);\n}\n\nfunction classNamePrefix(property: string, cssProperty: string) {\n let className = propertyInfo.properties[cssProperty];\n if (className && property === '--' + className) {\n return '-' + className + '_-';\n }\n\n if (className && !property.startsWith('--')) {\n return className;\n }\n\n return '-' + generateArbitraryValueSelector(property, true) + '-';\n}\n\ninterface MacroContext {\n addAsset(asset: {type: string, content: string}): void\n}\n\nexport function createTheme<T extends Theme>(theme: T): StyleFunction<ThemeProperties<T>, 'default' | Extract<keyof T['conditions'], string>> {\n let properties = new Map<string, Property<any>>(Object.entries(theme.properties).map(([k, v]) => {\n if (!Array.isArray(v) && v.cssProperties) {\n return [k, v as Property<any>];\n }\n\n return [k, new MappedProperty(k, v as any)];\n }));\n\n let dependencies = new Set<string>();\n let hasConditions = false;\n return function style(this: MacroContext | void, style, allowedOverrides?: readonly string[]) {\n // Check if `this` is undefined, which means style was not called as a macro but as a normal function.\n // We also check if this is globalThis, which happens in non-strict mode bundles.\n // Also allow style to be called as a normal function in tests.\n // @ts-ignore\n // eslint-disable-next-line\n if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {\n throw new Error('The style macro must be imported with {type: \"macro\"}.');\n }\n\n // Generate rules for each property.\n let rules = new Map<string, Rule>();\n let values = new Map();\n dependencies.clear();\n let usedPriorities = 0;\n let setRules = (key: string, value: [number, Rule[]]) => {\n usedPriorities = Math.max(usedPriorities, value[0]);\n rules.set(key, new GroupRule(value[1]));\n };\n\n hasConditions = false;\n for (let key in style) {\n let value = style[key]!;\n let themeProperty = key;\n values.set(key, value);\n\n // Get the type of custom properties in the theme.\n if (key.startsWith('--')) {\n themeProperty = value.type;\n value = value.value;\n }\n\n // Expand shorthands to longhands so that merging works as expected.\n if (theme.shorthands[key]) {\n let shorthand = theme.shorthands[key];\n if (typeof shorthand === 'function') {\n let expanded = mapConditionalShorthand(value, shorthand);\n for (let k in expanded) {\n let v = expanded[k];\n values.set(k, v);\n setRules(k, compileValue(k, k, v));\n }\n } else {\n for (let prop of shorthand) {\n values.set(prop, value);\n setRules(prop, compileValue(prop, prop, value));\n }\n }\n } else if (themeProperty in theme.properties) {\n setRules(key, compileValue(key, themeProperty, value));\n }\n }\n\n // For properties referenced by self(), rewrite the declarations to assign\n // to an intermediary custom property so we can access the value.\n for (let dep of dependencies) {\n let value = values.get(dep);\n if (value != null) {\n if (!(dep in theme.properties)) {\n throw new Error(`Unknown dependency ${dep}`);\n }\n let prop = properties.get(dep)!;\n let name = `--${shortCSSPropertyName(prop.cssProperties[0])}`;\n // Could potentially use @property to prevent the var from inheriting in children.\n setRules(name, compileValue(name, dep, value));\n setRules(dep, compileValue(dep, dep, name));\n }\n }\n dependencies.clear();\n\n let css = '';\n\n // Declare layers for each priority ahead of time so the order is always correct.\n css += '@layer ';\n let first = true;\n for (let i = 0; i <= usedPriorities; i++) {\n if (first) {\n first = false;\n } else {\n css += ', ';\n }\n css += layerName(generateName(i, true));\n }\n css += ';\\n\\n';\n\n // If allowed overrides are provided, generate code to match the input override string and include only allowed classes.\n // Also generate a variable for each overridable property that overlaps with the style definition. If those are defined,\n // the defaults from the style definition are omitted.\n let allowedOverridesSet = new Set<string>();\n let js = 'let rules = \" \";\\n';\n if (allowedOverrides?.length) {\n for (let property of allowedOverrides) {\n let shorthand = theme.shorthands[property];\n let props = Array.isArray(shorthand) ? shorthand : [property];\n for (let property of props) {\n if (property.startsWith('--')) {\n allowedOverridesSet.add(property);\n continue;\n }\n \n let prop = properties.get(property);\n if (!prop) {\n throw new Error(`Invalid property ${property} in allowedOverrides`);\n }\n for (let property of prop.cssProperties) {\n allowedOverridesSet.add(property);\n }\n }\n }\n\n let loop = '';\n for (let property of rules.keys()) {\n let prop = properties.get(property);\n if (prop) {\n for (let property of prop.cssProperties) {\n if (property && allowedOverridesSet.has(property)) {\n let selector = classNamePrefix(property, property);\n let p = property.replace('--', '__');\n js += `let ${p} = false;\\n`;\n loop += ` if (p[1] === ${JSON.stringify(selector)}) ${p} = true;\\n`;\n }\n }\n } else if (property.startsWith('--') && allowedOverridesSet.has(property)) {\n let selector = classNamePrefix(property, property);\n let p = property.replace('--', '__');\n js += `let ${p} = false;\\n`;\n loop += ` if (p[1] === ${JSON.stringify(selector)}) ${p} = true;\\n`;\n }\n }\n\n let regex = `/(?:^|\\\\s)(${[...allowedOverridesSet].map(p => classNamePrefix(p, p)).join('|')})[^\\\\s]+/g`;\n if (loop) {\n js += `let matches = (overrides || '').matchAll(${regex});\\n`;\n js += 'for (let p of matches) {\\n';\n js += loop;\n js += ' rules += p[0];\\n';\n js += '}\\n';\n } else {\n js += `rules += ((overrides || '').match(${regex}) || []).join('')\\n`;\n }\n }\n\n // Generate JS and CSS for each rule.\n let isStatic = !(hasConditions || allowedOverrides);\n let className = '';\n let rulesByLayer = new Map<string, string[]>();\n let rootRule = new GroupRule([...rules.values()]);\n if (isStatic) {\n className += rootRule.getStaticClassName();\n } else {\n js += rootRule.toJS(allowedOverridesSet) + '\\n';\n }\n rootRule.toCSS(rulesByLayer);\n\n for (let [layer, rules] of rulesByLayer) {\n css += `@layer ${layerName(layer)} {\\n`;\n css += rules.join('\\n\\n');\n css += '}\\n\\n';\n }\n\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n\n if (isStatic) {\n return className;\n }\n\n js += 'return rules;';\n if (allowedOverrides) {\n return new Function('props', 'overrides', js) as any;\n }\n return new Function('props', js) as any;\n };\n\n function compileValue(property: string, themeProperty: string, value: StyleValue<Value, Condition<T>, any>) {\n return conditionalToRules(value as any, 0, new Set(), new Set(), (value, priority, conditions, skipConditions) => {\n return compileRule(property, themeProperty, value, priority, conditions, skipConditions);\n });\n }\n\n function conditionalToRules<P extends CustomValue | any[]>(\n value: PropertyValueDefinition<P>,\n parentPriority: number,\n currentConditions: Set<string>,\n skipConditions: Set<string>,\n fn: (value: P, priority: number, conditions: Set<string>, skipConditions: Set<string>) => [number, Rule[]]\n ): [number, Rule[]] {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n let rules: Rule[] = [];\n\n // Later conditions in parent rules override conditions in child rules.\n let subSkipConditions = new Set([...skipConditions, ...Object.keys(value)]);\n\n // Skip the default condition if we're already filtering by one of the other possible conditions.\n // For example, if someone specifies `dark: 'gray-400'`, only include the dark version of `gray-400` from the theme.\n let skipDefault = Object.keys(value).some(k => currentConditions.has(k));\n let wasCSSCondition = false;\n let priority = parentPriority;\n\n for (let condition in value) {\n if (skipConditions.has(condition) || (condition === 'default' && skipDefault)) {\n continue;\n }\n subSkipConditions.delete(condition);\n\n let val = value[condition];\n\n // If a theme condition comes after runtime conditions, create a new grouping.\n // This makes the CSS class unconditional so it appears outside the `else` block in the JS.\n // The @layer order in the generated CSS will ensure that it overrides classes applied by runtime conditions.\n let isCSSCondition = condition in theme.conditions || /^[@:]/.test(condition);\n if (!wasCSSCondition && isCSSCondition && rules.length) {\n rules = [new GroupRule(rules)];\n }\n wasCSSCondition = isCSSCondition;\n\n // Increment the current priority whenever we see a new CSS condition.\n if (isCSSCondition) {\n priority++;\n }\n\n // If this is a runtime condition, inherit the priority from the parent rule.\n // Otherwise, use the current maximum of the parent and current priorities.\n let rulePriority = isCSSCondition ? priority : parentPriority;\n\n if (condition === 'default' || isCSSCondition || /^is[A-Z]/.test(condition) || /^allows[A-Z]/.test(condition)) {\n let subConditions = currentConditions;\n if (isCSSCondition) {\n subConditions = new Set([...currentConditions, condition]);\n }\n let [subPriority, subRules] = conditionalToRules(val, rulePriority, subConditions, subSkipConditions, fn);\n rules.push(...compileCondition(currentConditions, condition, priority, subRules));\n priority = Math.max(priority, subPriority);\n } else if (val && typeof val === 'object' && !Array.isArray(val)) {\n for (let key in val) {\n let [subPriority, subRules] = conditionalToRules(val[key], rulePriority, currentConditions, subSkipConditions, fn);\n rules.push(...compileCondition(currentConditions, `${condition} === ${JSON.stringify(key)}`, priority, subRules));\n priority = Math.max(priority, subPriority);\n }\n }\n }\n return [priority, rules];\n } else {\n // @ts-ignore - broken in non-strict?\n return fn(value, parentPriority, currentConditions, skipConditions);\n }\n }\n\n function compileCondition(conditions: Set<string>, condition: string, priority: number, rules: Rule[]): Rule[] {\n if (condition === 'default' || conditions.has(condition)) {\n return [new GroupRule(rules)];\n }\n\n if (condition in theme.conditions || /^[@:]/.test(condition)) {\n // Conditions starting with : are CSS pseudo classes. Nest them inside the parent rule.\n let prelude = theme.conditions[condition] || condition;\n let preludes = Array.isArray(prelude) ? prelude : [prelude];\n return preludes.map(prelude => {\n if (prelude.startsWith(':')) {\n let rulesWithPseudo = rules.map(rule => {\n rule = rule.copy();\n rule.addPseudo(prelude);\n return rule;\n });\n\n return new GroupRule(rulesWithPseudo, generateName(priority, true));\n }\n\n // Otherwise, wrap the rule in the condition (e.g. @media).\n // Top level layer is based on the priority of the rule, not the condition.\n // Also group in a sub-layer based on the condition so that lightningcss can more effectively deduplicate rules.\n let layer = `${generateName(priority, true)}.${propertyInfo.conditions[prelude] || generateArbitraryValueSelector(condition, true)}`;\n return new AtRule(rules, prelude, layer);\n });\n }\n\n hasConditions = true;\n return [new ConditionalRule(rules, condition)];\n }\n\n function compileRule(property: string, themeProperty: string, value: Value, priority: number, conditions: Set<string>, skipConditions: Set<string>): [number, Rule[]] {\n let propertyFunction = properties.get(themeProperty);\n if (propertyFunction) {\n // Expand value to conditional CSS values, and then to rules.\n let arbitrary = parseArbitraryValue(value);\n let cssValue = arbitrary ? arbitrary : propertyFunction.toCSSValue(value);\n let cssProperties = propertyFunction.toCSSProperties(property.startsWith('--') ? property : null, cssValue);\n\n return conditionalToRules(cssProperties, priority, conditions, skipConditions, (value, priority, conditions) => {\n let [obj] = value;\n let rules: Rule[] = [];\n for (let key in obj) {\n let k = key as any;\n let value = obj[k];\n if (value === undefined) {\n continue;\n }\n if (typeof value === 'string') {\n // Replace self() references with variables and track the dependencies.\n value = value.replace(/self\\(([a-zA-Z]+)/g, (_, v) => {\n let prop = properties.get(v);\n if (!prop) {\n throw new Error(`self(${v}) is invalid. ${v} is not a known property.`);\n }\n let cssProperties = prop.cssProperties;\n if (cssProperties.length !== 1) {\n throw new Error(`self(${v}) is not supported. ${v} expands to multiple CSS properties.`);\n }\n dependencies.add(v);\n return `var(--${shortCSSPropertyName(cssProperties[0])}`;\n });\n }\n\n // Generate selector. This consists of three parts: property, conditions, value.\n let cssProperty = key;\n if (property.startsWith('--')) {\n cssProperty = propertyFunction.cssProperties[0];\n }\n\n let className = classNamePrefix(key, cssProperty);\n if (conditions.size > 0) {\n for (let condition of conditions) {\n let prelude = theme.conditions[condition] || condition;\n let preludes = Array.isArray(prelude) ? prelude : [prelude];\n for (let prelude of preludes) {\n className += propertyInfo.conditions[prelude] || generateArbitraryValueSelector(condition);\n }\n }\n }\n\n if (cssProperty !== key) {\n className += shortCSSPropertyName(cssProperty);\n }\n\n className += propertyInfo.values[cssProperty]?.[String(value)] ?? generateArbitraryValueSelector(String(value));\n className += POSTFIX;\n rules.push(new StyleRule(className, key, String(value)));\n }\n\n return [0, rules];\n });\n } else {\n throw new Error('Unknown property ' + themeProperty);\n }\n }\n}\n\nfunction kebab(property: string) {\n if (property.startsWith('--')) {\n return property;\n }\n return property.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`);\n}\n\n// Generate a class name from a number, e.g. index within the theme.\n// This maps to an alphabet containing lower case letters, upper case letters, and numbers.\n// For numbers larger than 62, an underscore is prepended.\n// This encoding allows easy parsing to enable runtime merging by property.\nfunction generateName(index: number, atStart = false): string {\n if (index < 26) {\n // lower case letters\n return String.fromCharCode(index + 97);\n }\n\n if (index < 52) {\n // upper case letters\n return String.fromCharCode((index - 26) + 65);\n }\n\n if (index < 62 && !atStart) {\n // numbers\n return String.fromCharCode((index - 52) + 48);\n }\n\n return '_' + generateName(index - (atStart ? 52 : 62));\n}\n\n// For arbitrary values, we use a hash of the string to generate the class name.\nfunction generateArbitraryValueSelector(v: string, atStart = false) {\n let c = toBase62(hash(v));\n if (atStart && /^[0-9]/.test(c)) {\n c = `_${c}`;\n }\n return c;\n}\n\nfunction toBase62(value: number) {\n if (value === 0) {\n return generateName(value);\n }\n\n let res = '';\n while (value) {\n let remainder = value % 62;\n res += generateName(remainder);\n value = Math.floor((value - remainder) / 62);\n }\n\n return res;\n}\n\n// djb2 hash function.\n// http://www.cse.yorku.ca/~oz/hash.html\nfunction hash(v: string) {\n let hash = 5381;\n for (let i = 0; i < v.length; i++) {\n hash = ((hash << 5) + hash) + v.charCodeAt(i) >>> 0;\n }\n return hash;\n}\n\nfunction layerName(name: string) {\n // All of our layers should be sub-layers of a single parent layer, so that\n // the unsafe overrides layer always comes after.\n return `_.${name}`;\n}\n\ninterface Rule {\n addPseudo(prelude: string): void,\n getStaticClassName(): string,\n toCSS(rulesByLayer: Map<string, string[]>, preludes?: string[], layer?: string): void,\n toJS(allowedOverridesSet: Set<string>, indent?: string): string,\n copy(): Rule\n}\n\n/** A CSS style rule. */\nclass StyleRule implements Rule {\n className: string;\n pseudos: string;\n property: string;\n value: string;\n\n constructor(className: string, property: string, value: string) {\n this.className = className;\n this.pseudos = '';\n this.property = property;\n this.value = value;\n }\n\n copy(): Rule {\n let rule = new StyleRule(this.className, this.property, this.value);\n rule.pseudos = this.pseudos;\n return rule;\n }\n\n addPseudo(prelude: string) {\n this.pseudos += prelude;\n }\n\n getStaticClassName(): string {\n return ' ' + this.className;\n }\n\n toCSS(rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer = 'a') {\n let prelude = `.${this.className}${this.pseudos}`;\n preludes.push(prelude);\n\n // Nest rule in our stack of preludes (e.g. media queries/selectors).\n let content = ' ';\n preludes.forEach((p, i) => {\n content += `${p} {\\n${' '.repeat((i + 2) * 2)}`;\n });\n content += `${kebab(this.property)}: ${this.value};\\n`;\n preludes.map((_, i) => {\n content += `${' '.repeat((preludes.length - i) * 2)}}\\n`;\n });\n\n // Group rule into the appropriate layer.\n let rules = rulesByLayer.get(layer);\n if (!rules) {\n rules = [];\n rulesByLayer.set(layer, rules);\n }\n rules.push(content);\n preludes.pop();\n }\n\n toJS(allowedOverridesSet: Set<string>, indent = ''): string {\n let res = '';\n if (allowedOverridesSet.has(this.property)) {\n res += `${indent}if (!${this.property.replace('--', '__')}) `;\n }\n res += `${indent}rules += ' ${this.className}';`;\n return res;\n }\n}\n\n/** Base class for rules that contain other rules. */\nclass GroupRule implements Rule {\n rules: Rule[];\n layer: string | null;\n\n constructor(rules: Rule[], layer?: string | null) {\n this.rules = rules;\n this.layer = layer ?? null;\n }\n\n copy(): Rule {\n return new GroupRule(this.rules.map(rule => rule.copy()), this.layer);\n }\n\n addPseudo(prelude: string) {\n for (let rule of this.rules) {\n rule.addPseudo(prelude);\n }\n }\n\n getStaticClassName(): string {\n return this.rules.map(rule => rule.getStaticClassName()).join('');\n }\n\n toCSS(rulesByLayer: Map<string, string[]>, preludes?: string[], layer?: string) {\n for (let rule of this.rules) {\n rule.toCSS(rulesByLayer, preludes, this.layer || layer);\n }\n }\n\n toJS(allowedOverridesSet: Set<string>, indent = ''): string {\n let rules = this.rules.slice();\n let conditional = rules.filter(rule => rule instanceof ConditionalRule).reverse().map((rule, i) => {\n return `${i > 0 ? ' else ' : ''}${rule.toJS(allowedOverridesSet, indent)}`;\n });\n\n let elseCases = rules.filter(rule => !(rule instanceof ConditionalRule)).map(rule => rule.toJS(allowedOverridesSet, indent));\n if (conditional.length && elseCases.length) {\n return `${conditional.join('')} else {\\n${indent} ${elseCases.join('\\n' + indent + ' ')}\\n${indent}}`;\n }\n\n if (conditional.length) {\n return conditional.join('');\n }\n\n return elseCases.join('\\n' + indent);\n }\n}\n\n/** A rule that applies conditionally in CSS (e.g. @media). */\nclass AtRule extends GroupRule {\n prelude: string;\n\n constructor(rules: Rule[], prelude: string, layer: string | null) {\n super(rules, layer);\n this.prelude = prelude;\n }\n\n copy(): Rule {\n return new AtRule(this.rules.map(rule => rule.copy()), this.prelude, this.layer);\n }\n\n toCSS(rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer?: string): void {\n preludes.push(this.prelude);\n super.toCSS(rulesByLayer, preludes, layer);\n preludes?.pop();\n }\n}\n\n/** A rule that applies conditionally at runtime. */\nclass ConditionalRule extends GroupRule {\n condition: string;\n\n constructor(rules: Rule[], condition: string) {\n super(rules);\n this.condition = condition;\n }\n\n copy(): Rule {\n return new ConditionalRule(this.rules.map(rule => rule.copy()), this.condition);\n }\n\n getStaticClassName(): string {\n throw new Error('Conditional rules cannot be compiled to a static class name. This is a bug.');\n }\n\n toJS(allowedOverridesSet: Set<string>, indent = ''): string {\n return `${indent}if (props.${this.condition}) {\\n${super.toJS(allowedOverridesSet, indent + ' ')}\\n${indent}}`;\n }\n}\n\nexport function raw(this: MacroContext | void, css: string, layer = '_.a'): string {\n // Check if `this` is undefined, which means style was not called as a macro but as a normal function.\n // We also check if this is globalThis, which happens in non-strict mode bundles.\n // Also allow style to be called as a normal function in tests.\n // @ts-ignore\n // eslint-disable-next-line\n if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {\n throw new Error('The raw macro must be imported with {type: \"macro\"}.');\n }\n let className = generateArbitraryValueSelector(css, true);\n css = `@layer ${layer} {\n .${className} {\n ${css}\n }\n}`;\n\n // Ensure layer is always declared after the _ layer used by style macro.\n if (!layer.startsWith('_.')) {\n css = `@layer _, ${layer};\\n` + css;\n }\n\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n return className;\n}\n\nexport function keyframes(this: MacroContext | void, css: string): string {\n // Check if `this` is undefined, which means style was not called as a macro but as a normal function.\n // We also check if this is globalThis, which happens in non-strict mode bundles.\n // Also allow style to be called as a normal function in tests.\n // @ts-ignore\n // eslint-disable-next-line\n if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {\n throw new Error('The keyframes macro must be imported with {type: \"macro\"}.');\n }\n let name = generateArbitraryValueSelector(css, true);\n css = `@keyframes ${name} {\n ${css}\n}`;\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n return name;\n}\n"],"names":[],"version":3,"file":"style-macro.mjs.map","sourceRoot":"../../../../../"}
|
|
1
|
+
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAMD,gDAAgD;AAChD,MAAM,6BAAO,KAAK,KAAK,CAAC,CAAA,GAAA,SAAC,EAAE,YAAY,CAAC,0CAAY,oBAAoB;AACxE,MAAM,gCAAU,2BAAK,OAAO,CAAC,QAAQ,CAAC,aAAa,2BAAK,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,GAAG,2BAAK,OAAO,CAAC,OAAO,CAAC,SAAS;AAEnH,MAAM;IAIX,YAAY,QAAgB,EAAE,KAA8B,CAAE;QAC5D,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,KAAK,GAAG,SAAU,CAAA,CAAC,QAAU,OAAO,MAAK;IAChD;IAEA,IAAI,gBAA0B;QAC5B,OAAO;YAAC,IAAI,CAAC,QAAQ;SAAC;IACxB;IAEA,WAAW,KAAQ,EAAkC;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB;IAEA,gBAAgB,cAA6B,EAAE,KAAqC,EAA4C;QAC9H,OAAO,0CAAoB,OAAO,CAAA,QAAS;gBAAC;oBAAC,CAAC,kBAAkB,IAAI,CAAC,QAAQ,CAAC,EAAE,OAAO;gBAAM;aAAE;IACjG;AACF;AAEO,MAAM,kDAA2C;IAGtD,YAAY,QAAgB,EAAE,OAAuC,CAAE;QACrE,KAAK,CAAC;QAC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,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,YACnC,IAAI,CAAC,QAAQ,CAAC;QACZ,MAAM;QACN,SAAS;IACX;IAEF,OAAO;AACT;AAEO,SAAS,0CAAqC,GAAW;IAC9D,sGAAsG;IACtG,iFAAiF;IACjF,+DAA+D;IAC/D,aAAa;IAEb,IAAI,AAAC,CAAA,IAAI,IAAI,QAAQ,IAAI,KAAK,UAAS,KAAM,QAAQ,GAAG,CAAC,QAAQ,KAAK,QACpE,MAAM,IAAI,MAAM;IAElB,IAAI,OAAO,qDAA+B,KAAK;IAC/C,MAAM,CAAC,WAAW,EAAE,KAAK;EACzB,EAAE,IAAI;CACP,CAAC;IACA,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,YACnC,IAAI,CAAC,QAAQ,CAAC;QACZ,MAAM;QACN,SAAS;IACX;IAEF,OAAO;AACT","sources":["packages/@react-spectrum/s2/style/style-macro.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type {Condition, CSSProperties, CSSValue, CustomValue, Property, PropertyValueDefinition, PropertyValueMap, RenderProps, ShorthandProperty, StyleFunction, StyleValue, Theme, ThemeProperties, Value} from './types';\nimport fs from 'fs';\nimport * as propertyInfo from './properties.json';\n\n// Postfix all class names with version for now.\nconst json = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8'));\nconst POSTFIX = json.version.includes('nightly') ? json.version.match(/-nightly-(.*)/)[1] : json.version.replace(/[0.]/g, '');\n\nexport class ArbitraryProperty<T extends Value> implements Property<T> {\n property: string;\n toCSS: (value: T) => CSSValue;\n\n constructor(property: string, toCSS?: (value: T) => CSSValue) {\n this.property = property;\n this.toCSS = toCSS || ((value) => String(value));\n }\n\n get cssProperties(): string[] {\n return [this.property];\n }\n\n toCSSValue(value: T): PropertyValueDefinition<Value> {\n return this.toCSS(value);\n }\n\n toCSSProperties(customProperty: string | null, value: PropertyValueDefinition<Value>): PropertyValueDefinition<[CSSProperties]> {\n return mapConditionalValue(value, value => [{[customProperty || this.property]: String(value)}]);\n }\n}\n\nexport class MappedProperty<T extends CSSValue> extends ArbitraryProperty<T> implements Property<T> {\n mapping: PropertyValueMap<T> | string[];\n\n constructor(property: string, mapping: PropertyValueMap<T> | string[]) {\n super(property);\n this.mapping = mapping;\n }\n\n toCSSValue(value: T): PropertyValueDefinition<Value> {\n if (Array.isArray(this.mapping)) {\n if (!this.mapping.includes(String(value))) {\n throw new Error('Invalid style value: ' + value);\n }\n return value;\n } else {\n let res = this.mapping[String(value)];\n if (res == null) {\n throw new Error('Invalid style value: ' + value);\n }\n return res;\n }\n }\n}\n\nexport type Color<C extends string> = C | `${string}/${number}`;\nexport class ColorProperty<C extends string> extends MappedProperty<C> implements Property<Color<C>> {\n toCSSValue(value: Color<C>): PropertyValueDefinition<Value> {\n let [color, opacity] = value.split('/');\n return mapConditionalValue(this.mapping[color], value => {\n return opacity ? `rgb(from ${value} r g b / ${opacity}%)` : value;\n });\n }\n}\n\nexport type LengthPercentageUnit = '%' | 'vw' | 'svw' | 'dvw' | 'vh' | 'svh' | 'dvh' | 'vmin' | 'svmin' | 'dvmin' | 'vmax' | 'svmax' | 'dvmax' | 'cqw' | 'cqh' | 'cqmin' | 'cqmax';\nexport type LengthPercentage = `${number}${LengthPercentageUnit}`;\n\nexport class PercentageProperty<T extends CSSValue> extends MappedProperty<T> implements Property<T | LengthPercentage> {\n constructor(property: string, mapping: PropertyValueMap<T> | string[]) {\n super(property, mapping);\n }\n\n toCSSValue(value: T | LengthPercentage): PropertyValueDefinition<Value> {\n if (typeof value === 'string' && /^-?\\d+(?:\\.\\d+)?(%|vw|svw|dvw|vh|svh|dvh|vmin|svmin|dvmin|vmax|svmax|dvmax|cqw|cqh|cqmin|cqmax)$/.test(value)) {\n return value;\n }\n\n return super.toCSSValue(value as T);\n }\n}\n\nexport class SizingProperty<T extends CSSValue> extends PercentageProperty<T> implements Property<T | number | LengthPercentage> {\n numberToCSS: (value: number) => string;\n\n constructor(property: string, mapping: PropertyValueMap<T> | string[], numberToCSS: (value: number) => string) {\n super(property, mapping);\n this.numberToCSS = numberToCSS;\n }\n\n toCSSValue(value: T | LengthPercentage | number): PropertyValueDefinition<Value> {\n if (typeof value === 'number') {\n return value === 0 ? '0px' : this.numberToCSS(value);\n }\n\n return super.toCSSValue(value);\n }\n}\n\nexport class ExpandedProperty<T extends Value> implements Property<T> {\n cssProperties: string[];\n mapping: Property<T> | null;\n expand: (v: T | CSSValue) => CSSProperties;\n\n constructor(properties: string[], expand: (v: T | CSSValue) => CSSProperties, mapping?: Property<T> | PropertyValueMap<CSSValue>) {\n this.cssProperties = properties;\n this.expand = expand;\n if (mapping instanceof MappedProperty) {\n this.mapping = mapping;\n } else if (mapping) {\n this.mapping = new MappedProperty<any>(properties[0], mapping as any);\n } else {\n this.mapping = null;\n }\n }\n\n toCSSValue(value: T): PropertyValueDefinition<Value> {\n if (!this.mapping) {\n return value;\n }\n\n return this.mapping.toCSSValue(value);\n }\n\n toCSSProperties(customProperty: string | null, value: PropertyValueDefinition<T>): PropertyValueDefinition<[CSSProperties]> {\n if (customProperty) {\n throw new Error('Style properties that expand into multiple CSS properties cannot be set as CSS variables.');\n }\n return mapConditionalValue(value, value => [this.expand(value)]);\n }\n}\n\nfunction mapConditionalValue<T, U>(value: PropertyValueDefinition<T>, fn: (value: T) => U): PropertyValueDefinition<U> {\n if (typeof value === 'object' && !Array.isArray(value)) {\n let res: PropertyValueDefinition<U> = {};\n for (let condition in value) {\n res[condition] = mapConditionalValue((value as any)[condition], fn);\n }\n return res;\n } else {\n return fn(value);\n }\n}\n\nfunction mapConditionalShorthand<T, C extends string, R extends RenderProps<string>>(value: PropertyValueDefinition<T>, fn: ShorthandProperty<T>): {[property: string]: StyleValue<Value, C, R>} {\n if (typeof value === 'object') {\n let res = {};\n for (let condition in value) {\n let properties = mapConditionalShorthand(value[condition], fn);\n for (let property in properties) {\n res[property] ??= {};\n res[property][condition] = properties[property];\n }\n }\n return res;\n } else {\n return fn(value);\n }\n}\n\nexport function parseArbitraryValue(value: Value): string | undefined {\n if (typeof value === 'string' && value.startsWith('--')) {\n return `var(${value})`;\n } else if (typeof value === 'string' && value[0] === '[' && value[value.length - 1] === ']') {\n return value.slice(1, -1);\n } else if (\n typeof value === 'string' && (\n /^(var|calc|min|max|clamp|round|mod|rem|sin|cos|tan|asin|acos|atan|atan2|pow|sqrt|hypot|log|exp|abs|sign)\\(.+\\)$/.test(value) ||\n /^(inherit|initial|unset)$/.test(value)\n )\n ) {\n return value;\n }\n}\n\nfunction shortCSSPropertyName(property: string) {\n return propertyInfo.properties[property] ?? generateArbitraryValueSelector(property, true);\n}\n\nfunction classNamePrefix(property: string, cssProperty: string) {\n let className = propertyInfo.properties[cssProperty];\n if (className && property === '--' + className) {\n return '-' + className + '_-';\n }\n\n if (className && !property.startsWith('--')) {\n return className;\n }\n\n return '-' + generateArbitraryValueSelector(property, true) + '-';\n}\n\ninterface MacroContext {\n addAsset(asset: {type: string, content: string}): void\n}\n\nlet isCompilingDependencies: boolean | null | string = false;\n\nexport function createTheme<T extends Theme>(theme: T): StyleFunction<ThemeProperties<T>, 'default' | Extract<keyof T['conditions'], string>> {\n let properties = new Map<string, Property<any>>(Object.entries(theme.properties).map(([k, v]) => {\n if (!Array.isArray(v) && v.cssProperties) {\n return [k, v as Property<any>];\n }\n\n return [k, new MappedProperty(k, v as any)];\n }));\n\n let dependencies = new Set<string>();\n let hasConditions = false;\n return function style(this: MacroContext | void, style, allowedOverrides?: readonly string[]) {\n // Check if `this` is undefined, which means style was not called as a macro but as a normal function.\n // We also check if this is globalThis, which happens in non-strict mode bundles.\n // Also allow style to be called as a normal function in tests.\n // @ts-ignore\n \n if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {\n throw new Error('The style macro must be imported with {type: \"macro\"}.');\n }\n\n // Generate rules for each property.\n let rules = new Map<string, Rule>();\n let values = new Map();\n dependencies.clear();\n let usedPriorities = 0;\n let setRules = (key: string, value: [number, Rule[]]) => {\n usedPriorities = Math.max(usedPriorities, value[0]);\n rules.set(key, new GroupRule(value[1]));\n };\n\n hasConditions = false;\n for (let key in style) {\n let value = style[key]!;\n let themeProperty = key;\n values.set(key, value);\n\n // Get the type of custom properties in the theme.\n if (key.startsWith('--')) {\n themeProperty = value.type;\n value = value.value;\n }\n\n // Expand shorthands to longhands so that merging works as expected.\n if (theme.shorthands[key]) {\n let shorthand = theme.shorthands[key];\n if (typeof shorthand === 'function') {\n let expanded = mapConditionalShorthand(value, shorthand);\n for (let k in expanded) {\n let v = expanded[k];\n values.set(k, v);\n setRules(k, compileValue(k, k, v));\n }\n } else {\n for (let prop of shorthand) {\n values.set(prop, value);\n setRules(prop, compileValue(prop, prop, value));\n }\n }\n } else if (themeProperty in theme.properties) {\n setRules(key, compileValue(key, themeProperty, value));\n }\n }\n\n // For properties referenced by self(), rewrite the declarations to assign\n // to an intermediary custom property so we can access the value.\n for (let dep of dependencies) {\n let value = values.get(dep);\n if (value != null) {\n if (!(dep in theme.properties)) {\n throw new Error(`Unknown dependency ${dep}`);\n }\n let prop = properties.get(dep)!;\n let name = `--${shortCSSPropertyName(prop.cssProperties[0])}`;\n // Could potentially use @property to prevent the var from inheriting in children.\n isCompilingDependencies = dep;\n setRules(name, compileValue(name, dep, value));\n isCompilingDependencies = null;\n setRules(dep, compileValue(dep, dep, name));\n isCompilingDependencies = false;\n }\n }\n dependencies.clear();\n\n let css = '';\n\n // Declare layers for each priority ahead of time so the order is always correct.\n css += '@layer ';\n let first = true;\n for (let i = 0; i <= usedPriorities; i++) {\n if (first) {\n first = false;\n } else {\n css += ', ';\n }\n css += layerName(generateName(i, true));\n }\n css += ';\\n\\n';\n\n // If allowed overrides are provided, generate code to match the input override string and include only allowed classes.\n // Also generate a variable for each overridable property that overlaps with the style definition. If those are defined,\n // the defaults from the style definition are omitted.\n let allowedOverridesSet = new Set<string>();\n let js = process.env.NODE_ENV !== 'production'\n ? 'let rules = \" \", currentRules = {};\\n'\n : 'let rules = \" \";\\n';\n if (allowedOverrides?.length) {\n for (let property of allowedOverrides) {\n let shorthand = theme.shorthands[property];\n let props = Array.isArray(shorthand) ? shorthand : [property];\n for (let property of props) {\n if (property.startsWith('--')) {\n allowedOverridesSet.add(property);\n continue;\n }\n\n let prop = properties.get(property);\n if (!prop) {\n throw new Error(`Invalid property ${property} in allowedOverrides`);\n }\n for (let property of prop.cssProperties) {\n allowedOverridesSet.add(property);\n }\n }\n }\n\n let loop = '';\n for (let property of rules.keys()) {\n let prop = properties.get(property);\n if (prop) {\n for (let property of prop.cssProperties) {\n if (property && allowedOverridesSet.has(property)) {\n let selector = classNamePrefix(property, property);\n let p = property.replace('--', '__');\n js += `let ${p} = false;\\n`;\n loop += ` if (p[1] === ${JSON.stringify(selector)}) ${p} = true;\\n`;\n }\n }\n } else if (property.startsWith('--') && allowedOverridesSet.has(property)) {\n let selector = classNamePrefix(property, property);\n let p = property.replace('--', '__');\n js += `let ${p} = false;\\n`;\n loop += ` if (p[1] === ${JSON.stringify(selector)}) ${p} = true;\\n`;\n }\n }\n\n let macroPart = process.env.NODE_ENV !== 'production' ? '|-macro\\\\$' : '';\n let regex = `/(?:^|\\\\s)(${[...allowedOverridesSet].map(p => classNamePrefix(p, p)).join('|')}${macroPart})[^\\\\s]+/g`;\n if (loop) {\n js += `let matches = String(overrides || '').matchAll(${regex});\\n`;\n js += 'for (let p of matches) {\\n';\n js += loop;\n js += ' rules += p[0];\\n';\n js += '}\\n';\n } else {\n js += `rules += (String(overrides || '').match(${regex}) || []).join('')\\n`;\n }\n }\n\n // Generate JS and CSS for each rule.\n let isStatic = !(hasConditions || allowedOverrides);\n let className = '';\n let rulesByLayer = new Map<string, string[]>();\n let rootRule = new GroupRule([...rules.values()]);\n if (isStatic) {\n className += rootRule.getStaticClassName();\n } else {\n js += rootRule.toJS(allowedOverridesSet) + '\\n';\n }\n rootRule.toCSS(rulesByLayer);\n\n for (let [layer, rules] of rulesByLayer) {\n css += `@layer ${layerName(layer)} {\\n`;\n css += rules.join('\\n\\n');\n css += '}\\n\\n';\n }\n // @ts-expect-error\n let loc = this?.loc?.filePath + ':' + this?.loc?.line + ':' + this?.loc?.col;\n if (isStatic && process.env.NODE_ENV !== 'production') {\n let id = toBase62(hash(className + loc));\n css += `.-macro-static-${id} {\n --macro-data-${id}: ${JSON.stringify({style, loc})};\n }\\n\\n`;\n className += ` -macro-static-${id}`;\n }\n\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n\n if (isStatic) {\n return className;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n js += `let targetRules = rules + ${JSON.stringify(loc)};\\n`;\n js += 'let hash = 5381;for (let i = 0; i < targetRules.length; i++) { hash = ((hash << 5) + hash) + targetRules.charCodeAt(i) >>> 0; }\\n';\n js += 'rules += \" -macro-dynamic-\" + hash.toString(36);\\n';\n js += `typeof window !== 'undefined' && window?.postMessage?.({action: 'stylemacro-update-macros', hash: hash.toString(36), loc: ${JSON.stringify(loc)}, style: currentRules}, \"*\");\\n`;\n }\n js += 'return rules;';\n if (allowedOverrides) {\n return new Function('props', 'overrides', js) as any;\n }\n return new Function('props', js) as any;\n };\n\n function compileValue(property: string, themeProperty: string, value: StyleValue<Value, Condition<T>, any>) {\n return conditionalToRules(value as any, 0, new Set(), new Set(), (value, priority, conditions, skipConditions) => {\n return compileRule(property, themeProperty, value, priority, conditions, skipConditions);\n });\n }\n\n function conditionalToRules<P extends CustomValue | any[]>(\n value: PropertyValueDefinition<P>,\n parentPriority: number,\n currentConditions: Set<string>,\n skipConditions: Set<string>,\n fn: (value: P, priority: number, conditions: Set<string>, skipConditions: Set<string>) => [number, Rule[]]\n ): [number, Rule[]] {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n let rules: Rule[] = [];\n\n // Later conditions in parent rules override conditions in child rules.\n let subSkipConditions = new Set([...skipConditions, ...Object.keys(value)]);\n\n // Skip the default condition if we're already filtering by one of the other possible conditions.\n // For example, if someone specifies `dark: 'gray-400'`, only include the dark version of `gray-400` from the theme.\n let skipDefault = Object.keys(value).some(k => currentConditions.has(k));\n let wasCSSCondition = false;\n let priority = parentPriority;\n\n for (let condition in value) {\n if (skipConditions.has(condition) || (condition === 'default' && skipDefault)) {\n continue;\n }\n subSkipConditions.delete(condition);\n\n let val = value[condition];\n\n // If a theme condition comes after runtime conditions, create a new grouping.\n // This makes the CSS class unconditional so it appears outside the `else` block in the JS.\n // The @layer order in the generated CSS will ensure that it overrides classes applied by runtime conditions.\n let isCSSCondition = condition in theme.conditions || /^[@:]/.test(condition);\n if (!wasCSSCondition && isCSSCondition && rules.length) {\n rules = [new GroupRule(rules)];\n }\n wasCSSCondition = isCSSCondition;\n\n // Increment the current priority whenever we see a new CSS condition.\n if (isCSSCondition) {\n priority++;\n }\n\n // If this is a runtime condition, inherit the priority from the parent rule.\n // Otherwise, use the current maximum of the parent and current priorities.\n let rulePriority = isCSSCondition ? priority : parentPriority;\n\n if (condition === 'default' || isCSSCondition || /^is[A-Z]/.test(condition) || /^allows[A-Z]/.test(condition)) {\n let subConditions = currentConditions;\n if (isCSSCondition) {\n subConditions = new Set([...currentConditions, condition]);\n }\n let [subPriority, subRules] = conditionalToRules(val, rulePriority, subConditions, subSkipConditions, fn);\n rules.push(...compileCondition(currentConditions, condition, priority, subRules));\n priority = Math.max(priority, subPriority);\n } else if (val && typeof val === 'object' && !Array.isArray(val)) {\n for (let key in val) {\n let [subPriority, subRules] = conditionalToRules(val[key], rulePriority, currentConditions, subSkipConditions, fn);\n rules.push(...compileCondition(currentConditions, `${condition} === ${JSON.stringify(key)}`, priority, subRules));\n priority = Math.max(priority, subPriority);\n }\n }\n }\n return [priority, rules];\n } else {\n // @ts-ignore - broken in non-strict?\n return fn(value, parentPriority, currentConditions, skipConditions);\n }\n }\n\n function compileCondition(conditions: Set<string>, condition: string, priority: number, rules: Rule[]): Rule[] {\n if (condition === 'default' || conditions.has(condition)) {\n return [new GroupRule(rules)];\n }\n\n if (condition in theme.conditions || /^[@:]/.test(condition)) {\n // Conditions starting with : are CSS pseudo classes. Nest them inside the parent rule.\n let prelude = theme.conditions[condition] || condition;\n let preludes = Array.isArray(prelude) ? prelude : [prelude];\n return preludes.map(prelude => {\n if (prelude.startsWith(':')) {\n let rulesWithPseudo = rules.map(rule => {\n rule = rule.copy();\n rule.addPseudo(prelude);\n return rule;\n });\n\n return new GroupRule(rulesWithPseudo, generateName(priority, true));\n }\n\n // Otherwise, wrap the rule in the condition (e.g. @media).\n // Top level layer is based on the priority of the rule, not the condition.\n // Also group in a sub-layer based on the condition so that lightningcss can more effectively deduplicate rules.\n let layer = `${generateName(priority, true)}.${propertyInfo.conditions[prelude] || generateArbitraryValueSelector(condition, true)}`;\n return new AtRule(rules, prelude, layer, condition);\n });\n }\n\n hasConditions = true;\n return [new ConditionalRule(rules, condition)];\n }\n\n function compileRule(property: string, themeProperty: string, value: Value, priority: number, conditions: Set<string>, skipConditions: Set<string>): [number, Rule[]] {\n let propertyFunction = properties.get(themeProperty);\n if (propertyFunction) {\n // Expand value to conditional CSS values, and then to rules.\n let propertyValue = value;\n let arbitrary = parseArbitraryValue(value);\n let cssValue = arbitrary ? arbitrary : propertyFunction.toCSSValue(value);\n let cssProperties = propertyFunction.toCSSProperties(property.startsWith('--') ? property : null, cssValue);\n\n return conditionalToRules(cssProperties, priority, conditions, skipConditions, (value, priority, conditions) => {\n let [obj] = value;\n let rules: Rule[] = [];\n for (let key in obj) {\n let k = key as any;\n let value = obj[k];\n if (value === undefined) {\n continue;\n }\n if (typeof value === 'string') {\n // Replace self() references with variables and track the dependencies.\n value = value.replace(/self\\(([a-zA-Z]+)/g, (_, v) => {\n let prop = properties.get(v);\n if (!prop) {\n throw new Error(`self(${v}) is invalid. ${v} is not a known property.`);\n }\n let cssProperties = prop.cssProperties;\n if (cssProperties.length !== 1) {\n throw new Error(`self(${v}) is not supported. ${v} expands to multiple CSS properties.`);\n }\n dependencies.add(v);\n return `var(--${shortCSSPropertyName(cssProperties[0])}`;\n });\n }\n\n // Generate selector. This consists of three parts: property, conditions, value.\n let cssProperty = key;\n if (property.startsWith('--')) {\n cssProperty = propertyFunction.cssProperties[0];\n }\n\n let className = classNamePrefix(key, cssProperty);\n if (conditions.size > 0) {\n for (let condition of conditions) {\n let prelude = theme.conditions[condition] || condition;\n let preludes = Array.isArray(prelude) ? prelude : [prelude];\n for (let prelude of preludes) {\n className += propertyInfo.conditions[prelude] || generateArbitraryValueSelector(condition);\n }\n }\n }\n\n if (cssProperty !== key) {\n className += shortCSSPropertyName(cssProperty);\n }\n\n className += propertyInfo.values[cssProperty]?.[String(value)] ?? generateArbitraryValueSelector(String(value));\n className += POSTFIX;\n rules.push(new StyleRule(className, key, String(value), isCompilingDependencies ? themeProperty : property, propertyValue));\n }\n\n return [0, rules];\n });\n } else {\n throw new Error('Unknown property ' + themeProperty);\n }\n }\n}\n\nfunction kebab(property: string) {\n if (property.startsWith('--')) {\n return property;\n }\n return property.replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`);\n}\n\n// Generate a class name from a number, e.g. index within the theme.\n// This maps to an alphabet containing lower case letters, upper case letters, and numbers.\n// For numbers larger than 62, an underscore is prepended.\n// This encoding allows easy parsing to enable runtime merging by property.\nfunction generateName(index: number, atStart = false): string {\n if (index < 26) {\n // lower case letters\n return String.fromCharCode(index + 97);\n }\n\n if (index < 52) {\n // upper case letters\n return String.fromCharCode((index - 26) + 65);\n }\n\n if (index < 62 && !atStart) {\n // numbers\n return String.fromCharCode((index - 52) + 48);\n }\n\n return '_' + generateName(index - (atStart ? 52 : 62));\n}\n\n// For arbitrary values, we use a hash of the string to generate the class name.\nfunction generateArbitraryValueSelector(v: string, atStart = false) {\n let c = toBase62(hash(v));\n if (atStart && /^[0-9]/.test(c)) {\n c = `_${c}`;\n }\n return c;\n}\n\nfunction toBase62(value: number) {\n if (value === 0) {\n return generateName(value);\n }\n\n let res = '';\n while (value) {\n let remainder = value % 62;\n res += generateName(remainder);\n value = Math.floor((value - remainder) / 62);\n }\n\n return res;\n}\n\n// djb2 hash function.\n// http://www.cse.yorku.ca/~oz/hash.html\nfunction hash(v: string) {\n let hash = 5381;\n for (let i = 0; i < v.length; i++) {\n hash = ((hash << 5) + hash) + v.charCodeAt(i) >>> 0;\n }\n return hash;\n}\n\nfunction layerName(name: string) {\n // All of our layers should be sub-layers of a single parent layer, so that\n // the unsafe overrides layer always comes after.\n return `_.${name}`;\n}\n\ninterface Rule {\n addPseudo(prelude: string): void,\n getStaticClassName(): string,\n toCSS(rulesByLayer: Map<string, string[]>, preludes?: string[], layer?: string): void,\n toJS(allowedOverridesSet: Set<string>, indent?: string): string,\n copy(): Rule\n}\n\nlet conditionStack: string[] = [];\n\n/** A CSS style rule. */\nclass StyleRule implements Rule {\n className: string;\n pseudos: string;\n property: string;\n value: string;\n themeProperty: string | undefined;\n themeValue: Value | undefined;\n\n constructor(className: string, property: string, value: string, themeProperty: string | undefined, themeValue: Value | undefined) {\n this.className = className;\n this.pseudos = '';\n this.property = property;\n this.value = value;\n if (process.env.NODE_ENV !== 'production' && isCompilingDependencies !== null) {\n this.themeProperty = themeProperty;\n this.themeValue = themeValue;\n }\n }\n\n copy(): Rule {\n let rule = new StyleRule(this.className, this.property, this.value, this.themeProperty, this.themeValue);\n rule.pseudos = this.pseudos;\n return rule;\n }\n\n addPseudo(prelude: string) {\n this.pseudos += prelude;\n }\n\n getStaticClassName(): string {\n return ' ' + this.className;\n }\n\n toCSS(rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer = 'a') {\n let prelude = `.${this.className}${this.pseudos}`;\n preludes.push(prelude);\n\n // Nest rule in our stack of preludes (e.g. media queries/selectors).\n let content = ' ';\n preludes.forEach((p, i) => {\n content += `${p} {\\n${' '.repeat((i + 2) * 2)}`;\n });\n content += `${kebab(this.property)}: ${this.value};\\n`;\n preludes.map((_, i) => {\n content += `${' '.repeat((preludes.length - i) * 2)}}\\n`;\n });\n\n // Group rule into the appropriate layer.\n let rules = rulesByLayer.get(layer);\n if (!rules) {\n rules = [];\n rulesByLayer.set(layer, rules);\n }\n rules.push(content);\n preludes.pop();\n }\n\n toJS(allowedOverridesSet: Set<string>, indent = ''): string {\n let res = '';\n if (allowedOverridesSet.has(this.property)) {\n res += `${indent}if (!${this.property.replace('--', '__')}) `;\n }\n res += `${indent}rules += ' ${this.className}';`;\n if (process.env.NODE_ENV !== 'production' && this.themeProperty) {\n let name = this.themeProperty;\n if (this.pseudos) {\n conditionStack.push(this.pseudos);\n }\n let propertyName = JSON.stringify(name);\n let valueJson = JSON.stringify(this.themeValue);\n if (conditionStack.length) {\n // name += ` (${conditionStack.join(', ')})`;\n let conditionKey = JSON.stringify(conditionStack.join(' && '));\n // Ensure currentRules[name] is an object, converting from simple value if needed\n res += ` currentRules[${propertyName}] = typeof currentRules[${propertyName}] === 'object' ? currentRules[${propertyName}] : {\"default\": currentRules[${propertyName}]};`;\n // Set the value for this specific condition\n res += ` currentRules[${propertyName}][${conditionKey}] = ${valueJson};`;\n } else {\n res += ` currentRules[${propertyName}] = ${valueJson};`;\n }\n if (this.pseudos) {\n conditionStack.pop();\n }\n }\n return res;\n }\n}\n\n/** Base class for rules that contain other rules. */\nclass GroupRule implements Rule {\n rules: Rule[];\n layer: string | null;\n\n constructor(rules: Rule[], layer?: string | null) {\n this.rules = rules;\n this.layer = layer ?? null;\n }\n\n copy(): Rule {\n return new GroupRule(this.rules.map(rule => rule.copy()), this.layer);\n }\n\n addPseudo(prelude: string) {\n for (let rule of this.rules) {\n rule.addPseudo(prelude);\n }\n }\n\n getStaticClassName(): string {\n return this.rules.map(rule => rule.getStaticClassName()).join('');\n }\n\n toCSS(rulesByLayer: Map<string, string[]>, preludes?: string[], layer?: string) {\n for (let rule of this.rules) {\n rule.toCSS(rulesByLayer, preludes, this.layer || layer);\n }\n }\n\n toJS(allowedOverridesSet: Set<string>, indent = ''): string {\n let rules = this.rules.slice();\n let conditional = rules.filter(rule => rule instanceof ConditionalRule).reverse().map((rule, i) => {\n return `${i > 0 ? ' else ' : ''}${rule.toJS(allowedOverridesSet, indent)}`;\n });\n\n let elseCases = rules.filter(rule => !(rule instanceof ConditionalRule)).map(rule => rule.toJS(allowedOverridesSet, indent));\n if (conditional.length && elseCases.length) {\n return `${conditional.join('')} else {\\n${indent} ${elseCases.join('\\n' + indent + ' ')}\\n${indent}}`;\n }\n\n if (conditional.length) {\n return conditional.join('');\n }\n\n return elseCases.join('\\n' + indent);\n }\n}\n\n/** A rule that applies conditionally in CSS (e.g. @media). */\nclass AtRule extends GroupRule {\n prelude: string;\n themeCondition: string | null;\n\n constructor(rules: Rule[], prelude: string, layer: string | null, themeCondition: string | null) {\n super(rules, layer);\n this.prelude = prelude;\n this.themeCondition = themeCondition;\n }\n\n copy(): Rule {\n return new AtRule(this.rules.map(rule => rule.copy()), this.prelude, this.layer, this.themeCondition);\n }\n\n toCSS(rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer?: string): void {\n preludes.push(this.prelude);\n super.toCSS(rulesByLayer, preludes, layer);\n preludes?.pop();\n }\n\n toJS(allowedOverridesSet: Set<string>, indent?: string): string {\n conditionStack.push(this.themeCondition || this.prelude);\n let res = super.toJS(allowedOverridesSet, indent);\n conditionStack.pop();\n return res;\n }\n}\n\n/** A rule that applies conditionally at runtime. */\nclass ConditionalRule extends GroupRule {\n condition: string;\n\n constructor(rules: Rule[], condition: string) {\n super(rules);\n this.condition = condition;\n }\n\n copy(): Rule {\n return new ConditionalRule(this.rules.map(rule => rule.copy()), this.condition);\n }\n\n getStaticClassName(): string {\n throw new Error('Conditional rules cannot be compiled to a static class name. This is a bug.');\n }\n\n toJS(allowedOverridesSet: Set<string>, indent = ''): string {\n conditionStack.push(this.condition);\n let res = `${indent}if (props.${this.condition}) {\\n${super.toJS(allowedOverridesSet, indent + ' ')}\\n${indent}}`;\n conditionStack.pop();\n return res;\n }\n}\n\nexport function raw(this: MacroContext | void, css: string, layer = '_.a'): string {\n // Check if `this` is undefined, which means style was not called as a macro but as a normal function.\n // We also check if this is globalThis, which happens in non-strict mode bundles.\n // Also allow style to be called as a normal function in tests.\n // @ts-ignore\n \n if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {\n throw new Error('The raw macro must be imported with {type: \"macro\"}.');\n }\n let className = generateArbitraryValueSelector(css, true);\n css = `@layer ${layer} {\n .${className} {\n ${css}\n }\n}`;\n\n // Ensure layer is always declared after the _ layer used by style macro.\n if (!layer.startsWith('_.')) {\n css = `@layer _, ${layer};\\n` + css;\n }\n\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n return className;\n}\n\nexport function keyframes(this: MacroContext | void, css: string): string {\n // Check if `this` is undefined, which means style was not called as a macro but as a normal function.\n // We also check if this is globalThis, which happens in non-strict mode bundles.\n // Also allow style to be called as a normal function in tests.\n // @ts-ignore\n \n if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {\n throw new Error('The keyframes macro must be imported with {type: \"macro\"}.');\n }\n let name = generateArbitraryValueSelector(css, true);\n css = `@keyframes ${name} {\n ${css}\n}`;\n if (this && typeof this.addAsset === 'function') {\n this.addAsset({\n type: 'css',\n content: css\n });\n }\n return name;\n}\n"],"names":[],"version":3,"file":"style-macro.mjs.map","sourceRoot":"../../../../../"}
|
package/style/runtime.ts
CHANGED
|
@@ -39,20 +39,31 @@ import {StyleString} from './types';
|
|
|
39
39
|
export function mergeStyles(...styles: (StyleString | null | undefined)[]): StyleString {
|
|
40
40
|
let definedStyles = styles.filter(Boolean) as StyleString[];
|
|
41
41
|
if (definedStyles.length === 1) {
|
|
42
|
-
|
|
42
|
+
let first = definedStyles[0];
|
|
43
|
+
if (typeof first !== 'string') {
|
|
44
|
+
// static macro has a toString method so that we generate the style macro map for the entry
|
|
45
|
+
// it's automatically called in other places, but for our merging, we have to call it ourselves
|
|
46
|
+
return (first as StyleString).toString() as StyleString;
|
|
47
|
+
}
|
|
48
|
+
return first;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
let map = new Map();
|
|
51
|
+
let map = new Map<string, string>();
|
|
52
|
+
|
|
46
53
|
for (let style of definedStyles) {
|
|
47
|
-
|
|
54
|
+
// must call toString here for the static macro
|
|
55
|
+
let str = style.toString();
|
|
56
|
+
|
|
57
|
+
for (let [k, v] of parse(str)) {
|
|
48
58
|
map.set(k, v);
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
|
-
|
|
61
|
+
|
|
52
62
|
let res = '';
|
|
53
63
|
for (let value of map.values()) {
|
|
54
64
|
res += value;
|
|
55
65
|
}
|
|
66
|
+
|
|
56
67
|
return res as StyleString;
|
|
57
68
|
}
|
|
58
69
|
|
|
@@ -74,7 +85,12 @@ function parse(s: string) {
|
|
|
74
85
|
}
|
|
75
86
|
|
|
76
87
|
let property = s.slice(start, condition);
|
|
77
|
-
|
|
88
|
+
if (process.env.NODE_ENV !== 'production' && property.startsWith('-macro-')) {
|
|
89
|
+
let value = s.slice(start, i);
|
|
90
|
+
properties.set(value, ' ' + value);
|
|
91
|
+
} else {
|
|
92
|
+
properties.set(property, (properties.get(property) || '') + ' ' + s.slice(start, i));
|
|
93
|
+
}
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
function readValue() {
|
package/style/style-macro.ts
CHANGED
|
@@ -176,7 +176,7 @@ export function parseArbitraryValue(value: Value): string | undefined {
|
|
|
176
176
|
return value.slice(1, -1);
|
|
177
177
|
} else if (
|
|
178
178
|
typeof value === 'string' && (
|
|
179
|
-
/^(var|calc|min|max|clamp|round|mod|rem|sin|cos|tan|asin|acos|atan|atan2|pow|sqrt|hypot|log|exp|abs|sign)\(.+\)$/.test(value) ||
|
|
179
|
+
/^(var|calc|min|max|clamp|round|mod|rem|sin|cos|tan|asin|acos|atan|atan2|pow|sqrt|hypot|log|exp|abs|sign)\(.+\)$/.test(value) ||
|
|
180
180
|
/^(inherit|initial|unset)$/.test(value)
|
|
181
181
|
)
|
|
182
182
|
) {
|
|
@@ -205,6 +205,8 @@ interface MacroContext {
|
|
|
205
205
|
addAsset(asset: {type: string, content: string}): void
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
let isCompilingDependencies: boolean | null | string = false;
|
|
209
|
+
|
|
208
210
|
export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemeProperties<T>, 'default' | Extract<keyof T['conditions'], string>> {
|
|
209
211
|
let properties = new Map<string, Property<any>>(Object.entries(theme.properties).map(([k, v]) => {
|
|
210
212
|
if (!Array.isArray(v) && v.cssProperties) {
|
|
@@ -221,7 +223,7 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
221
223
|
// We also check if this is globalThis, which happens in non-strict mode bundles.
|
|
222
224
|
// Also allow style to be called as a normal function in tests.
|
|
223
225
|
// @ts-ignore
|
|
224
|
-
|
|
226
|
+
|
|
225
227
|
if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {
|
|
226
228
|
throw new Error('The style macro must be imported with {type: "macro"}.');
|
|
227
229
|
}
|
|
@@ -280,8 +282,11 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
280
282
|
let prop = properties.get(dep)!;
|
|
281
283
|
let name = `--${shortCSSPropertyName(prop.cssProperties[0])}`;
|
|
282
284
|
// Could potentially use @property to prevent the var from inheriting in children.
|
|
285
|
+
isCompilingDependencies = dep;
|
|
283
286
|
setRules(name, compileValue(name, dep, value));
|
|
287
|
+
isCompilingDependencies = null;
|
|
284
288
|
setRules(dep, compileValue(dep, dep, name));
|
|
289
|
+
isCompilingDependencies = false;
|
|
285
290
|
}
|
|
286
291
|
}
|
|
287
292
|
dependencies.clear();
|
|
@@ -305,7 +310,9 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
305
310
|
// Also generate a variable for each overridable property that overlaps with the style definition. If those are defined,
|
|
306
311
|
// the defaults from the style definition are omitted.
|
|
307
312
|
let allowedOverridesSet = new Set<string>();
|
|
308
|
-
let js =
|
|
313
|
+
let js = process.env.NODE_ENV !== 'production'
|
|
314
|
+
? 'let rules = " ", currentRules = {};\n'
|
|
315
|
+
: 'let rules = " ";\n';
|
|
309
316
|
if (allowedOverrides?.length) {
|
|
310
317
|
for (let property of allowedOverrides) {
|
|
311
318
|
let shorthand = theme.shorthands[property];
|
|
@@ -315,7 +322,7 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
315
322
|
allowedOverridesSet.add(property);
|
|
316
323
|
continue;
|
|
317
324
|
}
|
|
318
|
-
|
|
325
|
+
|
|
319
326
|
let prop = properties.get(property);
|
|
320
327
|
if (!prop) {
|
|
321
328
|
throw new Error(`Invalid property ${property} in allowedOverrides`);
|
|
@@ -346,15 +353,16 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
346
353
|
}
|
|
347
354
|
}
|
|
348
355
|
|
|
349
|
-
let
|
|
356
|
+
let macroPart = process.env.NODE_ENV !== 'production' ? '|-macro\\$' : '';
|
|
357
|
+
let regex = `/(?:^|\\s)(${[...allowedOverridesSet].map(p => classNamePrefix(p, p)).join('|')}${macroPart})[^\\s]+/g`;
|
|
350
358
|
if (loop) {
|
|
351
|
-
js += `let matches = (overrides || '').matchAll(${regex});\n`;
|
|
359
|
+
js += `let matches = String(overrides || '').matchAll(${regex});\n`;
|
|
352
360
|
js += 'for (let p of matches) {\n';
|
|
353
361
|
js += loop;
|
|
354
362
|
js += ' rules += p[0];\n';
|
|
355
363
|
js += '}\n';
|
|
356
364
|
} else {
|
|
357
|
-
js += `rules += ((overrides || '').match(${regex}) || []).join('')\n`;
|
|
365
|
+
js += `rules += (String(overrides || '').match(${regex}) || []).join('')\n`;
|
|
358
366
|
}
|
|
359
367
|
}
|
|
360
368
|
|
|
@@ -375,6 +383,15 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
375
383
|
css += rules.join('\n\n');
|
|
376
384
|
css += '}\n\n';
|
|
377
385
|
}
|
|
386
|
+
// @ts-expect-error
|
|
387
|
+
let loc = this?.loc?.filePath + ':' + this?.loc?.line + ':' + this?.loc?.col;
|
|
388
|
+
if (isStatic && process.env.NODE_ENV !== 'production') {
|
|
389
|
+
let id = toBase62(hash(className + loc));
|
|
390
|
+
css += `.-macro-static-${id} {
|
|
391
|
+
--macro-data-${id}: ${JSON.stringify({style, loc})};
|
|
392
|
+
}\n\n`;
|
|
393
|
+
className += ` -macro-static-${id}`;
|
|
394
|
+
}
|
|
378
395
|
|
|
379
396
|
if (this && typeof this.addAsset === 'function') {
|
|
380
397
|
this.addAsset({
|
|
@@ -387,6 +404,12 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
387
404
|
return className;
|
|
388
405
|
}
|
|
389
406
|
|
|
407
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
408
|
+
js += `let targetRules = rules + ${JSON.stringify(loc)};\n`;
|
|
409
|
+
js += 'let hash = 5381;for (let i = 0; i < targetRules.length; i++) { hash = ((hash << 5) + hash) + targetRules.charCodeAt(i) >>> 0; }\n';
|
|
410
|
+
js += 'rules += " -macro-dynamic-" + hash.toString(36);\n';
|
|
411
|
+
js += `typeof window !== 'undefined' && window?.postMessage?.({action: 'stylemacro-update-macros', hash: hash.toString(36), loc: ${JSON.stringify(loc)}, style: currentRules}, "*");\n`;
|
|
412
|
+
}
|
|
390
413
|
js += 'return rules;';
|
|
391
414
|
if (allowedOverrides) {
|
|
392
415
|
return new Function('props', 'overrides', js) as any;
|
|
@@ -492,7 +515,7 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
492
515
|
// Top level layer is based on the priority of the rule, not the condition.
|
|
493
516
|
// Also group in a sub-layer based on the condition so that lightningcss can more effectively deduplicate rules.
|
|
494
517
|
let layer = `${generateName(priority, true)}.${propertyInfo.conditions[prelude] || generateArbitraryValueSelector(condition, true)}`;
|
|
495
|
-
return new AtRule(rules, prelude, layer);
|
|
518
|
+
return new AtRule(rules, prelude, layer, condition);
|
|
496
519
|
});
|
|
497
520
|
}
|
|
498
521
|
|
|
@@ -504,6 +527,7 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
504
527
|
let propertyFunction = properties.get(themeProperty);
|
|
505
528
|
if (propertyFunction) {
|
|
506
529
|
// Expand value to conditional CSS values, and then to rules.
|
|
530
|
+
let propertyValue = value;
|
|
507
531
|
let arbitrary = parseArbitraryValue(value);
|
|
508
532
|
let cssValue = arbitrary ? arbitrary : propertyFunction.toCSSValue(value);
|
|
509
533
|
let cssProperties = propertyFunction.toCSSProperties(property.startsWith('--') ? property : null, cssValue);
|
|
@@ -556,7 +580,7 @@ export function createTheme<T extends Theme>(theme: T): StyleFunction<ThemePrope
|
|
|
556
580
|
|
|
557
581
|
className += propertyInfo.values[cssProperty]?.[String(value)] ?? generateArbitraryValueSelector(String(value));
|
|
558
582
|
className += POSTFIX;
|
|
559
|
-
rules.push(new StyleRule(className, key, String(value)));
|
|
583
|
+
rules.push(new StyleRule(className, key, String(value), isCompilingDependencies ? themeProperty : property, propertyValue));
|
|
560
584
|
}
|
|
561
585
|
|
|
562
586
|
return [0, rules];
|
|
@@ -645,22 +669,30 @@ interface Rule {
|
|
|
645
669
|
copy(): Rule
|
|
646
670
|
}
|
|
647
671
|
|
|
672
|
+
let conditionStack: string[] = [];
|
|
673
|
+
|
|
648
674
|
/** A CSS style rule. */
|
|
649
675
|
class StyleRule implements Rule {
|
|
650
676
|
className: string;
|
|
651
677
|
pseudos: string;
|
|
652
678
|
property: string;
|
|
653
679
|
value: string;
|
|
680
|
+
themeProperty: string | undefined;
|
|
681
|
+
themeValue: Value | undefined;
|
|
654
682
|
|
|
655
|
-
constructor(className: string, property: string, value: string) {
|
|
683
|
+
constructor(className: string, property: string, value: string, themeProperty: string | undefined, themeValue: Value | undefined) {
|
|
656
684
|
this.className = className;
|
|
657
685
|
this.pseudos = '';
|
|
658
686
|
this.property = property;
|
|
659
687
|
this.value = value;
|
|
688
|
+
if (process.env.NODE_ENV !== 'production' && isCompilingDependencies !== null) {
|
|
689
|
+
this.themeProperty = themeProperty;
|
|
690
|
+
this.themeValue = themeValue;
|
|
691
|
+
}
|
|
660
692
|
}
|
|
661
693
|
|
|
662
694
|
copy(): Rule {
|
|
663
|
-
let rule = new StyleRule(this.className, this.property, this.value);
|
|
695
|
+
let rule = new StyleRule(this.className, this.property, this.value, this.themeProperty, this.themeValue);
|
|
664
696
|
rule.pseudos = this.pseudos;
|
|
665
697
|
return rule;
|
|
666
698
|
}
|
|
@@ -703,6 +735,27 @@ class StyleRule implements Rule {
|
|
|
703
735
|
res += `${indent}if (!${this.property.replace('--', '__')}) `;
|
|
704
736
|
}
|
|
705
737
|
res += `${indent}rules += ' ${this.className}';`;
|
|
738
|
+
if (process.env.NODE_ENV !== 'production' && this.themeProperty) {
|
|
739
|
+
let name = this.themeProperty;
|
|
740
|
+
if (this.pseudos) {
|
|
741
|
+
conditionStack.push(this.pseudos);
|
|
742
|
+
}
|
|
743
|
+
let propertyName = JSON.stringify(name);
|
|
744
|
+
let valueJson = JSON.stringify(this.themeValue);
|
|
745
|
+
if (conditionStack.length) {
|
|
746
|
+
// name += ` (${conditionStack.join(', ')})`;
|
|
747
|
+
let conditionKey = JSON.stringify(conditionStack.join(' && '));
|
|
748
|
+
// Ensure currentRules[name] is an object, converting from simple value if needed
|
|
749
|
+
res += ` currentRules[${propertyName}] = typeof currentRules[${propertyName}] === 'object' ? currentRules[${propertyName}] : {"default": currentRules[${propertyName}]};`;
|
|
750
|
+
// Set the value for this specific condition
|
|
751
|
+
res += ` currentRules[${propertyName}][${conditionKey}] = ${valueJson};`;
|
|
752
|
+
} else {
|
|
753
|
+
res += ` currentRules[${propertyName}] = ${valueJson};`;
|
|
754
|
+
}
|
|
755
|
+
if (this.pseudos) {
|
|
756
|
+
conditionStack.pop();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
706
759
|
return res;
|
|
707
760
|
}
|
|
708
761
|
}
|
|
@@ -759,14 +812,16 @@ class GroupRule implements Rule {
|
|
|
759
812
|
/** A rule that applies conditionally in CSS (e.g. @media). */
|
|
760
813
|
class AtRule extends GroupRule {
|
|
761
814
|
prelude: string;
|
|
815
|
+
themeCondition: string | null;
|
|
762
816
|
|
|
763
|
-
constructor(rules: Rule[], prelude: string, layer: string | null) {
|
|
817
|
+
constructor(rules: Rule[], prelude: string, layer: string | null, themeCondition: string | null) {
|
|
764
818
|
super(rules, layer);
|
|
765
819
|
this.prelude = prelude;
|
|
820
|
+
this.themeCondition = themeCondition;
|
|
766
821
|
}
|
|
767
822
|
|
|
768
823
|
copy(): Rule {
|
|
769
|
-
return new AtRule(this.rules.map(rule => rule.copy()), this.prelude, this.layer);
|
|
824
|
+
return new AtRule(this.rules.map(rule => rule.copy()), this.prelude, this.layer, this.themeCondition);
|
|
770
825
|
}
|
|
771
826
|
|
|
772
827
|
toCSS(rulesByLayer: Map<string, string[]>, preludes: string[] = [], layer?: string): void {
|
|
@@ -774,6 +829,13 @@ class AtRule extends GroupRule {
|
|
|
774
829
|
super.toCSS(rulesByLayer, preludes, layer);
|
|
775
830
|
preludes?.pop();
|
|
776
831
|
}
|
|
832
|
+
|
|
833
|
+
toJS(allowedOverridesSet: Set<string>, indent?: string): string {
|
|
834
|
+
conditionStack.push(this.themeCondition || this.prelude);
|
|
835
|
+
let res = super.toJS(allowedOverridesSet, indent);
|
|
836
|
+
conditionStack.pop();
|
|
837
|
+
return res;
|
|
838
|
+
}
|
|
777
839
|
}
|
|
778
840
|
|
|
779
841
|
/** A rule that applies conditionally at runtime. */
|
|
@@ -794,7 +856,10 @@ class ConditionalRule extends GroupRule {
|
|
|
794
856
|
}
|
|
795
857
|
|
|
796
858
|
toJS(allowedOverridesSet: Set<string>, indent = ''): string {
|
|
797
|
-
|
|
859
|
+
conditionStack.push(this.condition);
|
|
860
|
+
let res = `${indent}if (props.${this.condition}) {\n${super.toJS(allowedOverridesSet, indent + ' ')}\n${indent}}`;
|
|
861
|
+
conditionStack.pop();
|
|
862
|
+
return res;
|
|
798
863
|
}
|
|
799
864
|
}
|
|
800
865
|
|
|
@@ -803,7 +868,7 @@ export function raw(this: MacroContext | void, css: string, layer = '_.a'): stri
|
|
|
803
868
|
// We also check if this is globalThis, which happens in non-strict mode bundles.
|
|
804
869
|
// Also allow style to be called as a normal function in tests.
|
|
805
870
|
// @ts-ignore
|
|
806
|
-
|
|
871
|
+
|
|
807
872
|
if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {
|
|
808
873
|
throw new Error('The raw macro must be imported with {type: "macro"}.');
|
|
809
874
|
}
|
|
@@ -833,7 +898,7 @@ export function keyframes(this: MacroContext | void, css: string): string {
|
|
|
833
898
|
// We also check if this is globalThis, which happens in non-strict mode bundles.
|
|
834
899
|
// Also allow style to be called as a normal function in tests.
|
|
835
900
|
// @ts-ignore
|
|
836
|
-
|
|
901
|
+
|
|
837
902
|
if ((this == null || this === globalThis) && process.env.NODE_ENV !== 'test') {
|
|
838
903
|
throw new Error('The keyframes macro must be imported with {type: "macro"}.');
|
|
839
904
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {mergeStyles} from '../runtime';
|
|
14
|
-
import {style} from '../spectrum-theme';
|
|
15
|
-
|
|
16
|
-
describe('mergeStyles', () => {
|
|
17
|
-
it('should merge styles', () => {
|
|
18
|
-
let a = style({backgroundColor: 'red-1000', color: 'pink-100'});
|
|
19
|
-
let b = style({fontSize: 'body-xs', backgroundColor: 'gray-50'});
|
|
20
|
-
let expected = style({backgroundColor: 'gray-50', color: 'pink-100', fontSize: 'body-xs'});
|
|
21
|
-
let merged = mergeStyles(a, b);
|
|
22
|
-
expect(merged).toBe(expected);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should merge with arbitrary values', () => {
|
|
26
|
-
let a = style({backgroundColor: 'red-1000', color: '[hotpink]'});
|
|
27
|
-
let b = style({fontSize: '[15px]', backgroundColor: 'gray-50'});
|
|
28
|
-
let expected = style({backgroundColor: 'gray-50', color: '[hotpink]', fontSize: '[15px]'});
|
|
29
|
-
let merged = mergeStyles(a, b);
|
|
30
|
-
expect(merged).toBe(expected);
|
|
31
|
-
});
|
|
32
|
-
});
|