reflex-components-moment 0.9.0__tar.gz

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.
@@ -0,0 +1,24 @@
1
+ **/.DS_Store
2
+ **/*.pyc
3
+ assets/external/*
4
+ dist/*
5
+ examples/
6
+ .web
7
+ .states
8
+ .idea
9
+ .vscode
10
+ .coverage
11
+ .coverage.*
12
+ .venv
13
+ venv
14
+ requirements.txt
15
+ .pyi_generator_last_run
16
+ .pyi_generator_diff
17
+ reflex.db
18
+ .codspeed
19
+ .env
20
+ .env.*
21
+ node_modules
22
+ package-lock.json
23
+ *.pyi
24
+ .pre-commit-config.yaml
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: reflex-components-moment
3
+ Version: 0.9.0
4
+ Summary: Reflex moment components.
5
+ Author-email: Khaleel Al-Adhami <khaleel@reflex.dev>
6
+ Maintainer-email: Khaleel Al-Adhami <khaleel@reflex.dev>
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+
10
+ # reflex-components-moment
11
+
12
+ Reflex moment components.
@@ -0,0 +1,3 @@
1
+ # reflex-components-moment
2
+
3
+ Reflex moment components.
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "reflex-components-moment"
3
+ dynamic = ["version"]
4
+ description = "Reflex moment components."
5
+ readme = "README.md"
6
+ authors = [{ name = "Khaleel Al-Adhami", email = "khaleel@reflex.dev" }]
7
+ maintainers = [{ name = "Khaleel Al-Adhami", email = "khaleel@reflex.dev" }]
8
+ requires-python = ">=3.10"
9
+ dependencies = []
10
+
11
+ [tool.hatch.version]
12
+ source = "uv-dynamic-versioning"
13
+
14
+ [tool.uv-dynamic-versioning]
15
+ pattern-prefix = "reflex-components-moment-"
16
+ fallback-version = "0.0.0dev0"
17
+
18
+ [tool.hatch.build]
19
+ targets.sdist.artifacts = ["*.pyi"]
20
+ targets.wheel.artifacts = ["*.pyi"]
21
+
22
+ [tool.hatch.build.hooks.reflex-pyi]
23
+ dependencies = ["ruff", "reflex-base"]
24
+
25
+ [build-system]
26
+ requires = ["hatchling", "uv-dynamic-versioning", "hatch-reflex-pyi"]
27
+ build-backend = "hatchling.build"
@@ -0,0 +1,5 @@
1
+ """Moment.js component."""
2
+
3
+ from .moment import Moment, MomentDelta
4
+
5
+ moment = Moment.create
@@ -0,0 +1,136 @@
1
+ """Moment component for humanized date rendering."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import dataclasses
6
+ import datetime
7
+
8
+ from reflex_base.components.component import NoSSRComponent, field
9
+ from reflex_base.event import EventHandler, passthrough_event_spec
10
+ from reflex_base.utils.imports import ImportDict
11
+ from reflex_base.vars.base import LiteralVar, Var
12
+
13
+
14
+ @dataclasses.dataclass(frozen=True)
15
+ class MomentDelta:
16
+ """A delta used for add/subtract prop in Moment."""
17
+
18
+ years: int | None = dataclasses.field(default=None)
19
+ quarters: int | None = dataclasses.field(default=None)
20
+ months: int | None = dataclasses.field(default=None)
21
+ weeks: int | None = dataclasses.field(default=None)
22
+ days: int | None = dataclasses.field(default=None)
23
+ hours: int | None = dataclasses.field(default=None)
24
+ minutes: int | None = dataclasses.field(default=None)
25
+ seconds: int | None = dataclasses.field(default=None)
26
+ milliseconds: int | None = dataclasses.field(default=None)
27
+
28
+
29
+ class Moment(NoSSRComponent):
30
+ """The Moment component."""
31
+
32
+ tag: str | None = "Moment"
33
+ is_default = True
34
+ library: str | None = "react-moment@1.2.2"
35
+ lib_dependencies: list[str] = ["moment@2.30.1"]
36
+
37
+ interval: Var[int] = field(
38
+ doc="How often the date update (how often time update / 0 to disable)."
39
+ )
40
+
41
+ format: Var[str] = field(
42
+ doc="Formats the date according to the given format string."
43
+ )
44
+
45
+ trim: Var[bool] = field(
46
+ doc="When formatting duration time, the largest-magnitude tokens are automatically trimmed when they have no value."
47
+ )
48
+
49
+ parse: Var[str] = field(
50
+ doc=" Use the parse attribute to tell moment how to parse the given date when non-standard."
51
+ )
52
+
53
+ add: Var[MomentDelta] = field(
54
+ doc='Add a delta to the base date (keys are "years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds")'
55
+ )
56
+
57
+ subtract: Var[MomentDelta] = field(
58
+ doc='Subtract a delta to the base date (keys are "years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds")'
59
+ )
60
+
61
+ from_now: Var[bool] = field(
62
+ doc='Displays the date as the time from now, e.g. "5 minutes ago".'
63
+ )
64
+
65
+ from_now_short: Var[bool] = field(
66
+ doc='Displays the relative time in a short format using abbreviated units (e.g., "1h", "2d", "3mo", "1y" instead of "1 hour ago", "2 days ago", etc.).'
67
+ )
68
+
69
+ from_now_during: Var[int] = field(
70
+ doc="Setting fromNowDuring will display the relative time as with fromNow but just during its value in milliseconds, after that format will be used instead."
71
+ )
72
+
73
+ to_now: Var[bool] = field(
74
+ doc="Similar to fromNow, but gives the opposite interval."
75
+ )
76
+
77
+ with_title: Var[bool] = field(
78
+ doc="Adds a title attribute to the element with the complete date."
79
+ )
80
+
81
+ title_format: Var[str] = field(
82
+ doc="How the title date is formatted when using the withTitle attribute."
83
+ )
84
+
85
+ diff: Var[str] = field(
86
+ doc="Show the different between this date and the rendered child."
87
+ )
88
+
89
+ decimal: Var[bool] = field(doc="Display the diff as decimal.")
90
+
91
+ unit: Var[str] = field(doc="Display the diff in given unit.")
92
+
93
+ duration: Var[str] = field(
94
+ doc="Shows the duration (elapsed time) between two dates. duration property should be behind date property time-wise."
95
+ )
96
+
97
+ date: Var[
98
+ str | datetime.datetime | datetime.date | datetime.time | datetime.timedelta
99
+ ] = field(doc="The date to display (also work if passed as children).")
100
+
101
+ duration_from_now: Var[bool] = field(
102
+ doc="Shows the duration (elapsed time) between now and the provided datetime."
103
+ )
104
+
105
+ unix: Var[bool] = field(
106
+ doc="Tells Moment to parse the given date value as a unix timestamp."
107
+ )
108
+
109
+ local: Var[bool] = field(doc="Outputs the result in local time.")
110
+
111
+ tz: Var[str] = field(doc="Display the date in the given timezone.")
112
+
113
+ locale: Var[str] = field(doc="The locale to use when rendering.")
114
+
115
+ on_change: EventHandler[passthrough_event_spec(str)] = field(
116
+ doc="Fires when the date changes."
117
+ )
118
+
119
+ def add_imports(self) -> ImportDict:
120
+ """Add the imports for the Moment component.
121
+
122
+ Returns:
123
+ The import dict for the component.
124
+ """
125
+ imports = {}
126
+
127
+ if isinstance(self.locale, LiteralVar):
128
+ imports[""] = f"moment/locale/{self.locale._var_value}"
129
+ elif self.locale is not None:
130
+ # If the user is using a variable for the locale, we can't know the
131
+ # value at compile time so import all locales available.
132
+ imports[""] = "moment/min/locales"
133
+ if self.tz is not None:
134
+ imports["moment-timezone"] = ""
135
+
136
+ return imports
@@ -0,0 +1,147 @@
1
+ """Stub file for reflex_components_moment/moment.py"""
2
+
3
+ # ------------------- DO NOT EDIT ----------------------
4
+ # This file was generated by `reflex/utils/pyi_generator.py`!
5
+ # ------------------------------------------------------
6
+ import dataclasses
7
+ import datetime
8
+ from collections.abc import Mapping, Sequence
9
+ from typing import Any
10
+
11
+ from reflex_base.components.component import NoSSRComponent
12
+ from reflex_base.event import EventType, PointerEventInfo
13
+ from reflex_base.utils.imports import ImportDict
14
+ from reflex_base.vars.base import Var
15
+ from reflex_components_core.core.breakpoints import Breakpoints
16
+
17
+ @dataclasses.dataclass(frozen=True)
18
+ class MomentDelta:
19
+ years: int | None
20
+ quarters: int | None
21
+ months: int | None
22
+ weeks: int | None
23
+ days: int | None
24
+ hours: int | None
25
+ minutes: int | None
26
+ seconds: int | None
27
+ milliseconds: int | None
28
+
29
+ class Moment(NoSSRComponent):
30
+ def add_imports(self) -> ImportDict: ...
31
+ @classmethod
32
+ def create(
33
+ cls,
34
+ *children,
35
+ interval: Var[int] | int | None = None,
36
+ format: Var[str] | str | None = None,
37
+ trim: Var[bool] | bool | None = None,
38
+ parse: Var[str] | str | None = None,
39
+ add: MomentDelta | Var[MomentDelta] | None = None,
40
+ subtract: MomentDelta | Var[MomentDelta] | None = None,
41
+ from_now: Var[bool] | bool | None = None,
42
+ from_now_short: Var[bool] | bool | None = None,
43
+ from_now_during: Var[int] | int | None = None,
44
+ to_now: Var[bool] | bool | None = None,
45
+ with_title: Var[bool] | bool | None = None,
46
+ title_format: Var[str] | str | None = None,
47
+ diff: Var[str] | str | None = None,
48
+ decimal: Var[bool] | bool | None = None,
49
+ unit: Var[str] | str | None = None,
50
+ duration: Var[str] | str | None = None,
51
+ date: Var[
52
+ datetime.date | datetime.datetime | datetime.time | datetime.timedelta | str
53
+ ]
54
+ | datetime.date
55
+ | datetime.datetime
56
+ | datetime.time
57
+ | datetime.timedelta
58
+ | str
59
+ | None = None,
60
+ duration_from_now: Var[bool] | bool | None = None,
61
+ unix: Var[bool] | bool | None = None,
62
+ local: Var[bool] | bool | None = None,
63
+ tz: Var[str] | str | None = None,
64
+ locale: Var[str] | str | None = None,
65
+ style: Sequence[Mapping[str, Any]]
66
+ | Mapping[str, Any]
67
+ | Var[Mapping[str, Any]]
68
+ | Breakpoints
69
+ | None = None,
70
+ key: Any | None = None,
71
+ id: Any | None = None,
72
+ ref: Var | None = None,
73
+ class_name: Any | None = None,
74
+ custom_attrs: dict[str, Any | Var] | None = None,
75
+ on_blur: EventType[()] | None = None,
76
+ on_change: EventType[()] | EventType[str] | None = None,
77
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
78
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
79
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
80
+ on_focus: EventType[()] | None = None,
81
+ on_mount: EventType[()] | None = None,
82
+ on_mouse_down: EventType[()] | None = None,
83
+ on_mouse_enter: EventType[()] | None = None,
84
+ on_mouse_leave: EventType[()] | None = None,
85
+ on_mouse_move: EventType[()] | None = None,
86
+ on_mouse_out: EventType[()] | None = None,
87
+ on_mouse_over: EventType[()] | None = None,
88
+ on_mouse_up: EventType[()] | None = None,
89
+ on_scroll: EventType[()] | None = None,
90
+ on_scroll_end: EventType[()] | None = None,
91
+ on_unmount: EventType[()] | None = None,
92
+ **props,
93
+ ) -> Moment:
94
+ """Create the component.
95
+
96
+ Args:
97
+ *children: The children of the component.
98
+ interval: How often the date update (how often time update / 0 to disable).
99
+ format: Formats the date according to the given format string.
100
+ trim: When formatting duration time, the largest-magnitude tokens are automatically trimmed when they have no value.
101
+ parse: Use the parse attribute to tell moment how to parse the given date when non-standard.
102
+ add: Add a delta to the base date (keys are "years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds")
103
+ subtract: Subtract a delta to the base date (keys are "years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds")
104
+ from_now: Displays the date as the time from now, e.g. "5 minutes ago".
105
+ from_now_short: Displays the relative time in a short format using abbreviated units (e.g., "1h", "2d", "3mo", "1y" instead of "1 hour ago", "2 days ago", etc.).
106
+ from_now_during: Setting fromNowDuring will display the relative time as with fromNow but just during its value in milliseconds, after that format will be used instead.
107
+ to_now: Similar to fromNow, but gives the opposite interval.
108
+ with_title: Adds a title attribute to the element with the complete date.
109
+ title_format: How the title date is formatted when using the withTitle attribute.
110
+ diff: Show the different between this date and the rendered child.
111
+ decimal: Display the diff as decimal.
112
+ unit: Display the diff in given unit.
113
+ duration: Shows the duration (elapsed time) between two dates. duration property should be behind date property time-wise.
114
+ date: The date to display (also work if passed as children).
115
+ duration_from_now: Shows the duration (elapsed time) between now and the provided datetime.
116
+ unix: Tells Moment to parse the given date value as a unix timestamp.
117
+ local: Outputs the result in local time.
118
+ tz: Display the date in the given timezone.
119
+ locale: The locale to use when rendering.
120
+ style: The style of the component.
121
+ key: A unique key for the component.
122
+ id: The id for the component.
123
+ ref: The Var to pass as the ref to the component.
124
+ class_name: The class name for the component.
125
+ custom_attrs: Attributes passed directly to the component.
126
+ on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input.
127
+ on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input.
128
+ on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button.
129
+ on_context_menu: Fired when the user right-clicks on an element.
130
+ on_double_click: Fired when the user double-clicks on an element.
131
+ on_mouse_down: Fired when the user presses a mouse button on an element.
132
+ on_mouse_enter: Fired when the mouse pointer enters the element.
133
+ on_mouse_leave: Fired when the mouse pointer leaves the element.
134
+ on_mouse_move: Fired when the mouse pointer moves over the element.
135
+ on_mouse_out: Fired when the mouse pointer moves out of the element.
136
+ on_mouse_over: Fired when the mouse pointer moves onto the element.
137
+ on_mouse_up: Fired when the user releases a mouse button on an element.
138
+ on_scroll: Fired when the user scrolls the element.
139
+ on_scroll_end: Fired when scrolling ends on the element.
140
+ on_mount: Fired when the component is mounted to the page.
141
+ on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh.
142
+ on_change: Fires when the date changes.
143
+ **props: The props of the component.
144
+
145
+ Returns:
146
+ The component.
147
+ """