reflex-components-moment 0.9.0a1__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.
- reflex_components_moment-0.9.0a1/.gitignore +24 -0
- reflex_components_moment-0.9.0a1/PKG-INFO +12 -0
- reflex_components_moment-0.9.0a1/README.md +3 -0
- reflex_components_moment-0.9.0a1/pyproject.toml +27 -0
- reflex_components_moment-0.9.0a1/src/reflex_components_moment/__init__.py +5 -0
- reflex_components_moment-0.9.0a1/src/reflex_components_moment/moment.py +136 -0
- reflex_components_moment-0.9.0a1/src/reflex_components_moment/moment.pyi +100 -0
|
@@ -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.0a1
|
|
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,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,136 @@
|
|
|
1
|
+
"""Moment component for humanized date rendering."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import dataclasses
|
|
6
|
+
from datetime import date, datetime, time, timedelta
|
|
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[str | datetime | date | time | timedelta] = field(
|
|
98
|
+
doc="The date to display (also work if passed as children)."
|
|
99
|
+
)
|
|
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,100 @@
|
|
|
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
|
+
from collections.abc import Mapping, Sequence
|
|
8
|
+
from datetime import date, datetime, time, timedelta
|
|
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[date | datetime | str | time | timedelta]
|
|
52
|
+
| date
|
|
53
|
+
| datetime
|
|
54
|
+
| str
|
|
55
|
+
| time
|
|
56
|
+
| timedelta
|
|
57
|
+
| None = None,
|
|
58
|
+
duration_from_now: Var[bool] | bool | None = None,
|
|
59
|
+
unix: Var[bool] | bool | None = None,
|
|
60
|
+
local: Var[bool] | bool | None = None,
|
|
61
|
+
tz: Var[str] | str | None = None,
|
|
62
|
+
locale: Var[str] | str | None = None,
|
|
63
|
+
style: Sequence[Mapping[str, Any]]
|
|
64
|
+
| Mapping[str, Any]
|
|
65
|
+
| Var[Mapping[str, Any]]
|
|
66
|
+
| Breakpoints
|
|
67
|
+
| None = None,
|
|
68
|
+
key: Any | None = None,
|
|
69
|
+
id: Any | None = None,
|
|
70
|
+
ref: Var | None = None,
|
|
71
|
+
class_name: Any | None = None,
|
|
72
|
+
custom_attrs: dict[str, Var | Any] | None = None,
|
|
73
|
+
on_blur: EventType[()] | None = None,
|
|
74
|
+
on_change: EventType[()] | EventType[str] | None = None,
|
|
75
|
+
on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
|
|
76
|
+
on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
|
|
77
|
+
on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
|
|
78
|
+
on_focus: EventType[()] | None = None,
|
|
79
|
+
on_mount: EventType[()] | None = None,
|
|
80
|
+
on_mouse_down: EventType[()] | None = None,
|
|
81
|
+
on_mouse_enter: EventType[()] | None = None,
|
|
82
|
+
on_mouse_leave: EventType[()] | None = None,
|
|
83
|
+
on_mouse_move: EventType[()] | None = None,
|
|
84
|
+
on_mouse_out: EventType[()] | None = None,
|
|
85
|
+
on_mouse_over: EventType[()] | None = None,
|
|
86
|
+
on_mouse_up: EventType[()] | None = None,
|
|
87
|
+
on_scroll: EventType[()] | None = None,
|
|
88
|
+
on_scroll_end: EventType[()] | None = None,
|
|
89
|
+
on_unmount: EventType[()] | None = None,
|
|
90
|
+
**props,
|
|
91
|
+
) -> Moment:
|
|
92
|
+
"""Create the component.
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
*children: The children of the component.
|
|
96
|
+
**props: The props of the component.
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
The component.
|
|
100
|
+
"""
|